akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	if(n == 1) puts("Hello World");
	if(n == 2){
		int a, b; scanf("%d %d", &a, &b);
		printf("%d\n", a + b);
	}
	return 0;
}

Measured memory_bytes: 128
package main

/*
反転数
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func mergeSortWhileCounting(a []int, invCnt *int) []int {
	if len(a) <= 1 {
		return a
	}
	mid := len(a) / 2
	left := mergeSortWhileCounting(a[:mid], invCnt)
	right := mergeSortWhileCounting(a[mid:], invCnt)
	return mergeWhileCounting(left, right, invCnt)
}

func mergeWhileCounting(a, b []int, invCnt *int) []int {
	m := make([]int, len(a)+len(b))
	inversion := 0
	i, j := 0, 0
	for mi := 0; mi < len(m); mi++ {
		if i >= len(a) {
			m[mi] = b[j]
			j++
		} else if j >= len(b) {
			m[mi] = a[i]
			i++
		} else if a[i] < b[j] {
			m[mi] = a[i]
			i++
		} else {
			m[mi] = b[j]
			inversion += len(a) - i
			j++
		}
	}
	*invCnt += inversion
	return m
}

func main() {
	scanner := makeScanner(10000000000 * 500000)
	eGetInt(scanner)
	s := eGetInts(scanner)
	count := 0
	mergeSortWhileCounting(s, &count)
	fmt.Printf("%v\n", count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(max int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), max)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}



Measured memory_bytes: 16548
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

int input() {
	int n;
	std::cin >> n;
	return n;
}

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

	std::vector<std::vector<int>> g(n);
	for (int i = 0; i < n - 1; i++) {
		int u = input() - 1;
		int v = input() - 1;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	std::queue<int> q;
	q.push(0);
	q.push(n - 1);

	std::vector<int> color(n, -1);
	color[0] = 0;
	color[n - 1] = 1;


	while (!q.empty()) {
		int u = q.front();
		q.pop();

		for (int v : g[u]) {
			if (color[v] == -1) {
				color[v] = color[u];
				q.push(v);
			}
		}
	}

	int black = 0;
	int white = 0;
	for (int i = 0; i < n; i++) {
		if (color[i] == 0) {
			black++;
		} else {
			white++;
		}
	}

	if (black > white) {
		puts("Fennec");
	} else {
		puts("Snuke");
	}
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

int main(){
 ll n,m;cin>>n>>m;
 priority_queue<ll,vector<ll>,less<ll>> que;
 rep(i,n){
   ll a;cin>>a;
   que.push(a);
 }
 rep(i,m){
   ll b = que.top();
   que.pop();
   b /= 2;
   que.push(b);

 }
 ll ans=0;
 rep(i,n){
   ll c = que.top();
   que.pop();
   ans+=c;
 }

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

Measured memory_bytes: 1400
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for i in range(N)]
    w = [wv[i][0] for i in range(N)]
    v = [wv[i][1] for i in range(N)]
    MV = max(v)*N+1
    inf = float("inf")
    dp = [[inf]*MV for i in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(MV):
            if v[i] <= j:
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:
                dp[i+1][j] = dp[i][j]
    ldp = dp[N]
    for i in reversed(range(MV)):
        if ldp[i] <= W:
            print(i)
            exit()

if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 300540
#include <iostream>

using namespace std;

int main(void){
  int x,a,b;
  
  cin >> x >> a >> b;
  if(b <= a) cout << "delicious" << endl;
  else if(b <= a+x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MOD=998244353;

ll geom_prog[200005];
ll tpow[200005];

ll qexp(ll b,ll p,int m){
    ll res=1;
    while (p){
        if (p&1) res=(res*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return res;
}

int n,q;

struct node{
	int s,e,m;
	ll val,lazy=0;
	node *l,*r;
	
	node (int _s,int _e){
		s=_s,e=_e,m=s+e>>1;
		val=geom_prog[e-s]*tpow[s]%MOD;
		
		if (s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	
	void propo(){
		if (lazy){
			val=geom_prog[e-s]*tpow[s]%MOD*lazy%MOD;
			
			if (s!=e){
				l->lazy=lazy;
				r->lazy=lazy;
			}
			
			lazy=0;
		}
	}
	
	void update(int i,int j,int k){
		propo();
		if (s==i && e==j) lazy=k;
		else{
			if (j<=m) l->update(i,j,k);
			else if (m<i) r->update(i,j,k);
			else l->update(i,m,k),r->update(m+1,j,k);
			
			l->propo(),r->propo();
			
			val=(l->val+r->val)%MOD;
		}
	}
} *root;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	tpow[0]=geom_prog[0]=1;
	rep(x,1,200005){
		tpow[x]=(tpow[x-1]*10)%MOD;
		geom_prog[x]=(geom_prog[x-1]+tpow[x])%MOD;
	}
	
	cin>>n>>q;
	root=new node(0,n-1);
	//cout<<root->val<<endl;
	
	int a,b,c;
	while (q--){
		cin>>b>>a>>c;
		
		a=n-a,b=n-b;
		//cout<<a<<b<<c<<endl;
		root->update(a,b,c);
		root->propo();
		cout<<root->val<<endl;
	}
}





Measured memory_bytes: 31768
function main(input) {
    var line = input.split(/\r?\n/g);
    const A = line[1].split(" ").map(Number);
    var flg = true;
    for (var i in A)
        if (!(A[i] % 2) && (A[i] % 3) && (A[i] % 5)) {
            flg = false;
            break;
        }
    console.log(flg ? "APPROVED" : "DENIED");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int h,w,a,b;
    cin >> h >> w >> a >> b;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if((i < b) ^ (j < a)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }

}



Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;

 int main(){
   int k; cin >> k;
   if(k%2==0) cout << k*k/4 <<endl;
   else cout << (k-1)*(k+1)/4 <<endl;
 }

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readIntegerList()
    val map = Array(h) { readLine()!! }
    val dp = Array(h) { LongArray(w) }
    dp[0][0] = 1
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (i + 1 < h && map[i + 1][j] == '.') dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % 1000000007
            if (j + 1 < w && map[i][j + 1] == '.') dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % 1000000007
        }
    }
    println(dp[h - 1][w - 1])
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 54208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = a[0];
	rep(i, n) {
		 ans = gcd(ans, a[i]);
	}
	cout << ans;
	return 0;
}












Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

#define MAX 100
#define INF -1

int n;
int G[MAX][MAX];
int dist[MAX];

void bfs(){
  bool used[MAX];
  fill(dist,dist+n,INF);
  fill(used,used+n,false);
  dist[0] = 0;
  used[0] = true;

  queue<int> Q;
  Q.push(0);

  while(!Q.empty()){
    int v = Q.front(); Q.pop();

    for(int i = 0 ; i < n ; i++){
      if(!used[i] && G[v][i]){
	used[i] = true;
	dist[i] = dist[v] + 1;
	Q.push(i);
      }
    }
  }
}

int main(){
  cin >> n;

  for(int i = 0 ; i < n ; i++){
    int u,k,v;
    cin >> u >> k;
    for(int j = 0 ; j < k ; j++){
      cin >> v;
      G[u-1][v-1] = 1;
    }
  }

  bfs();

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

  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, int> E[100001];
int H[100001];
int memo[100001];
int sagasu(int A) {
	if (memo[A]) return memo[A];
	vector<int> kari;
	for (int i = H[A]; i; i = E[i].second) kari.pb(sagasu(E[i].first));
	sort(kari.begin(), kari.end(), greater<int>());
	int ret = 1;
	rep(i, kari.size()) ret = max(ret, i + kari[i] + 1);
	return memo[A] = ret;
}

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


	int N = getint();

	for (int i = 2; i <= N; i++) {
		int a = getint();
		E[i] = mp(i, H[a]);
		H[a] = i;
	}

	co(sagasu(1) - 1);

	Would you please return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define INF 100000000

int main(){
  int a;
  cin >> a;
  cout << (a+1)/2 << endl;
}  

Measured memory_bytes: 256
/* Name        : a
 * Creat       : Sat Jul 13 14:52:13 CST 2019
 * Accept      : Sat Jul 13 14:53:23 CST 2019
 * Author      : landcold7
 * Motto       : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a >= 13) {
    ans = b;
  }
  else if (6 <= a && a <= 12) {
    ans = b / 2;
  }
  else {
    ans = 0;
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())

for i in range(10):
    if 0<=abs(360*i-abs(30*H+(M/2)-6*M))<360:
        a=abs(360*i-abs(30*H+(M/2)-6*M))
        c=abs(360-abs(360*i-abs(30*H+(M/2)-6*M)))
        break
b=min(a,c)

print("{:.9f}".format(((A**2+B**2-2*A*B*(math.cos(b*(math.pi/180))))**(1/2))))

Measured memory_bytes: 62644
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = 110;
int n, m;
char a[N][N];
bool row[N], col[N];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            a[i][j] = getchar();
            while (a[i][j] != '.' && a[i][j] != '#') a[i][j] = getchar();
        }
    for (int i = 1; i <= n; i++){
        bool fl = 1;
        for (int j = 1; j <= m; j++)
            if (a[i][j] == '#'){
                fl = 0;
                break;
            }
        row[i] = fl;
    }
    for (int i = 1; i <= m; i++){
        bool fl = 1;
        for (int j = 1; j <= n; j++)
            if (a[j][i] == '#'){
                fl = 0;
                break;
            }
        col[i] = fl;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++)
            if (!row[i] && !col[j])
                putchar(a[i][j]);
        if (!row[i]) putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int[] nums = new int[n];
      int cnt = 0;
      for( int i = 0 ; i < n ; i++ ){
        nums[i] = scan.nextInt();
      }
      for( int i = 1 ; i < n-1 ; i++ ){
        if(
          (nums[i] != Math.max(nums[i],nums[i+1])) && 
          (nums[i] != Math.min(nums[i-1],nums[i])) ||
          (nums[i] != Math.max(nums[i-1],nums[i])) && 
          (nums[i] != Math.min(nums[i],nums[i+1]))     ) cnt++ ;
      }
      System.out.println(cnt);
    }
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define SZ(v)       (ll)(v).size()
#define ALL(v)      (v).begin(),(v).end()
#define UNIQ(v)     sort(ALL(v));(v).erase(unique(ALL(v)),(v).end())
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define BIT(n)      (1LL<<(n))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>
#define SHOW(x)     cout<<#x<<" = "<<x<<endl

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

int main() {
    string s; cin >> s;
    ll n = s.length();
    
    ll ans = n / 2;
    REP(i, n) if (s[i] == 'p') ans--;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

#0-indexed

#カードiが左からjの位置にあるときの表の数字
def getNum(i,j):
    return B[i] if abs(i-j)&1 else A[i]

#dp[使用済みカードを表すbit列][いちばん右のカードNo]=最小操作回数
INF=10**9
dp=[[INF for _ in range(N)] for __ in range(1<<N)]
for i in range(N):
    dp[1<<i][i] = i

for m in range(1,1<<N): #配置済みカードパターン
    cnt=bin(m).count('1') #配置済みカード数
    idx=dict() #未配置カードの位置
    tmp=cnt
    for i in range(N):
        if m & (1<<i) == 0:
            idx[i]=tmp
            tmp+=1
    for j in range(N): #新たに並べるカード
        if m & (1<<j):
            #もう使ったやつです
            continue
        num_j=getNum(j,cnt)
        for i in range(N): #配置済みのいちばん右にあるカード
            if m & (1<<i) == 0:
                #まだ配置済みじゃないです
                continue
            num_i=getNum(i,cnt-1)
            if num_i>num_j:
                #単調増加になりません
                continue
            dp[m|(1<<j)][j] = min(dp[m|(1<<j)][j], dp[m][i] + idx[j]-cnt)

ans=INF
for i in range(N):
    ans=min(ans,dp[(1<<N)-1][i])
print(ans if ans<INF else -1)


Measured memory_bytes: 127196
# 参照 https://qiita.com/Kerzival/items/6923c2eb3b91be86f19f
class UnionFind:
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.find_root(x)
        y = self.find_root(y)
        # すでに同じ木に属していた場合
        if x == y :
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    # ノードxが属する木のサイズを返す
    def count(self, x):
        return -self.root[self.find_root(x)]


N, M, K = map(int, input().split())
friend = [list(map(int, input().split())) for _ in range(M)]
block = [list(map(int, input().split())) for _ in range(K)]

friend_count = [0] * (N + 1)
block_with = [[] for _ in range(N + 1)]
uf = UnionFind(N + 1)

for f in friend:
    friend_count[f[0]] += 1
    friend_count[f[1]] += 1
    uf.unite(f[0], f[1])

for b in block:
    block_with[b[0]].append(b[1])
    block_with[b[1]].append(b[0])

for i in range(1, N + 1):
    ans = uf.count(i) - friend_count[i] - 1
    for b in block_with[i]:
        if uf.is_same_group(i, b):
            ans -= 1
    if i > 1:
        print(" ", end="")
    print(ans, end="")

print()


Measured memory_bytes: 65072
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	string s,t;
	cin>>s>>t;
	
	for(ll i=0;i<n;i++)
	{
		cout<<s[i]<<t[i];
	}
	cout<<endl;
	
	
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int V[100010][3];
int sum[100010];

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

	int N, K;
	string S;
	cin >> N >> K >> S;
	int c[2] = { 0 };
	vector<pair<int, int>> P;
	rep(i, 0, N)
	{
		if (S[i] == '0')
		{
			if (c[1] > 0)
			{
				P.push_back(mp(1, c[1]));
			}
			c[1] = 0;
			c[0]++;
		}
		else
		{
			if (c[0] > 0)
			{
				P.push_back(mp(0, c[0]));
			}
			c[0] = 0;
			c[1]++;
		}
		if (i == N - 1)
		{
			rep(j, 0, 2)
			{
				if (c[j] > 0)
				{
					P.push_back(mp(j, c[j]));
				}
			}
		}
	}

	int id = 0;
	rep(i, 0, SZ(P))
	{
		if (P[i].first == 0)
		{
			V[id][1] = P[i].second;
			if (0 < i)
			{
				V[id][0] = P[i - 1].second;
			}
			if (i < SZ(P) - 1)
			{
				V[id][2] = P[i + 1].second;
			}
			id++;
		}
	}

	rep(i, 0, id)
	{
		sum[i] = V[i][1] + V[i][2];
		if (0 < i)
		{
			sum[i] += sum[i - 1];
		}
	}

	int ans = 0;
	chmin(K, id);
	rep(i, 0, id - K + 1)
	{
		if (i == 0)
		{
			chmax(ans, sum[i + K - 1] + V[i][0]);
		}
		else
		{
			chmax(ans, sum[i + K - 1] - sum[i - 1] + V[i][0]);
		}
	}

	cout << (id==0?N:ans) << endl;

	return 0;
}

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

ll llpow(ll a,ll e){
  if(e==0){
    return 1LL;
  }
  return llpow(a,e-1)*a;
}
int main(){
  ll a,b;
  cin>>a>>b;
  ll x=b*1900+(a-b)*100;
  x*=llpow(2LL,b);
  cout<<x<<endl;

  return 0;
}

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

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = ri();
        int[] aArray = ria();

        int ans = 0;
        for (int i = 0; i < aArray.Length; i++)
        {
            if((i + 1) % 2 == 1 && aArray[i] % 2 == 1) ans++;
        } 

		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27512
from collections import deque

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

RD = [deque() for i in range(N)]
end = [False] * N

for i in range(M):

    L,R,D = map(int,input().split())
    RD[L-1].append([R-1,D])
    RD[R-1].append([L-1,-1 * D])
    end[L-1] = True
    end[R-1] = True
    
"""
    lp = wantp(L-1)
    rp = wantp(R-1)

    if lp != rp:

        if rank[lp] 
"""
    


endnum = 0
Q = deque()

cor = ["x"] * N
ans = "Yes"


for endp in range(N):

    if end[endp]:
        Q.append(endp)


        while len(Q) > 0:

            q = Q.pop()
            end[q] = False

            if cor[q] == "x":
                cor[q] = 0

            for r,d in RD[q]:

                if cor[r] == "x":
                    cor[r] = cor[q] + d
                    Q.append(r)

                elif cor[r] != cor[q] + d:
                    print ("No")
                    exit()


print ("Yes")


Measured memory_bytes: 129000
import java.util.*;
import java.lang.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        /*
        * assume that we have the list of 2-digit lunlun numbers({10,11,12,21,...,89,98,99}).
        * we can get the list of 3-digit lunlun numbers with this procedure:
        * for each 2-digit lunlun numbers N, add N ^ (N%10 +- 1)
        * [^ means string-concat]
        * */

        ArrayList<Long> lunluns = new ArrayList<>(120000);
        for(long i=1; i<=9; i++) lunluns.add(i);
        for(int n=0; n<100000; n++){
            if(lunluns.get(n)%10 > 0) lunluns.add(lunluns.get(n) * 10 + lunluns.get(n)%10 - 1);
            lunluns.add(lunluns.get(n) * 10 + lunluns.get(n)%10);
            if(lunluns.get(n)%10 < 9) lunluns.add(lunluns.get(n) * 10 + lunluns.get(n)%10 + 1);
        }
        System.out.println(lunluns.get(K - 1));
    }
}


