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

#define ll long long
#define ii pair<ll, ll>
#define dd pair<double, double>
#define pb(i) push_back(i)
const double PI = 3.14159265359;
const ll inf = 1e18;
const int mod = 1e9+7;
const double eps = 1e-7;
//int dir1[8] = {0, 0, 1, -1, 1, -1, 1, -1};
//int dir2[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir1[4] = {0, 0, 1, -1};
int dir2[4] = {1, -1, 0, 0};

ll cost(int a, int b);

ll solve(int l, int r);

ll pre[405];

ll dp[405][405];

int main()
{
    int i, j;

    int n;
    cin >> n;
    vector<int> v(n);
    for(i = 0; i < n; i++)
        cin >> v[i];

    pre[0] = v[0];
    for(i = 1; i < n; i++)
        pre[i] = pre[i-1] + v[i];
    
    memset(dp, -1, sizeof(dp));
    cout << solve(0, n-1) << '\n';
}

ll cost(int a, int b)
{
    if(a-1 >= 0)
        return pre[b] - pre[a-1];
    return pre[b];
}

ll solve(int l, int r)
{

    int i, j;

    ll &h = dp[l][r];
    if(l == r)
        return h = 0;

    if(h != -1)
        return h;
    
    h = inf;
    for(i = l; i <= r; i++)
        h = min(h, solve(l, i) + solve(i+1, r) + cost(l, r));

    return h;
}

Measured memory_bytes: 4920
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s, t;
int n, m, nm, nxt[500009], cnt, ans;
vector<int> vec[500009];
int ind[500009], ld[500009];

void fun()
{
	nxt[0] = 0;
	for (int i = 1, j  = 0; i < m; i++) {
		while (j > 0 && t[i] != t[j]) {
			j = nxt[j - 1];
		}
        if (t[i] == t[j]) {
            j++;
            nxt[i] = j;
        }
	}
}

void gun(int cur, int v)
{
	cnt++;
	ld[cur] = max(ld[cur], v);
	ans = max(ans, ld[cur]);
	if (ind[cur] == 0) {
		for (int i = 0; i < (int)vec[cur].size(); i++) {
			ind[vec[cur][i]]--;
			gun(vec[cur][i], ld[cur] + 1);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	n = s.length();
	m = t.length();
	nm = n + m;
	fun();
	for (int i = 0, j = 0; i < nm - 1; i++) {
		while (j > 0 && s[i%n] != t[j]) {
			j = nxt[j - 1];
		}
        if (s[i%n] == t[j]) {
		if (j == m - 1) {
			vec[(i + 1 - m) % n].pb((i + 1)%n);
			ind[(i + 1)%n]++;
			j = nxt[j];
		}
        else j++;
        }
	}
	for (int i = 0; i < n; i++) {
		if (ind[i] == 0)
			gun(i, 0);
	}
	if (cnt < n)
		cout << -1 << E;
	else {
		cout << ans << E;
	}
	//system("pause");
	return 0;
} 

Measured memory_bytes: 56220
balls = input()
nums  = input()
removed=input()

balls = balls.split()
nums  = nums.split()

if balls[0] == removed:
  nums[0] = int(nums[0]) - 1
  nums[1] = int(nums[1])
else:
  nums[0] = int(nums[0])
  nums[1] = int(nums[1]) - 1

print(str(nums[0]) + " " + str(nums[1]) )

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int i,j;
    char arr[2][4];
    for(i=0;i<2;i++)
    {
        for(j=0;j<4;j++)
        {
            scanf("%c",&arr[i][j]);

        }

    }
if((arr[0][0]==arr[1][2])&&(arr[0][1]==arr[1][1])&&(arr[0][2]==arr[1][0]))
{
    printf("YES");
}
else
    printf("NO");
return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int a[35] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n;
	cin >> n;
	cout << a[n - 1] << endl;

	return 0;
}


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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        int a,b,c,d,k;
        cin>>a>>b>>c>>d>>k;
        a=a*60+b;
        b=c*60+d;
        b-=a;
        cout<<b-k<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3628
import bisect

N = int(input())
L = [int(li) for li in input().split(' ')]
LMAX = 10 ** 3

L.sort()
# print(L)
ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        # 1,2番目の棒を長い順に決める
        # 3番目の棒として満たす
        lin = L[i] + L[j]

        ind = bisect.bisect_left(L, lin)
        ans += ind-j-1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}
