akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
signed main()
{
    int N;
    cin >> N;
    string S[2];
    cin >> S[0] >> S[1];
    int c0, c1, c2, c3;
    bool bar = true;
    c0 = c1 = c2 = c3 = 0;
    int i = 1;
    if (S[0][0] == S[1][0])
    {
        c0 = 3;
    }
    else
    {
        i = 2;
        c0 = 6;
        bar = false;
    }

    for (; i < N; i++)
    {
        if (bar)
        {
            if (S[0][i] == S[1][i])
            {
                c2++;
                bar = true;
            }
            else
            {
                c2++;
                bar = false;
                i++;
            }
        }
        else
        {
            if (S[0][i] == S[1][i])
            {
                c1++;
                bar = true;
            }
            else
            {
                c3++;
                bar = false;
                i++;
            }
        }
    }
    cout << (c0 * mpow(2, c2, MOD) * mpow(3, c3, MOD)) % MOD << endl;
}


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


citylis=[[] for i in range(n)]
for i in range(1,m+1):
  pi,yi=map(int,input().split())
  citylis[pi-1].append([i,yi])

for i in range(n):
  if len(citylis[i])!=0:
    citylis[i].sort(key=lambda x:x[1])

lis=[]
for i in range(n):
  for j in range(len(citylis[i])):
    cityposi=str(i+1)
    cityposi="0"*(6-len(cityposi))+cityposi
    ordernum=str(j+1)
    ordernum="0"*(6-len(ordernum))+ordernum
    lis.append([citylis[i][j][0],cityposi+ordernum])

lis.sort(key=lambda x:x[0])
for i in range(m):
  print(lis[i][1])

Measured memory_bytes: 49792
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut ramen = 700;
	for i in 0..3 {
		if s[i] == 'o' {
			ramen += 100;
		}
	}
	println!("{}", ramen);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		s.at(i) = 'x';
	}
	cout << s << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    int x;
    for (int i = 1; i <= N; ++i) {
        cin >> x;
        a[x - 1] = i;
    }
    for (int i = 0; i < N; ++i)
        cout << a[i] << ' ';
    cout << endl;
}


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

