akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int n,m,q;
vector<vector<int>> g;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    /*
    各点から半径どこまで塗られるかを記録しながら
    クエリを後ろから処理，
    各点に対し更新は最大でも10回しか起こらないので間に合う
    点uに対し距離dが塗られているなら隣接するvはd-1が塗られていると
    伝播するように処理できればよい
    */
    cin>>n>>m;
    g.resize(n);
    rep(i,m){
        int a,b;cin>>a>>b;a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin>>q;
    vector<tuple<int,int,int>> qs(q);
    rep(i,q){
        int u,d,c;cin>>u>>d>>c;u--;
        qs[i]=make_tuple(u,d,c);
    }
    vector<int> dp(n,0),col(n,0);
    reverse(ALL(qs));
    rep(_,q){
        int st=get<0>(qs[_]),ds=get<1>(qs[_]),c=get<2>(qs[_]);

        if(col[st]==0) col[st]=c;
        if(dp[st]>=ds) continue;
        queue<pair<int,int>> que;
        que.push(make_pair(st,ds));
        while(!que.empty()){
            int now=que.front().first,d=que.front().second;que.pop();
            for(auto to:g[now]){
                if(col[to]==0 and d>=0) col[to]=c;
                if(chmax(dp[to],d-1)){
                    que.push(make_pair(to,d-1));
                }
            }
        }
    }
    for(auto x:col){
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 8968
use std::io;
use std::str::FromStr;

fn main() {
    let (n, k) = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace();
        (
            i32::from_str(it.next().unwrap()).unwrap(),
            i32::from_str(it.next().unwrap()).unwrap(),
        )
    };
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut p: Vec<i32> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
    if n == 1 {
        println!("{}", p.get(0).unwrap());
        return
    }
    if n == k {
        let sum: i32 = p.iter().sum();
        println!("{}", sum);
        return
    }
    p.sort();
    let mut i = 0;
    let mut ans = 0;
    for a in p.iter() {
        if i >= k {
            println!("{}", ans);
            return
        }
        ans = ans + a;
        i = i + 1;
    }
}


Measured memory_bytes: 2124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<double, double> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const ll INF = 1e18;

const int MAX_V = 1010;

struct edge{int to; double cost;};

//V := number of nodes
//G := adj
int V;
vector<edge> G[MAX_V];
double d[MAX_V];
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep((int)G[v].size(), i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

double dis(double x1, double y1, double x2, double y2) {
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

void solve(void){
    int sx, sy, gx, gy, N;
    cin >> sx >> sy >> gx >> gy >> N;
    V = N + 2;
    vector <double> xs(N), ys(N), rs(N);
    rep(N, i) {
        cin >> xs[i] >> ys[i] >> rs[i];
    }

    G[0].push_back(edge{N+1, dis(sx, sy, gx, gy)});
    G[N+1].push_back(edge{0, dis(sx, sy, gx, gy)});
    rep(N, i) {
        G[i+1].push_back(edge{0, max(0., dis(sx, sy, xs[i], ys[i])-rs[i])});
        G[i+1].push_back(edge{N+1, max(0., dis(gx, gy, xs[i], ys[i])-rs[i])});
        G[0].push_back(edge{i+1, max(0., dis(sx, sy, xs[i], ys[i])-rs[i])});
        G[N+1].push_back(edge{i+1, max(0., dis(gx, gy, xs[i], ys[i])-rs[i])});
    }
    rep(N, i) Rep(i+1, N-1, j) {
        G[i+1].push_back(edge{j+1, max(0., dis(xs[i], ys[i], xs[j], ys[j])-rs[i]-rs[j])});
        G[j+1].push_back(edge{i+1, max(0., dis(xs[i], ys[i], xs[j], ys[j])-rs[i]-rs[j])});
    }

    dijkstra(0);

    printf("%.10lf\n", d[N+1]);

}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 22896
# -*- coding: utf-8 -*-
#https://atcoder.jp/contests/apc001/tasks/apc001_b
import sys
#import collections

n= int(input())
#s= input()
tmp = input().split()
a = list(map(lambda a: int(a), tmp))
tmp = input().split()
b = list(map(lambda a: int(a), tmp))

totala=0
totalb=0
odd=0
num=0
for i in range(n):
	totala+=a[i]
	totalb+=b[i]
	if(b[i]>a[i]):
		num+=(b[i]-a[i]+1)//2
#	elif(

#print(num)
#print(totalb-totala)
if(num<=totalb-totala):
	print("Yes")
else:
	print("No")



Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    char ans[15];
    int j=0,l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='B')
        {
            if(j>0)
                j--;
        }
        else
            ans[j++]=s[i];
    }
    ans[j++]='\0';
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	x := map[int]int{}

	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			x[i*j] = 1
		}
	}
	ans := "No"
	if _, ok := x[n]; ok {
		ans = "Yes"
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
from itertools import accumulate

def solve():
    N, M = map(int, input().split())
    As = list(map(int, input().split()))

    As.sort()

    def isOK(x):
        num = 0
        for k, A in enumerate(As, start=1):
            i = bisect_left(As, x-A)
            num += N-i
            if num >= M:
                return True
            elif num + (N-k)*N < M:
                return False
        return num >= M

    ng, ok = 2*10**5+1, 0
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
#    print('ok:', ok)

    score = 0
    num = 0
    accAs = list(accumulate([0]+As))
    for A in As:
        i = bisect_right(As, ok-A)
        score += A*(N-i) + accAs[N] - accAs[i]
        num += N-i
#    print('score:', score, '/ num:', num)

    ans = score + ok*(M-num)
    print(ans)


solve()


Measured memory_bytes: 21128
def P_Number(a , b):

    ans = 0

    for i in range(a, b + 1):
        rev = str(i)
        if str(i) == rev[::-1]:
            ans += 1

    return ans

def main():
    a , b = map(int , input().split())
    print(P_Number(a , b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 41580
#include<iostream>

using namespace std;

char ban[101][101];

int cont = 0;
int h, w;

void saiki(int y, int x, char moji)
{
	ban[y][x] = '0';
	/*
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ban[i][j] << flush;
		}
		cout << endl;
	}
	
	getchar();
	
	cout << endl;
	*/
	if(ban[y+1][x] == moji){
		saiki(y+1,x,moji);
	}
	if(ban[y-1][x] == moji){
		saiki(y-1,x,moji);
	}
	if(ban[y][x+1] == moji){
		saiki(y,x+1,moji);
	}
	if(ban[y][x-1] == moji){
		saiki(y,x-1,moji);
	}

}



int main()
{
	for(;;){
		
		cin >> h >> w;
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				ban[i][j] = '0';
			}
		}
		
		cont = 0;
		
		
		if(h == 0){
			break;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> ban[i][j];
			}
		}
		
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(ban[i][j] != '0'){
					saiki(i,j,ban[i][j]);
					cont++;
				}
			}
		}
		cout << cont << endl;
	}
}

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