unsigned long long Factorial(int n)
{
    const unsigned int M = 1000000007;
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;

    return f;
}
int a[ N ], b[ N ];
char arr[ N ], cm[ N ] ;
int n, k ;
int ans, ansL, ansR ;
bool can(int x)
{
    for(int i = 1, j = x ; j <= n ; ++j, ++i)
    {
        if(cm[ j ] - cm[i - 1] + k >= x)
        {
            ansL = i, ansR = j ;
            return true ;
        }
    }
    return false ;
}
int BS(int n)
{
    int low = 0, high = n ;
    while(low < high)
    {
        int mid = (low + high + 1) >> 1 ;
        if(can(mid))
            low = mid ;
        else
            high = mid - 1 ;
    }
    return low ;
}
int main()
{
    FastInputOutput() ;
    set < char > st ;
    char ch ;
    int n ;
    cin >> n ;
    for(int i = 0 ; i < n ; ++i)
     cin >> arr[ i ] ;
     for(int i = 0 ; i < n ; ++i)
     if(arr[ i ] == 'Y'){
        cout << "Four" << endl ;
        return 0;
     }
     cout << "Three" << endl ;

}


Measured memory_bytes: 2304
N, M = map(int, input().split())
items = []
for i in range(M):
    items.append(tuple(map(int, input().split())))

ran = [0 for i in range(N+2)]
for l, r in items:
    ran[l-1] += 1
    ran[r] -= 1


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

target = set()
for i, r in enumerate(ran):
    if r == M:
        target.add(i+1)
print(len(target))


Measured memory_bytes: 26900
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;

int N;
ll k;
ll a[200010];

vector<ll> vec;


int ope(int a,int b)
{
	return a + b;
}
struct Segment
{
	vector<int> node;
	int n;
	
	int init = 0;

	Segment(const vector<int>& vec)
	{
		int sz = vec.size();
		this->n = 1;
		while(this->n < sz) this->n <<= 1;

		node.resize(2 * n - 1,init);
		
		for(int i = 0;i < sz;i++)
		{
			node[n - i + 1] = vec[i];
		}
		for(int i = n - 2;i >= 0;i--)
		{
			node[i] = ope(node[i * 2 + 1] , node[i * 2 + 2]);

		}
	}

	void update(int i)
	{
		i += this->n - 1;

		node[i]++;

		while(i > 0)
		{
			i = (i - 1) / 2;
			node[i] = ope(node[i * 2 + 1],node[i * 2 + 2]);
		}
	}

	int get_inter(int a,int b,int k = 0,int l = 0,int r = -1)
	{
		if(r < 0) r = this->n;

		if(a <= l && r <= b) return node[k];

		if(r <= a || b <= l) return init;

		int lv = get_inter(a,b,2 *k + 1 ,l ,(l + r) / 2);
		int rv = get_inter(a,b,2 * k + 2,(l + r) / 2,r);

		return ope(lv,rv);
	}
};

ll b[200010];

