akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <iostream>
#include <chrono>

using namespace std;

const int DIV = 1000000007;

int64_t gcdCalc(int64_t a, int64_t b) {
    if (a == 0 && b == 0)
        return 1;
    while (b != 0) {
        int64_t r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int64_t twoPow(int p) {
    if (p == 0)
        return 1;
    int64_t a = twoPow(p / 2);
    int64_t b = (p & 1) ? (a * 2) : a;
    return (a * b) % DIV;
}

int main(int argc, char* argv[]) {
#ifdef VLAD_LOCAL
    ifstream f("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
    istream &f = cin;
#endif
    int n;
    f >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        f >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    int answer = 0;
    if (n & 1) {
        answer = b[(n - 1) / 2] - a[(n - 1) / 2] + 1;
    }
    else {
        answer = 1;
        answer += b[n / 2] - a[n / 2 - 1];
        answer += b[n / 2 - 1] - a[n / 2];
    }
    printf("%d\n", answer);
    
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("%.3lf\n", seconds);
#endif
	return 0;
}


Measured memory_bytes: 4764
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n, m, x = sc.nextInt()

    val bits = bitSearch(n, Vector(true, false))

    val cs = Vector.fill(n)(Vector.fill(m + 1)(sc.nextInt()))

    val ans =
      bits
        .map { bit =>
          val ar = new Array[Int](m + 1)
          cs.zip(bit).foreach {
            case (vec, b) =>
              if (b) {
                (0 to m).foreach { i =>
                  ar(i) += vec(i)
                }
              }
          }

          if (ar.tail.forall(_ >= x)) ar.headOption
          else None
        }
        .filter(_.isDefined)

    val ansStr = if (ans.isEmpty) -1 else ans.min.get

    println(ansStr)
  }

  def f(n: Int): Int = {
    if (n < 0) n + 360
    else if (n > 360) n % 360
    else n
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}


Measured memory_bytes: 58416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

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

void solve(int n) {
	vi v(n, 0);
	vi dist(n + 1, INF);
	vector<vector<bool>> dp(n + 1, vector<bool>(n, false));
	rep(i, n) {
		cin >> v[i];
	}
	for (int l = 2; l <= n; l += 2) {
		for (int i = 0; i + l <= n; i++) {
			bool b = false;
			if (l != 2) {
				for (int j = 2; j<l; j += 2) {
					if (dp[j][i] && dp[l - j][i + j])
						b = true;
				}
			}
			int dif = abs(v[i] - v[i + l - 1]);
			if (dif <= 1&&(l==2?1:dp[l-2][i+1]))b = true;
			if (b)dp[l][i] = true;
			//cout << l << " " << i << " " << dp[l][i] << endl;
		}
	}
	int pos = 0;
	deque<pii> q;
	q.push_back({ 0,0 });
	while (!q.empty()) {
		pii p = q.front(); q.pop_front();
		if (p.sc < dist[p.fs]) {
			dist[p.fs] = p.sc;
			if (p.fs == n) {
				cout << n - p.sc << endl;
				return;
			}
			for (int i = 2; i < n + 1; i += 2) {
				if (dp[i][p.fs]) {
					q.push_front({ p.fs + i,p.sc });
				}
			}
			q.push_back({ p.fs + 1 ,p.sc + 1 });
		}
	}

}

int main(void) {
	int n,m,sn=0;
	cin >> n;
	m = n;
	while (m) {
		sn += (m % 10);
		m /= 10;
	}
	cout << ((n%sn==0)?"Yes":"No") << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int sum = (a + b);
            int c = 0;

            do {
                sum /= 10;
                c++;

            } while (sum > 0);
            System.out.println(c);

        }

    }
}



Measured memory_bytes: 26096
def Divisors(a,b,c):
    num = 0
    for x in range(a,b+1):
        if c % x == 0:
            num += 1
    return num


def main():
    a, b, c= map(int, input().split())
    print(Divisors(a,b,c))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
INF = 10 ** 9 + 10

V = N * 1000
dp = [[INF] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
s = 0
for i in range(N):
    w = wv[i][0]
    v = wv[i][1]
    for j in range(V + 1):
        dpp = dp[i][j - v] + w
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v] + w)
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        if dp[i + 1][j] <= W:
            s = max(s, j)

print(s)

Measured memory_bytes: 120924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int firstIndex = s.indexOf("A");
		int lastIndex = s.lastIndexOf("Z");
		System.out.println(lastIndex - firstIndex + 1);
		in.close();
	}
}

