akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

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

int ans = 1000000;
int nans = 0;


int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)+m*(m-1))/2;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int a[100010];

int main(void)
{
    int n;
    cin >> n;
    REP(i, n)
    {
        int t;
        cin >> t;
        t++;
        a[t - 1]++;
        a[t]++;
        a[t + 1]++;
    }
    int ans = 0;
    REP(i, 100000)
    {
        ans = max(ans, a[i]);
    }
    cout << ans << endl;
}

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


int main() {

long INF = 1e15;
vector<long> c(100005);

for(int i=3;i<=100000;i++){
  int tmp=i;
  bool isprime=1;
  for(int j=2;j<=sqrt(tmp);j++){
    if(tmp%j==0||(tmp+1)/2%j==0) {
      isprime=0;
    }
  }
  if(isprime) c[i]=c[i-1]+1;
  else c[i]=c[i-1];
}
int Q;
cin>>Q;

for(int i=0;i<Q;i++){
  int l,r;
  cin>>l>>r;
  cout<<c[r]-c[l-1]<<endl;
}

}


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

using namespace std;

int main(){
	int n,
		b,
		f,
		r,
		v,
		inf[4][3][10] = { 0 },
		ans;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		inf[b - 1][f - 1][r - 1] = inf[b - 1][f - 1][r - 1] + v;
	}

	for (int i2 = 0; i2 < 4; i2++){

		for (int i1 = 0; i1 < 10; i1++){
			cout << " " << inf[i2][0][i1];
		}
		cout << endl;

		for (int i1 = 0; i1 < 10; i1++){
			cout << " " << inf[i2][1][i1];
		}

		cout << endl;

		for (int i1 = 0; i1 < 10; i1++){
			cout << " " << inf[i2][2][i1];
		}
		cout << endl;

		if (i2 != 3){ cout << "####################" << endl; }
	}

	cin >> ans;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main()
{
        long long int n,c,d;
        cin >>n;
        if((n%1000)==0)
        {
                cout<<"0"<<endl;
        }
        else
        {

                c=(n%1000);
                d=(1000-c);
                cout<<d<<endl;
        }
        return 0;
}


Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main(){
  	char X,Y;
  	cin >> X >> Y;
  	char buf=X-Y;
  	if(buf>0)
      cout << ">";
  	else if(buf == 0)
      cout << "=";
  	else if(buf < 0)
      cout << "<";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# Union-Find木
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        # 1-indexedのままでOK、その場合は[0]は未使用
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)
        # あるノードを根とする集合に属するノード数
        self.size = [1] * (n+1)
        # あるノードを根とする集合が木かどうか
        self.tree = [True] * (n+1)

    # 根の検索(グループ番号と言えなくもない)
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # 木かどうかの判定用
        if x == y:
            self.tree[x] = False
            return
        if not self.tree[x] or not self.tree[y]:
            self.tree[x] = self.tree[y] = False

        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # あるノードの属する集合のノード数
    def get_size(self, x):
        return self.size[self.find(x)]

    # 木かどうかの判定
    def is_tree(self, x):
        return self.tree[self.find(x)]

N,M=MAP()

lang=[[] for i in range(M+1)]
for i in range(N):
    for j in LIST()[1:]:
        lang[j].append(i+1)

uf=UnionFind(N)
for i in range(1, M+1):
    for j in range(1, len(lang[i])):
        a,b=lang[i][j-1],lang[i][j]
        if not uf.same(a, b):
            uf.union(a, b)

root=uf.find(1)
for i in range(2, N+1):
    if uf.find(i)!=root:
        NO()
        exit()
YES()


Measured memory_bytes: 20552
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: u8,
        b: u8,
    }

    if a * b % 2 == 0 {
        println!("No");
    } else {
        println!("Yes");
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
    int n,i;
    long num,min,max,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&num);
        sum+=num;
        if(i==0){
            min=num;
            max=num;
            continue;
        }
        if(num<min)
            min=num;
        else if(num>max)
            max=num;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