int main(){
    ll N,ans;
    cin >> N;
    ans = 0;
    while(N != 0){
        if(N%10 == 2)ans++;
        N /= 10;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;


void solve() {
    long long A, B, N; cin >> A >> B >> N;
    long long x = min(B - 1, N);
    long long ans = (A * x) / B - A * (x / B);
    cout << ans << endl;
}


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

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

typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> a(n+1);
    ll sum=0;
    cin >> a[0];
    for (int i=1; i<=n; ++i) {
        cin >> a[i];
        sum+=a[i];
    }
    if (a[n]==0) {
        cout << -1 << endl;
        return 0;
    }
    ll ans=0, cur=1;
    for (int i=0; i<=n; ++i) {
        sum-=a[i];
        ans+=cur;
        if (cur<a[i]) {
            cout << -1 << endl;
            return 0;
        }
        cur=min(cur*2-a[i]*2, sum);
    }
    cout << ans;
    return 0;
}

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

int main(){
	long int N, current_town = 1;
	long long int K;
	scanf("%ld %lld", &N, &K);
	int A[N+1];
	for(int i = 1; i <= N; i++){
		scanf("%d", &A[i]);
	}
	if(K <= N){
		for(int step_i = 1; step_i <= K; step_i++)
			current_town = A[current_town];
		printf("%ld", current_town);
	}
	else{
		int *p;
		p = (int *) malloc(sizeof(int) * (N + 1));	
		for(int town_i = 1; town_i <= N; town_i++)
			p[town_i] = -1;
		p[1] = 0;
		int count = 0, period = 0;
		while(count <= N){
			current_town = A[current_town];
			count++;
			if(p[current_town] == -1){
				p[current_town] = count;
			}
			else{
				period = count - p[current_town];
				count = N + 1;
				break;
			}
		}
		K = (K - p[current_town]) % period;
		for(int i = 1; i <= K; i++)
			current_town = A[current_town];
		printf("%ld", current_town);
	}
	return 0;
}

Measured memory_bytes: 3292
let hoge (x : int list) =
    let a = List.sort x
    x.[1] = a.[1]

let n = int (stdin.ReadLine())
let p = stdin.ReadLine().Split() |> Array.map int
let mutable c = 0
[for i in 1..n - 2 -> [p.[i - 1]; p.[i]; p.[i + 1]]] |> List.iter (fun d -> if (hoge d = true) then c <- c + 1)
printfn "%d" c

Measured memory_bytes: 14940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var n int

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func Left(i int) int {
	return i * 2
}
func Right(i int) int {
	return i*2 + 1
}
func maxHeapify(A []int, i int) {

	var largest int
	l := Left(i)
	r := Right(i)

	if l <= n && A[l] > A[i] {
		largest = l
	} else {
		largest = i
	}
	if r <= n && A[r] > A[largest] {
		largest = r
	}
	if largest != i {
		temp := A[i]
		A[i] = A[largest]
		A[largest] = temp
		maxHeapify(A, largest)
	}
}
func buildMaxHeap(A []int) {
	for i := (n / 2); i >= 1; i-- {
		maxHeapify(A, i)
	}
}
func main() {
	sc.Split(bufio.ScanWords)

	n = nextInt()

	A := make([]int, n+1)

	for i := 1; i <= n; i++ {
		A[i] = nextInt()
	}
	buildMaxHeap(A)

	for i := 1; i <= n; i++ {
		fmt.Printf(" %d", A[i])
	}
	fmt.Println("")
}



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

using namespace std;

int n, m;
const int N = 1e5 + 7;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    bool can = false;
    for(int i = 0 ; i <= x;  ++i) {
        /// suppose i turtles
        int legs = i * 2;
        int left = y - legs;
        if(left < 0) continue;
        if(left == 0) {
            if(i == x) {
                can = true;
                break;
            }
           /// can = true;
           // break;
        }
        if(left % 4 == 0) {
            if(left / 4 + i == x) {
                can = true;
                break;
            }
        }
    }

    if(can) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

int main() {
    int n, m, t[100010], p[110], x[100010], ans;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> t[i];
    cin >> m;
    for(int i=1; i<=m; i++) cin >> p[i] >> x[i];

    for(int i=1; i<=m; i++) {
        ans=0;
        for(int j=1; j<=n; j++) {
            if(p[i]==j) ans += x[i];
            else ans += t[j];
        }
        cout << ans << endl;
    }
}

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

if n >= m:
    print(0)
    exit(0)

x.sort()

l = []

for i in range(m-1):
    l.append(x[i+1] - x[i])

l.sort()

print(sum(l[:m-n]))


Measured memory_bytes: 13968
n,k = map(int,input().split())
l = [int(input()) for i in range(n)]
l.sort()
ans = l[-1]
for i in range(n-k+1):
  ans = min(ans,l[i+k-1]-l[i])
  if ans == 0:
    print(0)
    exit()
  
print(ans)
  


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
const long long NN = 2*pow(10,5)+100;
const long long MOD = pow(10,9)+7;
int main(){
  long long N;
  cin >> N;
  vector<long long> C(NN);
  for(long long i = 0; i < N; ++i) cin >> C[i];
  if(N <= 2){
    cout << 1;
    return 0;
  }
  vector<long long> cnt(NN,1);
  unordered_map<long long,long long> prevpos;
  vector<long long> Cprevpos(NN,-1);
  for(long long i = 0; i < N; ++i){
    if(prevpos.count(C[i])) Cprevpos[i] = prevpos[C[i]];
    prevpos[C[i]] = i;
  }
  unordered_map<long long,long long> cntcolor;
  cntcolor[C[0]] = 1;
  for(long long i = 1; i < N; ++i){
    if(Cprevpos[i] == i-1 or Cprevpos[i] == -1 or !cntcolor.count(C[i])) cnt[i] = cnt[i-1];
    else cnt[i] = (cntcolor[C[i]]+cnt[i-1])%MOD;
    cntcolor[C[i]] = cnt[i];
  }
  //for(long long i : cnt) cout << i << ' ';
  //cout << endl;
  cout << cnt[N-1];
  return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N= S.size();
    bool flag = true;
    for (int i = 0; i<N; ++i){
        if (S[i]!=T[i]) flag = false;
    }
    if (flag) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3620
# https://atcoder.jp/contests/abc075/tasks/abc075_c
# C - Bridge
import copy
import itertools

N, M = list(map(int, input().split()))
edge_list = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    edge_list.append((a, b))

all_edge_list = sorted(edge_list, key=lambda x: (x[0], x[1]))
all_node_list = list(set(list(itertools.chain.from_iterable(edge_list))))

bridge_list = []

for removed_edge in all_edge_list:  # 50
    r_a, r_b = removed_edge[0], removed_edge[1]

    # 当該エッジを除去した後のエッジリスト
    w_edge_list = copy.copy(all_edge_list)
    w_edge_list.remove((r_a, r_b))

    # 最初のエッジ
    a, b = w_edge_list[0]
    done_node_list = []
    done_node_list.append(a)
    done_node_list.append(b)

    done_edge_list = []
    done_edge_list.append((a, b))

    while True:
        # 探索済ノードから伸びているエッジを探す
        connected_edges = [edge for edge in w_edge_list if edge[0] in done_node_list or edge[1] in done_node_list]
        new_edges = set(connected_edges) - set(done_edge_list)
        for edge in new_edges:
            # 新しく見つかったエッジ
            done_edge_list.append(edge)
            done_node_list.append(edge[0])
            done_node_list.append(edge[1])
            done_node_list = list(set(done_node_list))
        if not new_edges:
            break

    if len(done_node_list) != len(all_node_list):
        # 全てのノードを探索し尽くしていない
        bridge_list.append((r_a, r_b))

ans = len(bridge_list)
print(ans)


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

using namespace std;

typedef long long ll;

const ll maxx = 1e3 + 20, mod = 1e9 + 7;

char t[maxx][maxx];
ll n, m, k, ted = 0, c1 = 0, e, c2 = 0, mat[2][2], tmp[2][2];
bool b1 = false, b2 = false;
vector<ll> v;

ll pw(ll a, ll b)
{
	if (!b) return 1ll;
	ll x = pw(a, b / 2);
	x = (x * x) % mod;
	if (b % 2) x = (x * a) % mod;
	return x;
}

void zrb(ll t1[][2], ll t2[][2])
{
	ll t3[2][2];
	for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) t3[i][j] = 0ll;
	for(ll i = 0; i < 2; i++)
		for(ll j = 0; j < 2; j++)
			for(ll o = 0; o < 2; o++)
				t3[i][j] = (((t3[i][j] + ((t1[i][o] * t2[o][j]) % mod)) % mod) + mod) % mod;
	for(ll i = 0; i < 2; i++)
		for(ll j = 0; j < 2; j++)
			mat[i][j] = t3[i][j];
}

void pw(ll x)
{
	if (x == 1) return;
	while (x >= 1) 
	{
		v.push_back(x);
		x /= 2;
	}
	reverse(v.begin(), v.end());
	x = 1ll;
	for(ll i = 1; i < v.size(); i++)
	{
		x *= 2ll;
		zrb(mat, mat);
		if (x != v[i]) x++, zrb(mat, tmp);
	}
	return;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for(ll i = 0; i < n; i++) for(ll j = 0; j < m; j++) cin >> t[i][j], ted += (t[i][j] == '#');
	if (k <= 1) return cout << 1 << endl, 0;
	for(ll i = 0; i < n; i++) if (t[i][0] == '#' && t[i][m-1] == '#') b1 = true, c1++;
	for(ll i = 0; i < m; i++) if (t[0][i] == '#' && t[n-1][i] == '#') b2 = true, c2++;
	if (b1 && b2) return cout << 1 << endl, 0; 
	if (!b1 && !b2) return cout << pw(ted, k - 1) << endl, 0;
	if (b1)
	{
//		if (k < 10) while (true) cout << 0 / 0 << endl;
		for(ll i = 0; i < n; i++) for(ll j = 0; j < m - 1; j++) if (t[i][j] == '#' && t[i][j + 1] == '#') e++;
		mat[0][0] = ted; mat[0][1] = -e; mat[1][0] = 0; mat[1][1] = c1;
		tmp[0][0] = ted; tmp[0][1] = -e; tmp[1][0] = 0; tmp[1][1] = c1;
		pw(k - 1);
		return cout << (((mat[0][0] + mat[0][1]) % mod) + mod) % mod << endl, 0;
	}
	else
	{
		for(ll i = 0; i < n - 1; i++) for(ll j = 0; j < m; j++) if (t[i][j] == '#' && t[i + 1][j] == '#') e++;
		mat[0][0] = ted; mat[0][1] = -e; mat[1][0] = 0; mat[1][1] = c2;
		tmp[0][0] = ted; tmp[0][1] = -e; tmp[1][0] = 0; tmp[1][1] = c2;
		pw(k - 1);
		return cout << (((mat[0][0] + mat[0][1]) % mod) + mod) % mod << endl, 0;
	}
	return 0;
}

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

double dp[305][305][305];
int N;

double dfs(int i,int j,int k){
    if(dp[i][j][k]>=0){
        return dp[i][j][k];
    }
    double ret=0.0;
    if(i>0) ret += dfs(i-1,j,k)*i;
    if(j>0) ret += dfs(i+1,j-1,k)*j;
    if(k>0) ret += dfs(i,j+1,k-1)*k;
    ret += N;
    ret /= (i+j+k);
    
    dp[i][j][k]=ret;
    return ret;
}

int main() {
    int a[4]={0,0,0,0};
    cin>>N;
    rep(i,N){
        int temp;
        cin>>temp;
        a[temp]++;
    }
    rep(i,305){
        rep(j,305){
            rep(k,305){
                dp[i][j][k]=-1;
            }
        }
    }
    dp[0][0][0]=0.0;
    printf("%.10f\n",dfs(a[1],a[2],a[3]));
    return 0;
}

Measured memory_bytes: 221952
#include <iostream>
using namespace std;
void heapify(int *a,int i,int n)
{
  int left=2*i+1;
  int right = 2*i+2;
  int largest=i;
  if(left<n&&a[largest]<a[left])
  {
    largest = left;
  }
  if(right<n&&a[largest]<a[right])
  {
  	largest = right;
  }
  if(largest!=i){
	swap(a[largest],a[i]);
    heapify(a,largest,n);
	}

  
}
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(int i=n/2-1;i>=0;i--)
  {
  	
  	
    heapify(a,i,n);
    
  }
  for(int i=0;i<m;i++)
  {
    a[0]=a[0]/2;
    heapify(a,0,n);
  }
  long long sum=0;
  for(int i=0;i<n;i++)
  {
    sum+=a[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  map<long long, int> vs;
  vs[0] = -1;
  long long s = 0;
  int m = 0;
  rep(i, N) {
    long long x; cin >> x;
    s += x;
    if (vs.find(s) != vs.end()) m = max(m, i-vs[s]);
    else vs[s] = i;
  }
  cout << m << "\n";
  return 0;
}

Measured memory_bytes: 15660
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;

#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define FORR(i,a,b) for(register int i=(a);i<=(b);++i)
#define ROR(i,a,b) for(register int i=(a);i>=(b);--i)
#define RORR(i,a,b) for(register int i=(a);i>(b);--i)
#define PQ priority_queue
#define VR vector
#define MST(a,b) memset(a,b,sizeof(a))
#define FGETS(s) fgets(s,sizeof(s),stdin)
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define FI first
#define SE second
typedef long long LL;
typedef long long unsigned LLU;
typedef pair<int,int> pii;

const int MAX = 1e5 + 20;
int x,y,a,b,c;
int p[MAX],q[MAX],r[MAX];
deque<int> qa,qb;

int main(void){
  scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
  FOR(i,0,a) scanf("%d",&p[i]);
  FOR(i,0,b) scanf("%d",&q[i]);
  FOR(i,0,c) scanf("%d",&r[i]);
  sort(p,p+a,greater<int>());
  sort(q,q+b,greater<int>());
  sort(r,r+c,greater<int>());
  FOR(i,0,x) qa.push_back(p[i]);
  FOR(i,0,y) qb.push_back(q[i]);

  FOR(i,0,c){
    int t = min(qa.back(), qb.back());
    if(t >= r[i]) break;
    if(qa.back() < qb.back()){
      qa.pop_back();
      qa.push_front(r[i]);
    }else{
      qb.pop_back();
      qb.push_front(r[i]);
    }
  }
  LL ans = 0;
  while(!qa.empty()) ans += qa.back(), qa.pop_back();
  while(!qb.empty()) ans += qb.back(), qb.pop_back();
  printf("%lld\n",ans);

  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll min(ll a,ll b)
{
	if(a<b){return a;}
	return b;
}
int main()
{
	fastio;
	//fopen();
	ll s,t,k;
	cin>>s>>t>>k;
	cout<<s-min(s,k)<<" "<<t-min(t,(k-min(s,k)));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define mp unordered_map
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
   ll d,t,s;
   cin>>d>>t>>s;

   ll x  = t*s;
   if(x>=d)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 3640
def solve():
    n, m = map(int, input().split())
    M = [0] * m
    for i in range(m):
        _, *S = map(int, input().split())
        for s in S:
            M[i] |= (1 << (s - 1))
    P = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        for j in range(m):
            if bin(i & M[j])[2:].count('1') % 2 != P[j]:
                break
        else:
            ans += 1
    print(ans)
solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define sfi(a) scanf("%d",&a)
#define m_p make_pair
#define inf 1e9
#define ff first
#define ss second
#define pi(x) pair<x,x>
#define mem(x) memset(x,-1,sizeof(x))
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int sz = 20;
const ld pi = acos(-1);

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==5 && a==b && c==7) puts("YES");
    else if(c==5 && c==a && b==7) puts("YES");
    else if(c==5 && c==b && a==7) puts("YES");
    else puts("NO");
    return 0;
}




Measured memory_bytes: 256
/* 以下は動的計画法を用いずにナイーブに書いたプログラム
#include<iostream>
using namespace std;

int fib(int n) {
    if (n == 0 || n == 1) return 1;
    else return fib(n - 1) + fib(n - 2);
}

int main() {
    int n;
    cin >> n;
    cout << fib(n) << endl;

    return 0;
}
*/

#include<iostream>
using namespace std;

int fib[45] = {0};

void solve(int n) {
    if (n == 0 || n == 1) {
        fib[n] = 1;
        return;
    }
    if (fib[n - 2] == 0) solve(n - 2);
    if (fib[n - 1] == 0) solve(n - 1);
    fib[n] = fib[n - 1] + fib[n - 2];
    return;
}

int main() {
    int n;
    cin >> n;
    solve(n);
    cout << fib[n] << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>

using namespace std;

using Edge = pair<int, int>;
using Graph = vector< vector<Edge> >;

int N;
Graph G;
vector<int> ans;


void dfs(int v, int p, int c){
    ans[v] = c;
    for(auto e : G[v]){
        if(e.first == p){
            continue;
        }
        if(e.second % 2 == 1){
            dfs(e.first, v, 1-c);
        }else{
            dfs(e.first, v, c);
        }
    }
}


int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for(int i = 0; i < N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    ans.assign(N, 0);

    dfs(0, -1, 1);

    for(auto v : ans){
        cout << v << endl;
    }


    return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;
public class Main
{
	static int ans;
	static int os[][];
	static int re[];
	static int r,c;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			r=in.nextInt();
			c=in.nextInt();
			if((r|c)==0)
				return;
			os=new int[r][c];
			re=new int[r];
			ans=0;
			for(int i=0;i<r;i++)
				for(int j=0;j<c;j++)
					os[i][j]=in.nextInt();
			turn(0);
			System.out.println(ans);
		}
	}
	public static void turn(int n)
	{
		if(n==r)
		{
			ans=Math.max(ans, count(os));
			return;
		}
		re[n]=0;
		turn(n+1);
		re[n]=1;
		turn(n+1);
	}
	public static int count(int o[][])
	{
		int cnt=0;
		for(int i=0;i<c;i++)
		{
			int t=0;
			for(int j=0;j<r;j++)
			{
				if((re[j]==1&&o[j][i]==1)||(re[j]==0&&o[j][i]==0))
				t++;
			}
			if(t<r-t)
				cnt+=r-t;
			else
				cnt+=t;
		}
		return cnt;
	}
}

Measured memory_bytes: 63328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int A,B,C; cin >> A >> B >> C;

  string ans = "NO";
  for(int i = 1; i <= 100; i++) {
    int a = A * i;
    if(a % B == C) {
      ans = "YES";
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int ans=0;
	int A=0;
	int B=0;
	int C=0;
	
	cin>>A>>B>>C;
	
	if(A*10+B+C>=B*10+A+C && A*10+B+C>=C*10+A+B)cout<<A*10+B+C;
	if(B*10+A+C>A*10+B+C && B*10+A+C>C*10+A+B)cout<<B*10+A+C;
	if(C*10+B+A>B*10+A+C && C*10+B+A>A*10+C+B)cout<<C*10+A+B;
}




Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
import itertools

def main():
    x_1, y_1, x_2, y_2 = map(int, sys.stdin.readline().split())
    x_3 = x_2 - (y_2-y_1)
    y_3 = y_2 + (x_2 - x_1)
    x_4 = x_3 - (x_2-x_1) 
    y_4 = y_3 - (y_2-y_1)
    
    print(x_3, y_3, x_4, y_4)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int mod = 1000000007;
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
int main()
{
    fast
    int n;
    cin>>n;
    vector<ll> vec(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>vec[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans ^= vec[i];
    }
    for(int i=0;i<n;i++)
    {
        int k = ans^vec[i];
        cout<<k<<" ";
    }
    cout<<endl;
    
    
  
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2 * acos (0.0)
int main()
{
    ll a,b,c,d,e,f,g,h,ct;
    string s1,s2,s3,s4;
    ll n,k,t,x,y,x1,x2,y1,y2,m;
    ct=0;
    cin>>t; //275
    a=t%100; //75
    b=t/100; //2
    c=a/10; //7
    d=a%10; //5
    //cout<<a<<" "<<b<<" "<<c<<" "<<d;
    if(b==7 || c==7 || d==7) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}






Measured memory_bytes: 3628
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-25T01:45:49+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,W; cin >> n >> W;
  vector<int> v(n),w(n);

  rep(i,n) cin >> v[i] >> w[i];

  int dp[110][10010];
  for(int i=0; i<=W; ++i) dp[0][i] = 0;

  rep(i,n){
      for(int j=0; j<=W; j++){
          if(j-w[i]>=0) chmax(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
          chmax(dp[i+1][j], dp[i][j]);
      }
  }

  cout << dp[n][W] << endl;

  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 7124
def fill_left(k, y, x, a, ans):
    global cnt
    for j in xrange(x, w):
        ans[y][j] = k + 1
        cnt += 1
        if cnt == a[k]:
            return j
    return -1

def fill_right(k, y, x, a, ans):
    global cnt
    for j in xrange(x, -1, -1):
        ans[y][j] = k + 1
        cnt += 1
        if cnt == a[k]:
            return j
    return -1

h, w = map(int, raw_input().split())
n = int(raw_input())
a = map(int, raw_input().split())
ans = [[0] * w for _ in xrange(h)]
nowy = 0
nowx = 0
left = True
cnt = 0
k = 0
while nowy < h:
    if left:
        tmp = fill_left(k, nowy, nowx, a, ans)
        if tmp == -1:
            left = False
            nowx = w - 1
            nowy += 1
        else:
            if tmp == w - 1:
                left = False
                nowx = w - 1
                nowy += 1
                k += 1
                cnt = 0
            else:
                k += 1
                nowx = tmp + 1
                cnt = 0
    else:
        tmp = fill_right(k, nowy, nowx, a, ans)
        if tmp == -1:
            left = True
            nowx = 0
            nowy += 1
        else:
            if tmp == 0:
                left = True
                nowx = 0
                nowy += 1
                k += 1
                cnt = 0
            else:
                k += 1
                nowx = tmp - 1
                cnt = 0
for i in xrange(h):
    for j in xrange(w):
        print ans[i][j],
    print


Measured memory_bytes: 33388
import copy
import sys
from collections import deque
N, M = map(int,input().split())
checked = [False for _ in range(N)]
path = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = list(map(lambda x: int(x)-1, s.split()))
    path[a].append(b)
    path[b].append(a)
dq = deque([[i,i] for i in range(N)])
friends = [[i] for i in range(N)]
while dq:
   i, num= dq.popleft()
   if checked[i]:
      continue
   checked[i] = True
   for j in range(len(path[i])):
      h = path[i][j]
      if not checked[h]:
         dq.appendleft([h, num])
         friends[num].append(h)
ans = 0
for i in range(N):
   f = set(friends[i])
   ans = max(ans, len(f))
print(ans)

Measured memory_bytes: 190560
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),n=t[0],r=t[1],o=0,u=0;u<3;u++)n[u]==r[u]&&(o+=1);console.log(o)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 21064
#include <stdio.h>
#include <stdlib.h>
#include <deque>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int n,q;
	deque<long int> myque;
	deque<string> nque;
	string name;
	long int time;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>name>>time;
	    nque.push_back(name);
	    myque.push_back(time);
	}
	long int sum=0;
	long int t;
	while(myque.size()!=0)
	{
	  	if(myque.front()>q){
	  	   sum+=q;
		   t = myque.front() - q;
		   name = nque.front();
		   myque.pop_front();
		   nque.pop_front();
		   myque.push_back(t);
		   nque.push_back(name);	
		}
		else{
		  sum+=myque.front();
		  cout<<nque.front()<<" "<<sum<<endl;
		  myque.pop_front();
		  nque.pop_front();
		} 
	}
	return 0;
} 


Measured memory_bytes: 6312
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int H,W;
    int h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;


    return 0;
}

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

struct Bits {
  int n: 31;
  int r: 1;
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<Bits> num(N + 1, {1,0});
  num[1].r = 1;
  for (int i = 0; i < M; ++i) {
    int x, y;
    cin >> x >> y;
    --num[x].n;
    ++num[y].n;
    if (num[x].r)
      num[y].r = 1;
    if (num[x].n == 0)
      num[x].r = 0;
  }

  int r = 0;
  for (int i = 1; i <= N; ++i) {
    if (num[i].r)
      ++r;
  }
  cout << r << "\n";

  return 0;
}



Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}