int main(){
  double x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  printf("%lf\n",d);
  
  return 0;
}
    



Measured memory_bytes: 3276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0020
{
	class Program
	{
		static void Main(string[] args)
		{
			var	s	= Console.ReadLine();
				s	= s.ToUpper();
			Console.WriteLine( s );
		}
	}
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}

int main(void) 
{	
	int n; cin>> n;
	string s; cin>> s;
	int k; cin>> k;
	char c = s[k-1];
	int r = s.size();
	rep(i,0,r-1){
		if(s[i] != c)
			s[i] = '*';
	}
	cout<<s;
	return 0;
} 



Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 04/07/2020
 * 18:26:42.02
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    int gcd = 0;
    for(int i = 0; i < n; ++i) {
        int health;
        cin >> health;
        gcd = __gcd(gcd, health);
    }
    cout << gcd << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
	int A,B,C,t;
	scanf("%d%d%d",&A,&B,&C);
	if(B/A>=C){
		t=C;
	}if(B/A<C){
		t=B/A;
	}
	printf("%d\n",t);
	return 0;
}

		

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
ab = [LIST() for _ in range(N)]
cd = [LIST() for _ in range(N)]

ab.sort(key=lambda x:(-x[1], -x[0]))
cd.sort(key=lambda x:(x[0], x[1]))

ans = 0
for c, d in cd:  # 青の点
	for i in range(len(ab)):  # 赤の点
		if c > ab[i][0] and d > ab[i][1]:  # マッチング
			# print(ab[i], c, d)
			ab.pop(i)
			ans += 1
			break
print(ans)


Measured memory_bytes: 3900
n=int(input())
A=list(map(int,input().split()))
q=int(input())
M=list(map(int,input().split()))