int main()
{
	cin >> N >> k;
	for(int i = 1;i <= N;i++)
	{
		cin >> a[i];
		a[i] -= k;
		b[i] = a[i] + b[i - 1];
		vec.push_back(b[i]);
		//cout << i << "===" << b[i] << endl;
	}	
	sort(vec.begin(),vec.end());
	ll now = 0;
	ll result = 0;

	Segment seg(vector<int>(N + 1,0));
	for(int i = 1;i <= N;i++)
	{
		int ite = lower_bound(vec.begin(),vec.end(),now) - vec.begin();
		//cout << now << " " << n - ite - seg.get_inter(ite,n + 1) << endl;
		result += N - ite - seg.get_inter(ite,N + 1);
		now = b[i];
		ite = lower_bound(vec.begin(),vec.end(),now) - vec.begin();
		seg.update(ite);
		//cout << now << "=" << ite << ":" << vec[ite] << endl;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 7792
// AOJ 2170: Marked Ancestor
// 2018.1.2 bal4u@uu

#include <stdio.h>
#include <string.h>

#define INF 0x01010101
typedef struct { int i, v; } T;
T tbl[100003]; int sz;
int p[100003];
int mk[100003];

#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int find(int v, int i)
{
	if (mk[v] < i) return v;
	return p[v] = find(p[v], i);
}

int main()
{
	int N, Q, i, cmd, v;
	long long ans;

	while (N = in()) {
		Q = in();
		p[1] = 1; for (i = 2; i <= N; i++) p[i] = in();

		memset(mk, INF, sizeof(mk));
		mk[1] = 0;

		sz = 0;
		for (i = 1; i <= Q; i++) {
			if ((cmd = getchar_unlocked()) < ' ') cmd = getchar_unlocked();
			v = in();
			if (cmd == 'M') { if (mk[v] == INF) mk[v] = i; }
			else tbl[sz].i = i, tbl[sz++].v = v;
		}

		ans = 0;
		while (sz--) ans += find(tbl[sz].v, tbl[sz].i);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3080
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<ll> sum(N,0);
  for(int i=0;i<N;++i){
    cin >> A.at(i);
    if(i==0) sum.at(i)=A.at(i);
    else sum.at(i)=sum.at(i-1)+A.at(i);
  }

  ll ave=sum.at(N-1)/2;
  int left=-1,right=N,mid;
  while(right-left>1){
    mid=(left+right)/2;
    if(sum.at(mid)<ave){
      left=mid;
    }
    else right=mid;
  }

  int ans=0;
  ans=min(abs(sum.at(N-1)-2*sum.at(left)),abs(sum.at(N-1)-2*sum.at(right)));
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5560
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)



mm = 998244353
def solve ():
	t = 1
	for tt in range (t):
		n=nu()
		a=li()
		if (a [ 0 ] != 0):
			print (0)
			continue
		a.sort()
		if(a[0]!=0):
			print(0)
		else:
			ox=[]
			cc=1
			las=a[0]
			for i in range(1,n):
				if(las==a[i]):
					cc+=1
				else:
					ox.append((las,cc))
					cc=1
					las=a[i]
			ox.append ((las, cc))
			if(ox[0][1]!=1):
				print(0)
				continue
			last=ox[0][1]
			next=ox[0][0]+1
			ans=1
			for i in range(1,len(ox)):
				if(next!=ox[i][0]):
					ans=0
				ans=(ans*pow(last,ox[i][1],mm))%mm
				last=ox[i][1]
				next+=1
			print(ans)










if __name__ == "__main__":
	solve ()

Measured memory_bytes: 79336
using System;

namespace ABC090_A_Diagonal_String
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			string input2 = Console.ReadLine();
			string input3 = Console.ReadLine();
			
			Console.WriteLine(input1.Substring(0, 1) + input2.Substring(1, 1) + input3.Substring(2, 1));
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll k,a,b;
  cin >> k >> a >> b;

  if (b - a <= 1) {
    cout << k + 1 << endl;
    return 0;
  }

  if (k <= a) {
    cout << k + 1 << endl;
    return 0;
  }

  if (b - a == 1) {
    cout << k + 1 << endl;
    return 0;
  }

  // k > a & a > b
  ll remain = k - a + 1;
  ll kaisuu = remain / 2;
  ll sub = b - a;
  ll ans = 0;
  if (remain % 2 == 0) {
    ans = sub * kaisuu + a;
  } else {
    ans = sub * kaisuu + a + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

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

void rec(vi &pre, vi &in, vi &post, int l, int r, int &pos) {
  if (l >= r) return;
  auto root = pre[pos++];
  int m = distance(in.begin(), find(ALL(in), root));
  rec(pre, in, post, l, m, pos);
  rec(pre, in, post, m + 1, r, pos);
  post.push_back(root);
}

int main() {
  int n;
  cin >> n;
  vi pre(n), in(n), post(0);
  REP(i, n) cin >> pre[i];
  REP(i, n) cin >> in[i];
  int pos = 0;
  rec(pre, in, post, 0, pre.size(), pos);
  print(post);
}


Measured memory_bytes: 3144
N = gets.to_i
str =[]
N.times do
  str << gets.split('').sort.join()
end

hash = {}
ans = 0

str.each do |s|
  if hash.has_key?(s)
    ans += hash[s]
    hash[s] += 1
  else
    hash[s] = 1
  end
end

puts ans

Measured memory_bytes: 32636
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double get = 0;
		int num = sc.nextInt();
		for(int i = 0; i < num; i ++) {
			get += sc.nextDouble() * (sc.next().equals("JPY") ? 1 : 380000.0);
		}
		System.out.println(get);
	}
}

Measured memory_bytes: 22612
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def law_of_cosines(a: float, b: float, gamma: float, is_degree: bool = False) -> float:
    if is_degree:
        gamma = math.radians(gamma)
    return a**2 + b**2 - 2*a*b*math.cos(gamma)


def solve(A: int, B: int, H: int, M: int):
    deg = (H + M/60) * 30 - M * 6
    return math.sqrt(law_of_cosines(A, B, deg, is_degree=True))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    print(f'{solve(A, B, H, M):.10f}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 70524
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

plus_list = []
minus_list = []
count = 0

for i in range(n):
    if a[i] < b[i]:
        count += 1
        minus_list.append(b[i]-a[i])
    elif a[i] > b[i]:
        plus_list.append(a[i]-b[i])

c = sum(minus_list)
plus_list.sort(reverse = True)

for num in plus_list:
    if c <= 0:
        break
    else:
        c -= num
        count += 1

if c > 0:
    print(-1)
else:
    print(count)
    
    

Measured memory_bytes: 18524
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  long long tot = 0;
  long long cur = min(a, k);
  tot += cur;
  k-=cur;
  cur = min(b, k);
  k -= cur;
  cur = min(c, k);
  tot -= cur;
  cout << tot << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  // cin >> tc;
  for(int i = 1; i <= tc; ++i) {
    // cout << "Case #" << i <<": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {
    static int[] colors;
    static ArrayList<Path>[] graph;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
		    graph[i] = new ArrayList<Path>();
		}
		for (int i = 0; i < n - 1; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int length = sc.nextInt();
		    graph[a].add(new Path(b, length));
		    graph[b].add(new Path(a, length));
		}
		colors = new int[n + 1];
		Arrays.fill(colors, -1);
		search(1, 0);
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    sb.append(colors[i]).append("\n");
		}
		System.out.print(sb);
	}
	
	static void search(int idx, int color) {
	    if (colors[idx] != -1) {
	        return;
	    }
	    colors[idx] = color;
	    for (Path x : graph[idx]) {
	        int next;
	        if (x.length % 2 == 0) {
	            next = color;
	        } else {
	            next = (1 + color) % 2;
	        }
	        search(x.to, next);
	    }
	}
	
	static class Path {
	    int to;
	    int length;
	    
	    public Path (int to, int length) {
	        this.to = to;
	        this.length = length;
	    }
	}
}