// namespace std {
//     template <>
//     class hash<std::pair<ll, ll>> {
//     public:
//         size_t operator()(const std::pair<int, int>& x) const{
//             return hash<int>()(x.first) ^ hash<int>()(x.second);
//         }
//     };
// }


int main (){
    int n;
    cin >> n;
    vector<P> vp(n,mp(0,0));
    Rep(i,n){
        cin >> vp[i].F >> vp[i].S;
    }
    map<LP,ll> cnt;
    Rep(i,n){
        Rep(j,n){
            if(j == i) continue;
            ll xsa = vp[j].F-vp[i].F;
            ll ysa = vp[j].S-vp[i].S;
            cnt[mp(xsa,ysa)]++;
        }
    }
    ll maxcnt = 0;
    for(auto itr = cnt.begin(); itr != cnt.end(); itr++){
        maxcnt = max(itr->S,maxcnt);
    }
    cout << n-maxcnt << "\n";
}

Measured memory_bytes: 384
N = gets.chomp.to_i
ai = gets.chomp.split(' ').map(&:to_i)

count = 0

ai.each_with_index do |a, index|
  if (index+1) % 2 == 1 then
    if a % 2 == 1 then
      count += 1
    end
  end
end  

print count

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

void print_ab( char*, int, int );
void reverse_ab( char*, int, int );
void replace_ab( char*, int, int, char* );

