akhauriyash/Code-Regression huggingface dataset:
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    string S;
    cin>>S;
    if(S=="SUN")
    {
        cout<<7<<endl;
    }
    if(S=="MON")
    {
        cout<<6<<endl;
    }
    if(S=="TUE")
    {
        cout<<5<<endl;
    }
    if(S=="WED")
    {
        cout<<4<<endl;
    }
    if(S=="THU")
    {
        cout<<3<<endl;
    }
    if(S=="FRI")
    {
        cout<<2<<endl;
    }
    if(S=="SAT")
    {
        cout<<1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    visited = [0]
    visited_set = set()
    now = 0
    for k in range(K):
        now = A[now] - 1
        if now in visited_set:
            start = visited.index(now)
            shuki = k + 1 - start
            print(visited[start:][(K - start) % shuki] + 1)
            return
        visited.append(now)
        visited_set.add(now)
    print(visited[-1] + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 35224
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int [n];
		long []b = new long [n+1];
		long sum = 0;
		
		for(int i = 0; i < n ;i++) {
			a[i] = sc.nextInt();
			}
		
		for(int i = 0 ; i < n-1 ; i++) {
			if(i % 2 == 0) {
				sum += a[i];
			}
			if(i % 2 == 1) {
				sum -= a[i];
			}
		}
		
		b[0] = a[n-1] + sum;
		
		for(int i = 0 ; i < n ;i++) {
			b[i+1] = 2*a[i] - b[i];
			System.out.print(b[i]+" ");
		}
		

	}

}


Measured memory_bytes: 71228
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
dire = [(0, -1), (-1, 0), (1, 0), (0, 1)]
def dfs(sx, sy):
    dist = [[-1]*W for _ in range(H)]
    dist[sx][sy] = 0
    res = 0
    que = deque([(sx, sy)])
    while que:
        x, y = que.popleft()
        d = dist[x][y]
        for dx, dy in dire:
            nx = x+dx
            ny = y+dy
            if 0<=nx<H and 0<= ny< W and S[nx][ny] == '.' and dist[nx][ny] == -1:
                dist[nx][ny] = d+1
                que.append((nx, ny))
                res = max(res, d+1)
    return res

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            ans = max(ans, dfs(i, j))
print(ans)



Measured memory_bytes: 45420
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

/*
 * ???????????§??????????´? EightQueen.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * AIZU???Time???????????¨????§????h:m:s???????????????
 *@author Iwanaga
 * @version 1.00
 */

class Main{
	/*
	 *main????????????
	 */
	public static void main(String[] args)throws IOException{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		String str = null;
		int sec = 0;
		int[] time=new int[3];

		str = br.readLine();
		sec = Integer.parseInt(str);
		
		for(int i=0; i<3; i++){
			time[i]=sec%60;
			sec=sec/60;
		}
		System.out.println(time[2]+":"+time[1]+":"+time[0]);
	}
}

Measured memory_bytes: 24304
require 'prime'

# 約数リスト
def divisors(n)
  n.prime_division.inject([1]) do |array, (k, v)|
    (0..v).map{ |i| k ** i }.product(array).map{ |a, b| a * b }
  end.sort
end

n, m = gets.split.map(&:to_i)
# n 以上の最小の約数で割る
# 商は n 個以上ある
puts m / divisors(m).bsearch { |i| i >= n }