Measured memory_bytes: 106504
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    int count, tmp;

    cin >> s;
    count = 0;
    tmp = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
            count++;
        else {
            tmp = max(tmp, count);
            count = 0;
        }
    }
    tmp = max(tmp, count);
    
    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n == 111:
  print(999)
if n == 119:
  print(991)
if n == 191:
  print(919)
if n == 199:
  print(911)
if n == 911:
  print(199)
if n == 919:
  print(191)
if n == 991:
  print(119)
if n == 999:
  print(111)


Measured memory_bytes: 3060
// JOI - Prelim  0511
// 未提出者は誰だ
#include <bits/stdc++.h>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto Ns(cin2vec<int64_t>(28));

    unordered_set<int64_t> set_n(Ns.cbegin(), Ns.cend());
    for (size_t i = 1; i <= 30; ++i) {
        if (set_n.count(i)) continue;
        cout << i << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define reg register

const int maxn = 2e5 + 5; //!

int N;
int A[maxn];
int B[maxn];

bool chk(int x){
        for(reg int i = 1; i <= 2*N-1; i ++) B[i] = (A[i]>x);
        for(reg int d = 1; d < N; d ++)
                if((B[N+d-1]&&B[N+d]) || (B[N-d+1]&&B[N-d])) return 1;
                else if(((!B[N+d-1])&&(!B[N+d])) || ((!B[N-d+1])&&(!B[N-d]))) return 0;
        return B[1];
}

int main(){
        scanf("%d", &N);
        for(reg int i = 1; i <= 2*N-1; i ++) scanf("%d", &A[i]);
        int l = 1, r = 2*N-1;
        while(l < r){
//                printf("%d %d\n", l, r);
                int mid = l+r >> 1;
                if(chk(mid)) l = mid + 1;
                else r = mid;
        }
        printf("%d\n", l);
        return 0;
}

Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    _ <- getLine
    s <- words <$> getLine
    -- 出力
    putStrLn $ if "Y" `elem` s then "Four" else "Three"


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  string s;
  cin >> s;
  int a[26] = {};

  int ok = 1;
  for (int i = 0; i < s.size(); i++){
    if (a[s[i] - 'a'] > 0){
      ok = 0;
    }
    
    a[s[i] - 'a']++;
  }

  cout << (ok ? "yes" : "no") << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

int main() {
	string first;
	int q;
	cin >> first >> q;

	deque<char> s;
	for (int i = 0; i < first.length(); ++i) {
		s.push_back(first[i]);
	}

	bool isHead = true;
	for (int i = 0; i < q; ++i) {
		int t, f;
		char c;
		cin >> t;
		if (t == 1) {
			isHead = !isHead;
		}
		else {
			cin >> f >> c;
			if (isHead) {
				if (f == 1) {
					s.push_front(c);
				}
				else {
					s.push_back(c);
				}
			}
			else {
				if (f == 1) {
					s.push_back(c);
				}
				else {
					s.push_front(c);
				}
			}
		}
	}

	if (isHead) {
		for (auto t : s) {
			cout << t;
		}
	}
	else {
		copy(s.rbegin(), s.rend(), ostream_iterator<char>(cout, ""));
	}
	cout << endl;

	return 0;
}

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

struct UnionFind{
    vector<int> data;

    UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int N,M;cin>>N>>M;
    UnionFind uf(N);
    vector<int> p(N);
    for(int i = 0; i < N ; i++){
        int pp;cin >> pp;pp--;
        p[i] = pp;
    }
    for(int i = 0 ; i < M ; i++){
        int x,y;cin >> x >> y;
        x--;y--;
        uf.unite(x,y);
    }
    int res = 0;
    for(int i = 0 ; i < N ; i++){
        if(uf.find(p[i]) == uf.find(i))res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
mod=10**9+7
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
for i in range(m+1):
  dp[0][i]=1
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
    else:
      dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
    dp[i+1][j+1]%=mod
print(dp[-1][-1])

Measured memory_bytes: 72668
n = int(input())
c = input().split()
d = c[:]

# bubblesort
for i in range(n):
    for j in range(n - 1, i, -1):
        if d[j][1] < d[j - 1][1]:
            d[j], d[j - 1] = d[j - 1], d[j]
print(*d)
print("Stable")

# selectionsort
for i in range(n):
    minj = i
    for j in range(i, n):
        if c[j][1] < c[minj][1]:
            minj = j
    c[i], c[minj] = c[minj], c[i]

print(*c)
print("Stable" if c == d else "Not stable")

Measured memory_bytes: 6724
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

constexpr uint64_t MOD = 1'000'000'007;
int32_t N;
int32_t X[100000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	//入力
	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> X[i];
	}

	uint64_t result = 1;//答えの通り数
	int32_t num_ON = 0;//既に数直線上においてあるロボットの個数
	//全てを奇数座標に
	for (int32_t i = 0; i < N; ++i)
	{
		++num_ON;
		auto standable = (X[i] + 1) / 2;//数直線上の奇数座標の数
		if (standable < num_ON) {
			//埋まっている=>どれかをゴールさせる
			result *= num_ON;
			result %= MOD;
			--num_ON;
		}
	}
	//残りを好きな順番でゴールさせる
	do{
		result *= num_ON;
		result %= MOD;
	}while (--num_ON);
	out << result << std::endl;

	return 0;
}
#endif

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

int main(void)
{
	int n, k, d, person;
	cin >> n >> k;
	vector<int> sss(n);
	
	
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> person;
			sss[person-1] = 1;
		}

	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (sss[i] == 0) {
			count++;
		}
	}
	
	cout << count;
		cout << endl;

	
	


}


Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