typedef long long ll;

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

    ll time_list[n];
    for(int i = 0; i < n; i++){
        cin >> time_list[i];
    }

    ll ans = 0;
    ll now = 0;
    for(int i = 0; i < n; i++){
        if(time_list[i] <= now){
            ans += t - (now - time_list[i]);
        }else{
            ans += t;
        }
        now = t + time_list[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
char s[N];
int main()
{
	scanf("%s", s + 1);
	int l = strlen(s + 1);
	int ans = 0;
	for(int i = 1; i <= l; i++)
	{
		ans += s[i] - '0';
		ans %= 9;
	}
	if(ans % 9 == 0)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}

Measured memory_bytes: 3880
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Policy;

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());

		var min = int.MaxValue;
		for (var i = 1; i <= n / 2 + 1; ++i) {
			var sum1 = Array.ConvertAll(i.ToString().ToCharArray(), num => int.Parse(num.ToString())).Sum();
			var sum2 = Array.ConvertAll((n - i).ToString().ToCharArray(), num => int.Parse(num.ToString())).Sum();
			if (sum1 + sum2 < min) {
				min = sum1 + sum2;
			}
		}

		Console.WriteLine(min);

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


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

using namespace std;

long long f[100010],c[100010],d[100010];
int x[100010];
int n,e,t,T;

inline void add1(int x,long long o)
{
	while(x<=n)
	{
		c[x]=min(c[x],o);
		x+=x&-x;
	}
}

inline long long ask1(int x)
{
	long long nowans=0x3f3f3f3f3f3f3f3fll;
	while(x)
	{
		nowans=min(nowans,c[x]);
		x-=x&-x;
	}
	return nowans;
}

inline void add2(int x,long long o)
{
	while(x)
	{
		d[x]=min(d[x],o);
		x-=x&-x;
	}
}

inline long long ask2(int x)
{
	long long nowans=0x3f3f3f3f3f3f3f3fll;
	while(x<=n)
	{
		nowans=min(nowans,d[x]);
		x+=x&-x;
	}
	return nowans;
}

int main()
{
	scanf("%d%d%d",&n,&e,&t);
	T=t;
	if(t%2)T++;
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	memset(f,0x3f,sizeof(f));
	memset(c,0x3f,sizeof(c));
	memset(d,0x3f,sizeof(d));
	f[0]=0;
	for(int i=1;i<=n;i++)
	{
		f[i]=min(f[i],f[i-1]+x[i]-x[i-1]+t);
		int now=upper_bound(x+1,x+1+i,x[i]-T/2)-x;
		if(x[i]-T/2>=x[1])
		{
			now--;
			long long nowans=ask1(now);
			f[i]=min(f[i],3ll*x[i]+nowans);
		}
		if(x[i]-T/2<x[1])now=0;
		now++;
		long long nowans=ask2(now);
		f[i]=min(f[i],x[i]+nowans);
		/*for(int j=i+1;j<=n;j++)
		{
			if((x[j]-x[i])*2>=t)f[j]=min(f[j],f[i-1]+3ll*(x[j]-x[i])+x[i]-x[i-1]);
			else f[j]=min(f[j],f[i-1]+t-2*(x[j]-x[i])+3ll*(x[j]-x[i])+x[i]-x[i-1]);
		}*/
		add1(i,-3ll*x[i]+f[i-1]+x[i]-x[i-1]);
		add2(i,0ll+t-x[i]+x[i]+f[i-1]-x[i-1]);
	}
	cout<<f[n]+e-x[n];
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	cout << min(a+b, min(b+c, c+a)) << ln;
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		double a,b;
		String op;
		
		while( true ) {
			a=kb.nextDouble();
			op=kb.next();
			b=kb.nextDouble();
			
			if( "?".equals( op) ) { break; }
			
			if( "+".equals( op) ) {
				System.out.printf( "%d\n", (int)a+(int)b );
			} else if( "-".equals( op) ) {
				System.out.printf( "%d\n", (int)a-(int)b );
			} else if( "*".equals( op) ) {
				System.out.printf( "%d\n", (int)a*(int)b );
			} else if( "/".equals( op) ) {
				System.out.printf( "%d\n", (int)a/(int)b );
			}
		}
			
	}
}