Measured memory_bytes: 2172
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    string S[22];
    rep(i,0,H) cin >> S[i];
    ll dist[410][410] = {};
    ll sz = H*W;
    rep(i,0,sz){
        rep(j,0,sz){
            if(i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }
    ll dh[4] = {0,0,1,-1};
    ll dw[4] = {1,-1,0,0};
    rep(i,0,H){
        rep(j,0,W){
            if(S[i][j] == '#') continue;
            rep(k,0,4){
                ll hh = i + dh[k];
                ll ww = j + dw[k];
                if(hh >= 0 && hh < H && ww >= 0 && ww < W){
                    if(S[hh][ww] == '.'){
                        ll from = i * W + j;
                        ll to = hh * W + ww;
                        dist[from][to] = 1;
                        dist[to][from] = 1;
                    }

                }
            }

        }
    }
    rep(k,0,sz){
        rep(i,0,sz){
            rep(j,0,sz){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i,0,sz){
        rep(j,0,sz){
            if(dist[i][j] == INF) continue;
            ans = max(ans,dist[i][j]);
        }
    }
    print(ans);
    

}

Measured memory_bytes: 1536
def permutation(n, k, mod):
    s = 1
    for _ in range(k):
        s *= n
        s %= mod
        n -= 1
    return s

def factorial(n, mod):
    s = 1
    for i in range(1, n + 1):
        s *= i
        s %= mod
    return s

h, w, a, b = map(int, input().split())
mod = pow(10, 9) + 7
x = h - a + b - 1
y = w - b + a - 2
p = permutation(x, h - a - 1, mod) * permutation(y, a - 1, mod) % mod
ans = p
for _ in range(w - b - 1):
    x += 1
    p = p * x * (y - (a - 1)) * pow((x - (h - a - 1)) * y, mod - 2, mod) % mod
    y -= 1
    ans += p
    ans %= mod
ans = ans * pow(factorial(a - 1, mod), mod - 2, mod) * pow(factorial(h - a - 1, mod), mod - 2, mod) % mod
print(ans)

Measured memory_bytes: 9212
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

ll ggd(ll a, ll b){
    ll m = a;
    ll n = b;

    while(m != n){
        if(n > m){
            ll t = n;
            n = m;
            m = t;
        }

        ll t = n;
        n = m - n;
        m = t;
    }

    return m;
}

ll lcm(ll a, ll b){
    return a * b / ggd(a, b);
}

int main(){
    ll A, B;
    ll ans;

    cin >> A >> B;

    ans = lcm(A, B);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
double dp[3001][3001];
int n;
double p1[3001],p2[3001];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;++i){
    	cin>>p1[i];p2[i]=1.0-p1[i];
	}
    dp[1][1]=p1[1],dp[1][0]=p2[1];
    for (int i=2;i<=n;++i){
    	for (int j=1;j<i;++j){
    		dp[i][j]= p1[i]*dp[i-1][j-1]+p2[i]*dp[i-1][j];
		}
		dp[i][0]=p2[i]*dp[i-1][0];
		dp[i][i]=p1[i]*dp[i-1][i-1];
	}
	double ans=0;
	for (int i=n/2+1;i<=n;++i) ans+=dp[n][i];
	printf("%0.10lf",ans);
    return 0; 
}

Measured memory_bytes: 68992
// Problem : D - Bouquet
// Contest : AtCoder - AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #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 std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359;
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000000001; //check the limits, dummy
ll mod_pow(ll x,ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n / 2);
	if (n & 1) res = res * x % MOD;
	return res;
}

ll comb(ll n, ll x) {
	ll ret = 1,k=1;
	F0R(i,x)ret = (ret * (n - i))%MOD;
	F0R(i,x)k = (k * (x-i))%MOD;
	k = mod_pow(k, MOD - 2);
	ret = (ret*k + MOD) % MOD;
	return ret;
}
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,A,B;
	cin>>N>>A>>B;
	ll ans=mod_pow(2,N)-1;
	ans=ans-comb(N,A);
	if(ans<0)ans+=MOD;
	ans=ans-comb(N,B);
	if(ans<0)ans+=MOD;
	cout<<ans<<endl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343
 



Measured memory_bytes: 256
t = [i for i in input()]
t.reverse
# print(t)

if t[0] == '?':
    t[0] = 'D'

for i in range(1, len(t)):
    if t[i] == '?':
        t[i] = 'D'
        # if t[i-1] == 'D':
        #     t[i] = 'P'
        # else:
        #     t[i] = 'D'

t.reverse
o = ''.join(t)

print(o)

Measured memory_bytes: 10792
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

using namespace std;

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

	ll n;
	cin >> n;

	vector<ll> c, s, f;
	for (int i = 0; i < n - 1; i++)
	{
		ll c_, s_, f_;
		cin >> c_ >> s_ >> f_;
		c.push_back(c_);
		s.push_back(s_);
		f.push_back(f_);
	}

	for(int i = 0; i < n - 1; i++)
	{
		ll now = 0;
		for(int j = i; j < n - 1; j++)
		{
			if (now <= s[j]) now = s[j] + c[j];
			else
			{
				while (now % f[j] != 0) now++;
				now += c[j];
			}
		}
		cout << now << endl;
	}
	cout << 0 << endl;

	return 0;
}


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