def check(i,m):
    if m<0 or m>sum(A):
        return False
    elif m==0:
        return True
    elif i>=n:
        return False

    return check(i+1,m) or check(i+1,m-A[i])

for m in M:
    if check(0,m):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5624
// Foods Loved by Everyone
#include <cmath>
#include <map>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int K = 0;
        cin >> K;
        for (int k = 0; k < K; k++) {
            int x;
            cin >> x;
            m[x-1]++;
        }
    }
    int count = 0;
    for (int i = 0; i < M; i++) {
        if (m[i] == N) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  pair<pair<string,int>,int> piii[9];
  for(int i=0;i<9;i++){
    string str;int a,b;
    cin>>str>>a>>b;
    piii[i]=make_pair(make_pair(str,a+b),200*a+300*b);
  } 
  for(int i=0;i<9;i++)
    cout<<piii[i].first.first<<" "<<piii[i].first.second<<" "<<piii[i].second<<endl;
  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<map>
#include<vector>

using namespace std;

const int maxm = 200000;
map<int, vector<int> > service;

bool valid(int n) {    
    for (int i = 0; i < service[1].size(); ++i) {
        int temp = service[1][i];
        for (int j = 0; j < service[temp].size(); ++j) {
            if (service[temp][j] == n)
                return true;
        }
    }
    return false;
}

int main() {
    int N, M;
    cin>>N>>M;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin>>a>>b;
        service[a].push_back(b);
    }
    cout<<(valid(N)?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 19320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

struct edge{int to, cost;};

vector<int> U(100), V(100);
vector<ll> X(100);
int id[100][100];
int M, N;
vector<edge> G[100];
vector<bool> seen;
ll search(int v, int target) {
    ll res;
    seen[v] = true; // v ��K��ςɂ���
    for (auto e: G[v]){
        int eid = id[v][e.to];
        if (seen[e.to]) continue; 
        //fprintf(stderr, "%d -> %d\n", v, e.to);
        if (e.to == target){
            return (1LL << eid);
        }
        res = search(e.to, target);
        if (res){
            return res | (1LL << eid);
        }
    }
    
    return 0;
}
// __builtin_popcountll
int bits(ll and_path){
    int cnt = 0;
    for (; and_path;  and_path /= 2){
        if (and_path & 1) cnt++;
    }
    return cnt;
}
ll dfs(int m, int k, ll and_path) {
    ll res = 0;
    
    if (m == M){
        if (k > 0){
            int c = bits(and_path);
            //res = ll(pow(-1, k - 1)) * ll(pow(2, N - 1 - c));
            if (k % 2 == 0){
                res = - (1LL << (N - 1 - c)); //ll(pow(2, N - 1 - c));
            } else {
                res = (1LL << (N - 1 - c)); //ll(pow(2, N - 1 - c));
            }
            //fprintf(stderr, "m = %d, k = %d, and_path = %x\n", m, k, and_path);
            //fprintf(stderr, "reresr = %d\n", res);
        }
    } else {
        res += dfs(m + 1, k + 1, and_path | X[m]);
        res += dfs(m + 1, k, and_path);
    }
    return res;
}    

int main() {
    cin >> N;
    vector<int> A(N), B(N);
    
    rep(i, N - 1){
        cin >>  A[i] >> B[i];
        G[A[i] - 1].push_back((edge){B[i] - 1, 0});
        G[B[i] - 1].push_back((edge){A[i] - 1, 0});
        id[A[i] - 1][B[i] - 1] = i;
        id[B[i] - 1][A[i] - 1] = i;
        
    }
    cin >> M;
    rep(i, M){
        cin >>  U[i] >> V[i];
        seen.assign(N, false); // �S���_���u���K��v�ɏ�����
        X[i] = search(U[i] - 1, V[i] - 1);
        //fprintf(stderr, "hoge,i = %d, X[i] = %x\n", i, X[i]);
    }
    //for (int i = 0; i < M; i++){
    //    fprintf(stderr, "i = %d, s[i] = %d\n", i, X[i] * 2);
    //}
    ll res = dfs(0, 0, 0); //(1 << (N - 1)) - 1);
    //fprintf(stderr, "res = %d\n", (int)res);
    cout << (1LL << (N - 1))- res;
    //cout << 1 << (N - 1)pow(2, N - 1) - res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1e18;

int mid(int a, int b, int c) {
    return a+b+c-max({a,b,c})-min({a,b,c});
}

int main(){
    int N, ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 1; i < N-1; i++) {
        if (mid(A[i-1], A[i], A[i+1]) == A[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
 	int num;
 	cin >> num;
	if(num % 10 == 2 || num % 10 ==  4 ||num % 10 ==  7 || num % 10 == 9 || num % 10 == 5){
		cout << "hon" << endl;
	} else if (num % 10 == 0 ||num % 10 == 1 ||num % 10 == 6 ||num % 10 == 8){
		cout << "pon" << endl;
	} else if (num % 10 == 3){
		cout << "bon" << endl;
	}
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int n = sc.nextInt();

		if (n == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a + b);
		}
	}
}

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

pair<string,string> get_subtree(string tree) {
    tree.erase(tree.begin());
    tree.erase(tree.end()-1);
    int point = 0;
    for (int i = 0, count = 0; i < tree.size(); i++) {
        if (tree[i] == '(') count++;
        else if (tree[i] == ')') count--;
        else if (!count) {
            point = i;
            break;
        }
    }

    auto sub1 = string(tree.begin(), tree.begin() + point);
    auto sub2 = string(tree.begin() + point + 1, tree.end());

    return make_pair(sub1, sub2);
}

string pro_i(string t1, string t2) {
    if (t1 == "" || t2 == "") return "";

    auto p_subtree1 = get_subtree(t1);
    auto p_subtree2 = get_subtree(t2);

    return "(" + pro_i(p_subtree1.first, p_subtree2.first) + "," + pro_i(p_subtree1.second, p_subtree2.second) + ")";
}

string pro_u(string t1, string t2) {
    if (t1 == "") return t2;
    if (t2 == "") return t1;


    auto p_subtree1 = get_subtree(t1);
    auto p_subtree2 = get_subtree(t2);

    return "(" + pro_u(p_subtree1.first, p_subtree2.first) + "," + pro_u(p_subtree1.second, p_subtree2.second) + ")";
}

int main() {
    char s;
    string t1, t2;
    while (cin >> s >> t1 >> t2) {
        if (s == 'i') cout << pro_i(t1, t2) << endl;
        else cout << pro_u(t1, t2) << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(){
    string s;
    cin>>s;
    bool ok = true;
    s = " "+s;
    int ans = 1e9;
    
  
    for(int i=2;i<=(int)s.length();i++){
        if(s[i]!=s[i-1]){
            ans = min(ans,max(i-1,(int)s.length()-i));
        }
    }
    if(ans == 1e9){
        cout<<s.length()<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
using namespace std; 


/*start:17/5/19 16:00*/
/*end:17/5/19   16:58  */

int i,x,y,n,m;
int b[55];
int main()
{
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		b[x]++;
		b[y]++;
	}
	for(i=1;i<=n;i++)
	{
		cout<<b[i]<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static char buf[100000];
static int ndigits = 0;

static void
next_runrun()
{
  if (ndigits == 0)
  {
    ndigits = 1;
    buf[0] = '1';
    buf[1] = '\0';
  }
  else if (ndigits == 1)
  {
    if (buf[0] < '9')
    {
      buf[0]++;
    }
    else
    {
      ndigits = 2;
      buf[0] = '1';
      buf[1] = '0';
      buf[2] = '\0';
    }
  }
  else
  {
    int i = ndigits - 1;
    while (0 < i && (buf[i] == '9' || buf[i - 1] < buf[i]))
    {
      i--;
    }
    if (i == 0 && buf[0] == '9')
    {
      ndigits++;
      buf[0] = '1';
      for (int n = 1; n < ndigits; n++)
      {
        buf[n] = '0';
      }
      buf[ndigits] = '\0';
    }
    else
    {
      buf[i]++;
      while (++i < ndigits)
      {
        buf[i] = (buf[i - 1] == '0' ? '0' : buf[i - 1] - 1);
      }
    }
  }
}

int
main()
{
  int K;
  cin >> K;
  for (int k = 0; k < K; k++)
  {
    next_runrun();
  }
  cout << buf << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

struct mint {
    static constexpr long MOD = 1000000007;
    long value;

    constexpr mint(long value = 0) noexcept : value((value % MOD + MOD) % MOD) {}
    constexpr mint operator-() const noexcept {
        return mint(-value);
    }
    constexpr mint& operator+=(const mint& rhs) noexcept {
        if ((value += rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator-=(const mint& rhs) noexcept {
        if ((value += MOD - rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator*=(const mint& rhs) noexcept {
        (value *= rhs.value) %= MOD;
        return *this;
    }
    constexpr mint operator+(const mint& rhs) const noexcept {
        mint res(*this);
        return res += rhs;
    }
    constexpr mint operator-(const mint& rhs) const noexcept {
        mint res(*this);
        return res -= rhs;
    }
    constexpr mint operator*(const mint& rhs) const noexcept {
        mint res(*this);
        return res *= rhs;
    }
    constexpr mint pow(long e) const noexcept {
        if (e == 0) return 1;
        mint a = pow(e >> 1);
        a *= a;
        if (e % 2 == 1) a *= *this;
        return a;
    }
    constexpr mint inv() const noexcept {
        return pow(MOD - 2);
    }
    constexpr mint& operator/=(const mint& rhs) noexcept {
        return *this *= rhs.inv();
    }
    constexpr mint operator/(const mint& rhs) const noexcept {
        mint res(*this);
        return res /= rhs;
    }
    friend constexpr mint pow(const mint& a, const long& b) noexcept {
        return a.pow(b);
    }
    friend ostream& operator<<(ostream& os, const mint& n) noexcept {
        os << n.value;
        return os;
    }
};

mint solve(int n, vector<mint>& a) {
    if (a[n].value != 0) return a[n];
    mint ans = 0;
    for (int i = 3; i <= n; i++) {
        ans += solve(n - i, a);
    }
    return a[n] = ans;
}

int main() {
    int s;
    cin >> s;
    vector<mint> a(s + 1);
    a[0] = 1;

    cout << solve(s, a) << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 1000000007;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

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

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

int n,m;
ll dp[2001][2001];
char g[2001][2001];
int xm[] = {1,0};
int ym[] = {0,1};


void solve(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>g[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                int xto = i+xm[k];
                int yto = j+ym[k];
                if(xto<n && yto<m && g[xto][yto]=='.'){
                    dp[xto][yto] = dp[xto][yto] + dp[i][j];
                    if(dp[xto][yto]>=MOD){
                        dp[xto][yto]-=MOD;
                    }
                }
            } 
        }
    }

    cout<<dp[n-1][m-1]<<'\n';
    

}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 20608
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 100'002

typedef long long ll;

using namespace std;

int A[MAX_N];

int main() {
  int N;
  cin >> N;
  A[0] = 0;
  A[N + 1] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  ll t = 0;
  for (int i = 0; i < N + 1; ++i) {
    t += abs(A[i] - A[i + 1]);
  }
  for (int i = 1; i < N + 1; ++i) {
    if ((A[i - 1] > A[i] && A[i] > A[i + 1]) || (A[i - 1] < A[i] && A[i] < A[i + 1])) {
      printf("%lld\n", t);
    } else {
      printf("%lld\n", t - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]));
    }
  }
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    string s;
    cin >> s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    }

Measured memory_bytes: 3624
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int MAX_N = 1e5 + 5;
const int INF = 0x7fffffff;
const double eps = 1e-6;


int n;
int a[2][105];


int main()
{
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, 1, n+1) cin >> a[0][i];
    REP(i, 1, n+1) a[0][i] += a[0][i-1];
    REP(i, 1, n+1) cin >> a[1][i];
    REP(i, 1, n+1) a[1][i] += a[1][i-1];
    int ans = 0;
    REP(i, 1, n+1) {
        ans = max(ans, a[0][i] + a[1][n] - a[1][i-1]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
if a % 2 == 0 and b % 2 == 0:num = (b-a)//2;ans = (num%2) ^ b
elif a % 2 == 0:ans = ((b-a+1)//2) % 2
elif b % 2 == 0:ans = a^b^(((b-a-1)//2)%2)
else:ans = a^(((b-a)//2)%2)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b)
{
	if (a%b==0)return(b);
	else return gcd(b,a%b);
}
signed main(){
    int n,a,ans;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(i)ans=gcd(ans,a);
        else ans=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;
#define ll long long
#define endl '\n'
#define x first
#define y second
#define pb push_back
#define all(k) (k).begin(),(k).end()
#define fr(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define db(k) cerr << #k<< " = " << k << endl




int32_t main(){
 	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	stack<int> q;
	fr(i,1,n){
		int a;
		cin>>a;
		q.push(a);
	}	
	int ans=0,c=0;
	while(q.size()){
		c=0;
		int aux = q.top();
		q.pop();
		while(q.size() and aux<=q.top()){
			aux = q.top();
			q.pop();
			c++;
		}
		ans=max(ans,c);


	}


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


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (n % k == 0) {
			System.out.print("0");
		} else {
			System.out.print("1");
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n;
		cin >> n;
		vector<int> sides(n);
		for(int i = 0; i < n; i++) {
			cin >> sides[i];
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n; j++) {
				if(sides[j] == sides[i]) {
					continue;
				}
				for(int k = j+1; k < n; k++) {
					if(sides[k] == sides[i] || sides[k] == sides[j]) {
						continue;
					}
					vector<int> all{sides[i], sides[j], sides[k]};
					sort(all.begin(), all.end());
					if(all[0] + all[1] > all[2]) {
						ans++;
					}
				}
			}
		}
		cout << ans << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main(void){
    
    int n, l;
    cin >> n >> l;

    vector<string> vec;

    for(int i=0; i<n; i++) {
        string temp;
        cin >> temp;
        vec.push_back(temp);
    }

    sort(vec.begin(), vec.end());

    for(int i=0; i<n; i++) {
        cout << vec[i];
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int w,h,n;
	scanf("%d %d %d",&w,&h,&n);

	int ws = w*h;
	int left = 0;
	int right = w;
	int top = h;
	int bottom = 0;
	int flag = 0;
	
	int x[n+5], y[n+5], a[n+5];
	for(int i = 1; i < n + 1; i++){
		scanf("%d %d %d", &x[i],&y[i],&a[i]);
	}
	
	int bs[n+5];
	
	for(int i = 1; i < n + 1; i++){
		if(a[i] == 1){
			if((x[i] - left) > 0){
				bs[i] = (x[i] - left)*(top - bottom);
				left = x[i];
			}else{
				bs[i] = 0;
			}
			
		} else if(a[i] == 2){
			if((right - x[i]) > 0){
				bs[i] = (right - x[i])*(top - bottom);
				right = x[i];
			}
			else {
				bs[i] = 0;
			}
			
		} else if(a[i] == 3){
			if((y[i] - bottom) > 0){
				bs[i] = (right - left)*(y[i] - bottom);
				bottom = y[i];
			} else {
				bs[i] = 0;
			}
			
		} else if(a[i] == 4){
			if((top - y[i]) > 0){
				bs[i] = (right - left)*(top - y[i]);	
				top = y[i];
			} else{
				bs[i] = 0;
			}
		
			
		}
		
		if(left >= right || top <= bottom){
			flag = 1;
			break;
		}
	}
	int ans =ws;
	for(int i = 1; i < n+1; i++){
		ans -=bs[i];
	}
	if(flag ==0){
	printf("%d\n",ans);
	}
	else if(flag == 1){
		printf("0");
	}
	
	return 0;
}


Measured memory_bytes: 128
n = gets.to_s.to_i
s = gets.to_s.chomp.bytes

cnt = 0
n.times do |i|
  j = i + 1
  k = i + 2
  while k < n
    cnt += 1 if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
    j += 1
    k += 2
  end
end

# p "RGB".bytes #=> [82, 71, 66]
puts s.count(82) * s.count(71) * s.count(66) - cnt

Measured memory_bytes: 14340
#include<iostream>
#include<vector>
#include<set>
#include<cmath>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

struct UnionFind{
    int n;
    vector<int> p;
    UnionFind(int nn) : n(nn+1){
        p.resize(n);
        rep(i, n) p[i] = i;
    }
    int root(int x){
        if(p[x] == x) return x;
        else return p[x] = root(p[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x != y) p[y] = x;
    }
    bool query(int x, int y){
        return root(x) == root(y);
    }
};


int main(){
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    UnionFind ut(N);
    set<int> c;
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        if(a != b){
            c.insert(a);
            c.insert(b);
        }
        ut.unite(a, b);
    }
    set<int> s;
    rep(i, N){
        int r = ut.root(i);
        if(r != i) s.insert(ut.root(i));
    }
    int city = s.size();
    int vil = N - c.size();
    cout << abs(vil - city) << endl;

    return 0;
}

Measured memory_bytes: 3208
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
int N;
int A[10];
int main() {
	cin >> N;
	int prod = 1;
	REP(i, 0, N) {
		cin >> A[i];
		if (A[i] % 2 == 0) prod *= 2;
	}
	cout << (int)pow(3, N) - prod << endl;
	return 0;
}






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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int left_c[3] = { a, b, c};

    int count = 0;
    char flag;
    if(c > 0){
        flag = 'c';
        count++;
        left_c[2]--;
    }
    else if(b > 0){
        flag = 'b';
        count++;
        left_c[1]--;
    }
    else {
        flag = 'a';
        left_c[0]--;
    }
    while(true){
        if(flag == 'c'){
            if(left_c[1] > 0){
                flag = 'b';
                left_c[1]--;
                count++;
            }
            else if(left_c[0] > 0){
                flag = 'a';
                left_c[0]--;
            }
            else {
                break;
            }
        }
        else if(flag == 'b'){
            if(left_c[2] > 0){
                flag = 'c';
                left_c[2]--;
                count++;
            }
            else if(left_c[1] > 0){
                flag = 'b';
                left_c[1]--;
                count++;
            }
            else {
                break;
            }
        }
        else {
            if(left_c[2] > 0){
                flag = 'c';
                left_c[2]--;
                count++;
            }
            else if(left_c[1] > 0){
                flag = 'b';
                left_c[1]--;
                count++;
            }
            else {
                break;
            }
        }
    }

    cout << count << endl;
    
}

Measured memory_bytes: 256
using System;

public class Test
{
	public static void Main()
	{
	string[] data = Console.ReadLine().Split();//????????\?????????	
	 int a = 0, b = 0; //??????????????´??°
            a = int.Parse(data[0]);//??????????????°?????????
            b = int.Parse(data[1]);//??????????????°?????????
            if (a == b)//a??¨b??????????????´???
            {
                Console.WriteLine("a == b");
            }
            else
            {
                if (a > b)//a???b????????§????????´???
                {
                    Console.WriteLine("a > b");
                }
                else//????????\????????´???
                {
                    Console.WriteLine("a < b");
                }
            }
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    int a = 0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        for(int j=0;j<i;j++){
            if(w[i] == w[j]){
                a = 1;
            }
        }
    }
    if(a == 0){
        for(int k=1;k<n;k++){
            if(w[k-1].back() != w[k].front()){
                a = 1;
                break;
            }
            
        }
    }

    if(a != 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

L = []
R = []

for i in range(N):
    x,l = map(int,input().split())
    L.append( x-l )
    R.append( x+l )

R,L = zip(*sorted(zip(R,L)))
cnt = 1
maxR = R[0]
for i in range(1,N):
    if maxR <= L[i]:
        cnt += 1
        if maxR < R[i]:
            maxR = R[i]
            
print(cnt)

Measured memory_bytes: 26032
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll X;
	cin >> X;
	for (int i = 1; i <= X; i++) {
		if (i * (i + 1) / 2 >= X) {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  double S=(W*H)/2;
  if(x==W/2 && y==H/2) cout << S << " " << 1 << endl;
  else cout << S << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int sort(int *p, int i)
{
    if(*p>*(p+1))
    {
        int t=*p;
        *p=*(p+1);
        *(p+1)=t;
    }
    else return 0;
    if(i>0)
    {
        sort(--p,--i);
    }
    return 0;
}
int main() {
int n,ans=0;
cin>>n;
int a[2*n];
for(int i=0;i<2*n;i=i+1)
{
    cin>>a[i];
    
}
for(int i=0;i<2*n-1;i++)
{
    sort(&a[i],i);
}
for (int i=0;i<2*n;i=i+2)
{
    ans+=a[i];
    
}
cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  int A = abs(a - x);
  int B = abs(b - x);
  if(A > B) cout << "B" << endl;
  else cout << "A" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
n=int(input())
i=1
while(i<=n):
    x=i
    if(x%3==0):
        print(" ",end="")
        print(i,end="")
    else:
        while(x > 0):
            if(x%10==3):
                print(" ",end="")
                print(i,end="")
                break
            x//=10

    i+=1
print()



Measured memory_bytes: 6164
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N;
    cin >> N;
    double ans=0;
    for(int i=1;i<=N;i++) if(i%2==1) ans+=1.0/N;
    cout << ans << endl;
}

Measured memory_bytes: 256