akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, M; cin >> N >> M;
    mat A(N, vec(M));
    REP(i, N) readindex(A[i]);
    
    int ans = INF;
    vector<bool> erased(M, false);
    vec index(N, 0);
    REP(i, M){
        vec count(M, 0);
        REP(j, N){
            while(erased[A[j][index[j]]]) index[j]++;
            count[A[j][index[j]]]++;
        }
        int maxc = 0, maxi;
        REP(j, M){
            if(count[j] > maxc){
                maxc = count[j];
                maxi = j;
            }
        }
        ans = min(ans, maxc);
        erased[maxi] = true;
    }

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long[] a=cin.ArrayLong(2,0);
        long ans=a[0];
        if(a[0]%a[1]==0)ans=-1;
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 13140
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	W, _ := strconv.Atoi(read())
	wv := make([][]int, N)
	for i := 0; i < N; i++ {
		wv[i] = make([]int, 2)
		wv[i][0], _ = strconv.Atoi(read())
		wv[i][1], _ = strconv.Atoi(read())
	}
	// 品物, 重量
	var dp = [100][1e5 + 5]int{}
	w, v := wv[0][0], wv[0][1]
	dp[0][w] = v
	for i := 1; i < N; i++ {
		w, v := wv[i][0], wv[i][1]
		for j := 1; j <= W; j++ {
			if 0 <= j-w {
				dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j], dp[i][j-1])
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
			}
		}
	}
	fmt.Println(dp[N-1][W])
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 83328
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

int main(){
  string s;cin>>s;
  ll cnt=0,n=s.size();
  rep(i,0,s.size()){
      cnt+=s[i]-'0';
  }
  if(cnt%9)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3756
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var num = new long[N];
            foreach (var a in Ai)
                ++num[a];
            if (N % 2 == 0)
            {
                //偶数の場合奇数のとこに2が入るのみ
                for (var i = 0; i < N; i += 2)
                {
                    if (num[i] != 0 || num[i + 1] != 2)
                    {
                        WriteLine(0);
                        return;
                    }
                }
            }
            else
            {
                //奇数の場合0に1、偶数に2が入るのみ
                if (1 != num[0])
                {
                    WriteLine(0);
                    return;
                }
                for (var i = 1; i < N; i += 2)
                {
                    if (num[i] != 0 || num[i + 1] != 2)
                    {
                        WriteLine(0);
                        return;
                    }
                }
            }
            WriteLine(ModPow(2, N / 2, Mod));
        }
        static long ModPow(long a, long n,long mod)
        {
            var res = 1L;
            while(0<n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
    }
}

Measured memory_bytes: 36820
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

int dxy[4] = {1,-1,0,0};
int H, W;

// int solve(int y, int x, int gy, int gx, vector<string>& S, vector<vector<int>>& used, int d){
	// if(y == gy && x == gx) return 0;
	
	// if(used[y][x]) return INF;
	// used[y][x] = true;
	
	// int res = INF;
	
	// for(int i = 0; i < 4; i++){
		// int ny = y + dxy[i], nx = x + dxy[3-i];
		
		// if(ny >= H || ny < 0 || nx >= W || nx < 0) continue;
		// if(S[ny][nx] == '#') continue;

		// res = min(res, solve(ny, nx, gy, gx, S, used) + 1);
	// }
	
	// return res;
// }

int solve(int sy, int sx, int gy, int gx, vector<string>& S){
	int res = 0;
	
	
	vector<vector<int>> used(H, vector<int>(W, INF));
	queue<pair<int,pair<int,int>>> Q;
	
	Q.push({0,{sy,sx}});
	used[sy][sx] = 0;
	
	while(Q.size()){
		pair<int,pair<int,int>> p = Q.front(); Q.pop();
		int y = p.second.first , x = p.second.second;
		int d = p.first;
		
		if(gy == y && gx == x) return d;
		
		if(used[y][x] < d) continue;
		
		for(int i = 0; i < 4; i++){
			int ny = y + dxy[i], nx = x + dxy[3-i];
			
			if(ny >= H || ny < 0 || nx >= W || nx < 0) continue;
			if(S[ny][nx] == '#') continue;
			if(used[ny][nx] > d + 1){
				used[ny][nx] = d + 1;
				Q.push({d+1,{ny,nx}});
			}
		}
	}
	
	return res;
}
signed main(){
	// cin.tie(nullptr);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int maximum = 0;
	vector<string> S;
	
	cin>>H>>W;
	
	S.resize(H);
	
	for(int i = 0; i < H; i++){
		cin>>S[i];
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(S[i][j] == '#') continue;
			for(int k = 0; k < H; k++){
				for(int l = 0; l < W; l++){
					if(S[k][l] == '#') continue;
					
					int ans = solve(i, j, k, l, S);
					// cout<<i<<" "<<j<<" "<<k<<" "<<l<<" ans "<<ans<<endl;
					
					maximum = max(maximum, ans);
				}
			}
		}
	}
	
	cout<<maximum<<endl;
	
	return 0;
}

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