Measured memory_bytes: 20372
program ABC163C
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::A,Ans
    read*,N
    allocate(A(N-1))
    allocate(Ans(N))
    read*,A
    Ans=0

    do i=1,N-1
        Ans(A(i))=Ans(A(i))+1
    end do

    do i=1,N
        print'(i0)',Ans(i)
    end do
end program ABC163C

Measured memory_bytes: 6268
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int in;
	int a,b,c,d;//入力パート
	int i = 0, j = 0, run = 0, flag = 0;
	int ans;

	cin >> in;

	a = floor(in / 1000);
	in = in%1000;
	b = floor(in / 100);
	in = in % 100;
	c = floor(in / 10);
	in = in % 10;
	d = in;
	
	if ((a + b + c + d) == 7)cout << a << '+' << b << '+' << c << '+' << d << "=7" << "\n";
	else if ((a + b + c - d) == 7)cout << a << '+' << b << '+' << c << '-' << d << "=7" << "\n";
	else if ((a + b - c + d) == 7)cout << a << '+' << b << '-' << c << '+' << d << "=7" << "\n";
	else if ((a + b - c - d) == 7)cout << a << '+' << b << '-' << c << '-' << d << "=7" << "\n";
	else if ((a - b + c + d) == 7)cout << a << '-' << b << '+' << c << '+' << d << "=7" << "\n";
	else if ((a - b + c - d) == 7)cout << a << '-' << b << '+' << c << '-' << d << "=7" << "\n";
	else if ((a - b - c + d) == 7)cout << a << '-' << b << '-' << c << '+' << d << "=7" << "\n";
	else if ((a - b - c - d) == 7)cout << a << '-' << b << '-' << c << '-' << d << "=7" << "\n";

}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

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

const ll MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int ans[200005];