int main(){
	char word[1001] = {'\0'};
	char order[10] = {'\0'};
	int times = 0;
	int a = 0;
	int b = 0;
	int i;
	char enter;
	
	scanf( "%s", word );
	scanf( "%d", &times );
	
	for( i = 0; i < times; i++ ){
		scanf( "%s %d %d", &order, &a, &b );
		
		if( order[2] == 'i' ){
			print_ab( word, a, b );
		}
		else if( order[2] == 'v' ){
			reverse_ab( word, a, b );
		}
		else if( order[2] == 'p' ){
			static char new_word[1001] = {'\0'};
			scanf( "%s", new_word );
			replace_ab( word, a, b, new_word );
		}
		scanf( "%c", &enter );
	}
	
	return 0;
}

void print_ab( char* word, int a, int b ){
	int i;
	for( i = a; i <= b; i++){
		printf( "%c", word[i] );
	}
	printf( "\n" );
}

void reverse_ab( char* word, int a, int b ){
	int range = b - a;
	int i;
	char* work;
	
	work = ( char* )malloc( sizeof( char ) * range );
	
	for( i = 0; i <= range; i++ ){
		work[i] = word[b - i];
	}
	
	for( i = 0; i <= range; i++ ){
		word[i + a] = work[i];
	}
}