int main()
{
    int l,r,d;
    cin >> l >> r >> d;

    int cnt = 0;
    rep2(i, l, r + 1) {
        if (i % d == 0)
            cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
long long gcd(long long a,long long b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
int a[100005];
int main()
{
	long long n,k;
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	cin>>n>>k;
	long long temp;
		int tot=0;
	cin>>a[1];
	temp=a[1];
	if(a[1]>=k) tot++;
	int flag1=1;
	int flag2=0;
	int MAX=a[1];

	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=k) tot++;
		if(a[i]>MAX) MAX=a[i];
		temp=gcd(temp,a[i]);
	}
	//temp=gcd(temp,k);
	if(MAX<k)
	flag1=0;
	sort(a+1,a+n+1);
    for(int i=n;i>n-tot;i--)
    if((a[i]-k)%temp==0)
    flag2=1;
    
    if(flag1&&flag2)
	cout<<"POSSIBLE"<<endl;
	else
	cout<<"IMPOSSIBLE"<<endl;

	return 0;
}


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

int main() {
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;
    std::cout << (char)toupper(s1[0]) 
              << (char)toupper(s2[0]) 
              << (char)toupper(s3[0]) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int> b;
    for(int i=0;i<n;i++){
        if(i==0)b.push_back(a[i]);
        else{
            if(b.back()==a[i])continue;
            b.push_back(a[i]);
        }
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    int res=1;
    bool up=(b[0]<b[1]);
    for(int i=1;i<b.size();i++){
        if(b[i]>b[i-1]&&up)continue;
        else if(b[i]>b[i-1]&&!up){
            res++;
            up=(b[i]<b[i+1]);
        }
        else if(b[i]<b[i-1]&&!up)continue;
        else{
            res++;
            up=(b[i]<b[i+1]);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <cstdio>
#include <cstdlib>
const int INFN = 1e9+7;
const int MAXN = 1e5+5;
int dp[MAXN];
int H[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
    dp[i] = INFN;
  }
  dp[1] = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= 2; ++j) {
      dp[i+j] = std::min(dp[i] + std::abs(H[i] - H[i+j]), dp[i+j]);
    }
  }
  printf("%d\n", dp[N]);
  return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=998244353
input=lambda :sys.stdin.readline().rstrip()
def divisors(n):
    S,T=[],[]
    for i in range(1,int(n**.5)+1):
        if n%i==0:
            S.append(i)
            T.append(n//i)
    T.reverse()
    return S+T if S[-1]!=T[0] else S+T[1:]

def resolve():
    N=int(input())
    x=input()
    y=''.join('1' if c=='0' else '0' for c in x) # xのbit反転
    D=divisors(N)
    C={d:0 for d in D} # x以下の数字のうち、周期2dの個数
    for d in D:
        if (N//d)%2==0: continue # N/dがevenなら0個
        else:
            z=(x[:d]+y[:d])*((N//d-1)//2)+x[:d]
            C[d]=int(x[:d],2)+1-(x<z)
            C[d]%=MOD
    # ここでC[d]を約数包除で最小周期2dの個数に更新
    for d in D:
        for d1 in D:
            if (d%d1==0 and d!=d1):
                C[d]-=C[d1]
    ans=0
    for d in D:
        ans+=2*d*C[d]%MOD
    print(ans%MOD)
resolve()

Measured memory_bytes: 117916
n = int(input())
a = []
for _ in range(2):
    s = list(map(int, input().split()))
    a.append(s)

for i in range(1, n):
    a[0][i] += a[0][i - 1]

for i in range(n - 2, -1, -1):
    a[1][i] += a[1][i + 1]

ans = max([a[0][i] + a[1][i] for i in range(n)])
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> M;
	vector< int > X(N);
	rep(i, N) cin >> X[i];
	vector< vector< int > > Y(M);
	rep(i, N) Y[X[i] % M].push_back(X[i]);
	rep(i, M) sort(Y[i].begin(), Y[i].end());
	int ans = 0;
	for (int k = 1; k < (M + 1) / 2; k++) {
		int k1 = k, k2 = M - k;
		if (Y[k1].size() > Y[k2].size())
			swap(k1, k2);
		int L1 = Y[k1].size(), L2 = Y[k2].size();
		for (int i = 0; L1 + 1 < L2 && i < Y[k2].size() - 1; i++) {
			if (Y[k2][i] == Y[k2][i + 1]) {
				L2 -= 2;
				ans++;
				i++;
			}
		}
		ans += L1;
	}
	ans += Y[0].size() / 2;
	if (M % 2 == 0)
		ans += Y[M / 2].size() / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
long long  n,i,j,a[200001],b[200001],ans;
int main() {
    cin >> n;
    for (i=1; i<=n; i++)
        cin >> a[i];
        b[1]=a[1];
    for (i=1; i<=n-1; i++)
    {
        j=i+1;
        if (a[j]<b[i])
        {
            b[j]=b[i];
            ans+=b[i]-a[j];
        }
        else
        b[j]=a[j];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 6696
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> d(n);
	REP(i,n) cin>>d[i];
	vector<ll> c(13,0);
	c[0]=1;
	REP(i,n) {
		c[d[i]]++;
	}
	vector<bool> used(24,false);
	used[0]=true;
	vector<ll> vec;
	REP(i,13) {
		if(c[i]>1) {
			used[i]=true;
			if(i!=0) used[24-i]=true;
		} else if(c[i]==1&&i!=0) {
			vec.pb(i);
		}
	}
	REP(i,13) {
		if(i==0&&c[i]>1) {
			cout<<0<<endl;
			return 0;
		}
		if(i!=0&&c[i]>2) {
			cout<<0<<endl;
			return 0;
		}
	}
	ll ret=0;
	if((ll)vec.size()==0) {
		ll minima=INF;
		REP(i,24) {
			FOR(j,i+1,24) {
				if(used[i]&&used[j]) minima=min(minima,min(j-i,24-(j-i)));
			}
		}
		ret=minima;
	} else {
	REP(bit,(ll)(1<<(ll)vec.size())) {
		ll mini=INF;
		vector<bool> buf(24);
		REP(i,24) buf[i]=used[i];
		vector<bool> docchi((ll)vec.size(),false);
		ll hoge=bit;
		REP(i,(ll)vec.size()) {
			if(hoge%2) docchi[i]=true;
			hoge/=2;
		}
		REP(i,(ll)vec.size()) {
			if(docchi[i]) {
				buf[vec[i]]=true;
			} else {
				buf[24-vec[i]]=true;
			}
		}
		REP(i,24) {
			FOR(j,i+1,24) {
				if(buf[i]&&buf[j]) mini=min(mini,min(j-i,24-(j-i)));
			}
		}
		ret=max(ret,mini);
	}
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,r,g,b,d,ans,best;
char col[8][15]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
char code[24];

int main(){
	while(1){
		scanf("%s",&code);
		if(code[0]=='0')break;
		sscanf(code,"#%2x%2x%2x",&r,&g,&b);
		best=99999999;
		for(i=0;i<8;i++){
			d=(r-255*(i>3))*(r-255*(i>3))+(g-255*(i%4>1))*(g-255*(i%4>1))+(b-255*(i%2))*(b-255*(i%2));
			if(d<best){best=d;ans=i;}
		}
		printf("%s\n",col[ans]);
	}
	return 0;
}

Measured memory_bytes: 600
/*input
6 2
1 2
1 3
2 4
3 6
2 5
1 10
1 10
*/
/**
    Author: Kristopher Paul
    Date Created: 18-08-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

vector<int> adj[200005];
int val[200005];

void dfs(int cv,int par,int c){
    val[cv] += c;
    FOR(i,0,adj[cv].size()){
        if(adj[cv][i] != par){
            dfs(adj[cv][i],cv,val[cv]);
        }
    }
}

void solve(){
    int n,q;
    cin >> n >> q;
    FOR(i,1,n+1){
        val[i] = 0;
    }
    FOR(i,0,n-1){
        int a,b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    WL(q){
        int p,x;
        cin >> p >> x;
        val[p] += x;
    }
    dfs(1,0,0);
    FOR(i,1,n+1){
        cout << val[i] << " ";
    }
    cout << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> s(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sum+=s[i];
    }
    sort(s.begin(),s.end());
    if(sum%10!=0){
        cout<<sum<<endl;
    }
    else{
        bool flag=true;
        for(int i=0;i<n;i++){
            if((sum-s[i])%10!=0){
                sum-=s[i];
                flag=false;
                break;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else {
            cout<<sum<<endl;
        }
    }
    return 0;
}


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

// using ll = long long;
// #define int long long,

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
#define INIT 100
/***** MAIN *****/
signed main() {
  string s, t;
  cin >> s >> t;
  unordered_map<char, int> convert_from_prev;
  unordered_map<char, int> convert_from_after;
  for(char c = 'a'; c <= 'z'; ++c) {
    convert_from_prev[c] = INIT;
    convert_from_after[c] = INIT;
  }
  REP(i,s.size()) {
    char prev_c = s[i], after_c = t[i];
    if(convert_from_prev[prev_c] == INIT) {
      convert_from_prev[prev_c] = after_c - prev_c;
    } else {
      char c = prev_c + convert_from_prev[prev_c];
      if(c != after_c) {
        cout << "No" << endl;
        return 0;
      }
    }
    if(convert_from_after[after_c] == INIT) {
      convert_from_after[after_c] = prev_c - after_c;
    } else {
      char c = after_c + convert_from_after[after_c];
      if(c != prev_c) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
  
P calc(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
  
int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P ans=calc(P(ax,ay),P(bx,by),P(cx,cy),P(dx,dy));
    printf("%.8f %.8f\n",ans.real(),ans.imag());
  }
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

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

Measured memory_bytes: 256
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuffer sb = new StringBuffer();
        
        while(true)
        {
            String[] strAry = (br.readLine()).split(" ");
            int h = Integer.parseInt(strAry[0]);
            int w = Integer.parseInt(strAry[1]);
        
            if(0 == h & 0 == w)
            {
                break;
            }

            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    sb.append("#");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX 1000100

bool p[MAX];

void eratos(){
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for(int i = 0 ; i * i < MAX ; i++){
    if(p[i]){
      for(int j = 2*i ; j < MAX ; j += i){
	p[j] = false;
      }
    }
  }
}

int main(){
  eratos();
  int n, x;
  while(cin >> n >> x){
    if(n == 0 && x == 0) break;
    vector<int> v(n);
    for(int i = 0 ; i < n ; i++){
      cin >> v[i];
    }
    
    bool budget[MAX];
    memset(budget, false, sizeof(budget));
    budget[0] = true;
    
    for(int i = 0 ; i < x ; i++){
      if(budget[i]){
	for(int j = 0 ; j < n ; j++){
	  if(i + v[j] <= x) budget[i+v[j]] = true;
	}
      }
    }
    
    bool flag = true;
    
    for(int i = x ; i >= 0 ; i--){
      if(budget[i] && p[i]){
	flag = false;
	cout << i << endl;
	break;
      }
    }
    if(flag) cout << "NA" << endl;
  }
  return 0;
}

  
    

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

int main() {
    int N, x;
    cin >> N >> x;
    vector<long long> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    long long ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            long long t = a[i] + a[i + 1] - x;
            a[i + 1] -= t;
            if (a[i + 1] < 0) a[i + 1] = 0;
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, W):
    for i in range(1, N):
        if W[i-1][-1] != W[i][0]:
            return 'No'

    if len(set(W)) != N:
        return 'No'
    return 'Yes'


def main():
    N = read_int()
    W = [read_str() for _ in range(N)]
    print(slv(N, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int A, B, C, D, E, F;
int pos[3330][3330];
pii ans;

void solve(){
	cin >> A >> B >> C >> D >> E >> F;
	pos[0][0] = 1;
	for(int i=0;i<=F;i++) {
		for(int j=0;j<=i;j++) {
			if(pos[i][j]) {
				if(i > 1) {
					if(ans == pii(0, 0) || (ans.Fi + ans.Se) * j > (i) * ans.Se) ans = pii(i-j, j);
				}
				if(i+100*A <= F) pos[i+100*A][j] = 1;
				if(i+100*B <= F) pos[i+100*B][j] = 1;
				int pp[2] = {C, D};
				rep(u, 2) {
					int nj = j + pp[u];
					int x = i - j;
					if(nj * 100 <= E * x) pos[i + pp[u]][nj] = 1;
				}
			}
		}
	}
	printf("%d %d\n", ans.Fi + ans.Se, ans.Se);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
};

Measured memory_bytes: 37120
#include <stdio.h>
#define INF 2000000
#define N 100
int n;
int p[N];
int m[N][N];
void MatrixChainOrder(){
    int i;
    int l;
    int j;
    int k;
    int q;
    for(i=1; i<=n; i++) m[i][i]=0;
    for(l=2; l<=n; l++){
        for(i=1; i<=n-l+1; i++){
            j=i+l-1;
            m[i][j]=INF;
            for(k=i; k<=j-1; k++){
            q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
            if(m[i][j]>q) m[i][j]=q;
            }
        }
    }
}
int main(){
    int i;
    int tmp;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d %d", &p[i], &tmp);
    }
    p[n]=tmp;
    MatrixChainOrder();
    printf("%d\n", m[1][n]);
    return 0;
}

Measured memory_bytes: 632
#include <iostream>

int main()
{
  int r;
  int d;
  int x_2000;
  std::cin >> r >> d >> x_2000;

  int x = x_2000;
  for (int i = 1; i <= 10; ++i) {
    x = r * x - d;
    std::cout << x << std::endl;
  }
}


Measured memory_bytes: 256
/**
*    created: 23.05.2020 03:17:00
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.rbegin(), l.rend());
    int mx = l[0];
    int sum = 0;
    rep2(i,1,n) sum += l[i];
    if (mx < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef set<int>::iterator si;

const int N = 26;

set<int> s[N];
string str;
int pos;

set<int> exp();

set<int> val(){
	set<int> res;
	if(str[pos] == 'c'){
		++pos;
		set<int> tmp = val();
		for(si ite=s['U'-'A'].begin();ite!=s['U'-'A'].end();++ite){
			if(tmp.find(*ite) == tmp.end()) res.insert(*ite);
		}
	}else if(str[pos] == '('){
		++pos;
		res = exp();
		++pos;
	}else if('A' <= str[pos] && str[pos] <= 'Z'){
		res = s[str[pos] - 'A'];
		++pos;
	}
	return res;
}

set<int> exp(){
	set<int> a = val();
	while(pos < str.size()){
		set<int> b, c;
		if(str[pos] == 'u'){
			++pos;
			b = val();
			for(si ite=a.begin();ite!=a.end();++ite) c.insert(*ite);
			for(si ite=b.begin();ite!=b.end();++ite) c.insert(*ite);
		}else if(str[pos] == 'i'){
			++pos;
			b = val();
			for(si ite=a.begin();ite!=a.end();++ite){
				if(b.find(*ite) != b.end()) c.insert(*ite);
			}
		}else if(str[pos] == 'd'){
			++pos;
			b = val();
			for(si ite=a.begin();ite!=a.end();++ite){
				if(b.find(*ite) == b.end()) c.insert(*ite);
			}
		}else if(str[pos] == 's'){
			++pos;
			b = val();
			set<int> d, e;
			for(si ite=a.begin();ite!=a.end();++ite){
				if(b.find(*ite) == b.end()) c.insert(*ite);
			}		
			for(si ite=b.begin();ite!=b.end();++ite){
				if(a.find(*ite) == a.end()) c.insert(*ite);
			}		
		}else break;
		a = c;
	}
	return a;
}

int main(){
	char c;
	int n;
	while(cin >> c >> n){
		for(int i=0;i<N;++i) s[i].clear();
		while(1){
			if(c == 'R' && n == 0) break;
			for(int i=0;i<n;++i){
				int in;
				cin >> in;
				s[c-'A'].insert(in);
			}
			cin >> c >> n;
		}
		for(int i=0;i<N;i++){
			for(si ite=s[i].begin();ite!=s[i].end();++ite) s['U'-'A'].insert(*ite);
		}
		cin >> str;
		pos = 0;
		set<int> ans = exp();
		if(ans.size() == 0){
			cout << "NULL" << endl;
		}else{
			for(si ite=ans.begin();ite!=ans.end();++ite){
				if(ite != ans.begin()) cout << ' ';
				cout << *ite;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
A,B,C,X,Y = map(int,input().split())

ans=10**10
for i in range(0,2*max(X,Y)+1,2):#ABピザを買う枚数を２枚ずらしで全探索
    tmp = max(0,A*(X-0.5*i)) + max(0,B*(Y-0.5*i)) + C*i
    ans=min(ans,tmp)
print(int(ans))

Measured memory_bytes: 67464
#include<bits/stdc++.h>
using namespace std;int f,Q,T,F;char S[1<<20],*x=S+(1<<18),*y;main(){for(cin>>x>>Q,y=strlen(x)+x;Q--&&cin>>T;)if(T&1)f^=1;else cin>>F,cin>>*(F-1^f?y++:--x);reverse(x,f?y:x);cout<<x;}

Measured memory_bytes: 896
#include <stdio.h>

int main()
{
	int n,q; scanf("%d %d",&n,&q);
	char s[n]; scanf("%s",s);
	int counter[n-1];
	for (int i = 0; i < n-1; ++i)
	{
		if(s[i]=='A'&&s[i+1]=='C'){
			counter[i]=1;
		}else{
			counter[i]=0;
		}
	}

	int l[q],r[q];
	int ans=0; 
	for (int i = 0; i < q; ++i)
	{
		scanf("%d %d",&l[i],&r[i]);
		l[i]--; r[i]--;
		for (int j = l[i]; j < r[i]; ++j)
		{
			ans+=counter[j];
		}
		printf("%d\n",ans);
		ans=0;
	}

	return 0;
}


Measured memory_bytes: 2048
/*
 * Lang  : C++ 17
 * Author: little_angel
 * Date  : 23-07-2020 03:45 23
 */

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define sort(a) sort(a.begin(), a.end())
#define ub(a, x) upper_bound(a.begin(), a.end(), x)
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define dbg(x) cerr<<"["<<#x<<"="<<x<<"]"
#define endl '\n'

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

void sol() {
    long double d, x, y;
    int n, ans = 0;
    cin >> n >> d;
    while (n--) {
        cin >> x >> y;
        if (abs(sqrt(x * x + y * y) - d) <= 1e-9 or sqrt(x * x + y * y) <= d)ans++;
    }
    cout << ans << endl;

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) sol();
}

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

map<string, int> mp;

int main() {
  int a;
  cin >> a;
  for(int i = 0; i < a; ++i) {
    string s;
    cin >> s;
    ++mp[s];
  }
  cin >> a;
  for(int i = 0; i < a; ++i) {
    string s;
    cin >> s;
    --mp[s];
  }
  a = 0;
  for(auto it : mp) a = max(a, it.second);
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int a[]=new int[3];
		
		for(int i=0;i<3;i++)a[i]=cin.nextInt();
		Arrays.sort(a);
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
	}

}



Measured memory_bytes: 26412
from math import gcd

k = int(input())

gcd_table = [[1] * k for _ in range(k)]
ab = {i: 1 for i in range(1, k+1)}

for i in range(1, k+1):
  for j in range(i + 1, k + 1):
    gcd_table[i-1][j-1] =  gcd_table[j-1][i-1] = gcd(i, j)
    ab[gcd_table[i-1][j-1]] += 2
  gcd_table[i-1][i-1] = i


ans = 0
for gcd_ab, v in ab.items():
  for i in range(1, k+1):
    ans += gcd_table[gcd_ab-1][i-1] * v

print(ans)




Measured memory_bytes: 9336
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

void print(int A[], int N) {

  for (auto i = 0; i < N; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
}

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

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

  print(A, N);

  for (auto i = 1; i < N; i++) {
    auto key = A[i];
    auto j = i - 1;
    while (j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;

    print(A, N);
  }

  return 0;
}



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

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> c.at(i);
    for (int j = 0; j < m; ++j) {
      cin >> a.at(i).at(j);
    }
  }

  bool test;
  int min_sum_c = 100000000;
  for (int i = 1; i < 1 << n; ++i) {
    bitset<12> b(i);
    vector<int> v(m);
    int sum_c = 0;

    for (int j = 0; j < n; ++j) {
      if (b.test(j)) {
        for (int k = 0; k < m; ++k) {
          v.at(k) += a.at(j).at(k);
        }
        sum_c += c.at(j);
      }
    }

    test = true;
    for (auto& e : v) {
      if (e < x) {
        test = false;
        break;
      }
    }

    if (test) {
      min_sum_c = min(min_sum_c, sum_c);
    }
  }

  if (min_sum_c == 100000000) {
    cout << -1 << endl;
  } else {
    cout << min_sum_c << endl;
  }
}


Measured memory_bytes: 3584
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	int H, N;
	cin >> H >> N;
	for(int i=0;i<N;++i)
	{
		int A; cin >> A;
		H -= A;
	}

	cout << (H > 0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        lr: [(usize, usize); q]
    }
    let c_sum = {
        let mut v = vec![0; n];
        for i in 0..(s.len() - 1) {
            let (a, c) = (&s[i], &s[i + 1]);
            v[i + 1] = v[i] + if *a == 'A' && *c == 'C' { 1 } else { 0 }
        }
        v
    };
    for &(l, r) in lr.iter() {
        println!("{}", c_sum[r-1] - c_sum[l-1]);
    }
}


Measured memory_bytes: 6908
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() float64 {
	sc.Scan()
	num, _ := strconv.ParseFloat(sc.Text(), 64)
	return num
}

func main() {
	N := nextLine()

	var i int64
	var N64 = int64(N)
	var result = int64(1.0e12)
	var r = int64(math.Sqrt(N)) + 1
	for i = 1; i <= r; i++ {
		if b := i + N64/i - 2; N64%i == 0 {
			if b < result {
				result = b
			} else {
				break
			}
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from fractions import gcd

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    c = gcd(A, B)
    ans = (A * B) // c
    return ans


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7736
/*
	0077:Run Length
*/
#include	<iostream>
#include	<string>

using namespace std;

int main(void) {
	while(1) {
		string str1;
		string str2;
		
		cin >> str1;
		
		if( cin.eof() ) { break; }
		
		for(int i = 0; i < (int)str1.length(); i++) {
			if(str1[i] == '@') {
				int n = str1[i + 1] - '0';
				for(int j = 0; j < n; j++) {
					str2 += str1[i + 2];
				}
				i += 2;
			} else {
				str2 += str1[i];
			}
		}
		cout << str2 << endl;
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i != 0) continue;
        ans = min(ans, n / i + i - 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll x,y,a,b,c,i,j;cin>>x>>y>>a>>b>>c;
vector<ll> p(a),q(b),r(c);
for(i=0;i<a;i++) cin>>p[i];
for(i=0;i<b;i++) cin>>q[i];
for(i=0;i<c;i++) cin>>r[i];
sort(p.begin(),p.end(),greater<int>());sort(q.begin(),q.end(),greater<int>());sort(r.begin(),r.end(),greater<int>());
ll s=0,m=0;
for(i=0;i<x;i++) s+=p[i];
for(i=0;i<y;i++) s+=q[i];
i=x-1;int k=0;j=y-1;
while(i>=0 || j>=0)
{
	if(k>c-1) break;
	if(i>=0 && j>=0)
	{
		if(r[k]>min(p[i],q[j]))
		{
			if(p[i]<q[j])
			{
				s=s+r[k]-p[i];i--;k++;
			}
			else
			{
				s=s+r[k]-q[j];j--;k++;
			}
		}
		else break;
	}
	else if(i>=0)
	{
		if(r[k]>p[i])
		{
			s+=r[k]-p[i];i--;k++;
		}
		else break;
	}
	else
	{
		if(r[k]>q[j])
		{
			s+=r[k]-q[j];j--;k++;
		}
		else break;
	}
}
cout<<s;

return 0;
}

Measured memory_bytes: 2560