map<ll, ll> factor(ll n, const std::vector<ll> &min_factor)
{
  map<ll, ll> mp;
  while (n > 1)
  {
    mp[min_factor[n]]++;
    n /= min_factor[n];
  }
  return mp;
}

std::vector<ll> sieve(ll n)
{
  std::vector<ll> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (ll i = 2; i * i < n; ++i)
  {
    if (res[i] < i)
      continue;
    for (ll j = i * i; j < n; j += i)
      if (res[j] == j)
        res[j] = i;
  }
  return res;
}

int main()
{
  long long N;
  scanf("%lld", &N);

  // vector<ll> res = sieve(N + 1);
  ll ans = 0;
  for (ll i = 1; i <= N; ++i)
  {
    //   map<ll, ll> t = factor(i, res);
    //   ll s = 1;
    //   for (auto &e : t)
    //     s *= e.second + 1;
    //   ans += i * s;
    ll t = N / i;
    ans += i * t * (t + 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i< N; i++) {
    cin >> vec.at(i);
  }
  int x=vec.at(0);
  for (int i=1; i< N; i++) {
      if(vec.at(i)>vec.at(i-1)) {
        x += vec.at(i)-vec.at(i-1);
    }
  }
  
  cout << x << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
int main(){
  int x[100],i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      i--;
      x[i-1]=x[i-1]+x[i];
    } else if ( s[0] == '-' ){
      i--;
      x[i-1]=x[i-1]-x[i];
    } else if ( s[0] == '*' ){
      i--;
      x[i-1]=x[i-1]*x[i];
    } else {
      x[i] = atoi(s);
      i++;
    }
  }
  printf("%d\n",x[0]);
  return 0;
}