void replace_ab( char* word, int a, int b, char* new_word ){
	int range = b - a;
	int i;
	
	for( i = 0; i <= range; i++ ){
		word[a + i] = new_word[i];
	}
}



Measured memory_bytes: 2112
from heapq import*
n,*a=map(int,open(0).read().split())
hq1=[x for x in a[:n]]
hq2=[-x for x in a[n+n:]]
su1=sum(hq1)
su2=-sum(hq2)
mem1=[su1]
mem2=[su2]
heapify(hq1)
heapify(hq2)
for x in a[n:n+n]:
	y=heappop(hq1)
	if x>y:
		heappush(hq1,x)
		su1+=x-y
	else:
		heappush(hq1,y)
	mem1.append(su1)
for x in reversed(a[n:n+n]):
	y=-heappop(hq2)
	if x<y:
		heappush(hq2,-x)
		su2-=y-x
	else:
		heappush(hq2,-y)
	mem2.append(su2)
print(max(f-b for f,b in zip(mem1,mem2[::-1])))

Measured memory_bytes: 38116
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
#define VSORT(v) sort(v.begin(), v.end());
typedef long long ll;

int main(){
    string S;
    cin >> S;
    string ans[16] = {"KIHBR", "AKIHBR", "KIHABR", "AKIHABR", "KIHBAR", "AKIHBAR", "KIHABAR", "AKIHABAR", "KIHBRA", "AKIHBRA", "KIHABRA", "AKIHABRA", "KIHBARA", "AKIHBARA", "KIHABARA", "AKIHABARA"};
    bool flag = false;
    REP(i,16) if(S == ans[i]) flag = true;
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
S = list(map(int, list(input())))
L = len(S)
ans = 0
for bit in range(2**(L-1)):
    temp = 0

    for i in range(L-1):
        temp =temp*10 + S[i]
        if bit & (1<<i):
            ans += temp
            temp = 0
    temp  = temp*10 + S[-1]
    ans += temp


print(ans)



Measured memory_bytes: 9208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	s := sc.NextLine()

	ans := 0
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			ans++
		}
	}
	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
