akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, C, B[20], A, t, c;

int main() {
	cin >> N >> M >> C;
	for (int i = 0; i != M; ++i)
		cin >> B[i];
	while (N--) {
		t = C;
		for (int i = 0; i != M; ++i) {
			cin >> A;
			t += A * B[i];
		}
		if (t > 0)
			++c;
	}
	cout << c << endl;
	return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b;
  cin >> a >> b;
  if (b % a == 0)
    pr(a + b);
  else
    pr(b - a);

  return 0;
}


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

int main(){
	int N, M;
	cin >> N;
	vector<int> T(N);
	int sum = 0;
	rep(i, N){
		cin >> T.at(i);
		sum += T.at(i);
	}
	cin >> M;
	rep(i, M){
		int Num, time;
		cin >> Num >> time;
		int ans = sum - T.at(Num - 1) + time;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

struct wait{
	char num;
	int count;
};

void out(int, int);

int main(){
	int n;
	string input;
	struct wait now;
	int i, j;
	
	cin >> n;
	for(i = 0; i < n; i++){
		now.count = 0;
		cin >> input;
		
		for(j = 0;j < input.size(); j++){
			if(input[j] == '0'){
				out(now.num - '0', now.count);
				now.count = 0;
			}
				
			else{
				now.num = input[j];
				now.count++;
			}
		}
		cout << endl;
	}
	
	return 0;
}

void out(int num, int count){
	char output[9][5] = {{'.', ',', '!', '?', ' '}, {'a', 'b', 'c'}, {'d', 'e', 'f'},
						{'g', 'h', 'i'}, {'j', 'k', 'l'}, {'m', 'n', 'o'},
						{'p', 'q', 'r', 's'}, {'t', 'u', 'v'}, {'w', 'x', 'y', 'z'}};
	int size[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
	int which;
	
	if(count == 0)
		return;
	
	if(count % size[num - 1] == 0)
		which = size[num - 1] - 1;
	else
		which = count % size[num - 1] - 1;
	cout << output[num - 1][which];
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	int n, z, w, a[100010];
	cin >> n >> z >> w;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	if (n == 1) cout << abs(a[0] - w) << endl;
	else cout << std::max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
}

Measured memory_bytes: 256
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e3 + 10;
const ll mod = 1e9 + 7;

char a[N][N];
ll dp[N][N];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++)
            cin >> a[i][j];
    dp[0][1] = 1LL;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j <= m; j ++)
        {
            if (a[i][j] == '.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b; cin >> a >> b;
    cout << max({a + b, a - b, a * b});
    return 0;
}


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

int main () {
  char c;
  int p = 700;
  rep(i,3){
    cin >> c;
    if(c == 'o') p += 100;
  }
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N;
vv<int> graph;

int dfs(int v, int p) {
    int sum = 0;
    int zc = 0;

    for (int u : graph[v]) {
        if (u == p) continue;
        int r = dfs(u, v);
        sum += r;
        zc += r == 0;
    }

    return zc > 0 ? sum + zc - 1 : sum;
}

int main() {
    cin >> N;
    graph.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ans = 0;
    rep(i, N) {
        if (graph[i].size() > 2) {
            ans = dfs(i, -1);
            break;
        }
    }

    write(ans ? ans : 1);
}

Measured memory_bytes: 9088
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    y,m,d = [int(i) for i in N[l].split()]
    id = y * 10000 + m * 100 + d
    if id < 18680908:
        print("pre-meiji")
    elif id < 19120730:
        print("meiji", y - 1867, m, d)
    elif id < 19261225:
        print("taisho", y - 1911, m, d)
    elif id < 19890108:
        print("showa", y - 1925, m, d)
    else:
        print("heisei", y - 1988, m, d)




Measured memory_bytes: 5596
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))

odd = 0
for a in As:
    odd += a % 2
if odd % 2:
    print('NO')
else:
    print('YES')



Measured memory_bytes: 17608
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l, cnt,s,col;
ll a[100500];
ll ff(ll x) {
    ll sum = 0;
    while (x) {
        sum += x%10;
        x /= 10;
    }
    return sum;
}
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n;
    ll ans = MOD;
    for (int i = 1; i <= n-1; i++)
        ans = min(ans, ff(i) + ff(n-i));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
package main

import (
	"fmt"
)

func main() {
	var N, ans string
	fmt.Scan(&N)

	if (N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]) {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int n;
int main(){
    cin>>n;
    int a[n+1];
    rep(i,n){
        cin>>a[i];
    }
    a[n]=-1;
    sort(a,a+n);
    int temp=a[0];
    int count=0;
    int ans=0;
    for(int i=0;i<n+1;i++){
        if(a[i]==temp)count++;
        else {
            if(count%2==1)ans++;
            temp=a[i];
            count=1;
        }
    }
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 640
#include<cstdio>

int n, m;
int sz[111111], red[111111];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) sz[i] = 1;
	red[1] = true;
	for(int i=0;i<m;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (red[x]) {
			red[y]=true;
			if (sz[x]==1) red[x] = false;
		}
		sz[x]--; sz[y]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=red[i];
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
BTC = 380000

N = int(input())
sum_otoshidama = 0

for n in range(N):
    otoshidama = input().split()
    if otoshidama[1] == 'BTC':
        sum_otoshidama += float(otoshidama[0])*BTC
    else:
        sum_otoshidama += float(otoshidama[0])

print(sum_otoshidama)


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    int four,seven;
    int i;
    int n;
    scanf("%d",&n);
    for (four=0;4*four<=n;four++)
        for (seven=0;4*four+7*seven<=n;seven++)
            if (four*4+seven*7==n) {
                printf("Yes\n");
                return 0;
            }
    printf("No\n");
    return 0;
}


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

vector<int> primes={2,3,5,7};
int primes_extend(int calc_from, int calc_to);
int factoring(int n, map<int,int> &factors);

const int combination_max=100000+1000;
const int combination_modulo=1000000007;
vector<int64_t> factorials(combination_max);
vector<int64_t> factorials_inv(combination_max);
vector<int64_t> inverse(combination_max);
int combination_mod(int n, int k);
int prepare_combination_mod();
	

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

	primes_extend(10,100);
	primes_extend(100,10000);
	primes_extend(10000,32767);

	map<int,int> factors;
	factoring(m,factors);
	for (pair<int,int> p:factors)
	{
	 	// fprintf(stderr,"%d: %d\n",p.first,p.second);
	}

	prepare_combination_mod();

	int64_t patterns=1;
	for (pair<int,int> p:factors)
	{
		int c=combination_mod(p.second+n-1,n-1);
		// fprintf(stderr,"%d: %d patterns\n",p.first,c);
		patterns*=c;
		patterns%=combination_modulo;
	}
	cout << patterns << endl;
}

int primes_extend(int calc_from, int calc_to)
{

	for (int i=calc_from;i<=calc_to;++i)
	{
		int j;
		int loop_max=sqrt(i);
		for (j=0;(primes[j]<=loop_max)&&(j<primes.size());++j)
		{
			if ((i%primes[j])==0)
			{
				// not prime...
				break;
			}
		}
		if ((j>=primes.size())||(primes[j]>loop_max))
		{
			primes.push_back(i);
		}
	}
	//fprintf(stderr,"count: %d\n",primes.size());
}

int factoring(int n, map<int,int> &factors)
{
	int maxfactor=sqrt(n);
	for (int i=0;(n>1)&&(primes[i]<=maxfactor);++i)
	{
		while ((n%primes[i])==0)
		{
			n/=primes[i];
			factors[primes[i]]++;
		}
	}
	if (n!=1)
	{
		factors[n]++;
	}

	return 0;
}

int prepare_combination_mod()
{
	factorials[0]=1;
	factorials[1]=1;
	factorials_inv[0]=1;
	factorials_inv[1]=1;
	inverse[1]=1;
	for (int i=2;i<combination_max;++i)
	{
		factorials[i]=factorials[i-1]*i%combination_modulo;
		inverse[i]=combination_modulo - inverse[combination_modulo%i]*(combination_modulo/i)%combination_modulo;
		factorials_inv[i]=factorials_inv[i-1]*inverse[i]%combination_modulo;
	}
}

int combination_mod(int n, int k)
{
	return factorials[n]*(factorials_inv[k]*factorials_inv[n-k]%combination_modulo)%combination_modulo;
}






Measured memory_bytes: 2688
#include <iostream>
#include <cassert>
#include <deque>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 50
using namespace std;
int ans;
int n,r,c,p;
deque<int> deck;
int main() {
  while(1){
    cin >> n >> r;
    if(n==0&&r==0) return 0;
    deck.clear();
    rep(i,n) deck.push_front(i+1);
    rep(i,r){
      cin >> p >> c;
      rep(j,c){
        deck.push_front(deck[p-1+c-1]);
        deck.erase(deck.begin()+p-1+c);
      }
    }
    ans = deck[0];
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    sort(rALL(a));

    ll x = a[0];
    ll y = 0;
    REP(i,1,n){
        if(abs(a[i]-x/2)<abs(y-x/2)){
            y = a[i];
        }
    }
    ll ans=0;
    cout<<x<<" "<<y<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,char> p2;
void solve(){
	ll n;
	cin>>n;
	string s;
	while(n>0){
		n--;
		s.push_back(char(n%26)+'a');
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3652
N,M = list(map(int, input().split()))
ab = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[1])
last = ab[0][1]
s = 1
for one in ab[1:]:
    a,b = one
    if a>=last:
        s+=1
        last = b
print(s)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Hitachi String
            var S = Console.ReadLine();

            if (S.Replace("hi", "") == "")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = s / 10 % 10;
  s3 = s % 10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
     
using namespace std;
     
int findSumOfDigits(int x){
  int sum;
  if(x == 0) sum = 0;
  while(x > 0){
    sum += x % 10;
    x /= 10; 
  }
  return sum;
}
  
     
int main(){
  int N;
  cin >> N;
  int mins = 100000;
for (int i = 1; i <= N - 1 ; i++){
  int a = N - i;
  int b = i;
  int s;
  s = findSumOfDigits(a) + findSumOfDigits(b);
  mins = min(s, mins);
  }
cout << mins;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x < abs(K-x)) {
      sum += x*2;
    }
    else {
      sum += abs(K-x)*2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 510;
char v[N][N];
char r[N][N];
char b[N][N];
int main(){
	int h,w;
	scanf("%d%d", &h, &w);
    for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			scanf(" %c", &v[i][j]);
		}
	}
	memset(b, '.', sizeof b);
	memset(r, '.', sizeof r);
	// blue
	for (int i = 0; i < h; ++i){
		if (i % 2 == 0){
			b[i][0] = '#';
		} else {
			for (int j = 0; j < w-1; ++j)
				b[i][j] = '#';
		}
	}
    // red
	for (int i = 0; i < h; ++i) {
		if (i % 2 == 1) {
			r[i][w-1] = '#';
		} else {
			for (int j = 1; j < w; ++j)
				r[i][j] = '#';
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if(b[i][j] == '.' && v[i][j] == '#') {
				b[i][j] = '#';
			}
			if(r[i][j] == '.' && v[i][j] == '#') {
				r[i][j] = '#';
			}
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			printf("%c", b[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			printf("%c", r[i][j]);
		}
		printf("\n");
	}
}

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

using namespace std;

using int64 = long long;

vector< int > zeta(int N, vector< int > f) { //get F(S)=Σ(T⊂S)G(T)
  vector< int > g(f);
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 1 << N; j++) {
      if(j & (1 << i)) {
        g[j] = max(g[j], f[j] + f[j & ~(1 << i)]);
        f[j] = max(f[j], f[j & ~(1 << i)]);
      }
    }
  }
  return g;
}

int main() {
  int N;
  cin >> N;
  vector< int > A(1 << N);
  for(int i = 0; i < 1 << N; i++) {
    cin >> A[i];
  }
  auto x = zeta(N, A);
  int sum = 0;
  bool first = false;
  for(auto &p : x) {
    sum = max(sum, p);
    if(first++) cout << sum << endl;
  }
}


Measured memory_bytes: 5116
#include <iostream>
#include <iomanip>

using namespace std;
/*
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
*/
#define pi 3.1415926

int main() {
    double r;
    cin >> r;
    cout << setprecision(10)<<2*pi*r;
    return 0;
}


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

int main(){
	string s;
	while(cin>>s,s!="#"){
		int step=0;
		int num=-1;
		for(int i=s.size()-1;i>=0;i--){
			
			if(s[i]=='n'){
				if(step==0)
					num=0;
				else
					num=num*2-90;
				
				step++;


			}
			else if(s[i]=='w'){
				if(step==0)
					num=90;
				else
					num=num*2+90;
				step++;
			}



		}
		for(;;){
			if(num%2==0 && step>1)
				num/=2,step--;
			else
				break;

		}
		if(step==1)
			cout<<num<<endl;
		else
			cout<<num<<"/"<<(1<<(step-1))<<endl;



	}
}

Measured memory_bytes: 3168
module IntWeightedDirectedGraphByArray = struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  (* 辺の重さがごく小さい場合は，Mapをキュー代わりに使うより配列を使った方が効率的
     時間計算量はO(E+VW)，空間計算量はO(E+W) *)
  let dijkstra_special :
    (* 頂点数n *)
    int ->
    (* 辺の重さの上限W *)
    int ->
    (* 頂点uを受け取って，
       uから伸びる辺の終点vと重さwの組みのリストを返す関数
       辺の重さwはW以下でなくてはならない *)
    (int -> (int * int) church_list) ->
    (* 始点 *)
    int ->
    (* 始点から辿り着けなければinfを返す関数
       この関数を覚えておけば，呼び出しごとの途中までの計算結果がシェアされる *)
    (int -> int)
  = fun n mw es s ->
    (* 各頂点への最短距離を格納するやつ *)
    let d = Array.make n max_int in
    (* キュー *)
    let q = Array.make (mw + 1) [] in
    (* ヒープの最小要素の重み *)
    let w = ref 0 in
    (* ヒープの最小要素がどのインデックスに対応するか *)
    let i = ref 0 in
    (* ヒープに格納されている要素の数 *)
    let m = ref 1 in
    d.(s) <- 0;
    q.(0) <- [s];
    let rec dijkstra_aux t =
      (* 既に終点までの距離が分かっているので返す *)
      if !m <= 0 || d.(t) <= !w then d.(t) else
      match q.(!i) with
      (* ヒープには重さがwの要素は無かった *)
      | [] ->
          incr w;
          incr i;
          if mw < !i then i := 0;
          dijkstra_aux t
      (* ヒープには重さwの要素uが存在する *)
      | u :: us ->
          (* ヒープから重さwの要素を削除する *)
          q.(!i) <- us;
          decr m;
          if !w <= d.(u) then
            (* 未だ頂点uを訪れていない *)
            (es u).fold (fun (v, c) () ->
              if !w + c < d.(v) then begin
                d.(v) <- !w + c; (* 頂点vの重さを緩和 *)
                (* ヒープにvを追加する *)
                incr m;
                let j = !i + c - if !i + c <= mw then 0 else mw + 1 in
                q.(j) <- v :: q.(j)
              end) ();
          dijkstra_aux t in
    dijkstra_aux
end

let () = Scanf.scanf "%d" @@ fun k ->
  Printf.printf "%d\n" @@
  succ @@
  IntWeightedDirectedGraphByArray.dijkstra_special k 1 (fun i ->
    { IntWeightedDirectedGraphByArray.fold = fun f acc -> f ((i + 1) mod k, 1) @@ f (i * 10 mod k, 0) acc }) 1 0


Measured memory_bytes: 6400
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


struct cake {
    ll x = 0;
    ll y = 0;
    ll z = 0;
};

ll sum(const cake& c, ll mode) {
    switch (mode) {
        case 0:
            return c.x + c.y + c.z;
        case 1:
            return -c.x + c.y + c.z;
        case 2:
            return c.x -c.y + c.z;
        case 3:
            return c.x + c.y - c.z;
        case 4:
            return -c.x - c.y + c.z;
        case 5:
            return c.x - c.y - c.z;
        case 6:
            return -c.x + c.y - c.z;
        case 7:
            return -c.x - c.y - c.z;
    }
    assert(false);
}


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<cake> C;
    rep (i, N) {
        cake c;
        cin >> c.x >> c.y >> c.z;
        C.pb(c);
    }
    ll ans = -linf;
    rep (mode, 8) {
        cake dp[1001];
        set<ll> memo;
        for (ll i = 1; i <= M; ++i) {
            cake cur = dp[i - 1];
            ll val = -linf;
            ll id = -1;
            rep (j, N) {
                if (memo.count(j)) continue;
                cake c = C[j];
                ll v = sum({cur.x + c.x, cur.y + c.y, cur.z + c.z}, mode);
                if (v > val) {
                    val = v;
                    id = j;
                }
            }
            memo.ist(id);
            cake c = C[id];
            dp[i] = {cur.x + c.x, cur.y + c.y, cur.z + c.z};
        }
        ans = max(ans, sum(dp[M], mode));
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.lang.*;
import java.util.*;
public class Main{
public static void main(String[] args) 
{
	Scanner scanner=new Scanner(System.in);
	int n=scanner.nextInt();
	int[] x=new int[n];
	int[] f=new int[n+1];
	long ans=1;
	long m=(int)Math.pow(10,9)+7;
	for(int i=0;i<n;i++)
	{
		x[i]=scanner.nextInt();
		f[x[i]]++;
	}
	int a;
	if(n%2==0)a=1;
	else a=2;
	for(int i=a;i<n+1;i=i+2)
	{
		if(f[i]!=2){ans=0;break;}
	}
	if(ans==0)System.out.print(0);
	else {
		for(int i=0;i<(n/2);i++)
		{
			ans*=2;
			ans%=m;
		}
		System.out.print(ans);
	}
}	
}

Measured memory_bytes: 51612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n, q, sum=0;
  cin >> n;
  //vector<int> vec(n+1);//マジもんの数列
  vector<long long> x(100010);//ある数の個数
  for(int i=1; i<n+1; i++){
    int a;
    cin >> a;//Ai入力
    sum+=a;
    x.at(a)++;
  }
  //cout << sum << endl;
  cin >> q;
  for(int i=0;i<q;i++){
    int b,c;
    cin >> b >> c;
    sum=sum+(c-b)*x.at(b);
    x.at(c)=x.at(c)+x.at(b);//新しいCiの個数
    x.at(b)=0;
    cout << sum << endl;
    //for(int j=0;j<4;j++) cout << x.at(j) << endl;
  }
}

    


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int dpw[3010], dps[3010];
signed main(){
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	A *= 100;
	B *= 100;

	dpw[0] = dps[0] = 1;
	for(int i = 0; i <= F; ++i) {
		if(i >= A) {
			dpw[i] |= dpw[i - A];
		}
		if(i >= B) {
			dpw[i] |= dpw[i - B];
		}
		if(i >= C) {
			dps[i] |= dps[i - C];
		}
		if(i >= D) {
			dps[i] |= dps[i - D];
		}
	}
	set<int> s;
	for(int i = 0; i <= F; ++i) {
		if(dps[i]) s.insert(i);
	}
	double res = -1;
	int p, q;
	for(int i = 1 ; i <= F; ++i) if(dpw[i]) {
		for(auto j: s) if(i + j <= F && j <= i * E / 100) {
			double tmp = (double)j / (i + j);
			if(tmp > res) {
				res = tmp;
				p = i + j;
				q = j;
			}
		}
	}
	cout << p << " " << q << endl;
	return 0;
}


Measured memory_bytes: 384
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False

if v.count(v[0]) == n:#全部同じ
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            k = True
        else:
            g = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if g:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if k:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

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

int main(){
	int n; cin >> n;
	double ans;
	if(n % 2 == 0){
		ans = 0.5;
	}else{
		ans = (n + 1)/(2.0 * n);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
cumA = [0] * (n + 1)
for i in range(n):
    cumA[i+1] = cumA[i] + A[i]

ans = 0
ok, ng = 0, 1e6
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    t = 0
    for a in A:
        t += n - bisect.bisect_left(A, mid-a)
    if t >= m: ok = mid
    else: ng = mid

ans = 0
t = 0
for i in range(n):
    k = bisect.bisect_left(A, ng - A[i])
    t += n - k
    ans += cumA[n] - cumA[k] + (n-k)*A[i]
ans += ok*(m-t)
print(int(ans))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int A[N];
  REP(i, N) A[i] = nextInt();

  ll all = 1;
  ll odd = 1;
  REP(i, N) {
    all *= 3;
    int o = 0;
    for (int b = A[i] - 1; b <= A[i] + 1; b++) {
      if (b % 2 == 1) o++;
    }
    odd *= o;
  }
  cout << (all - odd) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	string S;
	cin >> S;
	int s = (int)S.size();
	bool judge  = true;
	bool existC = false;
	for (int i = 0; i < s; ++i)
	{
		if(i == 0 && S[i] != 'A'){
			judge = false;
		}
		if((i == 1 || i == s-1) && !('a' <= S[i] && S[i] <= 'z')){
			judge = false;
		}
		if(1 < i && i < s-1){
			if(S[i] == 'C'){
				if(existC){
					judge = false;
				}else{
					existC =true;
				}
			}else if(!('a' <= S[i] && S[i] <= 'z')){
				judge = false;
			}
		}
		
	}
    if(!existC)judge = false;
	if(judge){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

from fractions import gcd
def two(n):
    ans = 0
    while n%2==0:
        n //= 2
        ans += 1
    return ans

def multi_lcm(A):
    ans = A[0]
    for a in A:
        ans *= a//gcd(ans,a)
    return ans

def solve(N,M,A):
    ans = 0
    num_two = len(set(map(two,A)))
    if num_two != 1:
        return 0
    l = multi_lcm(A)
    ans = (M+l//2)//l
    return ans
print(solve(N,M,A))


Measured memory_bytes: 19860
import java.util.Scanner;

public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		
		x=sc.nextInt();
		System.out.println(x*x*x);
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
import sys,math
if sys.version_info[0]>=3: raw_input=input
N=int(raw_input())
for i in range(N):
	x1,y1,x2,y2,x3,y3=[float(e) for e in raw_input().split()]
	a1=2*x2-2*x1
	b1=2*y2-2*y1
	c1=x1*x1-x2*x2+y1*y1-y2*y2
	a2=2*x3-2*x1
	b2=2*y3-2*y1
	c2=x1*x1-x3*x3+y1*y1-y3*y3
	x=(b1*c2-b2*c1)/(a1*b2-a2*b1)
	y=(c1*a2-c2*a1)/(a1*b2-a2*b1)
	print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))

Measured memory_bytes: 6828
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m;
  rd(n, m);

  writeln((2 ^^ m) * ((1900 * m) + (100 * (n - m))));
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	vector<int> a(n), cnt(n + 10, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}

	vector<int> v;
	for (int i = 0; i <= n; i++)
	{
		if (cnt[i] == 0)continue;
		v.push_back(cnt[i]);
	}

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

	int ans = 0;
	int siz = v.size();
	while (v.size() > k) {

		ans += v.back();
		v.pop_back();

	}
	cout << ans << endl;





	return 0;
}


Measured memory_bytes: 2936
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 * the base of this program is 
 * https://www.youtube.com/watch?v=gdQxKESnXKs
 * written by chokudai
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
string S,T ;

/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }

  cin >> S >> T ;
  vector<int> start(26,-1) ;
  vector<int> goal(26,-1) ;

  REP(i,S.size()){
    int a = S[i] - 'a' ;
    int b = T[i] - 'a' ;

    if( start[a] != -1 || goal[b] != -1  ){
      if(start[a] != b || goal[b] != a  ){
        cout << "No" << endl;
        return 0 ;
      }
    }else{

    start[a] = b ;
    goal[b] = a ;
    }
  }
  cout << "Yes" << endl ;
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}
/******** scan **************/
int scanInt(void ){
  int n ;
  if(std::scanf("%d",&n)){
  }else{
    std::printf("scanN error\n");
    std::exit(1);
  }
  return n ;
}
void scanLlArr(ll *a , int n){
  int ireadA ; 
  for (ireadA =  0 ; ireadA < n ; ireadA++){
    if(std::scanf("%lld",&a[ireadA])){
    }else{
      std::printf("readA error\n");
      std::exit(1);
    }
  }
}

string scanString(void){
  string s ;
  if(cin >> s){ 
  }
  else{
    std::printf("scanString error\n");
    std::exit(1);
  }
  return s;
}

void scanCharArr(char *string){
  if(scanf("%s",string))
  {}
  else{
    std::printf("scanCharStr error\n");
    std::exit(1);
  }
}
/************* print **************/
void printInt(int p){
  if(std::printf("%d\n",p)){
  }else{
    std::printf("intPrintf Error\n");
    std::exit(1);
  }
}

void printLlArr(ll *a){
  int i ;
  for(i = 0 ; i < sizeof(a)/sizeof(ll) ; i++){
    if(std::printf("%lld ",a[i] )){
    }else{
      std::printf("intPrintN Error i = %d stopped \n",i);
      std::exit(1);
    }
  }
  std::printf("\n");
}
void printCharArr(char *string){
 for(int i = 0 ; i < sizeof(string)/sizeof(char); i++){
   if(printf("%c",string[i])){
     }
   else{
      std::printf("charStrPrint Error i = %d stopped \n",i);
      std::exit(1);
   }
 }
 printf("\n");
}

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


public class Main {
	
	boolean[] getPrime(final int n){
		boolean[] list = new boolean[n+1];
		for(int i=2; i<=n; ++i){ list[i] = true;}
		for(int i=2; i*i<=n; ++i){
			if(list[i]){
				for(int j=i*2; j<=n; j+=i){
					list[j] = false;
				}
			}
		}
		return list;
	}
	
	int countGoldbach(final boolean[] map){
		int c=0;
		int target = map.length -1;
		
		for(int i=2; i<=target/2; ++i){
			int j = target - i;
			if(map[i] && map[j])++c;
		}
		
		return c;
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			final int n = sc.nextInt();
			if(n==0)return;
			System.out.println(countGoldbach(getPrime(n)));
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
	
	void debug(Object... os){
		System.out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
h, w = map(int, input().split())
lst = [['*' for i in range(w+2)]]
for i in range(h):
    lsti = ['*']
    lsti.extend(list(input()))
    lsti.append('*')
    lst.append(lsti)
lst.append(['*' for i in range(w+2)])

lst_cnt = [[300 for i in range(w+2)] for j in range(h+2)]
if lst[1][1] == '#': lst_cnt[1][1] = -1
else: lst_cnt[1][1] = 0

for i in range(1, h+1):
    for j in range(1, w+1):
        if i == 1 and j == 1: continue
        if lst[i][j] == '.':
            lst_cnt[i][j] = min(abs(lst_cnt[i-1][j]), abs(lst_cnt[i][j-1]))
        else:
            if lst[i-1][j] == '#':
                kouho1 = lst_cnt[i-1][j]
            else:
                kouho1 = -(lst_cnt[i-1][j]+1)
            if lst[i][j-1] == '#':
                kouho2 = lst_cnt[i][j-1]
            else:
                kouho2 = -(lst_cnt[i][j-1]+1)
            lst_cnt[i][j] = -min(abs(kouho1), abs(kouho2))

print(abs(lst_cnt[h][w]))

Measured memory_bytes: 3316
def main():
  N = int(input())

  d = N % 10

  if(d == 2 or d == 4 or d == 5 or d == 7 or d == 9):
    print("hon")
  elif(d == 0 or d == 1 or d == 6 or d == 8):
    print("pon")
  elif(d == 3):
    print("bon")
  

if __name__ == "__main__":
  main()

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<int,int>mp;
    int n,i,k,x,ans=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        mp[x]++;
        if(mp[x]==x)ans-=x;
        ans++;
    }cout<<ans;
    return 0;
}

Measured memory_bytes: 7980
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<vector>

using namespace std;

void showNodes(vector<int> tnodes){
  for(int in = 1; in < tnodes.size(); in++){
    //tnodes?????????1????????????????????¨?????¨???
    printf("node %d: key = %d, ", in, tnodes[in]);
    
    int in_p = in/2;
    if(in_p >= 1 && in != in_p){
      printf("parent key = %d, ", tnodes[in_p]);
    }

    int in_l = 2*in+0;
    int in_r = 2*in+1;
    if(in_l < tnodes.size()){
      printf("left key = %d, ", tnodes[in_l]);
    }
    if(in_r < tnodes.size()){
      printf("right key = %d, ", tnodes[in_r]);
    }

    printf("\n");
  }
}

int main(){
  int n;
  cin >> n;
  
  vector<int> nodes;
  nodes.push_back(-1);

  for(int i = 0; i<n; i++){
    int tmpNodeId;
    cin >>   tmpNodeId;
    nodes.push_back(tmpNodeId);
  }
  
  showNodes(nodes);
  
  return 0;
}

Measured memory_bytes: 3268
n = int(input())
a = list(map(int, input().split()))
pm_sum = 0
pm_count = 0
mp_sum = 0
mp_count = 0
for i in range(n):
    pm_sum += a[i]
    mp_sum += a[i]
    if i % 2 == 0:
        pm_d = max(0, 1 - pm_sum)
        mp_d = max(0, mp_sum - (-1))
        pm_sum += pm_d
        mp_sum -= mp_d
    else:
        pm_d = max(0, pm_sum - (-1))
        mp_d = max(0, 1 - mp_sum)
        pm_sum -= pm_d
        mp_sum += mp_d
    pm_count += pm_d
    mp_count += mp_d
print(min(pm_count, mp_count))

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b,c,d;
  cin>>n;
  a=n/1000;
  b=n%1000/100;
  c=n%100/10;
  d=n%10;
  if((a==b && b==c) || (b==c && c==d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int main() {
  int N, X; cin >> N >> X;
  int ln = 0;
  for (int i = 0; i < N; i++) {
    int L; cin >> L;
    if (ln <= X) {
      ln += L;
    }
    if (ln > X) {
      cout << i + 1 << endl;
      break;
    }
    else if (i == N - 1) {
      cout << N + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


int main() {

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());

	ll mid;
	if (n % 2)
	{
		//odd
		mid = a[n / 2];
	}
	else
	{
		mid = (a[n / 2] + a[n / 2 - 1]) / 2;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans += abs(a[i] - mid);
	}
	cout << ans << endl;
}





Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	long long x,y,i;
  	scanf("%lld %lld",&x,&y);
	if(x%y==0)
    {
      	printf("-1");
      	return 0;
    }
  	if(y%100000007!=0)
  		printf("%lld",x*100000007);
	else
  		printf("%lld",x*1000000007);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
int N,K;
vector<pii> E;
//=================================================

void dfs(int cur, int pre, int num, int &ans, vector<vector<int>> &g) {
    ans = ans * num % MOD;

    num = K - 1;

    if (pre != -1) --num;
    for (auto x : g[cur]) {
        if (x == pre) continue;
        dfs(x, cur, num, ans, g);
        --num;
    }

}

//=================================================
void input()
{
    cin>>N>>K;
    E.resize(N-1);
    rep(i,N-1){
        cin>>E[i].first>>E[i].second;
    }
}
//=================================================
void solve()
{
    vector<vector<int>> g(N+1);
    for (auto x : E) {
        g[x.first].push_back(x.second);
        g[x.second].push_back(x.first);
    }
    int ans = 1;
    dfs(1,-1,K,ans,g);
    cout<<ans<<endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 13184
class Car
  num = 1
  
  define_method(:initialize) do |time|
    @num = num
    num += 1
    @time = time
  end
  attr_accessor :num, :time
  
  define_singleton_method(:clear) {num = 1}
end

class ParkingLot
  Space = Struct.new(:upper, :lower)
  
  def initialize(num)
    @spaces = num.times.map {|i| Space.new}
  end
  
  def add(waiting_time)
    idx = @spaces.index {|sp| sp.lower.nil?}
    if idx
      @spaces[idx].lower = Car.new(waiting_time)
    else
      return false if @spaces.all?(&:upper)
      
      idxs = @spaces.map.with_index {|sp, i| i unless sp.upper}.compact
      idx = idxs.map do |i|
        diff = @spaces[i].lower.time - waiting_time
        diff >= 0 ? [diff, i] : nil
      end.compact.sort_by(&:itself).first&.last
      unless idx
        idx = idxs.map {|i| [waiting_time - @spaces[i].lower.time, i]}
                  .sort_by(&:itself).first.last
      end
      
      @spaces[idx].upper = @spaces[idx].lower.dup
      @spaces[idx].lower = Car.new(waiting_time)
    end
    true
  end
  
  def next
    @spaces.each do |sp|
      if sp.lower
        sp.lower.time -= 1
        sp.upper.time -= 1 if sp.upper
      end
    end
    
    result = []
    @spaces.each do |sp|
      if sp.lower and sp.lower.time <= 0
        result << sp.lower.num
        sp.lower = sp.upper.dup
        sp.upper = nil
      end
    end
    @spaces.each do |sp|
      if sp.lower and sp.lower.time <= 0
        result << sp.lower.num
        sp.lower = nil
      end
    end
    
    result
  end
  
  def empty?
    @spaces.all? {|sp| sp.lower.nil?}
  end
end

until (given = gets.split.map(&:to_i)) == [0, 0]
  m, n = given
  parking_time = n.times.map {gets.to_i}
  pl = ParkingLot.new(m)
  result = []
  wait = []
  Car.clear
  t = 0
  
  loop do
    result += pl.next
    
    wait << parking_time.shift if (t % 10).zero?
    t += 1
    while (waiting = wait.shift)
      unless pl.add(waiting)
        wait.unshift(waiting)
        break
      end
    end
    
    break if pl.empty?
  end
  
  puts result.join(" ")
end


Measured memory_bytes: 6884
N, *H = map(int, open(0).read().split())

ans = 0

def split_list(l, s):
    ans = []
    while l.count(s):
        pos = l.index(s)
        ans.append(l[:pos])
        l = l[pos+1:]
    ans.append(l)
    return ans

def f(L):
    if len(L) == 0:
        return
    while L.count(0) == 0:
        global ans
        ans += 1
        L = [l - 1 for l in L]
    for m in split_list(L, 0):
        f(m)

f(H)
print(ans)

Measured memory_bytes: 67524
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int t[N+1];
  int x[N+1];
  int y[N+1];
  bool flag=true;
  for(int i=1;i<N+1;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(int i=0;i<N;i++){
    int d;
    d=x[i+1]-x[i]+y[i+1]-y[i];
    int s;
    s=t[i+1]-t[i];
    if(d>s || (s-d)%2==1){
      flag=false; 
    }
  }
if(flag==true){
 cout << "Yes" << endl; 
}
  else{
   cout << "No" << endl;
  }
return 0;}

Measured memory_bytes: 1408