Measured memory_bytes: 26040
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
no1 = max(A)
import sys
if A.count(no1) > 1:
    for i in range(N):
        print(no1)
    sys.exit()
else:
    ind = A.index(no1)
    no2 = max(A[:ind]+A[ind+1:])
    for i in range(N):
        if i == ind:
            print(no2)
        else:
            print(no1)

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

using namespace std;
int main(void) {
	int N;
	cin >> N;
	string W[110];
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (W[i] == W[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < N-1; i++) {
		if (W[i].back() != W[i + 1].front()) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	#define int ll
	int I, O, J, L; cin >> I >> O >> J >> J >> L;
	cout << max(2 * (I / 2) + 2 * (J / 2) + 2 * (L / 2), (I > 0 && J > 0 && L > 0) * (2 * ((I - 1) / 2) + 2 * ((J - 1) / 2) + 2 * ((L - 1) / 2) + 3)) + O << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int N,M,C;
    std::cin >> N >> M >> C;
    int B[M+2];
    for(int i = 1; i <= M; i++) std::cin >> B[i];
    int A[N+2][M+2];
    for(int i = 1; i <= N; i++) for(int j = 1; j <= M; j++) std::cin >> A[i][j];
    int ans = 0;
    int sum;
    for(int i = 1; i <= N; i++){
        sum = 0;
        for(int j = 1; j <= M; j++){
            sum += A[i][j] * B[j];
        }
        sum += C;
        if(sum > 0) ans++;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

l,r,d = inm()
sm = 0
for i in range(l,r+1):
    if i%d==0:
        sm += 1
print(sm)


Measured memory_bytes: 61832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  vector<vector<ll>> ans(n+10,vector<ll>(5,INF));
  rep(i,5){
    ans[0][i]=0;
  }
  rep(i,n){
    chmin(ans[i+1][0],ans[i][0]+p[i]);
    
    if(p[i]==0) chmin(ans[i+1][1],min(ans[i][0],ans[i][1])+2);
    else chmin(ans[i+1][1],min(ans[i][0],ans[i][1])+p[i]%2);
    
    chmin(ans[i+1][2],min({ans[i][0],ans[i][1],ans[i][2]})+(p[i]+1)%2);

    if(p[i]==0) chmin(ans[i+1][3],min({ans[i][0],ans[i][1],ans[i][2],ans[i][3]})+2);
    else chmin(ans[i+1][3],min({ans[i][0],ans[i][1],ans[i][2],ans[i][3]})+p[i]%2);

    chmin(ans[i+1][4],min({ans[i][0],ans[i][1],ans[i][2],ans[i][3],ans[i][4]})+p[i]);
  }

  ll an=INF;
  rep(i,5){
    chmin(an,ans[n][i]);
  }

  cout << an << endl;
}

Measured memory_bytes: 18816
#include <stdio.h>
#include <math.h>

 #define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);
long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);
 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
}


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


int main() {
  int n; cin>>n;
  string s,t;  cin>>s>>t;
  rep(i,n){cout<<s.at(i)<<t.at(i);}
}

Measured memory_bytes: 256
/*
氏名：鈴木丈人
学籍番号：190441067
概要：1つの整数xを読み込み、それをそのまま出力するプログラム
*/
#include<stdio.h>
int main(void)
{
	int i = 0;   //判定用
	int j = 0;
	int data[10000] = { 0 };   //入力された数値

	while (1)
	{
		scanf("%d", &data[i]);
		if (data[i] == 0)
		{
			break;
		}
		i++;

	}

	for (j = 0; j < i; j++)
	{
		printf("Case %d: %d\n", j + 1, data[j]);
	}

	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(){
  int i,j;
  i = 1;
  j = 1;
  int a[1000000];
  while(1){
    scanf("%d",&a[i]);
    if(a[i] ==0)break;
    ++i;
  }
  while(1){
    printf("Case %d: %d\n",j,a[j]);
    ++j;
    if(j >= i)break;
  }return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
	FAST_IO();
	string S; cin >> S;
	rep(i, sz(S)) {
		if((i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R')) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    sm = 0
    for i in a:
        if i > 0:
            sm += i
    ws = 0
    bs = 0
    for i in a[:k:]:
        if i > 0:
            ws += i
        else:
            bs -= i
    ms = min(ws,bs)
    for i in range(n-k):
        ai = a[i]
        af = a[i+k]
        if ai > 0:
            ws -= ai
        else:
            bs += ai
        if af > 0:
            ws += af
        else:
            bs -= af
        if ms > ws:
            ms = ws
        elif ms > bs:
            ms = bs
    print(sm-ms)



    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 61164
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let k = v[1];
	if n%k != 0 {
		println!("1");
	}else{
		println!("0");
	}
}

Measured memory_bytes: 4352
N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
L.insert(0, 0)
T = 1
D = 0
for i in range(1, N + 1):
    D = D + L[i]
    if D > X:
        break
    else:
        T += 1
print(T)

Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7

ans = 0
p = 1
for i in range(60):
    s = sum(1 for b in a if b&p)
    ans += s*(n-s)*p
    ans %= mod
    p <<= 1
print(ans)

Measured memory_bytes: 50936
#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
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = 1e9 + 7;
ll dp[101][256][101];
ll a[101];
ll fact[101];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, x;
	cin>>n>>x;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	fact[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		fact[i] = (ll(fact[i-1])*i)%MOD;
	}
	dp[0][0][0] = 1;
	dp[0][a[0]][1] = 1;
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j <= 255; j++)
		{
			dp[i][0][0] = 1;
			for(int k = 1; k <= n; k++)
			{
				dp[i][j][k] = (dp[i-1][j][k]+dp[i-1][(j^a[i])][k-1])%MOD;
			}
		}
	}	
	ll ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = (ans + (fact[i]*dp[n-1][x][i])%MOD)%MOD;
	}	
	cout<<ans<<'\n';
}


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

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[N], b[N];

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n + 1; i++) {
        scanf("%d", a + i);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", b + i);
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        int m = min(a[i], b[i]);
        b[i] -= m;
        ans += m;
        m = min(a[i + 1], b[i]);
        a[i + 1] -= m;
        ans += m;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4736
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n, m; cin>>n>>m;

    vi a(n);

    int s = 0;

    for(int & x : a)cin>>x, s+= x;


    s = ceil((double)s/(4*m));

    sort(all(a));

    for(int i = n-1; i >=(n-m); i--){
        if(a[i] < s){
            cout<<"No\n";
            return 0;
        }
    }

    cout<<"Yes\n";
    return 0;
    
    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 66156
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>

using namespace std;

int score[2010][2010];

int main(){
  int H, W;
  vector<string> S;
  string s;
  cin >> H >> W;
  for(int i=0; i<H; i++){
    cin >> s;
    S.push_back(s);
  }

  for(int y=0; y<H; y++){
    vector<int> ren;
    bool tuduki=false;
    for(int x=0; x<W; x++){
      if(S[y][x] == '.'){
        if(tuduki){
          ren.back()++;
        }
        else{
          ren.push_back(1);
          tuduki = true;
        }
      }
      else{
        tuduki = false;
      }
    }
    int itr=0;
    char last = '#';
    for(int x=0; x<W; x++){
      if(S[y][x] == '.'){
        score[y][x] += ren[itr];
      }
      else{
        if(last == '.'){
          itr++;
        }
      }
      last = S[y][x];
    }
  }

  for(int x=0; x<W; x++){
    vector<int> ren;
    bool tuduki=false;
    for(int y=0; y<H; y++){
      if(S[y][x] == '.'){
        if(tuduki){
          ren.back()++;
        }
        else{
          ren.push_back(1);
          tuduki = true;
        }
      }
      else{
        tuduki = false;
      }
    }
    int itr=0;
    char last = '#';
    for(int y=0; y<H; y++){
      if(S[y][x] == '.'){
        score[y][x] += ren[itr];
      }
      else{
        if(last == '.'){
          itr++;
        }
      }
      last = S[y][x];
    }
  }

  int ans = 0;
  for(int y=0; y<H; y++){
    for(int x=0; x<W; x++){
      //cout << score[y][x]-1 << " ";
      ans = max(ans, score[y][x]);
    }
    //cout << endl;
  }

  cout << max(0,ans-1) << endl;
  return 0;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const ll INF = (ll)(1e18);

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n+1);
  b[0] = 0;
  REP(i, n){
    cin >> a[i];
    b[i+1] = a[i] + b[i];
  }
  ll ans = INF;
  FORe(i, 0, n){
    ll l = 0, r = i;
    while(r-l > 1){
      ll c = (l+r)/2;
      if(b[c] >= b[i] - b[c]) r = c;
      else l = c;
    }
    ll P[] = {b[l], b[r]};
    ll Q[] = {b[i]-b[l], b[i]-b[r]};
    ll lmin = min(P[0], Q[0]), lmax = max(P[0], Q[0]);
    if(abs(P[1]-Q[1]) < abs(P[0]-Q[0])) lmin = min(P[1], Q[1]), lmax = max(P[1], Q[1]); 
    l = i; r = n;
    while(r-l > 1){
      ll c = (l+r)/2;
      if(b[c]-b[i] >= b[n] - b[c]) r = c;
      else l = c;
    }
    ll R[] = {b[l]-b[i], b[r]-b[i]};
    ll S[] = {b[n]-b[l], b[n]-b[r]};
    ll rmin = min(R[0], S[0]), rmax = max(R[0], S[0]);
    if(abs(R[1]-S[1]) < abs(R[0]-S[0])) rmin = min(R[1], S[1]), rmax = max(R[1], S[1]);
    ll tmp = max(lmax, rmax) - min(lmin, rmin);
    chmin(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

const int MAX_N = 2e5;
int h[MAX_N];
int dp[MAX_N];

const int inf = 2e9;

signed main(void){
  
  int N,K; cin >> N >> K;
  for(int i = 0; i < N; i++){ cin >> h[i];}
  
  for(int i = 1; i < N; i++){ 
    int res = inf;
    for(int j = 1; j <= K; j++){
      if( i-j >= 0 ){ res = min(res,dp[i-j]+abs(h[i]-h[i-j]));}
    }
    dp[i] = res;
  }
  
  cout << dp[N-1] << endl;
  
  return 0;
} 

Measured memory_bytes: 1792
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/

#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>

ll power(ll x,ll y,ll p);
int Bit(ll x);
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}

const int N=1e5 + 5;
unordered_map<int,int> mp;
int n;
ll cnt=1e18,m;

void div(int n){
	m=0;
	while(!(n&1))
		n=(n>>1),++m;
	cnt=min(cnt,m);
}


int main(){
	n=D();
	while(n--)
		div(D());
	
	printf("%lld",cnt);

}










ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}


int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}


















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

