akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vec arr (n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int rs =0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            for (int k = j + 1; k < n; k++){
                if (arr[i] == arr[j] || arr[i] == arr[k] || arr[k] == arr[j]){
                    continue;
                }
                if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[k] + arr[j] > arr[i]){
                    // cts(arr[i]);cts(arr[j]);ctn(arr[k]);
                    rs++;
                }
            }
        }
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#define NUM 100000
using namespace std;
int p[NUM];

int main(){
	int i,j;
	p[0]=0;//ツ素ツ青板テツーツブツδ仰づーツ催ャツづゥ
	p[1]=0;
	for(i=2;i<NUM;i++)p[i]=1;
	for(i=2;i<sqrt(NUM);i++){
		if(p[i]){
			for(j=i*2;j<NUM;j+=i){
				p[j]=0;//ツ倍ツ青板づーツ渉慊つュ
			}
		}
	}
	/*
	for(i=0;i<NUM;i++)
		if(p[i])cout<<i<<",";
		*/
	int a;
	int min,max;
	while(cin>>a){
		for(i=a-1;i>=0;i--){
			if(p[i]){
				min=i;
				break;
			}
		}
		for(j=a+1;j<=NUM;j++){
			if(p[j]){
				max=j;
				break;
			}
		}
		cout<<min<<" "<<max<<endl;		
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int k[] = new int[(r+1)*(c+1)];
		for(int a = 0;a<r*c;a++){
			k[a] = scan.nextInt();
		}
		int kaunto = 0;
		int tate = 0;
		int tateR = 0;
		for(int b = 0;b<r;b++){
			int yoko = 0;
			for(int d = 0;d<(c+1);d++){
				if(d != c){
					System.out.print(k[kaunto] + " ");
					yoko = yoko + k[kaunto];
					++kaunto;
				}else{
					System.out.println(yoko);
					tateR = tateR + yoko;
				}
			}
		}
		for(int e = 0;e<(c+1);e++){
			if(e != c){
				for(int f = 0;f<r*c;f++){
					if(f % c == e){
						tate = tate + k[f];
					}
				}
				System.out.print(tate + " ");
				tate = 0;
			}else{
				System.out.println(tateR);
			}
		}
	}
}

Measured memory_bytes: 38280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
signed main(){
	ll n; cin>>n;
	vl a(n+10); rep(i,1,n+1)cin>>a[i];
	vl cnt(n+10),ans(0);
	for(ll i=n;i>=1;--i){
		if(cnt[i]%2!=a[i]){
			ans.push_back(i);
			for(ll j=1;j*j<=i;j++){
				if(i%j==0){
					cnt[j]++;
					if(j!=i/j)cnt[i/j]++;
				}
			}
		}
	}
	cout<<ans.size()<<endl;
	rep(i,0,ans.size())cout<<ans[i]<<" ";
	cout<<endl;

	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[5000];
int main(){
    int N;
    cin >> N;
    ll Z, W;
    cin >> Z >> W;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll ans;
    ll num1 = abs(A[N-1] - W);
    if(N > 1){
        ll num2 = abs(A[N-1] - A[N-2]);

        ans = max(num1, num2);
    }
    else{
        ans = num1;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	if(n < 30)
	{
		cout << "No";
	}
	else
	{
		cout << "Yes";
	}
	return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    
    int cnt = 0;
    int maxCnt = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == 'R'){
            cnt++;
        }else {
            maxCnt = max(cnt, maxCnt);
            cnt = 0;
        }
    }
    maxCnt = max(cnt, maxCnt);
    cout << maxCnt << endl;
    return 0;
}

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