int main() {
	int n;
	scanf("%d", &n);
	int a;
	scanf("%d", &a);
	ans[n / 2] = a;
	int right = n / 2 + 1, left = n / 2 - 1;
	rep(i, n - 1) {
		scanf("%d", &a);
		if(n % 2 == 0) {
			if(i % 2 == 0) {
				ans[left] = a;
				--left;
			}
			else {
				ans[right] = a;
				++right;
			}
		}
		else {
			if(i % 2) {
				ans[left] = a;
				--left;
			}
			else {
				ans[right] = a;
				++right;
			}
		}
	}
	rep(i, n) (i != n - 1) ? printf("%d ", ans[i]) : printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	static long[][] dp;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int W = in.nextInt();
		long w[] = new long[n];
		int v[] = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
			sum += v[i];
		}
		dp = new long[n + 1][sum + 1];
		int ans = 0;
		for (int i = sum; i >= 0; i--) {
			if (knapsack(w, v, i, n) <= W) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}

	public static long knapsack(long w[], int v[], int Val, int N) {
		if (Val <= 0)
			return 0;
		if (N <= 0)
			return Integer.MAX_VALUE;
		long ans = 0;
		if (dp[N][Val] > 0)
			return dp[N][Val];
		ans = Math.min(knapsack(w, v, Val, N - 1), w[N - 1] + knapsack(w, v, Val - v[N - 1], N - 1));
		dp[N][Val] = ans;
		return ans;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 137680
a = list(map(int,input()))

d = []
for i in range(0,8):
  x = str(format(i,'b'))
  x = x.zfill(3) #1が”＋”とする
  d.append(x)
#print(a,d)
ans = 0
for i in d:
  c = a[0] #チェッカー
  for j in range(3):
    if i[j] == "0":
      c -= a[j+1]
    elif i[j] == "1":
      c += a[j+1]
  if c == 7:
    ans = i
    break
b = [0]*3    
for i in range(3):
  if ans[i] == "0":
    b[i] = "-"
  else:
    b[i] = "+"
print("{}{}{}{}{}{}{}=7".format(a[0],b[0],a[1],b[1],a[2],b[2],a[3]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll n, k,x;
   cin>>n>>k;
   set<int>s;
   fn(i,k){
     cin>>x;
     
     fn(i,x){
       ll m;
       cin>>m;
       s.insert(m);
     }
   }
   
   cout<<n-sz(s)<<endl;
   return 0;
}
    

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

int main() {
  string s;
  cin >> s;
  vector<int> population(s.size(), 0);
  vector<int> distL(s.size(), 0);
  vector<int> distR(s.size(), 0);
  int lastLR;
  lastLR = 0;
  rep (i, s.size()) {
    if (s[i] == 'L') {
      rep (j, i-lastLR+1) {
        distL[i - j] = j;
      }
      lastLR = i + 1;
    }
  }
  lastLR = s.size()-1;
  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == 'R') {
      rep (j, lastLR-i+1) {
        distR[i + j] = j;
      }
      lastLR = i - 1;
    }
  }
  rep (i, s.size()) {
    if (s[i] == 'L') {
      population[i - distR[i] + distR[i] % 2]++;
    }else{
      population[i + distL[i] - distL[i] % 2]++;
    }
  }
  rep (i, s.size()) {
    if (i != s.size() - 1) cout << population[i] << " ";
    if (i == s.size() - 1) cout << population[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
    long N, T, a;
    cin >> N >> T >> a;
    int surplus[N], max_a[N], min_a, count=0;
    max_a[0] = a;
    min_a = a;
    surplus[0] = max_a[0] - min_a;
    for (int i=1; i<N; i++){
        cin >> a;

        if (a > max_a[count]){
            max_a[count] = a;
            surplus[count] = max_a[count] - min_a;
        }else if (a < min_a){
            count ++; 
            min_a = a;  
            max_a[count] = a;
            surplus[count] = max_a[count] - min_a;

        }
    }

    int cost=1, max_surplus;
    max_surplus = surplus[0];
    for (int i=1; i <= count; i++){
        //cout << surplus[i] << endl;
        if (surplus[i] > max_surplus){
            cost = 1;
            max_surplus = surplus[i];
        }else if(surplus[i] == max_surplus){
            cost++;
        }
    }
    cout << cost << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	int ma = -1;
	int mi = INT_MAX;
	int x;

	int i;

	rep(i, n) {
		cin >> x;

		Max(ma, x);
		Min(mi, x);
	}

	Out(ma - mi);
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n,k = MI()
a = LI()

def cutting_isOK(x,li,k):
    ans = 0
    if x == 0:
      return False
    else:
      for i in range(n):
        ans += math.ceil(li[i]/x) - 1
      if ans <= k:
          return True
      else:
          return False
left = 0
right = 10**9+1
#全丸太の長さはk回以内の操作でright以下にできる
while right != left + 1:
    mid = (left+right)//2
    if cutting_isOK(mid,a,k):
        right = mid
    else:
        left = mid
print(right)



Measured memory_bytes: 32372
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(W: int, a: int, b: int):
    print(max(abs(a-b)-W, 0))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(W, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
 
int main(){
   int a,b,n,mi,ma;
    
   scanf("%d %d %d",&n,&a,&b);
   ma=a;
   if (ma>b) ma=b;
   mi=a+b-n;
   if (mi<0) mi=0;
   printf("%d %d\n",ma,mi);
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a[100000],b[100000],c=0,d=0,u[100000];
    long long s=0,p=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        s-=b[i];
        if(a[i]<b[i]){
            c++;
            p+=b[i]-a[i];
        }else if(a[i]>b[i]){
            u[d]=a[i]-b[i];
            d++;
        }
    }
    if(s<0){
        cout<<-1<<endl;
        return 0;
    }
    sort(u,u+d,greater<int>());
    
    for(int i=0;i<d&&p>0;i++){
        c++;
        p-=u[i];
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1280
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
 
 
int main() {
        ios::sync_with_stdio(0);
    string s;
	cin >> s;
	if(s=="SUN")cout<<"7";
	else if(s=="SAT")cout<<"1";
	else if(s=="FRI")cout<<"2";
	else if(s=="THU")cout<<"3";
	else if(s=="WED")cout<<"4";
	else if(s=="TUE")cout<<"5";
	else
        cout<<"6";
 
    return 0;
}

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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

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

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 2 * 1e5;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int dp[maxn], n, h[maxn], k;

int f(int id)
{
    if (id == n - 1)
        return 0;

    if (dp[id] != -1)
        return dp[id];

    dp[id] = abs(h[id] - h[id + 1]) + f(id + 1);
    
    for (int i = 2; i <= k && id + i < n; ++i)
        dp[id] = min(dp[id], abs(h[id] - h[id + i]) + f(id + i));

    return dp[id];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    cout << f(0);
}


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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


divs = make_divisors(N)
if N // divs[len(divs) // 2] == divs[len(divs) // 2]:
    i = len(divs) // 2
else:
    i = len(divs) // 2 - 1
print(divs[i]-1 + N // divs[i]-1)


Measured memory_bytes: 38640
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    s = input()
    ans = "Yes"
    for i in range(len(s)):
        if i%2==0:
            if s[i]=="L":
                ans = "No"
        else:
            if s[i]=="R":
                ans = "No"
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 4208
/*
注意范围！
short范围：-32768~32767
unsigned short范围：0~65535
int范围：-2147483648~2147483647
uint范围：0~4294967295
INT范围：-9223372036854775808~9223372036854775807
UINT范围：0~18446744073709551615
float范围：-3.4e38～3.4e38，精度：6~7位
double范围：-1.7e308~1.7e308，精度：15~16位
ldouble范围：-1.2e4932~1.2e4932，精度：18~19位
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

INT k;
INT beit[55],xunhuan[55][55];

void init()
{
	memset(xunhuan[0],0,sizeof(xunhuan[0]));
	for(int i=0;i<50;i++)
		for(int j=0;j<50;j++)
		{
			if(j==i)
				xunhuan[i+1][j]=xunhuan[i][j]+50;
			else
				xunhuan[i+1][j]=xunhuan[i][j]-1;
		}
}

int main()
{
	init();
	cin>>k;
	INT d=49+(k/50);
	fill(beit,beit+50,d);
	INT a=k%50;
	for(int i=0;i<50;i++)
		beit[i]+=xunhuan[a][i];
	cout<<50<<endl;
	for(int i=0;i<50;i++)
		cout<<beit[i]<<(i==49?'\n':' ');
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = (int)(k);i < (int)(n);i++)
int main() {
  int N, K;cin >> N >> K;
  vector<int> dp(100005), c(N);
  rep(i, 0, N) cin >> c[i];
  dp[0] = 0;
  rep(i, 1, K) dp[i] = abs(c[0] - c[i]);
  rep(i, K, N) {
    dp[i] = dp[i-1]+abs(c[i-1]-c[i]);
    rep(j, 1, K) dp[i] = min(dp[i], dp[i-j-1]+abs(c[i-j-1]-c[i]));
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 3936
n=int(input())
h=list(map(int,input().split()))
li=[0]
while len(h)>1:
  for i in range(len(h)):
    if i==len(h)-1:
      li += [len(h)-1]
      del h[1:]
    elif h[i]<h[i+1]:
      li += [len(h[0:i+1])-1]
      del h[0:i+1]
      break
print(max(li))

Measured memory_bytes: 15020
import numpy as np
N, C = map(int, input().split())

xv = [(0, 0)]
for i in range(N):
    x, v = map(float, input().split())
    xv.append((x, v))

sumA = np.zeros(N+2, dtype=float)
sumB = np.zeros(N+2, dtype=float)

xv.sort(key=lambda tup:tup[0])
xv.append((C,0))

for i in range(N+1):
    sumA[i+1] = sumA[i] + xv[i+1][1]
    sumB[i+1] = sumB[i] + xv[N-i][1]

maxA = [0]*(N+1)
maxB = [0]*(N+1)
for i in range(N):
    if sumA[i+1] < xv[i+1][0]: sumA[i+1] = 0
    else: sumA[i+1] -= xv[i+1][0]
    if sumB[i+1] < C - xv[N-i][0]: sumB[i+1] = 0
    else: sumB[i+1] -= C - xv[N-i][0]

    maxA[i + 1] = maxA[i]
    if sumA[i+1] > maxA[i]:
        maxA[i+1] = sumA[i+1]
    maxB[i + 1] = maxB[i]
    if sumB[i+1] > maxB[i]:
        maxB[i+1] = sumB[i+1]

ans = 0
for i in range(N):
    #when to turn back?
    #valB = -xv[i][0] + max(sumB[:N-i+1])
    valB = -xv[i][0] + maxB[N - i]
    if valB < 0:
        ans = max(ans, sumA[i])
    else:
        ans = max(ans, sumA[i] + valB)

    #when to turn back?
    valA = -C+xv[N-i+1][0] + maxA[N-i]
    if valA < 0:
        ans = max(ans, sumB[i])
    else:
        ans = max(ans, sumB[i] + valA)

print(int(ans))


Measured memory_bytes: 49472
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    ll h, n, a;
    cin >> h >> n;
    vector<ll> A;
    rep(i,n) {
        cin >> a;
        A.pb(a);
    }
    sort(all(A), std::greater<ll>());
    int total = 0;
    rep(i,A.size()) {
        total += A[i];
        if (total >= h) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int K;
    cin >> K;
    vector<ll> A(K),l(K+1,2), r(K+1,2);
    rep(i,K)cin>>A[i];
    reverse(all(A));
    rep(i,K){
        //l[i] ~ r[i]に含まれるA[i]の倍数の最小値になる最小のX
        l[i+1] = (l[i] + A[i] - 1) / A[i] * A[i];
        //l[i] ~ r[i]に含まれるA[i]の倍数の最大値になる最大のX
        r[i+1] = r[i] / A[i] * A[i] + A[i] - 1;
    }
    if(l[K] > r[K]){
        cout << -1 << endl;
    }
    else{
        cout << l[K] << " " << r[K] << endl;
    }
}

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

namespace _DSU{
#define SZ 300000
    int mem[2][2][SZ];
    int cnt=0;
}
class UnionFind{
private:
public:
    int *par,*rank;
    int find(int x){
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
    }
    UnionFind(int n,int *par,int *rank) :par(par),rank(rank){
	for(int i = 0; i < n; i++)par[i] = i,rank[i] = 0;
    }
    UnionFind(int n):UnionFind(n,_DSU::mem[_DSU::cnt][0],_DSU::mem[_DSU::cnt][1]){_DSU::cnt++;}
    bool unite(int x, int y){
	x = find(x);y = find(y);
	if (x == y)return false;
	if (rank[x] < rank[y]) par[x] = y;
	else{
	    par[y] = x;
	    if (rank[x] == rank[y])rank[x]++;
	}
	return true;
    }
    bool same(int x, int y){
	return find(x) == find(y);
    }
};


int main(){
    int N,K,L;
    cin>>N>>K>>L;
    UnionFind a(N),b(N);
    REP(i,K){
        int p,q;cin>>p>>q;
        a.unite(p-1,q-1);
    }
    REP(i,L){
        int p,q;cin>>p>>q;
        b.unite(p-1,q-1);
    }
    using P=pair<int,int>;
    map<P,int> cnt;
    REP(i,N)cnt[P(a.find(i),b.find(i))]++;
    REP(i,N){
        cout<<" "+(!i)<<cnt[P(a.find(i),b.find(i))];
    }cout<<endl;
    
    return 0;
}


Measured memory_bytes: 15104
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = (int)Math.pow(2, n)-1;
		
		System.out.println("0:");
		
		for(int i=1; i<=m; i++) {
			String binary = Integer.toBinaryString(i);
			System.out.print(i + ":");

			for(int j=0; j<binary.length(); j++) {
				char one = binary.charAt(binary.length()-j-1);
				if(one == '1') System.out.print(" " + j);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 95260
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll n,m;

ll per(ll a){
  ll ret = a;
  a--;
  while(a != 0){
    ret *= a;
    a--;
  }
  return ret;
}

int main(){
  cin >> n >> m;
  
  ll ans = 1LL;
  
  if(abs(n-m) >= 2){
    cout << 0;
    return 0;
  }
  
  for(int i = 1; i <= n;i++){
    ans *= i;
    ans = ans%1000000007;
  }
  for(int i = 1; i <= m;i++){
    ans *= i;
    ans = ans%1000000007;
  }
  if(n == m){
    ans *= 2;
    ans = ans%1000000007;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        quit()
    for h in range(H):
        for w in range(W):
            if h != 0 and \
                h != H-1 and \
                w != 0 and \
                w != W-1:
                print(".",end="")
            else:
                print("#",end="")
        print()
    print()


Measured memory_bytes: 7004
import java.util.Scanner;
 
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s[] = new int[13];
        int h[] = new int[13];
        int c[] = new int[13];
        int d[] = new int[13];
        for(int i=0;i<n;i++){
            String t = sc.next();
            if(t.equals("S")){
                int j = sc.nextInt();
                s[j-1]++;
            }else if(t.equals("H")){
                int j = sc.nextInt();
                h[j-1]++;
            }else if(t.equals("C")){
                int j = sc.nextInt();
                c[j-1]++;
            }else{
                int j = sc.nextInt();
                d[j-1]++;
            }
        }
        for(int i=0;i<13;i++){
            if(s[i]==0){
                int t = i+1;
                System.out.println("S "+t);
            }
        }
        for(int i=0;i<13;i++){
            if(h[i]==0){
                int t = i+1;
                System.out.println("H "+t);
            }
        }
        for(int i=0;i<13;i++){
            if(c[i]==0){
                int t = i+1;
                System.out.println("C "+t);
            }
        }
        for(int i=0;i<13;i++){
            if(d[i]==0){
                int t = i+1;
                System.out.println("D "+t);
            }
        }
    }
 
}

Measured memory_bytes: 26312
# import bisect
# import copy
# import fractions
# import math
import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    A=np.array(list(map(int,input().split())))

    cnt=0
    while all(i%2==0 for i in A):
        A = A//2
        cnt+=1
    print(cnt)



resolve()

Measured memory_bytes: 21764
# just copy and paste from https://atcoder.jp/contests/abc121/submissions/15377652
for i in range(pow(10,6)):
    pass
# added due to avoid search list with duplicated solvers.

a,b = map(int,input().split())
if a % 2 == 0:
    if (b - a + 1) % 2 == 0:
        if (b-a + 1) % 4 == 0:
            print(0)
        else:
            print(1)
    else:
        if (b - a) % 4 == 0:
            print(0^b)
        else:
            print(1^b)
else:
    if (b - a) % 2 == 0:
        if (b-a) % 4 == 0:
            print(a^0)
        else:
            print(a^1)
    else:
        if (b - a - 1) % 4 == 0:
            print(0^b^a)
        else:
            print(1^b^a)

Measured memory_bytes: 9148
//
//  main.cpp
//  ABC125
//
//  Created by hiroaki on 2019/04/27.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
//    int a,b,t;
//    cin >>a>>b>>t;
//    int s=(t+0.5)/a;
//    cout<<s*b<<endl;
    
    int n = 0;
    cin >> n;
    vector<int> v(n),c(n);
    
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
    }
    for (int i=0; i<n; i++) {
        cin >> c.at(i);
    }
    vector<int> dif; // 差
    
    for (int i=0; i<n; i++) {
        dif.push_back(v[i]-c[i]);
    }
    
    sort(dif.begin(), dif.end());
    
    int difference=0;
    for (int i=0; i<n; i++) {
        if(dif[n-1-i]<0){
            break;
        }
        difference+=dif[n-1-i];
    }
    cout<<difference<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cmath>
#include<iterator>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c=0;
	string str;
	cin >> str;
	b=str.length();
	for(a=0;a<b/2;a++)
	{
		if(str[a]!=str[b-a-1])	c++;
	}
	cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,b,f,r,v;
    int count[4][3][10];
    
   for(int i = 0; i < 4; i++ )
   {
      for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 10; k++ )
            {
                count[i][j][k] = 0;
            }
         }
   }    
   
 cin >> n;
 
 for(int x = 0; x < n; x++)
 {
     cin >> b >> f >> r >> v;
     
     count[b - 1][f - 1][r - 1] += v;
 }
 
 for(int i = 0; i < 4; i++ )
   {
      for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 10; k++ )
            {
                cout << " " << count[i][j][k];
            }
            cout << endl;
         }
         
         if(i != 3){ cout << "####################" << endl;}
   }  
   
   return 0;
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n],pre[n];
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			if(i==0)
			pre[i] = arr[i];
			else
			pre[i] = pre[i-1]+arr[i];
			pre[i]%=mod;
		}
		int ans = 0;
		for(int i=n-1;i>0;--i)
		{
			(ans+=arr[i]*pre[i-1])%=mod;
		}
		cout<<ans;		
    }
    return 0;
}


Measured memory_bytes: 6780
/* 
 * Project: AtCoder Beginners Contest 177 B - Substring
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

string s;
string t;

void solve() {

    uint32_t cnt_min = t.size();
    for (uint32_t i=0;i<=s.size() - t.size();i++) {
        uint32_t cnt = 0;
        for (uint32_t j=0;j<t.size();j++) {
            if (s[i+j] != t[j]) {
                cnt++;
            }
        }
        cnt_min = min(cnt_min,cnt);
    }
    printf("%d\n",cnt_min);
}

int main() {

    cin >> s >> t;

    solve();

}

Measured memory_bytes: 3188
#include <stdio.h>

int main() {
  int N, i, sum = 0, r, l;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d %d", &r, &l);
    sum += (l - r + 1);
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	println((H-h)*(W-w));
	return 0;
}


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

for i in range(1, n):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1
    A[j + 1] = key

print(*A)



Measured memory_bytes: 5984
import java.io.*;
import java.util.*;

class Main{

  public static int i, H;
  public static int[] A;

  public static void main(String[] args){
    String s;
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      s = bf.readLine();
      H = Integer.parseInt(s);
      A = new int[H+1];

      StringTokenizer S = new StringTokenizer(bf.readLine());
      //配列の初期化
      for(i=1 ; i<=H ; i++){
        A[i] = Integer.parseInt(S.nextToken());
      }
      bf.close();
    }
    catch(IOException e){
      System.out.println(e);
    }
    /*for(i=1 ; i<=H ; i++){
      System.out.println(A[i]);
    }*/
    buildMaxHeap(A);
    StringBuffer sb = new StringBuffer();
    for(i=1 ; i<=H ; i++){
	   	sb.append(" "+A[i]);
		}
    //sb.append(A[i]);
	 	System.out.println(sb);
  }

  public static void maxHeapify(int A[], int i){
    int l, r, largest, a;
    l = left(i);
    r = right(i);
    //左の子、自分、右の子で最大のノードをえらぶ
    if( l <= H && A[l] > A[i] ){
      largest = l;
    }
    else{
      largest = i;
    }
    if( r <= H && A[r] > A[largest] ){
      largest = r;
    }

    if( largest != i ){
        a = A[i];
        A[i] = A[largest];
        A[largest] = a;
      maxHeapify(A, largest);
        }
  }
  public static void buildMaxHeap(int A[]){
    for(i = H/2 ; i>=1 ; i--){
      maxHeapify(A, i);
    }
  }
  public static int left(int i){
    //if( i*2 <= H ) {
      return i*2;
    //}
  }
  public static int right(int i){
    //if( i*2+1 <= H ) {
      return i*2+1;
    //}
  }

}



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

long long int n,s;

bool chk(long long int n,long long int i,long long int s){
  long long int tot=0,x=n;
  while(x){
    tot += x%i;
    x/=i;
  }
  return tot==s;
}

long long int calc(long long int n,long long int s){
  if(s>n) return -1;
  if(s==n) return n+1;

  for(long long int i=2;i*i<=n;i++){
    if(chk(n,i,s)) return i;
  }

  long long int now=n-s,res=-1;
  for(long long int i=1;i*i<n;i++){
    if(now%i==0){
      long long int x = now/i+1;
      if(chk(n,x,s)){
        if(res==-1||res>x) res = x;
      }
    }
  }
  return res;
}

int main(){
  cin >> n >> s;
  cout << calc(n,s) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,a[55];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i];
	
	ll c=0;
	while(1){
		sort(a,a+n); reverse(a,a+n);
		if(a[0]<n) break;
		
		ll pos=a[0]/n; a[0]-=pos*n;
		REP(i,1,n) a[i]+=pos;
		c+=pos;
	}
	
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 256