int main(){
	int n[36]={};
	int m;
	for(int a=0; a<10; a++){
		for(int b=0; b<10; b++){
			for(int c=0; c<10; c++){
				for(int d=0; d<10; d++){
					n[a+b+c+d-1]+=1;
				}
			}
		}
	}

	while(cin>>m){
		if(m>36){
			cout << "0" << endl;
			continue;
		}
		cout << n[m-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2992
import java.util.Scanner;

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

    void solve(Scanner sc) {
        char[][] addeds = {"dream".toCharArray(), "dreamer".toCharArray(), "erase".toCharArray(), "eraser".toCharArray()};
        char[] s = sc.next().toCharArray();

        int endIndex = s.length;
        while (endIndex > 0) {
            boolean f = false;
            for (char[] added : addeds) {
                if (isMatch(s, added, endIndex)) {
                    endIndex -= added.length;
                    f = true;
                    break;
                }
            }

            if (f == false) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    boolean isMatch(char[] s, char[] added, int endIndex) {
        if (endIndex - added.length < 0) {
            return false;
        }

        for (int i = 0; i < added.length; i++) {
            if (added[i] != s[endIndex - added.length + i]) {
                return false;
            }
        }

        return true;
    }
}


Measured memory_bytes: 26324
N = int(input())

Max = 0
Cnt = 0

Tmp = []
Tmp = input().rstrip().split(' ')
nTmp = int(Tmp[0])
for i in range(N-1):
  nTmp2 = int(Tmp[i+1])
  if nTmp >= nTmp2:
    Cnt += 1
    if Cnt > Max:
      Max = Cnt
  else:
    Cnt = 0
  nTmp = nTmp2

print(Max)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  map<int32,int32> cnt;
  REP(i,n){
    int32 a;
    cin >> a;
    ++cnt[a];
  }
  vector<int32> cnt2(n+1,0);
  for(auto p : cnt)cnt2[p.second] += p.second;
  vector<int32> cnt3(n+1,0);
  for(auto p : cnt)++cnt3[p.second];
  // REP(i,n+1)ANS(cnt2[i]);
  REP(i,n)cnt2[i+1] += cnt2[i];
  REP(i,n)cnt3[i+1] += cnt3[i];
  vector<int32> f(n+1,0); //f[x] := x個取り出せる長さの最大
  f[0] = INF;
  FOR(i,1,n+1){
    f[i] = (cnt2[i] + i * (cnt.size() - cnt3[i])) / i;
  }
  // REP(i,n+1)cout << i << " " << f[i] << endl;
  FOR(i,1,n+1){
    int32 l=0,r=n+1;
    while(r - l > 1){
      int32 mid = (l + r) / 2;
      if(f[mid] >= i){
        l = mid;
      }else{
        r = mid;
      }
    }
    ANS(l);
  }
  return 0;
}

Measured memory_bytes: 25728
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = []
for i in range(N):
  a = list(map(int, input().split()))
  A.append(a)

ans = 0
for i in range(N):
  t = C
  for j in range(M):
    t += A[i][j] * B[j]
  
  if t > 0:
    ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int n = N;
    int s = 0;
    while (n != 0) {
      s += n%10;
      n /= 10;
    }
    
    if (N % s == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
def gcd(a, b):
    if a < b:
        a, b = b, a
    
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)

n = int(input())
A = list(map(int,input().split()))

g = A[0]
for i in range(1, n):
    g = gcd(g, A[i])

print(g)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int n;
   cin >> n;
   string ans="No";
   for(int i=1;i<=9;i++){
      for(int j=1;j<=9;j++){
         if(n==i*j)
         ans="Yes";
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
int N,K;
string S;
int ans = 0,cnt = 0;

int main() {
    cin >> N >> K >> S;
  	if(S.size() == 1){cout << 0 << endl; return 0;}
  	else if(S.size() == 2){
      	if(S[0] == S[1]){cout << 1 << endl; return 0;}
      	else{cout << 0 << endl; return 0;}
    }
    REP(i,S.size()-1) if(S[i] == S[i+1]) cnt++;
  	cout << min(N-1,cnt + 2*K) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long long int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
long long int c=a[0]*a[1];
if(a[2]%2==0 || c%2==0){
cout<<0<<endl;
return 0;
}
cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

}

Measured memory_bytes: 19228
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <sstream>

using namespace std;

#define MAX 100
 template < typename T > std::string to_string( const T& n )
    {
        std::ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }

class Stack{
private:
    string stack_list[MAX];
    int top;
    int length;
public:
    Stack(){
        top = -1;
        length = 0;
    }
    string pop(){
        if(length == 0){
            std::cerr << "There is no item\n";
            return "Error";
        }else{
            top--;
            length--;
            return stack_list[top+1];
        }
    }
    void push(string input_num){
        if(top < MAX-1){
            stack_list[++top] = input_num;
            length++;
        }else{
            std::cerr << "Stack is full\n";
        }
    }
    int get_length(){
        return length;
    }
    void print_stack(){
        for(int i=0; i<length; i++){
            cout << stack_list[i] << " ";
        }
        cout << endl;
    }
};

int my_stoi(string str){
    int output;
    output = 0;
    if(str[0] == '-'){
        for(int i=1; i<str.length(); i++){
            output =output*10 + (str[i] - '0');
        }
        output *= -1;
    }
    else{
        for(int i=0; i<str.length(); i++){
            output =output*10 + (str[i] - '0');
        }
    }
    return output;
}

int main()
{
    stringstream ss;
    string s, str_out;
    Stack stack1;
    int output, num1, num2;
    getline(cin, s);
    output = 0;
    ss << s;
    while(!ss.eof()){
        ss >> str_out;
        switch((int)str_out[0]){
            case (int)'+': num2 = my_stoi(stack1.pop()), num1 = my_stoi(stack1.pop());
                output = num1 + num2;
                stack1.push(to_string(output));
                break;
            case (int)'-': num2 = my_stoi(stack1.pop()), num1 = my_stoi(stack1.pop());
                output = num1 - num2;
                stack1.push(to_string(output));
                break;
            case (int)'*': num2 = my_stoi(stack1.pop()), num1 = my_stoi(stack1.pop());
                output = num1 * num2;
                stack1.push(to_string(output));
                break;
            default: stack1.push(str_out);
        }
         
    }
    cout << output << endl;
    return 0;
}


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

int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> h(n);
    rep(i,n){
        cin>>h[i];
    }
    vector<ll> a(m);
    vector<ll> b(m);
    vector<ll> judge(n);
    rep(i,m){
        cin>>a[i]>>b[i];
        if(h[a[i]-1]<h[b[i]-1]){
            judge[a[i]-1] = 1;
        }else if(h[a[i]-1]>h[b[i]-1]){
            judge[b[i]-1] = 1;
        }else{
            judge[a[i]-1] = 1;
            judge[b[i]-1] = 1;
        }
    }
    ll ans = 0;
    rep(i,n){
        if(judge[i]==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6376
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, X = ni()
    val M = na(N)
    val S = M.sum
    val x = X - S
    val ans = N + x / M.min
    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Measured memory_bytes: 27072
#include <stdio.h>

int main(){
	int a, b;
	int max, min;
	int i;
	
	scanf("%d %d", &a, &b);
	
	if(a>b){
		max = a;
		min = b;
	}
	else{
		max = b;
		min = a;
	}
	
	for(i=0; i<max; ++i){
		printf("%d", min);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int D,N,ans=1;
  cin>>D>>N;
  if(D>0&&D<100) for(int i=0;i<D;i++) ans*=100;
  if(N<100)cout<<ans*N<<endl;
  else cout<<ans*101<<endl;
}

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

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

  int64_t N;
  cin >> N;
  pair<int, int> P[N];
  rep(i, N){
    int b = {};
    cin >> b;
    P[i].first = b;
    P[i].second = i;
  }
  sort(P, P+N);
  rep(i, N){
    cout << P[i].second + 1 << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {

    public static long dp[][] = new long[22][(1<<21)+1];
    public static long mod = (long) 1000000007;

    public static long solve(int i,int womenSet,int n,int arr[][]){
        if(i == n+1){
            if(womenSet == 0) return 1;
            else return 0;
        }
        if(dp[i][womenSet] != -1) return dp[i][womenSet];
        long ans = 0;
        for(int w=0;w<n;w++){
            boolean availble = ( (1<<w) & (womenSet) ) == 0 ? false : true;
            if( availble && (arr[i][w+1] == 1)  ) {
                ans = (ans + solve(i+1,womenSet ^ (1<<w),n,arr) ) % mod;
            }
        }

        return dp[i][womenSet] = ans;
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[][] = new int[n+1][n+1];

        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                arr[i][j] = sc.nextInt();
            }
        }

        int womenSet = ( (1<<n) -1 );

        for(int i=0;i<=n;i++){
            for(int j=0;j<=womenSet;j++){
                dp[i][j] = -1;
            }
        }

        System.out.print(solve(1,womenSet,n,arr));
    }
}

Measured memory_bytes: 384980
solve k a b
  | b - a < 2 = k + 1
  | k' == 0 = 1 + a'
  | otherwise = 1 + a' + cnt * (b-a) + m
    where
      a' = min k (a-1)
      k' = k - a'
      cnt = k' `div` 2
      m = k' `mod` 2

main = do
  [k,a,b] <- map read . words <$> getLine :: IO [Int]
  print $ solve k a b


Measured memory_bytes: 508
def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))

    for i in range(N):
        A[i + 1] += A[i]

    B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

    ans = 0
    t = 40
    while t:
        count = 0
        tmp = pow(2, t -1)
        for b in B:
            if ((b & (tmp + ans)) == (tmp + ans)):
                count += 1
            if count >= K:
                ans += tmp
                break
        t -= 1

    print (ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65788
#include <stdio.h>

typedef struct{
  int data;
}dice;

void roll(char move,dice *a,dice *b,dice *c,dice *d,dice *e,dice *f)
{
  dice temp;

  temp = *a;
  if(move == 'E'){//???
    *a = *d;    *d = *f;    *f = *c;    *c = temp;
  }
  else if(move == 'N'){//???
    *a = *b;    *b = *f;    *f = *e;    *e = temp;
  }
  else if(move == 'S'){//???
    *a = *e;    *e = *f;    *f = *b;    *b = temp;
  }
  else if(move == 'W'){//???
    *a = *c;    *c = *f;    *f = *d;    *d = temp;
  }
}

void spin(char move,dice *a,dice *b,dice *c,dice *d)
{
  dice temp;

  temp = *a; //??±?????????
  if(move == 'R'){ //???????????????????????????????¨??????????
    *a = *b;    *b = *d;    *d = *c;    *c = temp;    
  }
  else if(move == 'L'){  //??????????????????????????????????¨??????????
    *a = *c;    *c = *d;    *d = *b;    *b = temp;
  }
}

int main(void)
{
  int i,j,k,l;
  int da[6],dda[6];

  for(i=0; i<6; i++){
    scanf("%d",&da[i]);
  }
  for(i=0; i<6; i++){
    scanf("%d",&dda[i]);
  }
  
  dice one[6] = {
    {da[0]}, {da[1]}, {da[2]}, {da[3]}, {da[4]}, {da[5]},
  };
  dice two[6] = {
    {dda[0]}, {dda[1]}, {dda[2]}, {dda[3]}, {dda[4]}, {dda[5]},
  };

  for(i=0; i<=3; i++){
    roll('S',&two[0],&two[1],&two[2],&two[3],&two[4],&two[5]);
    for(j=0; j<=3; j++){
      spin('L',&two[1],&two[2],&two[3],&two[4]);
      for(k=0; k<=5; k++){
	if(one[k].data != two[k].data){
	  break;
	}
	else if((one[k].data == two[k].data) && (k==5)){
	  puts("Yes");
	  return(0);
	}
      }
    }
  }
  
  for(i=1; i<=2; i++){
    for(l=0; l<i; l++){
      roll('W',&two[0],&two[1],&two[2],&two[3],&two[4],&two[5]);
    }
    for(j=0; j<=3; j++){
      spin('L',&two[1],&two[2],&two[3],&two[4]);
      for(k=0; k<=5; k++){
	if(one[k].data != two[k].data){
	  break;
	}
	else if((one[k].data == two[k].data) && (k==5)){
	  puts("Yes");
	  return(0);
	}
      }
    }
  }
  puts("No");

  return(0);
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N;
  cin >> N;

  vector<lint> nums;
  while(N) {
    if(N%26 == 0) {
      nums.push_back(26);
      N -= 26;
      N /= 26;
    } else {
      nums.push_back(N%26);
      N /= 26;
    }
  }
  reverse(nums.begin(), nums.end());

  string ans;
  for(int i=0; i<nums.size(); i++) {
    ans.push_back('a' + nums[i] - 1);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 1003
#define MOD 1000000007
#define MAXV 500
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

// 일단 b는 모두 골고루 뿌려지고 a-b가 필요한 만큼 더 뿌려지는 사고방식

ll n, a, b, h[100111], buf[100111];

bool chk(ll lm) {
	for(int i=0;i<n;i++)	buf[i] = h[i] - b * lm;
	ll ret = 0;
	for(int i=0;i<n;i++) {
		if(buf[i] > 0)
			ret += buf[i] / (a-b) + ((buf[i] % (a-b) != 0) ? 1LL : 0LL); 
	}
	return ret <= lm;
}

int main () {
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++)	scanf("%lld",h+i);
	ll hi = 2000000009LL, lo = 1, mid, ret;
	for(int i=0;i<500;i++) {
		mid = (hi + lo) / 2LL;
		if(chk(mid))	hi = mid-1LL, ret = mid;
		else		lo = mid+1LL;
	}
	printf("%lld\n",ret);
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; ++i){
        cin >> A.at(i);
    }
    int64_t res = 0;
    if ( N % 2 == 0 ){
        int64_t ans[N][2];
        for ( int i = 0; i < N; ++i){
            if ( i >= 2 ){
                ans[i][0] = ans[i-2][0] + A.at(i);
            } else if ( i == 0 ) {
                ans[i][0] = A.at(i);
            } else {
                ans[i][0] = 0;
            }
        }
        for ( int i = 0; i < N; ++i){
            if ( i >= 3 ){
                 ans[i][1] = max(ans[i-3][0], ans[i-2][1]) + A.at(i);
            } else if ( i == 1 ) {
                ans[i][1] = A.at(i);
            } else {
                ans[i][1] = 0;
            }
        }
        res = max( ans[N-2][0], ans[N-1][1] );
    } else {
        int64_t ans[N][3];
        for ( int i = 0; i < N; ++i){
            if ( i >= 2 ){
                ans[i][0] = ans[i-2][0] + A.at(i);
            } else if ( i == 0 ){
                ans[i][0] = A.at(i);
            } else {
                ans [i][0] = 0;
            }
        }
        for ( int i = 0; i < N; ++i){
            if ( i >= 3 ){
                ans[i][1] = max(ans[i-2][1],ans[i-3][0]) + A.at(i);
            } else if ( i == 1 ){
                ans[i][1] = A.at(i);
            } else {
                ans[i][1] = 0;
            }
        }
        for ( int i = 0; i < N; ++i){
            if ( i >= 4 ){
                ans[i][2] = max(ans[i-2][2],max(ans[i-3][1],ans[i-4][0])) + A.at(i);
            } else if ( i == 2 ){
                ans[i][2] = A.at(i);
            } else {
                ans [i][2] = 0;
            }
        }
        
        res = max( ans[N-1][2], max( ans[N-2][1], ans[N-3][0] ));
        
        
        
    }
    
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 8804
#include <iostream>

using namespace std;

int main(){
	
	long long int N, M;
	
	cin >> N >> M;
	
	long long int ans = 0;
	
	if(N * 2 >= M){
		ans = M / 2;
	}else{
		ans = (N * 2 + M) / 4;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define mod 1000000007

using namespace std;
int n,i,x,y;
struct nodS
{
    int parent=0;
    bool viz=false;
    long long dpa=1, dpb=1;
    vector <int> vecini;
} nod[100005];
struct poz
{
    int parent, id;
    poz(int id, int parent)
    {
        this->id=id;
        this->parent=parent;
    }
};
queue <poz> q;
void rez(int poz)
{
    for(auto it : nod[poz].vecini)
    {
        if(it!=nod[poz].parent)
        {
            rez(it);
            nod[poz].dpa*=(nod[it].dpa+nod[it].dpb);
            nod[poz].dpa%=mod;
            nod[poz].dpb*=nod[it].dpa;
            nod[poz].dpb%=mod;
        }
    }
}
int main()
{
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>x>>y;
        nod[x].vecini.push_back(y);
        nod[y].vecini.push_back(x);
    }
    for(auto it : nod[1].vecini)
    {
        q.push(poz(it, 1));
    }


    while(!q.empty())
    {
        poz curr=q.front();
        nod[curr.id].parent=curr.parent;
        for(auto it : nod[curr.id].vecini)
            if(it!=curr.parent)
            {
                q.push(poz(it, curr.id));
            }

        q.pop();
    }

    /*
    for(i=1;i<=n;i++)
    {
        cout<<nod[i].parent<<' ';
    }
    */

    rez(1);
    /*
    for(i=1;i<=n;i++)
    {
        cout<<nod[i].dpa<<' '<<nod[i].dpb<<'\n';
    }
    */

    cout<<(nod[1].dpa+nod[1].dpb)%mod;
    return 0;
}


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

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; cin >> str; int n = str.size();
	int ans = 0;
	for(int i = 0; i < (1 << (n - 1)); i++) {
		int cur = 0;
		for(int j = 0; j < n; j++) {
			cur = cur * 10 + (str[j] - '0');
			if((i >> j) & 1) {
				ans += cur;
				cur = 0;
			}
		}
		ans += cur;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
void solve(std::istream &in, std::ostream &out);
 
int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}
 
struct DSU {
  int n;
  vector<int> par, sz;
  vector<pair<int, int>> vx;
  int64_t ret = 0;
 
  DSU() = default;
 
  DSU(int n) : n(n) {
    par.resize(2 * n);
    iota(par.begin(), par.end(), 0);
    sz.assign(2 * n, 1);
    vx.resize(2 * n);
    for (int i = 0; i < n; ++i) {
      vx[i] = make_pair(1, 0);
    }
    for (int i = n; i < 2 * n; ++i) {
      vx[i] = make_pair(0, 1);
    }
  }
 
  int get(int x) {
    return x == par[x] ? x : get(par[x]);
  }
 
  int64_t calc(pair<int, int> p) {
    return (int64_t) p.first * p.second;
  }
 
  void unite(int x, int y) { // union-by-rank
    x = get(x), y = get(y);
    if (x == y) {
      return;
    }
    if (sz[x] < sz[y]) swap(x, y);
    sz[x] += sz[y];
    par[y] = x;
    ret -= calc(vx[x]);
    ret -= calc(vx[y]);
    vx[x].first += vx[y].first;
    vx[x].second += vx[y].second;
    ret += calc(vx[x]);
  }
};

DSU uf;

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  uf = DSU(1 << 19);
  for (int i = 0, x, y; i < n; ++i) {
    in >> x >> y;
    uf.unite(x, y + (1 << 19));
  }
  out << uf.ret - n << '\n';
}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  const int N=1100000;
  static bool cmp[N+1]={true,true};
  for(int i=2;i<=N;i++){
    if(!cmp[i]){
      for(int j=i*2;j<=N;j+=i){
	cmp[j]=true;
      }
    }
  }
  static int le[1000001];
  fill(begin(le),end(le),1<<29);
  long long A,B;
  cin>>A>>B;
  for(int i=0;i<=N;i++){
    if(!cmp[i]){
      for(long long j=max<long long>(i,(A-B+i-1)/i*i);j<=A+B;j+=i){
	int x=j-(A-B);
	int e=0;
	for(long long c=j;c%i==0;c/=i,e++);
	le[x]=(le[x]>=e)?e:-1;
      }
    }
  }
  int ans=0;
  for(int i=0;i<B*2+1;i++){
    ans+=i+A-B>=2&&le[i]>0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6144