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

int main() {
  int64_t N;
  cin >> N;
  
  int d = 12;//最小値
  for(int i = 1; i <= pow(N, 0.5); i++){
    if(N % i == 0){
      int64_t M = N / i;
      int c = 0;
      while(M > 0){
        M /= 10;
        c++;
      }
      if(c < d){
        d = c;
      }
    }
  }
  
  cout << d << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  string a,b;
  cin >> a >> b;
  string ch = a+b;
  int res = stoi(ch);
  bool suc = false;
  for(int i=1;i*i<=res;i++){
     if(i*i == res) suc = true;
  }
  if(suc) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  if ((B + A) % 2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (B + A) / 2 << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() 
{
    string word;
    int m, h;
    while(true){
        cin >> word;
        if (word == "-")
            break;
        
        cin >> m;
        for (int i = 0; i < m; i++) 
        {
            cin >> h;
            word +=  word.substr(0, h);
            word.erase(0, h);
        }
        cout << word << endl;
    }
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
//#define end endl
//#define endl() end()
#define f first
#define s second
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){ _
	char end = '\n';

	int a, b, c, k;

	cin >> a >> b >> c >> k;

	if (a >= k)
	{
		cout << k << endl;
	}
	else if (a+b >= k)
	{
		cout << a << endl;
	}
	else
	{
		cout << a-(k-(a+b)) << endl;
	}


	exit(0);
}


Measured memory_bytes: 3648
# include <bits/stdc++.h>
 
//# define int long long
 
using namespace std;

int32_t main()
{	
	int n, mn = 1e9;
	cin >> n;

	vector < int > a(n);

	for ( auto & i: a ) {
		cin >> i;
	}
	for ( int i = 1; i <= 100; i++ ) {
		int x = 0;

		for ( int j = 0; j < n; j++ ) {
			x += pow( a[j] - i, 2 );
		}
		mn = min( mn, x );
	}
	cout << mn;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n;
	RES(a, n);
	REP(i, n){
		cin >> a[i];
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		if(i % 2 == 1 && a[i-1] % 2 == 1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int a,b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if(op=='?') break;
        if(op=='+') cout << a+b << endl;
        if(op=='-') cout << a-b << endl;
        if(op=='*') cout << a*b << endl;
        if(op=='/') cout << a/b << endl;;
    }
    
    return 0;
}


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

h = list(map(int, input().split()))

from collections import defaultdict

g = defaultdict(set)

for _ in range(m):
    a, b = map(int, input().split())

    g[a].add(h[b - 1])
    g[b].add(h[a - 1])

ret = 0
for i in range(1, n + 1):
    for x in g[i]:
        if x >= h[i - 1]:
            break
    else:
        ret += 1

print(ret)

Measured memory_bytes: 118844
#include<stdio.h>

typedef long long int ll;

int main(void){
    int M, N;
    int a[100000];
    int br[100000];
    int i = 0;
    int j = 0;
    ll ans = 1;
    ll div=1000000007;
    ll st[100001];

	for(i = 0; i < 100000; i++){
    	a[i] = 0;
    }

  
    scanf("%d %d", &N, &M);
    for(i = 0; i < M; i++){
        scanf("%d", &a[i]);
        if(i != 0 && a[i-1]+1 == a[i]){
            printf("0");
            return 0;
        }
    }

    br[0] = 0;

    for(i = 1; i <= N; i++){
        if(i == a[j]){
            br[i] = 1;
          	j++;
        }else{
            br[i] = 0;
        }
    }

    st[0] = 1;
    if(br[1] == 0){
        st[1] = 1;
    }else{
        st[2] = 2;
    }

    for(i = 2; i <= N; i++){
        if(br[i] == 0){
            if(br[i-1] == 0 && br[i-2] == 0){
                st[i] = st[i-1] + st[i-2];
            }else if(br[i-1] == 1){
                st[i] = st[i-2];
            }else if(br[i-2] == 1){
                st[i] = st[i-1];
            }
          	st[i] = st[i]%div;
            ans = st[i];
        }
    }


    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
)
var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var str string
	// 入力の読み込み
	if scanner.Scan() {
		str = scanner.Text()
		bytestr := []byte(str)
		intstr := int(bytestr[0])
		fmt.Println(string(intstr+1))
	}
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    print((n + 1) // 2)


if __name__ == '__main__':
    solve()

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

using namespace std;

const int N = 100010;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, int> M;
    for (int i = 1; i <= n; i++) {
        int u;
        cin >> u;
        M[-u]++;
    }    
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        M[-v] += u;
    }
    long long res = 0;
    int tot = 0;
    for (auto u : M) {
        int now = min(n - tot, u.second);
        res -= 1ll * now * u.first;
        tot += now;
        if (tot == n) break;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11392
def lcs():
  x = raw_input()
  y = raw_input()
  x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

  for i in range(x_len):
    z1 = z2 + []
    ele = x[i]
    for k in range(y_len):
      if ele == y[k]:
        z2[k+1] = z1[k] + 1
      elif z2[k+1] < z2[k]:
        z2[k+1] = z2[k]

  return z2[-1]

num = input()
for j in range(num):
  print lcs()

Measured memory_bytes: 6392
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 3600
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var P = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = 0;
            for (var i = 1; i < N - 1; i++)
            {
                if (P[i - 1] < P[i] && P[i] < P[i + 1]
                    || P[i + 1] < P[i] && P[i] < P[i - 1])
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13268
import sys

lines = sys.stdin.readlines()

M = []
for n, line in enumerate(lines):
  if n == 0:
    N, X = [int(_) for _ in line.strip().split(' ')]
    continue
  
  M.append(int(line.strip()))

if not len(M) == N:
  raise

cur_X = X
M = sorted(M)
num_donut = 0
for m in M:
  if cur_X - m < 0:
    print(num_donut)
    break
  else:
    num_donut += 1
    cur_X -= m

while cur_X - M[0] > 0:
  num_donut += 1
  cur_X -= M[0]

if cur_X - M[0] == 0:
  num_donut += 1
  
print(num_donut)

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

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

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		int max=0;
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		for(int i=0;n-1>i;i++) {
			for(int j=i+1;n>j;j++) {
				int b = Math.abs(list.get(i)-list.get(j));
				if(b>max)
					max=b;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 22100
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

struct state {
	int x, y, d;

	state(int tx = 0, int ty = 0, int td = 0) {
		x = tx;
		y = ty;
		d = td;
	}
};

#define MAXN (1 << 10)

deque<state> q;
int a[MAXN][MAXN];
int h, w, sx, sy, fx, fy;
int d[MAXN][MAXN];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

bool ok(int x, int y) {
	return (x >= 0 && y >= 0 && x < h && y < w && !a[x][y]);
}

int main() {
	cout << fixed << setprecision(12);	
	cin >> h >> w;
	cin >> sx >> sy;
	cin >> fx >> fy;
	sx--;
	sy--;
	fx--;
	fy--;
	

	for (int i = 0; i < h; i++) {
		string t;
		cin >> t;
		for (int j = 0; j < w; j++) {
			if (t[j] == '#') {
				a[i][j] = 1;
			}
		}
	}
	
	q.push_front(state(sx, sy, 0));
	memset(d, 63, sizeof(d));
	while (!q.empty()) {
		state cur = q.front();
		q.pop_front();
		int x = cur.x;
		int y = cur.y;
		if (cur.d > d[x][y]) {
			continue;
		}
		d[x][y] = cur.d;
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			int nd = cur.d;
			if (ok(nx, ny) && nd < d[nx][ny]) {
				q.push_front(state(nx, ny, nd));
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int nx = x + i;
				int ny = y + j;
				int nd = cur.d + 1;
				if (ok(nx, ny) && nd < d[nx][ny]) {
					q.push_back(state(nx, ny, nd));
				}
			}
		}
	}
/*	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cerr << d[i][j] << " ";
		}
		cerr << endl;
	}*/
	if (d[fx][fy] < MAXN * MAXN) {
		cout << d[fx][fy] << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 13816
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double EPS = 1e-8;

int main(){
  int total_games;
  while(~scanf("%d",&total_games)){
    for(int game_i = 0; game_i < total_games; game_i++){
      int num_of_stones;
      int num_of_players;
      scanf("%d %d",&num_of_stones,&num_of_players);
      if(num_of_stones < num_of_players){
        printf("%d\n",num_of_stones);
      }
      else{
        if(num_of_stones % num_of_players == 0){
          printf("%d\n",num_of_players);
        }
        else{
          printf("%d\n",num_of_stones % num_of_players);
        }
      }
    }
  }
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	string s, t;
	cin >> s >> t;
	s = "." + s;
	t = "." + t;

	vector<vector<int>> dp(s.size(), vector<int>(t.size(), 0)); 
	for(int i=1; i<s.size(); i++) {
		for(int j=1; j<t.size(); j++) {
			dp[i][j] = max(dp[i-1][j-1] + (s[i] == t[j]), max(dp[i-1][j], dp[i][j-1]));
		}
	}

	string ans = "";
	int i = s.size()-1;
	int j = t.size()-1;
	while (i > 0 and j > 0) {
		if (s[i] == t[j]) {
			ans += s[i]; 
			i--;
			j--;
		} else {
			if (dp[i-1][j] > dp[i][j-1]) i--;
			else j--;
		}
	}
	reverse(ans.begin(), ans.end());
	if (ans == "") ans = " ";
	cout << ans << endl;

	/*for(int i=1; i<s.size(); i++) {
	 for(int j=1; j<t.size(); j++) {
	  cout << dp[i][j] << " ";
	 }
	 cout << endl;
	}*/

}


Measured memory_bytes: 35584
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


a, b = LI()
if a == b:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 39664
(let ((n (read))
    (ans_amari 1))

    (loop for i from 1 to n do
        (setq ans_amari (* ans_amari i))
        (if (>= ans_amari 1000000007)
            (setq ans_amari (rem ans_amari 1000000007))
        )
    )
    (princ ans_amari)
)

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

int main() {
  
  int n;
  cin >> n;
  
  int A;
  vector<int> a(n);
  REP(i,n-1) { 
    cin >> A;
    a[A-1]++;
  }
  
  REP(i,n) {
    cout << a[i] << endl;
  }

}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin>>D ;
    if(D==25) cout << "Christmas"<<"\n";
    if(D==24) cout <<"Christmas Eve" <<"\n";
    if(D==23) cout << "Christmas Eve Eve"<<"\n";
    if(D==22) cout << "Christmas Eve Eve Eve"<<"\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100001;

int smin(int x,int y){
	if(x == y) return x;
	else if(x > y) return smin(x-y , y);
	else return smin(y-x , x);
} 

int main(){
	int n ;
	long long i ,zmin ,st ,a[maxn]={0};
	cin>>n>>st;
	for(i=1;i<=n;i++){
		cin>>a[i];
		a[i]-=st;
		if(a[i] < 0) a[i]=-a[i];
	}
	zmin = a[1];
	for(i=2;i<=n;i++){
		if(a[i]%zmin == 0) continue;
		zmin = smin(zmin , a[i]);
		if(zmin == 1){
			cout<<'1';
			return 0; 
		}
	}
	cout<<zmin;
	return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define rep(x, l, r) for (x = l; x < r; x++)

const ll mod=1000000007;

void solve()
{
	ll i, j, k, l, m, n, x, y, u, v, r, p,a,b,aa,bb;
	cin>>n;
	vector<ll> cnt(100010,0);
	ll sm=0;
	for(i=0;i<n;i++){
        cin>>k;
        cnt[k]++;
        sm+=k;
	}
    ll q;
    cin>>q;
    while(q--){
        cin>>a>>b;
        sm-=a*cnt[a];
        sm+=b*cnt[a];
        cnt[b]+=cnt[a];
        cnt[a]=0;
        cout<<sm<<"\n";
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
//    cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3984
from collections import Counter

h, w = map(int, input().split())
a = Counter(''.join(input() for _ in range(h)))

center = h * w % 2
side = (h // 2) * (w % 2) + (w // 2) * (h % 2)

cnt = 0
for i in a:
    if a[i] % 2 == 1:
        a[i] -= 1
        cnt += 1
if cnt != center:
    print('No')
    exit()

cnt = 0
for i in a:
    if a[i] % 4 == 2:
        a[i] -= 2
        cnt += 1
if cnt > side:
    print('No')
    exit()

print('Yes' if sum(a[i] % 4 for i in a) == 0 else 'No')


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

int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == S[i]) {
			++cnt1;
		}
		else {
			++cnt2;
		}
	}
	cout << cnt1 + min(cnt2, K * 2) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> mp;
    rep(i, n) mp[a[i]] += 1;
    ll all = 0;
    for (auto i : mp){
        all += i.second * (i.second - 1) / 2;
    }
    rep(i, n){
        ll k = a[i];
        ll ans = all - mp[k] + 1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 12160
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int K = nextInt();
      ArrayList<Integer> list = nextIntArray();
      int output = 0;
      for(int i = 0; i < N; i++){
        output += Math.min(list.get(i), K - list.get(i)) * 2;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32976
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def same(x,y):
        xn,yn=len(x),len(y)
        # x,yの一致する位置を調べる
        res = [True] * 4005
        for i in range(xn):
            for c0, c1 in zip(x[i:], y):
                if c0 != q and c1 != q and c0 != c1:
                    res[i] = False
                    break
        return res

    q=ord("?")
    ss=[[ord(c) for c in SI()] for _ in range(3)]
    # 一致を調べる
    eq=[[0]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if i==j:continue
            eq[i][j]=same(ss[i],ss[j])
    # 位置を全探索
    ans=sum(len(ss[i]) for i in range(3))
    for si,sj,sk in permutations(range(3)):
        for i in range(len(ss[si])+1):
            for j in range(max(len(ss[sj]),len(ss[si])-i)+1):
                if eq[si][sj][i] and eq[sj][sk][j] and eq[si][sk][i+j]:
                    cur=max(len(ss[si]),len(ss[sj])+i,len(ss[sk])+i+j)
                    ans=min(ans,cur)
    print(ans)

main()


Measured memory_bytes: 45296
n, m = map(int, input().split())
tree = [-i for i in range(n+1)]

for _i in range(m):
    x, y, z = map(int, input().split())
    while tree[x]>0:
        x = tree[x]
    while tree[y]>0:
        y = tree[y]
    x, y = sorted([x, y])
    if x==y:
        continue
    else:
        tree[y] = x
print(sum(1 for i in tree if i<0))

Measured memory_bytes: 7088
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define INTMAX 2100000000

using namespace std;

int main(void)
{
	int r, g;

	cin >> r >> g;

	cout << 2 * g - r << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long long int N,N1,N2,K,X;
    scanf("%lld" ,&N);
    scanf("%lld" ,&K);
    X = N/K;
    N1 = llabs(N - K*X);
    N2 = llabs(N - K*(X+1));
    if(N1>=N2) N = N2;
    else N = N1;
    printf("%lld" ,N); //小数を評価するのは？
    return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>

#define KIND 26
#define MAX 365

struct horieyui {
	int mamegu[MAX];
};

int D;
int c[KIND];
int s[MAX][KIND];

int mizuhasu(const struct horieyui* kitaeri) {
	int sumipe = 0;
	int i, j;
	int last[KIND] = {0};
	for (i = 0; i < D; i++) {
		sumipe += s[i][kitaeri->mamegu[i]];
		last[kitaeri->mamegu[i]] = i + 1;
		for (j = 0; j < KIND; j++) {
			sumipe -= c[j] * ((i + 1) - last[j]);
		}
		printf("%d\n", sumipe);
	}
	return sumipe;
}

int main(void) {
	int i, j;
	struct horieyui otehon;
	if (scanf("%d", &D) != 1) return 1;
	for (i = 0; i < KIND; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	for (i = 0; i < D; i++) {
		for (j = 0; j < KIND; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
		}
	}
	for (i = 0; i < D; i++) {
		if (scanf("%d", &otehon.mamegu[i]) != 1) return 1;
		otehon.mamegu[i]--;
	}
	mizuhasu(&otehon);
	return 0;
}


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

count = 0
ans = 0

while True:
	mo = list(map(lambda x: x % 2, A))
	if 1 in mo:
		ans = count
		break
	else:
		A = list(map(lambda x:x/2,A))
		count += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int INF = int(1e8);

struct Fenwick
{
	vector<int> t; vector<ii> updates;
    void init(int n, int v=-INF)
    {
        t.assign(n+1,v);
    }
    void reset(int n)
    {
		t.assign(n+1, -INF); updates.clear();
	}
    void update(int p, int v)
    {
        for (; p < (int)t.size(); p += (p&(-p)))
        {
			updates.pb(mp(p,t[p]));
			t[p] = max(t[p],v);
		}
    }
    int query(int r) //finds [0, r] max
    {                     
        int mx=-INF;
        if(r>=t.size()) r=int(t.size())-1;
        for (; r; r -= (r&(-r))) mx=max(mx,t[r]);
        return mx;
    }
    void pop_till(int siz)
    {
		while(int(updates.size())>siz)
		{
			t[updates.back().fi]=updates.back().se;
			updates.pop_back();
		}
	}
};

const int N = 222222;
int a[N];
Fenwick fen[2];
int score[N];
int Q[N];
int dppos[2][N];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int m=int(1e9);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; a[i]=n+1-a[i];
		if(a[i]<m)
		{
			m=a[i]; score[i]=2;
		}
		else
		{
			score[i]=1;
		}
	
	}
	fen[0].init(n,0); fen[1].init(n);
	for(int i=n-1;i>=0;i--)
	{
		Q[i]=(score[i]==2?1:0)+Q[i+1];
	}
	for(int i=n-1;i>=0;i--)
	{
		int v[2] = {0,0};
		for(int j=0;j<2;j++)
		{
			v[j] = max(fen[j].query(a[i]),0);
		}
		for(int j=0;j<2;j++)
		{
			int par = (v[j]+score[i])%2;
			fen[par].update(a[i], v[j]+score[i]);
		}
		for(int j=0;j<2;j++)
		{
			dppos[j][i] = fen[j].updates.size();
		}
	}
	int r[2] = {0,0};
	int mn[2] = {INF,INF};
	string ans;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<2;j++) fen[j].pop_till(dppos[j][i+1]);
		for(int j=0;j<2;j++)
		{
			int newr[2] = {r[0],r[1]};
			int newmn[2] = {mn[0],mn[1]};
			if(a[i]<newmn[j])
			{
				newmn[j]=a[i];
				newr[j]++;
			}
			bool pos=0;
			if(i==n-1)
			{
				if(newr[0]==newr[1]){pos=1;}
			}
			else
			{
				for(int k=0;k<2;k++)
				{
					int sum = newr[k]-newr[k^1]+Q[i+1];
					if(sum<0) continue;
					int mxsum = fen[sum&1].query(newmn[k^1]);
					//cerr<<j<<' '<<k<<' '<<sum<<' '<<mxsum<<'\n';
					if(sum<=mxsum){pos=1; break;}
				}
			}
			if(pos)
			{
				ans+=j+'0';
				for(int k=0;k<2;k++)
				{
					r[k]=newr[k]; mn[k]=newmn[k];
				}
				break;
			}
		}
		//cerr<<ans<<' '<<r[0]<<' '<<r[1]<<' '<<mn[0]<<' '<<mn[1]<<'\n';
		if(ans.length()==i){cout<<-1<<'\n'; return 0;}
	}
	cout<<ans<<'\n';
}


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

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

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

	int N;
	cin >> N;

	long long int A[N+1], B[N];
	rep(i, N+1)
		cin >> A[i];

	rep(i, N)
		cin >> B[i];

	long long int t = 0;
	rep(i, N) {
		if (A[i] > B[i]) {
			t += B[i];
		} else {
			t += A[i];
			B[i] -= A[i];
			if (A[i+1] > B[i]) {
				t += B[i];
				A[i+1] -= B[i];
			} else {
				t += A[i+1];
				A[i+1] = 0;
			}
		}
	}

	cout << t << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
	long long int i, j, k, l, m,N,X, n,A,B, sum, flag, cc, cnt;
	sum = 0;
	flag = 1;
	cin >> N >> X;
	vector<long long int>x(N);
	vector<long long int>len(N);
	for (i = 0; i<N; i++) {
		cin >> x[i];
		len[i] = abs(X - x[i]);
	}
	if (N == 1) {
		cout << len[0] << endl;
	}
	else {
		sum = gcd(len[0], len[1]);
		for (i = 2; i < N; i++) {
			sum = gcd(sum, len[i]);
		}
		cout << sum << endl;
	}





    return 0;
}



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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	while(true){
		int n; cin >> n;
		if(n == 0)break;
		vector<vector<int> > a(n, vector<int>(n));
		for(auto &v : a)for(auto &e : v)cin >> e;
		vector<int> r,c;
		for(int i = 0; i < n; i++){
			int rm=(int)1e9,cm=0;
			for(int j = 0; j < n; j++){
				rm = min(rm, a[i][j]);
				cm = max(cm, a[j][i]);
			}
			r.push_back(rm);
			c.push_back(cm);
		}
		bool flag = false;
		int ans = 0;
		for(int i = 0; i < n && !flag; i++){
			for(int j = 0; j < n; j++){
				if(r[i] == c[j]){
					flag = true;
					ans = r[i];
					break;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}




Measured memory_bytes: 3116
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static final long sosu = 1000000007;
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			int X = scan.nextInt();
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			String o = "delicious";
			String s = "safe";
			String x = "dangerous"; 
			
			if(A >= B){
				System.out.println(o);
			}else if(A + X >= B){
				System.out.println(s);
			}else{
				System.out.println(x);
			}
		}
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    long double l; cin >> l;
    long double a = l / 3;
    cout << fixed << setprecision(10) << a * a * a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma gcc optimize( Ofast )
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

ll mod_pow(ll b, ll e, ll m){
    //formulan er b^e (mod m)
    ll res = 1;
    while(e)
    {
        if(1 & e) res = (res * b) % m;
        b = (b*b) % m;
        e /= 2;
    }
    return res % m;
}

int main(){
    cin.sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){

	int n,m;
	int a;
	cin>>n>>m;
	vector<int> v;
	int sum=0;
	for(int i=0;i<n;i++) {
		cin>>a;
		sum+=a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int ans = 1;
	int k = sum/(4*m);
	if(sum%(4*m)==0){
		for(int i=0;i<m;i++){
			if(v[i]<k){
				ans = 0;
				break;
			}
		}
	}
	else for(int i=0;i<m;i++){
			if(v[i]<=k){
				ans = 0;
				break;
			}
		}
	if(ans == 0) cout<<"No";
	else cout<<"Yes";
	
	
}

Measured memory_bytes: 384
unittest
{
	assert( [ "4", "2", "4", "3", "1" ].parse.expand.solve == 1 );
	assert( [ "5", "10", "8", "5", "3", "2" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	// 並べ替え前の位置を整理
	long[ long ] ps;
	foreach( i, a; as )
	{
		ps[ a ] = i;
	}
	
	// 並べ替え前と並べ替え後の位置の偶奇が不一致だったら操作1が必要
	auto ans = 0L;
	foreach( i, a; ps.keys.sort().enumerate( 0 ) )
	{
		ans += ( ps[ a ] % 2 != i % 2 );
	}
	return ans / 2;
}


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

using namespace std;

int main(void){
  int N,M;

  cin >> N >> M;
  vector<int> h(N);
  vector<int> f(N);

  for(int i =0;i < N;i++){
    cin >> h[i];
  }

  for(int i = 0;i < M;i++){
    int o,p;
    cin >> o >> p;
	if(h[o-1] == h[p-1]){
            f[p-1] = 1;
            f[o-1] = 1;
    }else if(h[o-1] > h[p-1]){
      f[p-1] = 1;
    }else{
      f[o-1] = 1;
    }
  }

  int total = 0;
  for(int i = 0;i < N;i++){
    if(f[i] != 1){
      total++;
    }
  }

  cout << total;

  return 0;
}

Measured memory_bytes: 3976
n=int(input())
s=str(input())
s=list(s)
if n%2==1:
  print("No")
else:
  temp1=s[-int(n/2):]
  temp2=s[:-int(n/2)]
  for i in range(0,int(n/2)):
    if temp1[i]!=temp2[i]:
      print("No")
      break
  else:
    print("Yes")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;

void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}


int main()
{
	ll N;
	cin >> N;
	lls h;
	cinv(h, N);

	lls tbl(N, INF);
	tbl[0] = 0;

	for (ll i = 0; i < N - 1; i++) {
		if (i + 1 < N) {
			ll cost = h[i] - h[i + 1];
			if (cost < 0) cost *= -1;

			tbl[i + 1] = std::min(tbl[i + 1], tbl[i] + cost);
		}

		if (i + 2 < N) {
			ll cost = h[i] - h[i + 2];
			if (cost < 0) cost *= -1;

			tbl[i + 2] = std::min(tbl[i + 2], tbl[i] + cost);
		}
	}

	cout << tbl[N-1] << '\n';

	return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    char S[100];
    int count = 0;
    scanf("%s",S);
    int len = strlen(S);
    for(int i = 0 ; i < len/2 ; i++){
        if(S[i] != S[len-i-1]) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 128
#include<stdio.h>
int s[100],n,i,j;
long long dp[100][21]={0};

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&s[i]);
	dp[0][s[0]]=1;
	for(i=0;i<n-1;i++)
		for(j=0;j<21;j++)
		{
			if(dp[i][j]&&j+s[i+1]<21)
				dp[i+1][j+s[i+1]]+=dp[i][j];
			if(dp[i][j]&&j-s[i+1]>=0)
				dp[i+1][j-s[i+1]]+=dp[i][j];
		}
	printf("%lld\n",dp[n-2][s[n-1]]);
	return 0;
}

Measured memory_bytes: 616
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1e5;
typedef long long LL;
using namespace std;
LL a[MaxN + 5] , b[MaxN + 5];
LL n , x , y;
bool check(LL cnt){
	for(int i = 1;i <= n;i++) b[i] = a[i];
	for(int i = 1;i <= n;i++) b[i] -= y * cnt;
	LL res = 0;
	for(int i = n;i >= 1;i--){
		if(b[i] <= 0) break;
		res += (b[i] + x - y - 1) / (x - y);
	}
	if(res > cnt) return false;
	return true;
}
void Init(){
	for(int i = 1;i <= n;i++) scanf("%lld" , &a[i]);
	sort(a + 1 , a + n + 1);
}
void Solve(){
	LL l = 0 , r = a[n];
	LL ans = 0 , mid;
	while(l < r - 1){
		mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid;
	}
	printf("%lld\n" , r);
}
int main()
{
	while(~scanf("%lld%lld%lld" , &n , &x , &y)){
		Init();
		Solve();
	}
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

const ll mod = 1000000007L;

#define NMAX 200002

// Aho-Corasick
const int K = 30;

struct vertex {
  int next[K];
  bool leaf;
  int p;
  char pch;
  int link;
  int go[K];
};
 
vertex t[NMAX+1];
int sz;
 
void init() {
	t[0].p = t[0].link = -1;
	memset(t[0].next, 255, sizeof(t[0].next));
	memset(t[0].go, 255, sizeof(t[0].go));
	sz = 1;
}
 
int add_string(char *s) {
	int v = 0;
	for (int i=0; s[i]; ++i) {
		int c = s[i]-'a';
		if (t[v].next[c] == -1) {
			memset(t[sz].next, 255, sizeof(t[sz].next));
			memset(t[sz].go, 255, sizeof(t[sz].go));
			t[sz].link = -1;
			t[sz].p = v;
			t[sz].pch = c;
			t[v].next[c] = sz++;
		}
		v = t[v].next[c];
	}
	t[v].leaf = true;
  return v;
}

int go(int v, int c);

int get_link(int v) {
	if (t[v].link == -1) {
		if (v == 0 || t[v].p == 0)
			t[v].link = 0;
		else
			t[v].link = go(get_link(t[v].p), t[v].pch);
  }
	return t[v].link;
}
 
int go(int v, int c) {
	if (t[v].go[c] == -1) {
		if (t[v].next[c] != -1)
			t[v].go[c] = t[v].next[c];
		else
			t[v].go[c] = v==0 ? 0 : go(get_link(v), c);
  }
	return t[v].go[c];
}
// Aho-Corasick end

void preprocess(int *val, int idx, char *seq, int t) {
	if (idx == 3) {
		seq[t] = '\0';
		//cout << seq << endl;
		add_string(seq);
		return;
	}

	if (val[idx] == 0) {
		preprocess(val, idx+1, seq, t);
	} else {
		int v = val[idx];
		for (int i=1; i<=v; i++) {
			seq[t] = i + 'a';
			val[idx] = v - i;
			preprocess(val, idx, seq, t+1);
		}
		val[idx] = v;
	}
}

ll pot[44], dp[NMAX][44];

ll solve(int v, int q) {
	if (t[v].leaf) return pot[q];
	if (!q) return 0LL;

	ll &ret = dp[v][q];
	if (ret != -1LL) return ret;
	ret = 0LL;

	for (int i=1; i<=10; i++) {
		ret += solve(go(v, i), q-1);
		if (ret >= mod) ret -= mod;
	}

	return ret;
}

int main() {
	int n, val[3];
	char seq[20];
	cin>>n>>val[0]>>val[1]>>val[2];
	
	init();
	preprocess(val, 0, seq, 0);
	//cout << sz << endl;

	pot[0] = 1LL;
	for (int i=1; i<=n; i++)
		pot[i] = (pot[i-1] * 10LL) % mod;

	memset(dp, -1LL, sizeof(dp));
	cout << solve(0, n) << endl;

	return 0;
}

Measured memory_bytes: 77440
#include <stdio.h>

int main(void) {
    int N, A, B[200005], i;
    scanf("%d", &N);
    for (i=1; i<=N; i++) B[i]=0;
    for (i=2; i<=N; i++) {
        scanf("%d", &A);
        B[A]++;
    }
    for (i=1; i<=N; i++) {
        printf("%d", B[i]);
        if (i!=N) printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  ll n, m;
  cin >> n >> m;
  cout << lcm(n, m) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s;
    else
    {
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = line[0];
            int M = line[1];

            var switchsEachLightBulb = new List<int>[M];

            for (int i = 0; i < M; i++)
            {
                switchsEachLightBulb[i] = new List<int>();

                var ks = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                for(int j = 1; j < ks[0] + 1; j++)
                {
                    switchsEachLightBulb[i].Add(ks[j]);
                }
            }

            var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = 0;

            for (var bits = 0; bits < 1 << N; bits++)
            {
                bool isElectric = true;

                for (int i = 0; i < M; i++)
                {
                    int onCount = 0;

                    for (int j = 0; j < switchsEachLightBulb[i].Count; j++)
                    {
                        if(((bits >> switchsEachLightBulb[i][j] -1) & 1) == 1)
                        {
                            onCount++;
                        }
                    }

                    if(onCount % 2 != p[i])
                    {
                        isElectric = false;
                        break;
                    }
                }

                if (isElectric)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int D[10];

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    FOR(i,0,k)
    {
        char c;
        cin>> c;
        D[c - '0'] = 1;
    }
    FOR(i,n,100005)
    {
        string s = to_string(i);
        FOR(j,0,s.size())
        {
            if(D[s[j] - '0']) goto E;
        }
        cout<<i<<"\n";
        break;
        E:;
    }
    return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;

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

        String str1 = scan.nextLine();
        String str2 = scan.nextLine();

        int count = 0;

        for (int i = 0; i < str1.length(); i++) {
            if (str1.charAt(i) != str2.charAt(i)) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 42676
object Main {
	def f(x: Int) = x*x
  
	def divisionQuadrature(d: Int) = {
		def divisionQuadrature(d: Int, d2: Int) : Int = {
			if(d2 >= 600) return 0
			else return f(600-d2)*d + divisionQuadrature(d, d2+d)
		}
		divisionQuadrature(d, d)
	}
	
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
	        val a = sc.nextInt
	        val ans = divisionQuadrature(a)
	        println(ans)
    	}
    }
}

Measured memory_bytes: 44604
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  cout << C << " " << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int i;
	for(i=0;i<a.size();i++)
		if(a[i]!=b[i])
		{
			cout<<"No"<<endl;
			return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main() {
  string s(3,'0');
  rep(i,3){
    cin >> s.at(i);
  }
  int x = stoi(s);
  if(x%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
}

Measured memory_bytes: 3616