Measured memory_bytes: 548
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(dead_code)]
fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

#[allow(unused_macros)]
macro_rules! p {
    ($x:expr) 
    => (println!("{}", $x));
    ($x:expr, $y:expr)
    => (println!("{} {}", $x, $y));
    ($x:expr, $y:expr, $z:expr) 
    => (println!("{} {} {}", $x, $y, $z));
}

#[allow(unused_macros)]
macro_rules! pl {
    ($x:expr) 
    => (println!("{}", $x));
    ($x:expr, $y:expr)
    => (println!("{}\n{}", $x, $y));
    ($x:expr, $y:expr, $z:expr) 
    => (println!("{}\n{}\n{}", $x, $y, $z));
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let S = &mut s;

    for _ in 0..1 {
        let n: usize = read(S);

        let mut c = vec![]; // かかる時間
        let mut s = vec![]; // 開始時間
        let mut f = vec![]; // 周期
        for i in 0..n-1 {
            let x: i32 = read(S);
            c.push(x);
            let x: i32 = read(S);
            s.push(x);
            let x: i32 = read(S);
            f.push(x);
        }

        for i in 0..n {
            let mut cur_t = 0;
            let mut j = i;
            while j != n - 1 {
                if cur_t < s[j] {
                    cur_t = s[j];
                }
                if (cur_t - s[j]) % f[j] != 0 {
                    cur_t += f[j] - (cur_t - s[j]) % f[j];
                }
                cur_t += c[j];
                j += 1;
            }
            p!(cur_t);
        }
    }
}