int n, m, q;
int a[50], b[50], c[50], d[50];
int x[11];
int ans = 0;

void dfs(int i, int j) {
    if (i == n+1) {
        int score = 0;
        for (int k = 0; k < q; k++) {
            if (x[b[k]] - x[a[k]] == c[k]) {
                score += d[k];
            }
        }
        if (score > ans) {
            ans = score;
        }
        return;
    }
    for (int k = j; k <= m; k++) {
        x[i] = k;
        dfs(i+1, k);        
    }
}

int main(){
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(1, 1);
    cout << ans;
} 

Measured memory_bytes: 3612
#
# abc073 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
6
2
6"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
2
5
5
2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
12
22
16
22
18
12"""
        output = """2"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    AM = {}
    for a in A:
        AM.setdefault(a, 0)
        AM[a] += 1

    ans = 0
    for v in AM.values():
        if v % 2 != 0:
            ans += 1

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 27768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 1e3+5;

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (c < a) {
    int x = a;
    a = c;
    c = x;
    int y = b;
    b = d;
    d = y;
  }
  if (c > b) {
    cout << 0 << endl;
  } else {
    if (b < d) {
      cout << b - c << endl;
    } else {
      cout << d - c << endl;
    }
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;

int main() {
	int N, L; cin >> N >> L;
	int min = INF;
	int sum = 0;
	rep(i, N) {
		int num = L + i;
		if (abs(min) > abs(num))min = num;
		sum += num;
	}
	cout << sum - min;
}

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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	string s;
	cin >> n >> s;
    
    char something = '%';
    int ans = 0;
    for (auto c : s) {
    	if (c != something) {
    		ans++;
    		something = c;
    	}
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
sx, sy, gx, gy = map(int, input().split())
gx -= sx
gy -= sy
print('R' * gx, end='')
print('U' * gy, end='')
print('L' * gx, end='')
print('D' * gy, end='')
print('D', end='')
print('R' * (gx+1), end='')
print('U' * (gy+1), end='')
print('L', end='')
print('U', end='')
print('L' * (gx+1), end='')
print('D' * (gy+1), end='')
print('R')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int a[200010];
int b[200010];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i+1];

    for(int i = (n+1)/2; i <= n; i++){
        b[i] = a[i];
    }

    for(int k = n; k >= 1; k--){
        int tmp = 0;
        for(int i = 2 * k; i <= n; i += k){
            tmp += b[i];
        }
        tmp += a[k];
        if (tmp%2 == 0) b[k] = 0;
        else b[k] = 1;
    }

    int cnt = 0;
    rep(i, n) cnt += b[i+1];
    cout << cnt << endl;
    if (cnt == 0) return 0;
    rep(i, n) if (b[i+1] > 0) cout << i+1 << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 5136
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef complex<double> cdouble;
typedef vector<complex<double>> vcd;
typedef vector<vector<complex<double>>> vvcd;

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

ll ceil_div(ll a, ll b) {
  if (a % b == 0) return a / b;
  else return a / b + 1;
}

class Binary_Search {
private:
  ll l;
  ll r;
  ll m;
public:
  ll result;
  // search [l, r), rule should be [y,...,y,n...,n], and return the index that causes the last 'y'
  Binary_Search(ll range_l, ll range_r, bool(*rule)(ll), bool upper_flag) {
    l = range_l;
    r = range_r;
    while (r - l > 1) {
      m = (l + r) / 2;
      if (rule(m)) l = m;
      else r = m;
    }
    result = upper_flag ? l + 1 : l;
  }
};

namespace BS_Rules {
  ll K;
  ll A;
  ll B;
  bool bs_rule(ll a) {
    if (B - a < 0) return false;
    ll b = (B - a) / K;
    if (a * K + b <= A) return true;
    else return false;
  }
}

int main() {
  ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  ll diff = B - A;
  Loop(k, N) {
    if (-k * D + (N - k - 1) * C <= diff && diff <= -k * C + (N - k - 1) * D) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc150/tasks/abc150_c
"""
import numpy as np
from itertools import permutations


def calc(N: int, P: np.ndarray, Q: np.ndarray) -> int:
    pairs = list(permutations(range(1, N + 1)))
    pairs_dict = {tuple(v): i for i, v in enumerate(pairs)}
    return abs(pairs_dict[tuple(P)] - pairs_dict[tuple(Q)])


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    P = load_input_as_int_array()
    Q = load_input_as_int_array()
    result = calc(N, P, Q)
    print(result)


main()


Measured memory_bytes: 19860
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans;cin>>N;
  cout<<(1000-N%1000)%1000<<endl;
  return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  bool ans = false;
  while(cnt <= k){
    if(b > a){
      if(c > b){
        ans = true;
        break;
      } else {
        c *= 2;
        cnt++;
      }
    } else {
      b *= 2;
      cnt++;
    }
  }
  if (ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
O=list(input())
E=list(input())

N=len(O)
M=len(E)

ans=['null' for a in range(N+M)]

for n in range(N):
  ans[2*n]=O[n]

for m in range(M):
  ans[2*m+1]=E[m]

print(''.join(ans))


Measured memory_bytes: 3060
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            int x=Integer.parseInt(ss[2]);
            int[][] arr=new int[n][m];
            int[] cost=new int[n];
            for(int i=0;i<n;i++){
                ss=br.readLine().split(" ");
                cost[i]=Integer.parseInt(ss[0]);
                for(int j=0;j<m;j++){
                    arr[i][j]=Integer.parseInt(ss[j+1]);
                }
            }
            long ans=Long.MAX_VALUE;
            for(int i=0;i<Math.pow(2,n);i++){
                long c=0;
                int[] aa=new int[m];
                for(int j=0;j<n;j++){
                    if((i&(1<<j))>0){
                        c+=cost[j];
                        for(int k=0;k<m;k++){
                            aa[k]+=arr[j][k];
                        }
                    }
                }
                boolean ff=false;
                for(int j=0;j<m;j++){
                    if(aa[j]<x){
                        ff=true;
                    }
                }
                if(!ff){
                    ans=Math.min(ans,c);
                }
            }
            if(ans!=Long.MAX_VALUE) {
                System.out.println(ans);
            }else{
                System.out.println(-1);
            }
        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void dfs(ArrayList<HashSet<Integer>> list,boolean[] vis,int i){
        vis[i]=true;
        Iterator<Integer> it=list.get(i).iterator();
        while(it.hasNext()){
            int u=it.next();
            if(!vis[u]){
                dfs(list,vis,u);
            }
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static void shuffle(String[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            String temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static class quad{
        int a,b,c,d;
        public quad(int a,int b,int c,int d){
            this.a=a;
            this.b=b;
            this.c=c;
            this.d=d;
        }
    }
}

Measured memory_bytes: 34436
import java.util.*;

public class Main {
 
	public static void main(String [] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[][]=new int[n][3];
		long dp[][]=new long[n][3];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<3;j++)
			{
				arr[i][j]=sc.nextInt();
			}
		}
		for(int i=0;i<n;i++)
		{
			Arrays.fill(dp[i], -1);
		}
		long ans=rec(arr,dp,0,0);
		System.out.println(ans);
	}
 
	private static long rec(int[][] arr, long[][] dp, int ind, int sel) {
		// TODO Auto-generated method stub
		if(ind==arr.length)
		{
			return 0;
		}
		long ans=0;
		//System.out.println(ind+" "+sel);
		if(sel!=0&&dp[ind][sel-1]!=-1)
		{
			//System.out.println("y");
			return dp[ind][sel-1];
		}
		if(sel==0)
		{
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][1]+rec(arr,dp,ind+1,2);
			long opt3=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, Math.max(opt2, opt3));
			return ans;
		}else if(sel==1)
		{
			long opt1=arr[ind][1]+rec(arr,dp,ind+1,2);
			long opt2=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, opt2);
		}else if(sel==2)
		{
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][2]+rec(arr,dp,ind+1,3);
			ans=Math.max(opt1, opt2);
		}else {
			long opt1=arr[ind][0]+rec(arr,dp,ind+1,1);
			long opt2=arr[ind][1]+rec(arr,dp,ind+1,2);
			ans=Math.max(opt1, opt2);
		}
		//System.out.println(ind+" "+sel);
		dp[ind][sel-1]=ans;
		return ans;
	}
}

Measured memory_bytes: 89312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int coins;
  cin >> A >> B;
  for(int i=0;i<2;i++){
    if(A >= B){
    coins += A;
    A--;
  } else if(A<B){
    coins += B;
    B--;
  }
    
  }
  cout << coins << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <cctype>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  string s, ans="";
  getline(cin,s);
  for(int i=0; i<s.size(); i++){
    if(!isalpha(s[i])) ans+=s[i];
    else if(islower(s[i])) ans+= toupper(s[i]);
    else if(isupper(s[i])) ans+= tolower(s[i]);
  }
  cout << ans << endl;
}



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

using namespace std;

void process(int n) {
	long long sum = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				sum += __gcd(__gcd(i, j), k);
			}
		}
	}
	
	cout << sum << "\n";
}

int main() {
	int n;
	cin >> n;
	process(n);
	return 0;
}

Measured memory_bytes: 3616
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << a * b / 2 << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

#define MOD 1e9+7

using namespace std;

class CShoppingStreet {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        int n;
        cin >> n;
        vector<vector<int>> f_vec(n, vector<int>(10, 0));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 10; ++j) {
                cin >> f_vec[i][j];
            }
        }
        vector<vector<int>> p(n, vector<int>(11));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 11; ++j) {
                cin >> p[i][j];
            }
        }
        int64_t ans = -(1 << 30);
        for (int bit = 1; bit < (1 << 10); ++bit) {
            int64_t tmp_ans = 0;
            for (int j = 0; j < n; ++j) {
                int count = 0;
                for (int k = 0; k < 10; ++k) {
                    if (bit & (1 << k) && f_vec[j][k]) count++;
                }
                tmp_ans += p[j][count];
            }
            ans = max(ans, tmp_ans);
        }
        cout << ans << endl;
    }
};


int main() {
    CShoppingStreet solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

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

	int N,A;
	cin >> N;
	cin >> A;

	if (N % 500 <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
// atcoder/jsc2019-qual/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int M, D;
  while (cin >> M >> D) {
    int cnt = 0;
    for (int m = 1; m <= M; ++m) {
      for (int d1 = 2; d1 < 10; ++d1) {
        for (int d2 = 2; d2 < 10; ++d2) {
          int x = d1 * 10 + d2;
          if (d1 * d2 == m && x <= D) {
            // cout << m << "/" << d1 << d2 << endl;
            ++cnt;
          }
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

int main()
{
#ifdef _MSC_VER
	freopen("a.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << (n >= 30 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3632
NUM=1000

X=int(input())

flg=False

for i in reversed(range(NUM)):
    for j in range(-1*NUM,NUM):
        res=(i**5)-(j**5)
        if res==X:
            ans_A=i
            ans_B=j
            flg=True
            break
    if flg:
        break

print(ans_A,ans_B)

Measured memory_bytes: 9120
#include<stdio.h>
#define N 500000
#define SENTINEL 1000000000

void Merge(int[],int,int,int);
void MergeSort(int[],int,int);
int s[N];
int count=0;

int main(){
  
  int i,n=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){ 
    scanf("%d",&s[i]);    
  }

  MergeSort(s,0,n);


  for(i=0;i<n;i++){
    printf("%d",s[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  
  printf("\n%d\n",count);

  return 0;
}

void Merge(int s[],int left,int mid,int right){
  
  int n1=0,n2=0,i,j=0,k=0;
  n1=mid-left;
  n2=right-mid;
  int l[n1+1];
  int r[n2+1];
  
  for(i=0;i<n1;i++){
    l[i]=s[left+i];
  }
  
  for(i=0;i<n2;i++){
    r[i]=s[mid+i];
  }
  l[n1]=SENTINEL+1;
  r[n2]=SENTINEL+1;
  i=0;
  for(k=left;k<right;k++){
    if(l[i]<=r[j]){
      s[k]=l[i];
      i+=1;
      count++;
    } else{
      s[k]=r[j];
      j+=1;
      count++;
    }
  }  
  
}

void MergeSort(int s[],int left,int right){
  
  int mid=0;
  if(left+1 < right){
    
    mid=(left+right)/2;
    MergeSort(s,left,mid);
    MergeSort(s,mid,right);
    Merge(s,left,mid,right);
    
  }

  
}

Measured memory_bytes: 4504
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// 各点到当前工厂的距?
int d[1024][1024];
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
int factory[16][2];
typedef pair<int, int> P;

int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
	//memset(d, -1, sizeof(d));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			d[j][i] = -1;
		}
	}
	queue<P> que;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size())
	{
		const P p = que.front(); que.pop();
		// 如果是?点就?束
		if (p.first == gx && p.second == gy)
		{
			break;
		}
 
		// 四方向漫游
		for (int i = 0; i < 4; ++i)
		{
			int nx = p.first + direction[i][0];
			int ny = p.second + direction[i][1];
			// 是否可以移?，并且?点没有???
			if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}

	return d[gx][gy];
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	cin >> h >> w >> n;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> map[j][i];
		}
	}
 
	for (int i = 0; i < h; ++i)
	{		for (int j = 0; j < w; ++j)
		{
			if (map[j][i] == 'S')
		{
				factory[0][0] = j;
				factory[0][1] = i;
				map[j][i] = '.';
			}
			else if (isdigit(map[j][i]))
			{
				int index = map[j][i] - '0';
				factory[index][0] = j;
				factory[index][1] = i;
			}
		}
	}
 
	int step = 0;
	for (int i = 0; i < n; ++i)
	{
		// 按?序吃遍中?
		step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
	}
	
	cout << step << endl;
 
	return 0;
}

Measured memory_bytes: 6312
// D - Face Produces Unhappiness

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

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

	string S;
	cin >> S;

	// 一番左端の人の向きに合うように、連続する逆向きの人を一塊として反転させる
	char dir = S[0]; // L or R
	char opposite_dir;
	if (dir == 'L') opposite_dir = 'R';
	else opposite_dir = 'L';

	// posから左の連続する一塊を反転して向きを揃える
	// 回数と場所だけ記録（実際の処理は後で）
	int pos = 0;
	for (pos; pos<N-1; pos++) {
		if (S[pos] == opposite_dir && S[pos+1] == dir) {
			K--;
			if (K == 0) break;
		}
	}

	if (K > 0) {
		// 右端の塊が逆向きなら反転
		if (S[N-1] == opposite_dir) {
			pos = N-1;
		}
	}

	// 処理後の状態を表す文字列を作成
	string R = string(pos+1, dir) + S.substr(pos+1);

	//cout << R << endl; // **** debug ****

	// 実際に数える
	int ans = 0;
	for (int i=0; i<N-1; i++) {
		if (R[i] == 'R' && R[i+1] == 'R') ans++;
		if (R[i+1] == 'L' && R[i] == 'L') ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()
    val t = scanner.next()
    var a = scanner.nextInt()
    var b = scanner.nextInt()
    val u = scanner.next()
    if (u == s) a -= 1 else b -= 1

    println("$a $b")
}

Measured memory_bytes: 31136
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


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

Measured memory_bytes: 256
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score(t):
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(len(t)):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution1():
    return [i % 26 for i in range(D)]

def solution2():
    t = None
    score = -1
    for i in range(26):
        nt = [(i + j) % 26 for j in range(D)]
        if calc_score(nt) > score:
            t = nt
    return t

def solution3():
    t = []
    for _ in range(D):
        score = -1
        best = None
        for i in range(26):
            new_score = calc_score(t + [i])
            if new_score > score:
                best = t + [i]
                score = new_score
        t = best
    return t

def optimize0(t):
    return t

def optimize1(t):
    score = calc_score(t)
    while time() - start_time + 0.15 < limit_secs:
        d = int(random() * D)
        q = int(random() * 26)
        old = t[d]
        t[d] = q
        new_score = calc_score(t)
        if new_score < score:
            t[d] = old
        else:
            score = new_score
    return t

t = solution3()
t = optimize0(t)
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 84056
#Half and Half

#入力
A, B, C, X, Y = map(int, input().split())

#計算
Yen = []
for i in range(max(X+1,Y+1)):
	Yen.append(A*max(0,X-i) + B*max(0,Y-i) + 2*C*i)

#出力
print(min(Yen))

Measured memory_bytes: 7096
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxsize


def main():
    num = int(stdin.readline())

    edges = []
    for _ in range(num):
        ns = [int(s) for s in stdin.readline().split()]
        for i in range(ns[1]):
            edges.append((ns[0], ns[2*i+2], ns[2*i+3]))

    dis = [maxsize] * num
    dis[0] = 0

    while 1:
        update = False
        for from_, to, cost in edges:
            if dis[from_] < maxsize and dis[to] > cost + dis[from_]:
                dis[to] = cost + dis[from_]
                update = True

        if not update:
            break

    for i, d in enumerate(dis):
        print(i, d)


main()

Measured memory_bytes: 69400
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
#define ll long long
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
map<string,int>M;
int main(){
	string str;ll s=0ll;int n;
	cin>>n;
	while(n--){cin>>str;sort(str.begin(),str.end());s+=(M[str]++);}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct file { ll sta, end, id; };
int main(){
	int n;
	while (cin >> n, n) {
		vector<file> v;
		rep(aa, n) {
			char t; cin >> t;
			int len = v.size();
			if (t == 'W') {
				ll x, y; cin >> x >> y;
				ll now = 0;
				rep(j, len) {
					if (y == 0)break;
					ll dif = v[j].sta - now;
					if (y <= dif) {
						v.insert(v.begin() + j, { now,now + y,x }); len++; j++;
						y = 0;
						break;
					}
					else if(dif>0){
						v.insert(v.begin() + j, { now,v[j].sta,x }); len++; j++;
						y -= dif;
					}
					now = v[j].end;
				}
				if (y > 0) {
					v.push_back({ now,now + y,x });
				}
			}
			if (t == 'D') {
				ll x; cin >> x;
				per(j, len) {
					if (v[j].id == x) {
						v.erase(v.begin() + j);
					}
				}
			}
			if (t == 'R') {
				ll x; cin >> x;
				bool ansed = false;
				rep(j, len) {
					if (x < v[j].sta) {
						cout << -1 << endl; ansed = true; break;
					}
					if (v[j].sta <= x && x < v[j].end) {
						cout << v[j].id << endl; ansed = true; break;
					}
				}
				if (!ansed)cout << -1 << endl;
			}
		}
		cout << endl;
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

map<pll, ll> mp;

ll func(ll X, ll Y){
	if(X==0) return 1;
	pll key = make_pair(X, Y);
	if (mp.find(key)!=mp.end()) return mp[key];
	ll res = 0;

	res += func(X/2, Y/2);
	res %= mod;

	if(X>0 && Y>0){
		res += func((X-1)/2, (Y-1)/2);
		res %= mod;
	}

	if(X>1){
		res += func((X-2)/2, Y/2);
		res %= mod;
	}

	mp[key] = res;
	return res;
}

int main(){

	ll N;
	cin >> N;

	cout << func(N, N) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
bool i[10000][10000];
long long u[11111111];
long long o[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=1,f=0;
  string s;
  cin >>s;
  for(int n=0;n<s.size();n++){
    if(s[n]=='A'){
      d=n;
      break;
    }
  }
  for(int n=s.size()-1;n>=0;n--){
    if(s[n]=='Z'){
      e=n;
      break;
    }
  }
  cout <<e-d+1<<'\n';
  return (0);
}


Measured memory_bytes: 720
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int ans1 = 2* c * max(x, y);
	int ans2;
	if (x>y) {
		ans2 = 2*c*y + a*(x-y);
	}
	else {
		ans2 = 2*c*x + b*(y-x);
	}
	int ans3 = x * a + y * b;
	cout << min(min(ans1, ans2), ans3) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
 
using namespace std;
 
int main() {
 
    unsigned long long X,Y;
    cin >>X>>Y;
    cout <<(1+(int)log2((long double)Y/X));
 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
vector<pair<int,ll> > tree[100010];
int n,q,k;
ll depth[100010];

void dfs(int v, int p, ll d){
  depth[v] = d;
  for(auto a: tree[v]){
    if(a.first == p) continue;
    else dfs(a.first, v, d + a.second);
  }
}

int main(){
  cin>>n;
  for(int i = 0; i < n-1; i++){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--; b--;
    tree[a].push_back(make_pair(b,c));
    tree[b].push_back(make_pair(a,c));
  }
  cin>>q>>k;
  int x[q],y[q];
  for(int i = 0; i < q; i++) {
    cin>>x[i]>>y[i];
    x[i]--; y[i]--;
  }
  dfs(k-1,-1,0);
  for(int i = 0; i < q; i++){
    cout<<depth[x[i]]+depth[y[i]]<<endl;
  }
  return 0;
}


Measured memory_bytes: 15104
#!/usr/bin/env python3
i = [0] * (10**5 + 1)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            i[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1

n = int(input())

print(*i[1:n + 1], sep="\n")


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

using namespace std;

typedef long long ll;

ll cntH[300001], cntW[300001];

int main() {
    ll H, W, M;
    cin >> H >> W >> M;
    map<pair<ll, ll>, bool> mines;
    for (ll m = 0; m < M; m++) {
        ll h, w;
        cin >> h >> w;
        cntH[h]++;
        cntW[w]++;
        mines[pair<ll, ll>(h, w)] = true;
    }

    ll idxH = 1;
    for (ll h = 2; h <= H; h++) {
        if (cntH[h] > cntH[idxH]) {
            idxH = h;
        }
    }
    vector<ll> candidateH;
    for (ll h = 1; h <= H; h++) {
        if (cntH[h] == cntH[idxH]) {
            candidateH.push_back(h);
        }
    }

    ll idxW = 1;
    for (ll w = 2; w <= W; w++) {
        if (cntW[w] > cntW[idxW]) {
            idxW = w;
        }
    }
    vector<ll> candidateW;
    for (ll w = 1; w <= W; w++) {
        if (cntW[w] == cntW[idxW]) {
            candidateW.push_back(w);
        }
    }

    ll cnt = cntH[idxH] + cntW[idxW];
    for (ll ch = 0; ch < candidateH.size(); ch++) {
        for (ll cw = 0; cw < candidateW.size(); cw++ ) {
            if (!mines[pair<ll, ll>(candidateH[ch], candidateW[cw])]) {
                cout << cnt << endl;
                return 0;
            }
        }
    }

 
    cout << cnt - 1 << endl;
}

Measured memory_bytes: 35016
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT

ll d8[]={0,1,1,0,-1,1,-1,-1,0};
int main(){
	ll w,h;
	while(scanf("%lld%lld",&w,&h),w){
		ll a[60][60]={};
		ll umi=0;
		rep(i,1,h+1)rep(j,1,w+1)scanf("%lld",&a[i][j]);
		ufinit(w*h);
		rep(i,1,h+1)rep(j,1,w+1){
			if(a[i][j]){
				rep(k,0,8){
					ll ii=i+d8[k];
					ll jj=j+d8[k+1];
					if(a[ii][jj])uni((i-1)*w+(j-1),(ii-1)*w+(jj-1));		
				}
			}else{
				umi++;
			}
		}
		ll ans=0;
		rep(i,1,h+1)rep(j,1,w+1)if(unicnt[(i-1)*w+(j-1)]>0)ans++;
		printf("%lld\n",ans-umi);
	}
}


Measured memory_bytes: 2036
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *ABC = map(int, read().split())
    A = sorted(ABC[:N])
    B = sorted(ABC[N : 2 * N])
    C = sorted(ABC[2 * N : 3 * N])

    ans = 0
    for b in B:
        ok = -1
        ng = N
        while ng - ok > 1:
            mid = (ok + ng) // 2
            if A[mid] < b:
                ok = mid
            else:
                ng = mid
        a_num = ok + 1

        ok = N
        ng = -1
        while ok - ng > 1:
            mid = (ok + ng) // 2
            if C[mid] > b:
                ok = mid
            else:
                ng = mid
        c_num = N - ok

        ans += a_num * c_num

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38620