from collections import deque

N,Q = map(int,input().split())

L = [[] for i in range(N)]
for i in range(N-1) :
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    L[u].append(v)
    L[v].append(u)

par = [-1]*N

cnt = [0]*N

for i in range(Q) :
    p,x = map(int,input().split())
    p -= 1
    cnt[p] += x

q = deque([0])
while len(q) :
    u = q.popleft()
    for v in L[u] :
        if v == par[u] :
            continue
        par[v] = u
        cnt[v] += cnt[u]
        q.append(v)


"""
for i in range(Q) :
    p,x = map(int,input().split())
    p -= 1
    q = deque([p])
    while len(q) :
        u = q.popleft()
        cnt[u] += x
        for v in L[u] :
            if v != par[u] :
                q.append(v)
"""
print(*cnt)


Measured memory_bytes: 105876
//A Double Helix
#include<bits/stdc++.h>
using namespace std;

int main()
{
  char x;
  cin>>x;
  if(x=='A')
    cout<<'T'<<endl;
  if(x=='C')
    cout<<'G'<<endl;
  if(x=='G')
    cout<<'C'<<endl;
  if(x=='T')
    cout<<'A'<<endl;
}


Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
struct1 = []
struct2 = []
dict1 = {}
dict2 = {}
k1, k2 = 0, 0
for i in range(n):
    if s[i] not in dict1:
        dict1[s[i]] = k1
        k1 += 1    
    struct1.append(dict1[s[i]])
    if t[i] not in dict2:
        dict2[t[i]] = k2
        k2 += 1
    struct2.append(dict2[t[i]])