Measured memory_bytes: 4352
while True:
    a,op,b = raw_input().split()
    a,b = map(int,(a,b))
    if op == "?":
        break
    if op == "+":
        print a + b
    elif op=="-":
        print a-b
    elif op=="*":
        print a*b
    elif op=="/":
        print a/b

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

using namespace std;

#define int long long

const int N = 1e5 + 100;

int cnt[N];
bool use[N];
int n, m, ans;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    fill(cnt, cnt + N, 1);
    use[1] = true;
    for (int i = 0; i < m; i++) {
	int x, y;
	cin >> x >> y;
	if (use[x]) use[y] = true;
	if (!--cnt[x]) use[x] = false;
	cnt[y]++;
    }
    for (int i = 1; i <= n; i++)
	ans += use[i];
    return cout << ans, 0;
}

Measured memory_bytes: 1152
/*---> 22 December 2019 <--- > 17:33:05 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		cout<<s[i]<<t[i];
	}
	cout<<"\n";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> height(n);
    rep(i,n)cin>>height.at(i);
    ll cost[n];
    rep(i,n)cost[i]=INF;
    cost[0]=0;
    cost[1]=abs(height.at(1)-height.at(0));
    for(int now=2;now<n;now++){
    chmin(cost[now],abs(height[now]-height[now-1])+cost[now-1]);
    chmin(cost[now],abs(height[now]-height[now-2])+cost[now-2]);
    }
    cout<<cost[n-1]<<endl;
    return 0;
}




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

int main() {
    vector<int> freq(9, 0);
    int N;  cin>>N;
    for (int i = 0; i < N; ++i) {
        int a;  cin>>a;
        if (a < 3200)
            freq[a/400]++;
        else
            freq[8]++;
    }
    
    int cnt = 0;
    for (int i = 0; i <= 7; ++i)
        if (freq[i])
            cnt++;
    
    if (cnt)
        cout<<cnt<<" "<<cnt+freq[8];
    else
        cout<<1<<" "<<freq[8];
    
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: u32,
        m: usize,
        sc: [(usize, char); m],
    }

    let ans = (0..10i32.pow(n))
        .filter(|x| {
            dbg!(x);
            let x = x.to_string().as_bytes().to_vec();
            x.len() == n as usize
                && sc
                    .iter()
                    .all(|(s, c)| matches!(x.get(*s-1), Some(x) if * x as char == * c))
        })
        .next()
        .unwrap_or(-1);

    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

ll power( ll a, int b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

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

	vector<int> a(n);
	for( auto &k : a ) cin >> k;

	vector<int> l(1000010, 0);
	vector<int> pset;
	
	for( auto k : a ){
		if( k == 1 ) continue;
		int t = k;
		for( int p = 2; p*p <= k; ++p ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			if( cnt > 0 ){
				pset.push_back(p);
				l[p] = max(l[p], cnt);
			}
		}
		if( t != 1 ){
			pset.push_back(t);
			l[t] = max(l[t], 1);
		}
	}
	
	sort( pset.begin(), pset.end() );
    pset.erase( unique( pset.begin(), pset.end() ), pset.end() );

	ll ans = 0;
	
	for( auto &t : a ){
		ll pro = 1;
		for( auto p : pset ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			pro *= pow((ll)p, l[p]-cnt);
			pro %= mod;
		}
		ans += pro;
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4608
/**
 *      AGC 15 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-07 14:09:20
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 N, A, B; cin >> N >> A >> B;

    if (A > B){
        cout << 0 << '\n'; 
    }
    else if (A == B){
        cout << 1 << '\n';
    }
    else if (N == 1){
        cout << 0 << '\n';
    }
    else {
        cout << B * (N - 2) - A * (N - 2) + 1 << '\n';
    }

    return 0;
}

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

int main(){
  while(true){
    string s1;
    cin>>s1;

    if(s1==".")break;

    string s2;
    cin>>s2;

    if(s1==s2){
      cout<<"IDENTICAL"<<endl;
      continue;
    }

    string t1=s1;
    string t2=s2;

    while(true){
      size_t d1b=t1.find('\"');
      if(d1b==string::npos)break;
      t1.replace(d1b,1,"@");
      size_t d1e=t1.find('\"');
      t1.replace(d1e,1,"@");

      size_t d2b=t2.find('\"');
      if(d2b==string::npos)break;
      t2.replace(d2b,1,"@");
      size_t d2e=t2.find('\"');
      t2.replace(d2e,1,"@");

      string u1=s1;
      u1.replace(d1b+1,d1e-d1b-1,"");
      string u2=s2;
      u2.replace(d2b+1,d2e-d2b-1,"");

      if(u1==u2){
        t1=u1;
        t2=u2;
        break;
      }
    }
    if(t1==t2){
      cout<<"CLOSE"<<endl;
    }else{
      cout<<"DIFFERENT"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3204
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e10
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
    const ll MOD = INF + 7;
     
     
     
    int main(){
       ll a;
       cin >> a;
       ll res = a + a * a + a * a * a;
       cout << res << endl;
    }

Measured memory_bytes: 3224
use std::io;

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

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	println!("{}", (a+b)/2 + (a+b)%2);
}

Measured memory_bytes: 4352
s = list(input())
t = list(input())
S,T = set(s),set(t)
sl = []
tl = []
for i in S:
    sl.append([j for j, x in enumerate(s) if x == i])

for i in T:
    tl.append([j for j, x in enumerate(t) if x == i])

if sorted(sl)==sorted(tl):print('Yes')
else:print('No')

Measured memory_bytes: 72140
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

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

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  string str; cin >> str;
  int ans = 1;
  forall(i,0,n-1){
    if( str[i] != str[i+1] ) ++ans;
  }
  cout << ans << endl;

  return 0;
}


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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

void solve(long long N){
    Sieve sieve = Sieve(N+1);
    ll ans =1;
    for(int i=2;i<=N;i++){
        vector<P> vec = sieve.factor(i);
        ll temp = 1;
        for(P p:vec){
            temp *= (p.second+1);
        }
        ans += i*temp;

    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 46532
n=int(input())
x=list(map(int,input().split()))

avg1=sum(x)//n
avg2=avg1+1

cnt1=0
cnt2=0
for i in range(n):
    cnt1+=(x[i]-avg1)**2
    cnt2+=(x[i]-avg2)**2
print(min(cnt1,cnt2))

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi v(n), c(n);
  rep(i, n) cin >> v[i];
  int val = 0, cost = 0;
  rep(i, n){
    cin >> c[i];
    if((double)v[i] / c[i] >= 1){
      val += v[i];
      cost += c[i];
    }
  }
  cout << val - cost << endl;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++) {
        if((i % 2) == 0) {
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256