akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int> > s(n);
  vector<pair<int, int> > c(m);
  rep(i, 0, n) cin >> s[i].first >> s[i].second;
  rep(i, 0, m) cin >> c[i].first >> c[i].second;
 
  rep(i, 0, n) {
    int mini = 1e9+7, ans = m;
    for(int j = m-1; j >= 0; j--) {
      int dis = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
      if(dis <= mini) {
        mini = dis;
        ans = j+1;
      }
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(lower_divisors + upper_divisors[::-1])


n = int(input())

ans = 0
for i in range(1, n + 1, 2):
    if make_divisors(i) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 9128
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33784
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int MAXd = 0, ans = 0, MIN = a[0];
    rep(i, 1, n){
        int tmp = a[i] - MIN;
        MIN = min(MIN, a[i]);
        if(tmp > MAXd){
            MAXd = tmp;
            ans = 1;
        }else if(tmp == MAXd){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
from sys import stdin

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
count = 0

for x in range(1, n+1):
  z = 0
  for y in str(x):
      z += int(y)
      
  if (z >= a) and (z <= b): count += x
    
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		try{
			while(true){
				int d = scn.nextInt();
				long ans = 0;
				for(int i = 1;i < 600/d;i++){
					ans += d * d * d * i * i;
				}
				System.out.println(ans);
			}
		}catch(Exception e){

		}
	}
}

Measured memory_bytes: 25864
#include <cstdio>

int main(){
	int n,s[5],tmp;
	int a[1010];int b[1010];int c[1010];

	scanf("%d",&n);

	for(int i =1;i<=n;i++){
		scanf("%d %d %d",&s[1],&s[2],&s[3]);
		int x = 1;
		while(x > 0){
			x=0;
			for(int k = 1;k<3;k++){
				if(s[k] > s[k+1]){
					tmp=s[k];s[k]=s[k+1];s[k+1]=tmp;x++;
				}
			}
		}
		c[i] = s[3];b[i]=s[2];a[i]=s[1];
	}

	for(int j =1;j<=n;j++){
		if((c[j]*c[j]) == ((a[j]*a[j])+(b[j]*b[j]))){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
}


Measured memory_bytes: 2620
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int n; cin >> n;
    double ans = 0.0;

    rep(i,n) {
        string s;
        double x;
        cin >> x;
        cin >> s;
        if(s == "JPY") {
            ans += x;
        } else {
            ans += 38e4 * x;
        }
    }
    printf("%.8f\n", ans);
    return 0;
}



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

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    import numpy as np
    return np.gcd.reduce(l)

A = input_one_number()
B = input_one_number()
C = input_one_number()
X = input_one_number()

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                cnt += 1

print(cnt)




Measured memory_bytes: 3192
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using mint = boost::multiprecision::cpp_int; //int1024_t etc...
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;

TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

char W = '1';
char B = '0';
int main(void) {
	string S;
	cin >> S;
	int N = S.size();
	int ans1 = 0;
	for (int i = 0; i < N; ++i) {
		//白
		if (i & 1) {
			if (S[i] != W)++ans1;
		}
		else {
			if (S[i] != B)++ans1;
		}
	}
	int ans2 = 0;
	for (int i = 0; i < N; ++i) {
		//黒
		if (i & 1) {
			if (S[i] != B)++ans2;
		}
		else {
			if (S[i] != W)++ans2;
		}
	}

	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int n,a[101],dp[100001];
int solve(int i){
	if (dp[i]!=-1)return dp[i];
    int res=0;
	for(int k=0;k<n;k++){
		if (a[k]<=i){
			if (!solve(i-a[k])){
				res=1;
				break;
			}
		}
	}
	return dp[i]=res;
}

int main(){
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
	cout <<(solve(k)?"First":"Second")<<endl;
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}

int main() {
	ll n, m, s, u, v, a, b;
	cin >> n >> m >> s;
	s = min(s, 2500ll);
	ll c[n + 1], d[n + 1];
	vector<pair<ll, pi > > graph[n + 1];
	FOR0(i, m) {
		cin >> u >> v >> a >> b;
		graph[u].pb({v, {a, b}});
		graph[v].pb({u, {a, b}});
	}
	FOR1(i, n) {
		cin >> c[i] >> d[i];
	}
	bool visited[n + 1][2501];
	ll minTime[n + 1][2501];
	ll ans[n + 1];
	memset(visited, false, sizeof(visited));
	FOR1(i, n) {
		FOR0(j, 2501) minTime[i][j] = INT64_MAX;
		ans[i] = INT64_MAX;
	}


	set<pair<ll, pi > > pq;
	ll j = s;
	ll t = 0;
	while (j <= 2500)
	{
		pq.insert({t, {j, 1}});
		minTime[1][j] = t;
		// cout << t << " " << j << endl;
		j += c[1];
		t += d[1];
	}

	while (!pq.empty())
	{
		auto entry = *pq.begin();
		pq.erase(entry);

		ll time = entry.ff;
		ll node = entry.ss.ss;
		ll coins = entry.ss.ff;
		// cout << time <<  " " << node << " " << coins << endl;

		for (auto x : graph[node])
		{
			if (coins - x.ss.ff < 0)
				continue;

			ll tmp = time + x.ss.ss;
			ll cns = coins - x.ss.ff;
			ll j = cns;
			ll t = tmp;
			while (j <= 2500)
			{
				if (t < minTime[x.ff][j])
					pq.erase({minTime[x.ff][j], {j, x.ff}}), minTime[x.ff][j] = t, pq.insert({t, {j, x.ff}});
				j += c[x.ff];
				t += d[x.ff];
			}
		}
	}

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < 2501; j++) {
			ans[i] = min(ans[i], minTime[i][j]);
		}
	}
	for (int i = 2; i <= n; i++) cout << ans[i] << endl;

}

Measured memory_bytes: 12152
//#pragma optimization_level 3

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <chrono>
#include <ctime>
#include <queue>
#include <math.h>
#include <deque>
#include <stack>
#include <iomanip>
#include <assert.h>
#include <stdio.h>
#include <cstring>
#include <random>

using namespace std;

#define int long long
#define ld long double
#define ull unsigned long long
//#define endl '\n'
#define try tr
#define pii pair<int, int>
#define ti tuple <int, int, int>
#define vi vector <int>
#define vpi vector <pii>
#define umap unordered_map
#define uset unordered_set
#define left left11
#define right right11
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define X first
#define Y second

ld TL = 1.0;
bool is_tl = 0;
int CALLS = 0;

inline bool IS() {
    if (++CALLS == 1000) {
        CALLS = 0;
        is_tl |= clock() > (TL - 0.1) * CLOCKS_PER_SEC;
    }
    return is_tl;
}

template<typename T1, typename T2>
inline void amin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void amax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
    os << p.first << ' ' << p.second << endl;
    return os;
}

template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    for (auto &u : v) os << u << ' ';
    os << endl;
    return os;
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 7, NS = 2e3 + 7, lg = 19, sq = 550, inf = 1e18 + 7, SM = 1e2 + 7;
const ld eps = 1e-9;
int hash_mod[4] = {1000000007, 998244353, 1000000009, 999999937}, mod = hash_mod[rnd() % 4];
int hash_pows[4] = {179, 239, 1007, 2003}, P = hash_pows[rnd() % 4];

void solve() {
    int n, x, ans = inf;
    cin >> n >> x;
    vi a(n), b;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    b = a;
    for (int i = 0; i < n; i++) {
        int cur = 0;
        for (int j = 0; j < n; j++) {
            amin(b[j], a[(j - i + n) % n]);
        }
        for (int i = 0; i < n; i++) {
            cur += b[i];
        }
        amin(ans, cur + x * i);
    }
    cout << ans;
}

signed main() {
    fast
    solve();

}


Measured memory_bytes: 3672
import scala.io.StdIn.readLine

object Main {
  def main(args:Array[String]) = {
    var s = ""
    while( {s = readLine;s} != "-1 -1 -1") {
      val n = s.split(" ").map(_.toInt)
      val sec = n(0)*3600 + n(1)*60 + n(2)
      val sd = 120*60 - sec
      val sd3 = sd*3
      printf("%02d:%02d:%02d\n", sd/3600, (sd/60) % 60, sd % 60)
      printf("%02d:%02d:%02d\n", sd3/3600, (sd3/60) % 60, sd3 % 60)
    }
  }
}

Measured memory_bytes: 44064
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		ArrayList<String> s = new ArrayList<String>(n);

		for (int i = 0; i < n; i++) {
			s.add(sc.next());
		}

		Collections.sort(s);

		for (int i = 0; i < n; i++) {

			System.out.print(s.get(i));
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n],i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n]={0};
	for(i=1;i<n;i++)
	{
		dp[i]=1e9;
		for(ll j=max(0LL,i-k);j<i;j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

long long a[100005] = {};

int main(){
    long long n,x,ans = 0;
    cin >> n >> x;
    cin >> a[0];
    for(int i = 1;i < n; i ++){
        cin >> a[i];
        long long cnt = a[i]+a[i-1]-x;
        if(cnt > 0){
            ans += cnt;
            a[i] -= cnt;
            if(a[i] < 0){
                if(a[i-1]+a[i] < 0){
                    a[i-1] = 0;
                    a[i+1] -= a[i];
                }else{
                    a[i-1] += a[i];
                }
                a[i] = 0;
            }
        }
    }

   // for(int i = 0;i < n; i ++)cout << a[i] << " ";
   // cout << endl;

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

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

int const N = 200000, md = 1e9 + 7;
char s[N + 1];
int dp[N + 1], n, m;

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline void sb(int &x, int y) { if ((x -= y) <  0 )x += md; }
inline void out(int an) { printf("%d\n", an); exit(0); }

void sad(){
	dp[0] = 1;
	dp[1] = 1;
	f(i, 2, n + 1)ad(dp[i] = dp[i - 1], dp[i - 2]);
	int an = dp[n];
	ad(an, dp[n - 2]);
	out(an);
}

int main(){
	scanf("%d%d%s", &n, &m, s);
	int mx = md;
	bool im = false;
	f(i, 0, m){
		int j = i;
		while (j + 1 < m && s[j + 1] == s[i])++j;
		if (i == 0 && j + 1 == m)sad();
		im = !im;
		if (im && j + 1 != m){
			int ln = j - i + 1;
			if (ln & 1)mx = min(mx, ln);
			else if (i == 0)mx = min(mx, ln | 1);
		}
		i = j;
	}
	if (n & 1)out(0);
	n >>= 1;
	mx = mx + 1 >> 1;
	int l = 1, s = 0;
	f(i, 1, n + 1){
		if (i - l > mx)sb(s, dp[l++]);
		dp[i] = s;
		if (i <= mx)ad(dp[i], i << 1);
		ad(s, dp[i]);
	}
	out(dp[n]);
}

Measured memory_bytes: 1280
fun main(args: Array<String>) {
    var (A, B) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!
    for (i in 0..(A+B)) {
        if ((i==A)&&(S[i]!='-')) {
            println("No")
            return
        }
        if ((i!=A)&&(S[i] !in arrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) {
            println("No")
            return
        }
    }
    println("Yes")
}


Measured memory_bytes: 37576
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static ll a[100010],b[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%lld%lld",&a[i],&b[i]);
	
	ll ret = 0;
	rrep(i,n){
		ll d = a[i]%b[i];
		if(d != 0)d = b[i]-d;
		ret = ((ret-d+b[i]-1)/b[i])*b[i]+d;
	}
	cout << ret << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<bitset>
typedef long long int ll;
typedef unsigned long long int llt;
#define vector<int> vi
#define pair<int, int> pii
using namespace std;
int main()
{
    int n;
	cin>>n;
	int arr[n];
	arr[n-1] = INT_MAX;
    for(int i=0;i<n-1;i++)
    {
        cin>>arr[i];
    }
    ll ans = arr[0];
    for(int i=1;i<n;i++)
    {
        ans += min(arr[i], arr[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	string S; cin >> S;
	S = S + '!';
	int mn=31415, mx, now;
	for(char ch='a'; ch<='z'; ++ch){
	    mx=now=0;
	    for(int i=0; i<S.size(); ++i){
	        if(S[i]!=ch && S[i]!='!') ++now;
	        else{
	            mx=max(mx, now);
	            now=0;
	        }
	    }
	    mn=min(mn, mx);
	}
	cout << mn << endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int a[N];
  int cnt=0;
  for (int i=0;i<N;i++){
    cin>>a[i];
  }
  for (int i=0;i<N;i++){
    int temp=a[i]-1;
    if(a[temp]==i+1){
      cnt++;
    }
  }
  cout<<cnt/2<<endl;
  return 0;
}

  
  

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

int main() {
  int N;
  cin >> N;
  vector<string> keep(N);
  for (int i = 0; i < N; i++) {
    cin >> keep.at(i);
  }
  sort(keep.begin(), keep.end());
  int count = 0;
  for (int j = 0; j < N; j++) {
    if (j == 0) {
      count++;
    }
    else {
      if (keep.at(j) != keep.at(j - 1)) {
        count++;
      }
    }
  }
  cout << count << endl; 
}

Measured memory_bytes: 9536
#include<stdio.h>
int main()
{
	int a,b,c,d,n,k=0;;
	while(scanf("%d",&n) != EOF)
	{
		for(a=0;a<10;a++)
		{
			for(b=0;b<10;b++)
			{
				for(c=0;c<10;c++)
				{
					for(d=0;d<10;d++)
					{
						if(n==a+b+c+d)
						{
							k++;
						}
					}
				}
			}
		}
		printf("%d\n",k);
		k=0;
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>

int main() {
  int a, b;
  while(scanf("%d %d", &a, &b) != EOF){
    char s[255];
    int c = a + b;
    sprintf(s, "%d", c);
    int length = strlen(s);
    printf("%d\n", length);
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
      
int main() {
  for (int W = 0; ; W++) {
   int A, B;
   cin >> A >> B;
    if (A == 0 && B == 0) {
     break; 
    }
    for (int X = 0; X < A; X++) {
 
     if (X % 2 == 0) {
      for (int Y1 = 0; Y1 < B; Y1++) {
       if (Y1 % 2 == 0) {
        cout << "#";
        }
       else
        cout << ".";
       }
       cout << endl;
      }
 
     if (X % 2 != 0) {
      for (int Y2 = 0; Y2 < B; Y2++) {
       if (Y2 % 2 == 0) {
        cout << ".";
       }
      else
       cout << "#";
     }
    cout << endl;
     }
 
  }
    cout << endl;
 }
}



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();
        sc.nextLine();
        String[] sArray = sc.nextLine().split(" ");
        int[] array=Arrays.stream(sArray).mapToInt(Integer::parseInt).toArray();

        //バブルソート
        //boolean flag =true;
        int i=0;
        int changeCount=0;
        while(i<=n-1){
            for (int j=n-1;j>0;j--){
                if (array[j-1]>array[j]){
                    int tmp=array[j-1];
                    array[j-1]=array[j];
                    array[j]=tmp;
                    changeCount+=1;
                }
            }
            i++;
        }

        StringBuilder sb = new StringBuilder();
 
        for(int k : array)
            sb.append(k + " ");
         
        sb.deleteCharAt(sb.length()-1);
 
        System.out.println(sb);
        System.out.println(changeCount);
    }
}


Measured memory_bytes: 32192
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	vector<int> hist(26,0);
	for(int i=0;i<size;++i){
		hist[ str[i]-'a' ]++;
	}
	for(int i=0;i<26;++i){
		if( hist[i] == 0 ){
			cout << (char)('a'+i) << endl;
			return;
		}
	}
	cout << "None" << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 512
#include<stdio.h>

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



Measured memory_bytes: 2100
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
vector<ll> A;
ll bik[114514];
ll bikinv[114514];
ll hoge[114514];
ll hogesum[114514]={0};
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0; // unsolvable
}
void bikcal(int NN){
	ll hoge=(ll)1;
	bik[0]=(ll)1;
	bikinv[0]=(ll)1;
	for(int i=1;i<=NN;i++){
		hoge=(hoge*i)%MOD;
		bik[i]=hoge;
		bikinv[i]=invMod(bik[i],MOD);
	}
}
int main(){
	cin>>N;
	bikcal(N);
	rep(i,N){
		ll x;
		cin>>x;
		A.pb(x);
	}
	rep(i,N){
		hoge[i+1] = bik[N]*invMod(i+1,MOD)%MOD;
		hogesum[i+1]+=(hogesum[i]+hoge[i+1])%MOD;
		//cout<<hoge[i+1]<<" "<<hogesum[i+1]<<endl;
	}
	ll ans=0;
	rep(i,N){
		ll fuga=(hogesum[i+1]+hogesum[N-i])%MOD;
		fuga=fuga+MOD-bik[N];
		fuga%=MOD;
		fuga*=A[i];
		fuga%=MOD;
		ans+=fuga;
		ans%=MOD;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4340
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
      primes(i) = primes(i) + primes(i-1)
      primes(i+1) = primes(i+1) + primes(i)
    }

    for(i<-Math.sqrt(n).toInt+1 to n)
      primes(i) = primes(i)+primes(i-1)

    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000000)
    for(i <- stdin.getLines) {
      println(p(i.toInt))
    }
  }
}

Measured memory_bytes: 63248
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,k,t,a[50];
	cin>>k;
	t=k/50;
	for (i=0;i<50;i++){
		a[i]=t;
		t++;
	}
	t=k%50;
	for (i=0;i<t;i++){
		a[i]+=50;
		for (j=0;j<50;j++){
			if (j!=i){
				a[j]--;
			}
		}
	}
	cout<<"50"<<"\n";
	for (i=0;i<50;i++){
		cout<<a[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.printf("%d %d\n", x * y, x * 2 + y * 2);
        sc.close();
    }
}


Measured memory_bytes: 26212
#include<stdio.h> 
int main()
{
	int a[100][100];
	int b[100];
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 0;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	
	int c[100]={0};
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<m;j++)
		{
			c[i]+=a[i][j]*b[j];
		}
	}
	for(int i = 0;i<n;i++)
	{
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{  
	int N;
	cin >> N;
    vector<int> a;
    for(int i=0; i<N; i++)
    {
    	int n;
    	cin >> n;
    	a.push_back(n);
    }
    sort(a.begin(), a.end(), greater<int>());

    int Alice = 0, Bob = 0;
    for(int i=0; i<N; i++)
    {
        if(i%2==0) Alice += a[i];
        else Bob += a[i];
    }

    cout << Alice - Bob << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, k = map(int, input().split())

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;
#define lol long long



int main()
{
	int R,G,B,N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int i = 0; i < (N / R) + 1; i++) {
		for (int j = 0; j < (N / G) + 1; j++) {
			int b = N - (i * R) - (j * G);
			if (b % B == 0 && b >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int a,b,C;
    double S,L,h,rad;
    cin >> a >> b >> C;
    rad = (acos(-1)*C)/180.0;
    S = (a*b*sin(rad))/2.0;
    L = a + b + sqrt(a*a+b*b-2*a*b*cos(rad));
    h = b*sin(rad);
    printf("%lf\n%lf\n%lf\n",S,L,h);
    return 0;
}


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int N,W,w,v,mw,ans;
deque<int> V[4];

signed main() {
    cin >> N >> W >> mw >> v;
    V[0].pb(v);
    rep(i,N-1) {
        cin >> w >> v;
        V[w-mw].pb(v);
    }
    rep(i,4) sort(rall(V[i]));
    rep(i,4) V[i].push_front(0);
    rep(i,4) rep11(j,V[i].size()) V[i][j] += V[i][j-1];
    rep(i,V[0].size()) rep(j,V[1].size()) rep(k,V[2].size()) {
        int tmp = W - (i*mw + j*(mw+1) + k*(mw+2));
        if (tmp >= 0) ans = max(ans, V[0][i] + V[1][j] + V[2][k] + V[3][min((int)(V[3].size()-1),tmp/(mw+3))]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int K =sc.nextInt();
        int FR[] =new int[N];
        int count =0;
        
        for(int i=0;i<N;i++){
            FR[i]=sc.nextInt();
        }
        for(int j=0;j<N;j++){
            if(FR[j]>=K){
                count++;
            }
        }
        
        System.out.println(count);
        
    }
}


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

int main()
{
    int arr[26][26];
    for(int i = 0;i < 26;i++)
        for(int j = 0;j < 26;j++)
            arr[i][j] = 0;
    char s[200001],t[200001];
    cin>>s>>t;
    int length = strlen(s);
    for(int i = 0;i < length;i++)
    {
        int x = s[i]-'a',y = t[i] - 'a';
        if(arr[x][y] == 0)
        {
            for(int j = 0;j < 26;j++)
            {
                if(arr[x][j] != 1 && j != y) arr[x][j] = -1;
                else if(arr[x][j] == 1)
                {
                    printf("No\n");
                    return 0;
                }
                if(arr[j][y] != 1 && j != x) arr[j][y] = -1;
                else if(arr[j][y] == 1)
                {
                    printf("No\n");
                    return 0;
                }
                
            }
            arr[x][y] = 1;
        }
        else if(arr[x][y] == -1)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int N, M; cin >> N >> M;
    vector<int> a(N);
    ll sum = 0;
    rep(i, N) {
        cin >> a[i];
    }
    sort(ALL(a));
    vector<pair<int, int>> bc(M);
    rep(i, M) {
        cin >> bc[i].second >> bc[i].first;
    }
    sort(ALL(a));
    sort(ALL(bc));

    ll ite = 0;
    M--;

    while(bc[M].first >= a[ite] && M >= 0) {
        while(bc[M].first > a[ite] && bc[M].second > 0) {
            a[ite] = bc[M].first;
            bc[M].second--;
            ite++;
        }
        M--;
    }

    rep(i, N) {
        sum += a[i];
    }
    COUT(sum);
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n;
    cout << n/3 << endl; return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define pb push_back
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;i--)
#define _rrep2(i,n) for(lint i=n-1;i>=0;i--)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;i--)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)
#define fi i.first
#define se i.second

int main(){
	stin(s);
	lint n=s.size();
	lint mxd=0;
	rep(i,1,n)if(s[i-1]!=s[i]){
		lint tmp=min(i-0,n-i);
		mxd=max(mxd,tmp);
	}cout<<n-mxd<<endl;
}

//sub-EOF


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   vector<int> ans{0,1,3,1,2,1,2,1,1,2,1,2,1};
   int x,y; cin>>x>>y;
   cout<<(ans[x]==ans[y]? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
input_list = lambda : list(map(int,input().split()))


#bfs内で処理すると使い回しが効かないのでsearch_color とか幅探索後の具体的な処理は別個にしたほうがいい
def bfs(s,n,node):
    c=[-1 for _ in range(n)]
    c[0]=0
    
    side_num_arr=list(map(lambda x :len(x),node))
    #print(l)
    queue=[-1 for _ in range(n)]
    now=0
    queue[now]=s
    ans=[-1 for _ in range(n)]
    ans[0]=[0]
    last_ind=1
    while last_ind<n:
        
        if now>=n:
            return []
        c[queue[now]]=True
        if side_num_arr[queue[now]]<=0:
            now+=1
            continue
        for edge in node[queue[now]]:
            #edge=i[0]
            if side_num_arr[edge]<=0 or c[edge]==True:
                continue
            side_num_arr[edge]-=1
            
            queue[last_ind]=edge
            last_ind+=1
            c[edge]=True
            ans[edge]=queue[now]

        side_num_arr[queue[now]]=0
        now+=1
    return ans



n,m=input_list()
node=[[] for _ in range(n)]

for i in range(m):
    u,v=input_list()
    u-=1
    v-=1
    node[u].append(v)
    node[v].append(u)

#print(np.array(node))

ans=bfs(0,n,node)
if len(ans)==0:
    print("No")
    exit()

print("Yes")
for each in ans[1:]:
    print(each+1)








Measured memory_bytes: 117008
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int h, w;
	cin >> h >> w;
	int c[10][10];
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> c[i][j];
		}
	}
	int cnt[10] = {};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int a;
			cin >> a;
			cnt[a]++;
		}
	}
	for(int k = 0; k < 10; k++){
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 10; i++){
		ans += cnt[i] * c[i][1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String a = sc.nextLine();
		String c;
		int b = 0;
		for(int i = 0; i < a.length(); i++){
			c = a.substring(i,i + 1);
			if(c.equals("1")){
				b += 1;
			}
			if(c.equals("2")){
				b += 2;
			}
			if(c.equals("3")){
				b += 3;
			}
			if(c.equals("4")){
				b += 4;
			}
			if(c.equals("5")){
				b += 5;
			}
			if(c.equals("6")){
				b += 6;
			}
			if(c.equals("7")){
				b += 7;
			}
			if(c.equals("8")){
				b += 8;
			}
		}
      if(b % 9 == 0){
      	System.out.println("Yes");
      }else{
      	System.out.println("No");
      }
		
		
		
	}
}

Measured memory_bytes: 50592
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N, K = map(int, input().split())
    H = [0] + list(map(int, input().split()))
    INF = 10 ** 9
    dp = [INF for _ in range(N + 1)]
    dp[1] = 0
    for i in range(1, N):
        for k in range(1, K + 1):
            if i + k <= N:
                tmp = dp[i] + abs(H[i + k] - H[i])
                if dp[i + k] > tmp:
                    dp[i + k] = tmp

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 57312
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> ban(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    int ret = 1145141919;
    for (int bit = 0; bit < 1 << (h - 1); bit++) {
        vector<int> divide(h);
        int count = 0;
        for (int i = 0; i < h - 1; i++) {
            divide[i + 1] = divide[i];
            if (bit & (1 << i)) divide[i + 1]++, count++;
        }

        vector<int> now(count + 1);
        bool possible = true;
        for (int i = 0; i < w; i++) {
            vector<int> here(now.size());
            for (int j = 0; j < h; j++) here[divide[j]] += ban[j][i] - '0';

            bool cut = false;
            for (int j = 0; j < now.size(); j++) {
                if (here[j] > k)possible = false;
                if (now[j] + here[j] > k)cut = true;
            }
            if (cut) count++;
            for (int j = 0; j < now.size(); j++) {
                if (cut)now[j] = here[j];
                else now[j] += here[j];
            }
        }

        if (possible)ret = min(ret, count);
    }

    cout << ret << endl;
    return 0;
}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int64_t> memo(N, N + 1);
  int64_t X = 0;
  int64_t Y;
  int64_t Z;
  memo.at(0) = 0;
  for (int64_t i = 0; i < N; i++) {
    if (memo.at(A.at(X) - 1) != N + 1) {
      Y = i - memo.at(A.at(X) - 1) + 1;
      Z = memo.at(A.at(X) - 1);
      break;
    }
    else {
      memo.at(A.at(X) - 1) = i + 1;
      X = A.at(X) - 1;
    }      
  }
  if (K >= Z) {
  for (int64_t i = 0; i < N; i++) {
    if (memo.at(i) == (K - Z) % Y + Z) {
      cout << i + 1 << endl;
      break;
    }
  }
  }
  else {
    int ans = 0;
  for (int i = 0; i < K; i++) {
    ans = A.at(ans) - 1;
  }
  cout << ans + 1 << endl;
  }    
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,a1,b1;
    cin>>a>>b;
    if(a>=b)
    {
        b1=b;
        while(a>1)
        {
            b=b1+10*b;
            a--;
        }
        cout<<b<<endl;
    }
    else if(a<b)
    {
        a1=a;
        while(b>1)
        {
            a=a1+10*a;
            b--;
        }
         cout<<a<<endl;
    }
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a==0 && b==0){
                System.exit(0);
            }
            for(int i=0;i<b;i++){
                System.out.printf("#");
            }
            System.out.println("");

            for(int j=1;j<a-1;j++){
                System.out.printf("#");
                for(int i=1;i<b-1;i++){
                    System.out.printf(".");
                }
                System.out.printf("#");
                System.out.println("");
            }
            for(int i=0;i<b;i++){
                System.out.printf("#");
            }
            System.out.println("");

            System.out.println("");
        }
    }
}


Measured memory_bytes: 55732
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);


	public void run() {
		HashMap<String,Integer> map=new HashMap<String, Integer>();
		map.put("A",0);map.put("B",0);map.put("AB",0);map.put("O",0);
		while(sc.hasNext()) {
			String s=sc.next().split(",")[1];
			map.put(s,map.get(s)+1);
		}
		ln(map.get("A"));
		ln(map.get("B"));
		ln(map.get("AB"));
		ln(map.get("O"));
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <stdio.h>
using namespace std;
using ll =long long;

int main (void) {
  int H,W;
  cin >> H >>W;
  char A[H][W];
  int count=0;
  for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        cin >> A[i][j];
        if (A[i][j]=='#'){
          count++;
        }
      }
  }
  puts((count==H+W-1)?"Possible":"Impossible");
}

Measured memory_bytes: 256
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut res = true;
    for (i, c) in s.chars().enumerate() {
        if !res {
            break;
        }

        if i % 2 == 0 {
            // 奇数
            res = match c {
                'R' | 'U' | 'D' => true,
                _ => false,
            };
        } else {
            // 偶数
            res = match c {
                'L' | 'U' | 'D' => true,
                _ => false,
            };
        }
    }
    if res {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
while 1:
    try:
        n = input()
        x = 0
        if n < 37:
            for a in range(10):
                for b in range(10):
                    for c in range(10):
                        for d in range(10):
                            if a + b + c + d == n:
                                    x += 1
        print x
    except EOFError:
        break

Measured memory_bytes: 6364