if struct1 == struct2:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 6716
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind() {}

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};
int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	UnionFind uf(n);
	vector<vector<int>> fs(n), bs(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		fs[a].push_back(b);
		fs[b].push_back(a);
		uf.merge(a, b);
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		bs[a].push_back(b);
		bs[b].push_back(a);
	}
	rep(i, n) {
		ll cs = uf.size(i);
		cs--;
		cs -= fs[i].size();
		auto u = uf.root(i);
		for (auto b : bs[i]) {
			if (uf.root(b) == u) {
				cs--;
			}
		}
		cout << cs << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 15736
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn main() {
  let n: String = read::<String>();

  for c in n.chars().as_str().chars() {
    println!("{}", add1_char(c));
  }
}

fn add1_char(c: char) -> char {
  std::char::from_u32(c as u32 + 1).unwrap_or(c)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;
long long int grr[3005][3005] ;

long long int compute(long long int arr[], long long int start, long long int end)
{	if (grr[start][end] != 0)
		return grr[start][end];
	if (start > end)
		return 0;
	if (start == end) {
		grr[start][end] = arr[start];
		return grr[start][end];
	}

	grr[start][end] = max(arr[start] + min(compute(arr, start + 2, end), compute(arr, start + 1, end - 1)),
	                      arr[end] + min(compute(arr, start, end - 2), compute(arr, start + 1, end - 1)));
	return grr[start][end];
}




int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n;
	cin >> n;
	long long int arr[n];
	long long int a = 0, b = 0;
	for (long long int i = 0; i < n; i++)
	{
		cin >> arr[i];
		b += arr[i];
	}
	a = compute(arr, 0, n - 1);

	cout << a - (b - a) << endl;

	return 0;


}


Measured memory_bytes: 49872
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include<chrono>
 
using namespace std;
//using namespace std::chrono;
 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vl int64_t

int main()
{
     int a,b;
     cin>>a>>b;
     cout<<6-a-b;
     return 0;
}


Measured memory_bytes: 384
A,B,C,K = map(int,input().split())
sum = 0
if K>0:
    if A>0:
        if A>K:
            sum = sum + K
        else:
            sum = sum + A
    K = K - A
if K > 0:
    if B>0:
        K = K - B
if K > 0:
    if C>0:
        sum = sum + K * (-1)
print(sum)

Measured memory_bytes: 9164
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int L;
    cin>>L;
    L--;
    vector<int> v;
    int N0(0),N1(0);
    while(L!=1){
        if(L%2==0){
            v.push_back(0);
            L/=2;
            N0++;
        }else{
            v.push_back(1);
            L--;
            L/=2;
            N1++;
        }
    }
    if(v.size()==0){
        cout<<2<<' '<<2<<endl;
        cout<<1<<' '<<2<<' '<<0<<endl;
        cout<<1<<' '<<2<<' '<<1<<endl;
        return 0;
    }
    cout<<(N0+N1+1)<<' '<<(2*N0+3*N1+1)<<endl;
    cout<<1<<' '<<2<<' '<<1<<endl;
    cout<<1<<' '<<2<<' '<<2<<endl;
    int x=2;
    if(v[v.size()-1]%2==1){
        cout<<1<<' '<<2<<' '<<3<<endl;
        x=3;
    }
    int n=2;
    for(int i=v.size()-2;i>=0;i--){
        if(v[i]==0){
            cout<<n<<' '<<(n+1)<<' '<<0<<endl;
            cout<<n<<' '<<(n+1)<<' '<<x<<endl;
            x*=2;
            n++;
        }else{
            cout<<n<<' '<<(n+1)<<' '<<0<<endl;
            cout<<n<<' '<<(n+1)<<' '<<x<<endl;
            cout<<1<<' '<<(n+1)<<' '<<(2*x+1)<<endl;
            x=2*x+1;
            n++;
        }
    }
    cout<<1<<' '<<(N0+N1+1)<<' '<<0<<endl;
    return 0;
}


Measured memory_bytes: 256