#define INF 1000000000000
int n;
vector<int>d(101);
vector<int>f(101);
vector<vector<int>>g(101,vector<int>(0));
int tim=1;
void dfs(int x){
      if(!d[x]){d[x]=tim;tim++;}
      if(!g[x].size()&& !f[x]){f[x]=tim; tim++;}
  rep(i,g[x].size()){
    if(!d[g[x][i]])dfs(g[x][i]);
    if(i==g[x].size()-1&& !f[x]){f[x]=tim;tim++;}
  }
}
int restart=0;
bool owari(vector<int>l){
  rep(i,n){
    if(l[i+1]==0){return false;}
  }
  return true;
}
signed main() {

   cin>>n;
   rep(i,n){
     int t,m;cin>>t>>m;
     rep(j,m){int k; cin>>k; if(k!=i+1){g[i+1].push_back(k);}}
   }

   while(!owari(d)){
     int restart=0;
     rep(i,n){if(d[i+1]==0){restart=i+1;break;}}
     dfs(restart);
   }
   rep(i,n){
     cout<<i+1<<' '<<d[i+1]<<' '<<f[i+1]<<endl;
   }
}



Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;

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

	if(d==0) d = 1;
	else if(d==1) d = 100;
	else d = 10000;

	if(n==100) cout << d * 101 << endl;
	else cout << d * n << endl;
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