Measured memory_bytes: 32980
#include<bits/stdc++.h>
using namespace std;
vector<int>e[111111];
int a[111111];
vector<int>b;
bool vis[111111];
void dfs(int x)
{
    b.push_back(x);
    vis[x]=1;
    for(int i=0;i<e[x].size();i++)
    {
        int v=e[x][i];
        if(vis[v])continue;
        dfs(v);
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    memset(vis,0,sizeof(vis));
    map<int,int>mp;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            b.clear();
            mp.clear();
            dfs(i);
            for(int j=0;j<b.size();j++)
            {
                mp[a[b[j]]]=1;
            }
            for(int j=0;j<b.size();j++)
            {
                if(mp[b[j]]==1)ans++;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 13560
#include<iostream>

using namespace std;

int main(){
	char name[10][16]={'\0'};
	int gozen[10]={0},gogo[10]={0};
	const int payGozen=200,payGogo=300;
	
	for(int i=0;i<9;i++){
		cin>>name[i]>>gozen[i]>>gogo[i];
	}
	
	for(int i=0;i<9;i++){
		cout<<name[i]<<" "<<gozen[i]+gogo[i]<<" "<<
			  payGozen*gozen[i]+payGogo*gogo[i]<<endl;
	}
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<int MOD>
struct ModInt {
    ModInt() :x(0) {}
    ModInt(long long x) :x((int)(x<0 ? MOD + x%MOD : x%MOD)) { }
    ModInt& operator+=(ModInt that) {
        x = x + that.x;
        if (x >= MOD)x -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        x -= that.x;
        if (x<0)x += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        x = (int)((long long)x * that.x % MOD);
        return *this;
    }
    ModInt operator+(ModInt that) {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) {
        return ModInt(*this) *= that;
    }
    int x;
};
typedef ModInt<1000000007> mint;
mint f[301][301][301];
vector<pii> r2lc[301];

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

    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int l, r, x;
        cin >> l >> r >> x;
        r2lc[r].emplace_back(l, x);
    }

    mint ans;
    auto upd = [&](int r, int g, int b) {
        int i = max(r, max(g, b));
        mint &w = f[r][g][b];
        if (w.x == 0)return;
        each(lc, r2lc[i]) {
            int c = (r >= lc.first) + (g >= lc.first) + (b >= lc.first);
            if (c != lc.second) {
                w = 0;
                return;
            }
        }
        if (i == N) {
            ans += w;
            return;
        }
        f[i+1][g][b] += w;
        f[r][i+1][b] += w;
        f[r][g][i+1] += w;
    };

    f[1][0][0] = f[0][1][0] = f[0][0][1] = 1;
    for (int i = 1; i <= N; ++i) {
        rep(r, i)rep(g, i) {
            int b = i;
            upd(r, g, b);
        }
        rep(g, i)rep(b, i) {
            int r = i;
            upd(r, g, b);
        }
        rep(b, i)rep(r, i) {
            int g = i;
            upd(r, g, b);
        }
    }

    cout << ans.x << endl;
}


Measured memory_bytes: 106752
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
B = [0] + LI()

A = [0,B[1]]
for i in range(1,N):
    if B[i] != B[i+1]:
        A.append(B[i+1])

N = len(A)-1

MAX = [0,1000] + [0]*N

from functools import lru_cache

@lru_cache(maxsize=None)
def dfs(n,money):
    if n == N+1:
        return money
    else:
        res = money
        for i in range(n,N):  # 購入
            for j in range(i+1,N+1):  # 売却
                if A[i] == min(A[i:j+1]) and A[j] == max(A[i:j+1]) and A[i] < A[j]:
                    if money+(A[j]-A[i])*(money//A[i]) > MAX[j+1]:
                        res = max(res,dfs(j+1,money+(A[j]-A[i])*(money//A[i])))
                        MAX[j+1] = money+(A[j]-A[i])*(money//A[i])
        return res

print(dfs(1,1000))


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vec(2*m);
    vector<int> ans(n);

    for(int i = 0; i < 2*m; i++){
        cin >> vec.at(i);
        ans.at(vec.at(i)-1)++;
    }

    for(int j = 0; j < n; j++) {
        cout << ans.at(j) << endl;
    }  
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int n,m;

int main(){
  cin>>n>>m;
  int cnt=0;
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    cnt+=uf.unite(a,b);
  }
  cout<<m-cnt<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;

    ll p[m];
    string s[m];
    rep(i, m){
        cin >> p[i] >> s[i];
        p[i]--;
    }

    vector<string> vec_answer[n];

    rep(i, m){
        vec_answer[p[i]].push_back(s[i]);
    }

    ll n_penalty = 0;
    ll n_passed = 0;
    rep(i, n){
        ll n_penalty_temp = 0;
        for(string s : vec_answer[i]){
            if(s == "WA"){
                n_penalty_temp++;
            }
            else{
                n_passed++;
                n_penalty += n_penalty_temp;
                break;
            }
        }
    }

    cout << n_passed << " " << n_penalty << endl;

    return 0;
}

Measured memory_bytes: 12032
#include<stdio.h>
#include<math.h>
 int a[10][10],d;
double distance(int i,int j)
{
    int k;
    double result=0;
    for(k=0; k<d; k++)
        result+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
    result=sqrt(result);
    return result;
}
int main()
{
    int n,i,j,c=0;
    
    double ans;
    scanf("%d%d",&n,&d);
    for(i=0; i<n; i++)
        for(j=0; j<d; j++)
            scanf("%d",&a[i][j]);
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            ans=distance(i,j);
            if(ans==(int)ans)
                c++;
        }
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n, d := io.ScanInt2()
	var count int
	for i := 0; i < n; i++ {
		x, y := io.ScanInt2()
		if math.Sqrt(float64(x*x+y*y)) <= float64(d){
			count++
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 7948
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int W = input[1];

            string[] s = new string[H];
            for(var i = 0; i < H; i++)
            {
                s[i] = Console.ReadLine();
            }

            for(var i = 0; i < H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    int cnt = 0;
                    if (s[i][j] == '#')
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        if (i > 0 && j > 0 && s[i - 1][j - 1] == '#') { cnt++; }
                        if (i > 0 && s[i - 1][j] == '#') { cnt++; }
                        if (i > 0 && j < W - 1 && s[i - 1][j + 1] == '#') { cnt++; }
                        if (j > 0 && s[i][j - 1] == '#') { cnt++; }
                        if (j < W - 1 && s[i][j + 1] == '#') { cnt++; }
                        if (i < H - 1 && j > 0 && s[i + 1][j - 1] == '#') { cnt++; }
                        if (i < H - 1 && s[i + 1][j] == '#') { cnt++; }
                        if (i < H - 1 && j < W - 1 && s[i + 1][j + 1] == '#') { cnt++; }
                        Console.Write(cnt);
                    }
                }
                Console.WriteLine();
            }

            //Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        public void Dfs(List<List<int>> graph, bool[] seen, int v)
        {
            seen[v] = true;
            //初めて訪れたタイミングでここの処理

            foreach (var next in graph[v])
            {
                if (seen[next] == true) { continue; }
                Dfs(graph, seen, next);
            }
            //行き先がない状態になったらこの部分の処理

        }

        public void Gin(List<List<int>> graph,int size)
        {
            for(var i = 0; i < size; i++)
            {
                graph.Add(new List<int>());
                
            }
        }

        public void Sfalse(bool[] seen)
        {
            for(var i = 0; i < seen.Length; i++)
            {
                seen[i] = false;
            }
        }

        public bool AllTrue(bool[] seen)
        {
            for(var i = 0; i < seen.Length; i++)
            {
                if (!seen[i])
                {
                    return false;
                }
            }
            return true;
        }
    }
}



Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int a[100];
int n;
void swap(int i,int j)
{
	int x=a[i];
	a[i]=a[j];
	a[j]=x;
}
bool check(int i,int j)
{
	swap(i,j);
	for(int x=1;x<n;x++)
	{
		if(a[x-1]>a[x])
		{
			swap(i,j);
			return false;
		}
	}
	return true;
}

main()
{
	cin >> n;
	
	for(int i=0;i<n;i++) cin >> a[i];
	
	if(check(n+5,n+5))
	{
		cout << "YES";
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(check(i,j))
			{
				cout <<"YES";
				return 0;	
			}
			
		}
	}
	cout << "NO";
}

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

using namespace std;

int main() {
  int64_t X;
  cin >> X;
  vector<int64_t> K;
  unordered_map<int64_t, int> M;
  for (int64_t i = -6208; i <= 6208; i++) {
    int64_t i5 = pow(i, 5);
    K.push_back(i5);
    M[i5] = i;
  }

  for (int64_t B5 : K) {
    int64_t A5 = B5 + X;
    if (M.find(A5) != M.end()) {
      cout << M[A5] << " " << M[B5] << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 4816
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int r = in.nextInt();
    int c = in.nextInt();
    int[][] spread = new int[r + 1][c + 1];

    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        spread[i][j] = in.nextInt();
        spread[i][c] += spread[i][j];
      }
    }
    for (int i = 0; i < c + 1; i++) {
      for (int j = 0; j < r; j++) {
        spread[r][i] += spread[j][i];
      }
    }
    for (int i = 0; i < r + 1; i++) {
      System.out.print(spread[i][0]);
      for (int j = 1; j < c + 1; j++) {
        System.out.print(" " + spread[i][j]);
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 42480
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N + 1) cin >> A[i];
	rep(i, 0, N) cin >> B[i];

	ll ans = 0;
	rep(i, 0, N) {
		ll lft = min(A[i], B[i]);

		ans += lft;
		A[i] -= lft;
		B[i] -= lft;

		ll rht = min(A[i + 1], B[i]);

		ans += rht;
		A[i + 1] -= rht;
		B[i] -= rht;
	}
	cout << ans << endl;
}







Measured memory_bytes: 1024
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        s = self.input_data()
        if s in "abcdefghijklmnopqrstuvwxyz":
            print("a")
        else:
            print("A")


solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 9904