signed main(){
  int N;
  int res = 0;

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if ((i % 2 == 0) && (a % 2 == 1))
      res++;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int N;

int main() {

#ifdef __APPLE__
    freopen("input3.txt", "r", stdin);
#endif

cin >> N;
    vector<long> A(N);
    vector<long> B(N);
    vector<long> C(N);

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

    long c_sum = 0;

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

    if (c_sum < 0) {
        cout << "No" << endl;
        return 0;
    }

    int plus_anchor = 0;
    int minus_anchor = 0;
    while (C[plus_anchor] <= 0) {
        if (plus_anchor == C.size()) {
            cout << "Yes" << endl; // all zero
            return 0;
        }
        ++plus_anchor;
    }

    while (C[minus_anchor] >= 0) {
        if (minus_anchor == C.size()) {
            cout << "Yes" << endl; // all positive
            return 0;
        }
        ++minus_anchor;
    }


    while (1) {
        assert(C[plus_anchor] > 0);
        assert(C[minus_anchor] < 0);

        if (C[plus_anchor] % 2 == 1) {
            C[plus_anchor] -= 1;
            c_sum -= 1;
            if (c_sum < 0) {
                cout << "No" << endl;
                return 0;
            }
        }

        if (C[plus_anchor] == 0) {
            while (C[plus_anchor] <= 0) {
                ++plus_anchor;
                if (plus_anchor == C.size()) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            continue;
            // move plus anchor
            // if there is no place that is positive, return "no"
        }

        assert(C[plus_anchor] > 0);
        assert(C[plus_anchor] % 2 == 0);

        long adding_point = C[plus_anchor] / 2;

        while (adding_point != 0) {
            if (adding_point > -C[minus_anchor]) {
                c_sum += C[minus_anchor];
                adding_point += C[minus_anchor];
                C[plus_anchor] -= C[minus_anchor];
                C[minus_anchor] = 0;
            } else {
                c_sum -= adding_point;
                C[minus_anchor] += adding_point;
                adding_point = 0;
                C[plus_anchor] = 0;
            }

            if (C[minus_anchor] == 0) {
                while (C[minus_anchor] >= 0) {
                    ++minus_anchor;
                    if (minus_anchor == C.size()) {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }

            if (c_sum < 0) {
                cout << "No" << endl;
                return 0;
            }
        }

        assert(C[minus_anchor] < 0);

        while (C[plus_anchor] <= 0) {
            ++plus_anchor;
            if (plus_anchor == C.size()) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    assert(false);
    return 0;
}

Measured memory_bytes: 512
#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,d,x,ans;
 cin>>n>>d>>x;
 ans=x;
 int cho[n];
 rep(i,n){
   cin>>cho[i];
   ans+=1+(d-1)/cho[i];
 }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
    
int par[100000];
    
void init(int);
int dep(int);
int inp(void);
   
char *p;
char in[1500000];
int tree[100000][15],idx[100000];
   
int main(){
  int n,i,j,id,k,c;
   
  fread(in,sizeof(in),1,stdin); 
  p = in;
   
  n = inp(); init(n);
  for(i = 0 ; i < n ; i++){
    id = inp();
    k = inp();
    for(j = 0 ; j < k ; j++){
      c = inp();
      par[c] = id;
      tree[id][idx[id]++] = c;
    }
  }
    
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, "
           ,i,par[i],dep(i));
       
    if(par[i] == -1){
      printf("root, [");
    }else if(!idx[i]){
      printf("leaf, [");
    }else{
      printf("internal node, [");
    }
   
    for(j = 0 ; j < idx[i] ; j++){
      printf("%d",tree[i][j]);
      if(j < idx[i]-1) printf(", ");
    }
    puts("]");
  }
  return 0;
}
   
void init(int n){
  int i;
  for(i = 0 ; i < n ; i++){
    par[i] = -1;
  }
}
   
int dep(int x){
  if(par[x] == -1) return 0;
  return dep(par[x]) + 1;
}
   
int inp(){
  int v = 0;
  while(!isdigit(*p)) ++p;
  v = *p++&15;
  while(isdigit(*p)){
    v = (v<<3)+(v<<1)+(*p++&15);
  }
  return v;
}

Measured memory_bytes: 4232
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 6000
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,X,f[N+5][2*N+5];
int main()
{
	RI i,j,k,x;scanf("%d%d",&n,&X),n*=3,f[0][n]=1;
	for(i=0;i^n;++i) for(j=0;j<=2*n;++j)
		i+1<=n&&Inc(f[i+1][j+1],f[i][j]),
		i+2<=n&&(f[i+2][j-1]=(1LL*(i+1)*f[i][j]+f[i+2][j-1])%X),
		i+3<=n&&(f[i+3][j]=((1LL*(i+1)*(i+2))%X*f[i][j]+f[i+3][j])%X);
	RI ans=0;for(j=n;j<=2*n;++j) Inc(ans,f[n][j]);return printf("%d",ans),0;
}

Measured memory_bytes: 281600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = k;
    for(ll i = 2; i <= n; i++){
        ans *= (k-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

class UnionFind:

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.height = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def getsize(self, x):
        return self.size[self.find(x)]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

def isBipertite(es):
    n = len(es)
    uf = UnionFind(2 * n)
    for v, e in enumerate(es):
        for u in e:
            uf.unite(v, n+u)
            uf.unite(u, n+v)
    for v in range(n):
        if uf.same(v, n+v):
            return False
    return True

N = int(input())
es = [input() for i in range(N)]
for i in range(N):
    es[i] = [j for j in range(N) if es[i][j] == '1']
if isBipertite(es):
    d = [[INF] * N for i in range(N)]
    for i in range(N):
        d[i][i] = 0
    for v in range(N):
        for u in es[v]:
            d[v][u] = 1
    for w in range(N):
        for v in range(N):
            for u in range(N):
                d[v][u] = min(d[v][u], d[v][w]+d[w][u])
    print(max([max(d[v]) for v in range(N)])+1)
else:
    print(-1)


Measured memory_bytes: 45416
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    
	string s;
	cin>>s;
	ll n=(ll)s.length();
	rep(i,0,n)
	{
		cout<<"x";
	}
}
//Goodbye...

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;cin >> n >> l;
    vector<ll> dp(n+1),pd(n+1),a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            chmax(dp[i+1],dp[i]+l-a[i-1]);
        }
    }
    for(int i=n-2;i>=0;i--){
        if(a[i]<a[i+1]){
            chmax(pd[i],pd[i+1]+l-a[i+1]);
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        chmax(ans,max(dp[i+1],pd[i])+l-a[i]);
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define bye(x) return void (cout <<(x) << endl);
#define all(e) (e).begin(), (e).end()
#define pb push_back

template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << 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...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  string s; cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int idx = s[i] - 'A';
    int j = (idx + n) % 26;
    char c = j + 'A';
    cout << c;
  }
  return 0;
}



Measured memory_bytes: 256
A = []
for _ in range(3):
    A.append(list(map(int, input().split())))

N = int(input())
B = set()
for _ in range(N):
    B.add(int(input()))

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = -1

Q = [-1,-1,-1]
for i in range(3):
    if A[i] == Q:
        print("Yes")
        exit()
A = list(zip(*A))
Q = (-1,-1,-1)
for i in range(3):
    if A[i] == Q:
        print("Yes")
        exit()

if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    print("Yes")
    exit()

print("No")


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

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int x,a,b,c;
	int ans=0;
	cin>>a>>b>>c>>x;
	int i,j,k;
	for(i=0; i<a+1;i++){
		j=0;
		for(j=0; j<b+1; j++){
			k=0;
			for(k=0; k<c+1;k++){
				//cout << 500*i+100*j+50*k<<endl;
				if(500*i+100*j+50*k== x)
				{
				ans++;
				//cout << i<<j<<k;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

int main() {
  long a, b, c, d, answer = -1e20;
  vector<long> data(4);
  cin >> a >> b >> c >> d;
  data.at(0) = a * c;
  data.at(1) = a * d;
  data.at(2) = b * c;
  data.at(3) = b * d;
  for (int i = 0; i < 4; i++) {
    if (data.at(i) > answer) {
      answer = data.at(i);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 3620
#include<cstdio> 
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
char s[maxn];
int i,j,k,l,r,mid,t,n,m;
bool check(int k){
	bool czy;
	czy=1;
	fo(i,n-k+1,k)
		if (s[i]!='0'){
			czy=0;
			break;
		}
	if (czy) return 1;
	czy=1;
	fo(i,n-k+1,k)
		if (s[i]!='1'){
			czy=0;
			break;
		}
	if (czy) return 1;
	return 0;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	l=1;r=n;
	while (l<r){
		mid=(l+r+1)/2;
		if (check(mid)) l=mid;else r=mid-1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 256
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: Jalpaiguri Govt Enggineering College
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll int
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define endl "\n"
#define alt(v) v.begin(),v.end()
#define ralt(v) v.rbegin(),v.rend()
#define pb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << " : " << x << '\n'
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define fba(i,a,b) for(int i=(b);i>=(a);i--)
int mod=1000000007;
// int mod=998244353;
int dx[]={-1,1,0,0,-1,-1,1,1};
int dy[]={0,0,1,-1,1,-1,1,-1};

bool test  = 0;

const int inf = 1e18;
const int N = 1e6 + 5;


int bit[N];

void update(int idx, int val)
{
  while(idx <= N)
  {
    bit[idx] += val;
    idx += idx & -idx;
  }
}

void updateMax(int idx, int val)
{
  while(idx <= N)
  {
    bit[idx] = max(bit[idx], val);
    idx += idx & -idx;
  }
}

int pref(int idx)
{
  int ans = 0;
  while(idx > 0)
  {
    ans += bit[idx];
    idx -= idx & -idx;
  }
  return ans;
}

int rsum(int l, int r)
{
  return pref(r) - pref(l - 1);
}

int prefMax(int idx)
{
  int ans = -2e9;
  while(idx > 0)
  {
    ans = max(ans, bit[idx]);
    idx -= idx & -idx;
  }
  return ans;
}



void solve()
{
    
  int n,q,x,ind,l,r;
  cin>>n>>q;
  int arr[n];
  for(int i = 1; i <= n; i++)
  {
    cin >> arr[i-1];
    update(i,arr[i-1]);
  }
 
  for(int i=0;i<q;i++)
  {
     int t1;
     cin>>t1;
     if(t1==0)  
     {
        cin>>ind>>x;
        ind+=1;
        update(ind,x);
     }
     else{
      cin>>l>>r;
      l+=1;
      cout<<rsum(l,r)<<"\n";
     }
  }

}




    

















signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // precompute();
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, q;
// string s;

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

    VVi x(n+1, Vi(n+1, 0));
    REP(i, m) {
        int l, r; cin >> l >> r;
        x[l][r]++;
    }

    REP2(i, 1, n+1) REP2(j, 1, n+1) {
        x[i][j] = x[i-1][j] + x[i][j-1] - x[i-1][j-1] + x[i][j];
    }

    REP(i, q) {
        int l, r; cin >> l >> r;
        std::cout << x[r][r] - x[l-1][r] - x[r][l-1] + x[l-1][l-1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
#define MAX 100000
#define N 200000000
struct Card{
  char s;
  int v;
};

struct Card L[MAX], R[MAX];
void merge(struct Card A[], int n, int left, int mid ,int right);
void m_sort(struct Card A[], int n, int left, int right);
int partition(struct Card A[], int n, int p, int r);
void quickSort(struct Card A[], int n , int p, int r);


int main(){
  int i,n,v;
  struct Card A[MAX],B[MAX];
  char M[10];
  int stable = 1;

  scanf("%d",&n);
  for(i = 0; i<n; i++){
    scanf("%s %d",M,&v);
    A[i].s = M[0];
    B[i].s = M[0];
    A[i].v = v;
    B[i].v = v;
  }
  m_sort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i = 0; i<n; i++){
    if(A[i].s != B[i].s){
      stable = 0;
    }
  }
  
    if(stable == 1){
      printf("Stable\n");
    }
    else {
      printf("Not stable\n");
    }
      for(i = 0 ;i < n ;i ++){
	printf("%c %d\n",B[i].s,B[i].v);
      }
      return 0;
    }

void merge(struct Card A[], int n, int left, int mid ,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0 ; i<n1; i++){
    L[i] = A[left +i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid +i];
  }

  L[n1].v = N;
  
  R[n2].v =N;

  i = 0;
  j = 0;

  for(k = left ; k<right ; k++){
    if(L[i].v <= R[j].v){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void m_sort(struct Card A[], int n, int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left +right)/2;
    m_sort(A,n,left,mid);
    m_sort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[] ,int n, int p, int r){
  int i,j;
  struct Card t,x;
  x = A[r];
  i = p - 1;
  for(j = p; j<r ; j++){
    if(A[j].v <= x.v){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i +1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p,int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}





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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; ++i){
		cin >> s.at(i);
		s.at(i).insert(s.at(i).begin(), '#');
		s.at(i).push_back('#');
	}

	string bgnend(s.at(0).size(), '#');
	cout << bgnend << endl;
	for (int i = 0; i < h; ++i){
		cout << s.at(i) << endl;
	}
	cout << bgnend << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int n;cin >> n;
    int sum=0,tem=0,num=n;
    
    while(n){
        tem=n%10;
        sum+=tem;
        n = n/10;
    }
    if(num%sum==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int ans = 1;
		
		for(int i = 0; i < n; i++) {
			if(ans < k) {
				ans *= 2;
			}else {
				ans += k;
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
long long n ;

long long powlog(long long base , long long power)
{
	if(power == 0)
		return 1ll ;
	long long x = powlog(base , power / 2ll) ;
	x *= x ;
	if(power & 1)
		x *= base ;
	return x ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	long long now = 1ll , sum = 0 , idx ;
	for(int i = 1 ; ; ++i)
	{
		now *= 26ll ;
		sum += now ;
		if(n <= sum)
		{
			idx = i ;
			break ;
		}
	}
	sum -= now ;
	n -= sum ;
	for(int i = 1 ; i <= idx ; ++i)
	{
		for(char c = 'a' ; c <= 'z' ; ++c)
		{
			long long x = powlog(26 , idx-i) ;
			if(n > x)
				n -= x ;
			else
			{
				cout<<c ;
				break ;
			}
		}
	}
	return 0 ;
}		

Measured memory_bytes: 3576
<?php
$data = array();
while ($line = trim(fgets(STDIN))) {
	list($p, $n) = explode(',', $line);
	$data[] = array($p, $n);
}

$sum = 0;
$avg = 0;
foreach ($data as $d) {
	$sum += $d[0] * $d[1];
	$avg += $d[1];
}

echo $sum . "\n";
echo round($avg / count($data)) . "\n";

Measured memory_bytes: 6632
class UnionFind:

  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0] * n
    self.sizes = [1] * n

  def find(self, x):
    if self.par[x] != x:
      self.par[x] = self.find(self.par[x])
    return self.par[x]

  def union(self, x, y):
    x, y = self.find(x), self.find(y)
    if x == y:
      return False
    elif self.rank[x] < self.rank[y]:
      self.par[x] = y
      self.sizes[y] += self.sizes[x]
    elif self.rank[x] > self.rank[y]:
      self.par[y] = x
      self.sizes[x] += self.sizes[y]
    else:
      self.par[y] = x
      self.rank[x] += 1
      self.sizes[x] += self.sizes[y]
    return True

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def size(self, x):
    return self.sizes[self.find(x)]

n = int(input())
nx = [0 for i in range(200020)]
ny = [0 for i in range(200020)]
uf = UnionFind(200020)
for i in range(n):
  x, y = list(map(int, input().split()))
  uf.union(x, y+100010)
ans = 0
for i in range(100010):
  nx[uf.find(i)] += 1
  ny[uf.find(i+100010)] += 1
for i in range(200020):
  ans += nx[i]*ny[i]
print(ans-n)

Measured memory_bytes: 17328
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;

int main() {
 int N;
 cin>>N;
 int64_t c[5]={0};
 for(int i=0;i<N;i++){
     string s;
     cin>>s;
     if(s[0]=='M'){c[0]++;}
     if(s[0]=='A'){c[1]++;}
     if(s[0]=='R'){c[2]++;}
     if(s[0]=='C'){c[3]++;}
     if(s[0]=='H'){c[4]++;}
 }
 int64_t ans=0;
  for(int i=0;i<5;i++){
   for(int j=i+1;j<5;j++){
    for(int k=j+1;k<5;k++){
     ans+=c[i]*c[j]*c[k];
     }
   }
  }
  cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  int cnt=0;
  vector<int> a(n);  
  for (int i=0;i<n;++i) {
    cin>>a[i];
  }  
  int ma=a[0];
  for (int j=0;j<n;++j) {
    if (a.at(j)<=ma) {
      cnt+=1;
      ma=a[j];
    }
  }
  cout<<cnt<<endl;
}




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

int main() {
  int a, b;
  string s;
  cin >> s;
  a = b = 0;

  for ( int i = 0; i < s.size(); i++ ) {
    int x = s[i] - '0';
    a += (x + i) % 2;
    b += (x + i + 1) % 2;
  } 

  cout << min(a, b) << endl;
  return 0;
}

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

int main()
{
    int a[5];
    rep(i, 5) cin >> a[i];

    int res = 1e9 + 7;
    do {
        int sum = 0;
        rep(i, 5) {
            if (sum % 10 == 0) sum += a[i];
            else sum += (10 - sum % 10) + a[i];
        }
        res = min(res, sum);
    } while (next_permutation(a, a+5));

    cout << res << endl;

    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m;
    cin >> n >> m;
    vector<vector<int32>> ancestors(n);
    vector<vector<int32>> adj(n);
    vector<int32> ancestorCnt(n);
    REP(i,n-1+m){
        int32 a,b;
        cin >> a >> b;
        a--;b--;
        ancestors[b].pb(a);
        ancestorCnt[b]++;
        adj[a].pb(b);
    }
    stack<int32> st;
    REP(i,n){
        if(ancestorCnt[i] == 0)st.push(i);
    }
    vector<int32> topological(n+1, -1);
    int32 cur = 0;
    while(!st.empty()){
        int32 x = st.top();
        st.pop();
        topological[x] = cur;
        cur++;
        for(int32 y : adj[x]){
            ancestorCnt[y]--;
            if(ancestorCnt[y] == 0)st.push(y);
        }
    }
    REP(i,n){
        int32 par = n;
        for(int32 x : ancestors[i]){
            if(topological[par] < topological[x]){
                par = x;
            }
        }
        if(par == n){
            par = 0;
        }else{
            par++;
        }
        ANS(par);
    }
    return 0;
}

Measured memory_bytes: 13312
N = int(input())
p = [int(i) for i in input().split()]

def is_in_ascending_order(p):
  res = True
  n = len(p)
  for i in range(n-1):
    if not p[i] <= p[i+1]:
      res = False
  return res

res = False
for i in range(N-1):
  for j in range(i+1, N):
    _p = p.copy()
    _p[i], _p[j] = _p[j], _p[i]
    if is_in_ascending_order(_p):
      res = True

# no swap
if is_in_ascending_order(p):
  res = True

if res:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((c+b-1)/b<=(a+d-1)/d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long double N;
  cin >> N;

  long long X = ceil((-1.0 + sqrt(1.0 + 8.0 * N)) / 2.0);

  vector<long long> ret;
  ret.push_back(X);
  long long cur = N;
  cur -= X;
  while (true) {
    if (cur <= X - 1) {
      ret.push_back(cur);
      break;
    } else {
      X = X - 1;
      if (X > cur)
        X = cur;
      ret.push_back(X);
      cur -= X;
      if (cur == 0)
        break;
    }
  }

  for (int i = ret.size() - 1; i >= 0; --i) {
    if (ret[i] == 0)
      continue;
    cout << ret[i] << endl;
  }

  return 0;
}

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

int N;
vll A;

bool f(ll k) {
    ll sum = 0;
    rep(i,A.size()) {
        sum += (A[i]+k+1)/(N+1);
    }
    return sum <= k;
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    rep(i,N) sum += A[i];
    for (ll i = sum-N*(N-1); ; i++) {
        if (f(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
N, M = map(int, input().split())
x = sorted([list(map(int, input().split())) for i in range(N)])
i = 0
minprice = x[i][0]
minnumber = x[i][1]
price = 0
while True:
    if M <= minnumber:
        price += minprice * M
        break
    else:
        price += minprice * minnumber
        M -= minnumber
        i += 1
        minprice = x[i][0]
        minnumber = x[i][1]
print(price)

Measured memory_bytes: 28648
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d;
    multiset<int> s;
    cin>>str;
    rep(i,str.size()){
        s.insert(str[i]);
    }
    ll i=1;
    for(char r='a';r!='z'+1;r++){
        if(s.count(r)%2) f=1;
    }
    if(f==1) No;
    else Yes;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;


int main()
{
    int N;
    cin >> N;
    vector<double> p(N);
    for( int i = 0; i < N; ++i ) cin >> p[i];


    // dp[i][head]: i-1 番目までのコインを投げたときに表が head 回出る確率
    double dp[3001][3001] = {};
    dp[0][0] = 1;
    for( int i = 0; i < N; ++i ){
        for( int head = 0; head < N; ++head ){
            dp[i+1][head+1] += dp[i][head] * p[i];
            dp[i+1][head]   += dp[i][head] * (1 - p[i]); 
        }
    }

    double ans = 0;
    for( int i = (N+1)/2; i <= N; ++i ) ans += dp[N][i];  
    cout << fixed << setprecision(9) << ans << endl;

    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int n;
int dp[100005][4];
int a[100005][3];
int dfs(int pos,int state)
{
	if(pos==n)
		return 0;
	if(dp[pos][state]!=-1)
		return dp[pos][state];
	int &an=dp[pos][state];
	an=0;
	f(i,0,3)
	{
		if(state!=i)
		{
			an=max(an,dfs(pos+1,i)+a[pos][i]);
		}
	}
	return an;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	f(i,0,100005)
		f(j,0,4)
			dp[i][j]=-1;
	f(i,0,n)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	cout<<dfs(0,3)<<endl;
	return 0;
}

Measured memory_bytes: 12032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int[] V=new int[N];
		int[] C=new int[N];
		for(int i=0; i<N; i++) {
			V[i]=sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			C[i]=sc.nextInt();
		}
		int ans=0;
		for(int i=0; i<N; i++) {
			if(V[i]>=C[i]) {
				ans+=(V[i]-C[i]);
			}
		}
		pl(ans);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 23124
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
count = 0
br = false
a.sort.each do |e|
  if x >= e
    count += 1
    x -= e
  else
    br = true
    break
  end
end
if x == 0 || br
  puts count
else
  puts [count - 1, 0].max
end


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long 
using namespace std;

signed main() {
	int N,K;
	cin >> N >> K;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> cnt(200020);
  	int count = 0;
	for(int i = 0;i < N;i++) {
		cnt.at(vec.at(i) - 1)++;
	}
  	for(int i = 0;i < 200020;i++) {
      	if(cnt.at(i) != 0) {
          	count++;
        }
    }
	sort(cnt.begin(),cnt.end());
	count = count - K;
	int answer = 0;
	for(int i = 0;i < 200020;i++) {
		if(cnt.at(i) != 0) {
         	if(count <= 0) {
				break;
			}
			count--;
			answer += cnt.at(i);
		}
	}
	cout<< answer << endl;
}


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

int main(){
  int K, X;
  cin >> K >> X;

  int left;
  if (X - K + 1 >= -1000000){
    left = X - K + 1;
  }
  else
  {
    left = -1000000;
  }

  int right;
  if (X + K - 1 <= 1000000){
    right = X + K - 1;
  }
  else
  {
    right = 1000000;
  }

  for (int i = left; i <= right; i++){
    cout << i;
    if (i != right) cout << " ";
  }

  cout << "" << endl;
  
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    int N;
    double odd=0.0;
    double even=0.0;
    double ans;
    cin >> N;
    for(int i=1;i<=N;i++)
    {
        if(i%2==0) even+=1.0;
        else odd+=1.0;
    }
    ans=odd/N;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}



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

int main (void) {
    
    int a, b, c; // ペンキの色
    int cnt; //個数

    cin >> a >> b >> c;

    // AtCoDeerくんが買ったペンキの色の種類を知りたい
        if (a == b && b == c ){
            cnt = 1;
         }
        else if (a == b && b != c ){
            cnt = 2;
             }
        else if (a != b && b == c){
            cnt = 2;
        }
        else if (a == c && c != b){
            cnt = 2;
        }
        else{
            cnt = 3;
        }

    cout << cnt;

    return 0;
}


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

int main(void){
	int n;
	cin >> n;
	vector<int> p(n);
	int ans = 0;
	for(int i = 0; i < n;++i){
		cin >> p[i];
	}
	for(int i = 1; i < n-1; ++i){
		if(p[i-1] < p[i] && p[i] < p[i+1]){
			ans++;
		}else if(p[i-1] > p[i] && p[i] > p[i+1]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    while (a > 0 && c > 0)
    {
        c = c - b;
        a = a - d;
    }
    if (a <= 0 && c <= 0)
    {
        printf("Yes\n");
    }
    else if (a <= 0)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 1644
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re

def count1(bits):
    counter = 0
    while bits > 0:
        if bits & 1:
            counter += 1
        bits >>= 1
    return counter

def sol(N, testimonies):
    # print(N)
    # print(testimonies)
    maxi = 0
    for i in range(1<<N):
        ok = True
        for j in range(N):
            for x, y in testimonies[j]:
                if i & (1 << j): #正直者
                    if i & (1 << (x-1)) and not y: # 正直者と行っており、そうじゃないやん
                        ok = False; break
                    elif not (i & (1 << (x-1))) and y: #嘘つきといってるけど、そうじゃないやん！
                        ok = False; break
            if not ok:
                break
        if ok:
            maxi = max(count1(i), maxi)
    return maxi


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    #S = parsed_lines[0][0]
    return n, k


if not do_submit:
    n, k = input_parse("""
    5
10 4 8 7 3
    """)
    print(sol(n, k))

    n, k = input_parse("""
    100000 5
    """)
    print(sol(n, k))


else:
    N = int(input().strip())
    testimonies = []
    for i in range(N):
        A = int(input().strip())
        XYs = []
        for j in range(A):
            x, y = list(map(int, input().split()))
            XYs.append((x, y))
        testimonies.append(XYs)
    #S = input()
    print(sol(N, testimonies))

    # S = input().strip()
    # print(sol(S))





Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long int i,j,a,b,c,x,y,r1,r2,s1,s2,z1,z2,m,n;
      int g[3];
      cin>>a>>b>>c>>x>>y;
      if(x==y)
      {
        r1 = a*x; 
        s1 = b*y;
        z1 = r1+s1;
        r2 = c*x*2;
        if(z1>r2)
        {
            cout<<r2<<endl;
        }
        else
            cout<<z1<<endl;
      }
      else
      {
         r1 = a*x;
        s1 = b*y;
        z1 = r1+s1;
        g[0] = z1;
         if(x>y)
         {
             r2 = c*y*2;
             s2 = (x-y)*a;
             z2 = r2+s2;
             g[1]=z2;
             g[2] = c*x*2;
         }
         else
         {
           r2 = c*x*2;
             s2 = (y-x)*b;
             z2 = r2+s2;
             g[1]=z2;
             g[2] = c*y*2;
         }
            sort(g,g+3);
            cout<<g[0]<<endl;
      }

      return 0;
      }


Measured memory_bytes: 256