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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

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

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int x = 1; x * x <= n; x++) {
        for(int y = 1; y * y <= n; y++) {
            for(int z = 1; z * z <= n; z++) {
                // debug(x, y, z, x * x + y * y + z * z + x * y + y * z + z * x);
                if(x * x + y * y + z * z + x * y + y * z + z * x <= n) {
                    ++ans.at(x * x + y * y + z * z + x * y + y * z + z * x - 1);
                } else {
                    break;
                }
            }
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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;
}


Measured memory_bytes: 3664
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int main(void)
{
	//変数の宣言
	int n;
	static int a[200010];
	static int b[200010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
//		scanf_s("%d %d",&a[i],&b[i]);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=0;i<n;i++){
		if(a[i]>b[i]){
			min=min(min,b[i]);
		}
		ans=ans+b[i];
	}

	if(min==INFINT){
		printf("0");
		return 0;
	}


	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans-min);

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int n,a,b,t;
  cin >> n >> a >> b;
  if (a+b>n) t=a+b-n;
  else t=0;
  cout << min(a,b) << ' ' << t << endl;
  return 0;
}

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

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

  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  // +1 : 単調増加
  // -1 : 単調減少
  //  0 : 値に変化がない
  int state = 0;
  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
    int current = A.at(i);
    int next = A.at(i + 1);
    int diff = current - next;
    switch (state) {
      case 0:
        if (diff > 0) {
          state = 1;
        } else if (diff < 0) {
          state = -1;
        } else {
          // diff == 0 の場合は何もしない
        }
        break;
      case 1:
        if (diff < 0) {
          ans++;
          state = 0;
        }
        break;
      case -1:
        if (diff > 0) {
          ans++;
          state = 0;
        }
        break;
      default:
        break;
    }
  }
  printf("%d", ans);
}


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;
	cin >> n;

	ll arr[n];
	ll backsum[n + 1];
	ll res = 0;

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

	backsum[n] = 0;
	for (int i = n - 1; i >= 0; i--) {
		backsum[i] = (arr[i] + backsum[i + 1]) % mod;
	}

	for (int i = 0; i < n - 1; i++) {
		res += (arr[i] % mod * backsum[i + 1] % mod) % mod;
	}
	cout << res % mod;
}

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

int main() {
	// your code goes here
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	long long int sum=0;
	if(k<=a){
		sum=sum+k;
	}
	else if(k<=a+b){
		sum=sum+a;
	}
	else if(k<=a+b+c){
		sum=a-(k-b-a);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

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

  string S;
  cin >> S;
  int N = S.size();
  for(int i=0;i<N-1;i++){
    if(S[i] == S[i+1]){
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  for(int i=0;i<N-2;i++){
    if(S[i] == S[i+2]){
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,mx=0,g=0;
	cin>>n>>k;
	int a[n+3];
	for(int i=0;i<n;i++)
	{
	  cin>>a[i];
	  g=__gcd(g,a[i]);
	  mx=max(mx,a[i]);
	}
	if(k%g==0 && k<=mx)
	cout<<"POSSIBLE"<<endl;
	else
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    int M = (N+999)/1000;
    cout<<M*1000-N<<endl;
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast", "unroll-loops", "no-stack-protector")

#include <bits/stdc++.h>

using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using ll = long long;
using ld = double;
using pii = pair<int, int>;
using uint = unsigned int;
using ull = unsigned long long;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;

void solve();

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);  
#endif 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << setprecision(16) << fixed;
    cerr << setprecision(16) << fixed;

    int tests = 1;
    cin >> tests;

    for (int test = 1; test <= tests; ++test) {
        // cout << "Case #" << test << ": ";
        solve();
    }

#ifdef LOCAL
    cerr << "Time: " << double(clock()) / CLOCKS_PER_SEC << endl;
#endif
}

// -----------------------------------------------------------------

map<ll, ll> mapa;
ll a, b, c, d;

ll solve(ll n) {  
    if (n == 0) {
        return 0;
    }
    if (mapa.count(n)) {
        return mapa[n];
    }
    ll ans = 1e18;
    for (int x = -1; x <= 1; ++x) {
        if ((n + x) % 2 == 0 && n + x >= 0 && (n + x) / 2 < n) {
            ans = min(ans, solve((n + x) / 2) + abs(x) * d + a);
        }
    }
    for (int x = -2; x <= 2; ++x) {
        if ((n + x) % 3 == 0 && n + x >= 0 && (n + x) / 3 < n) {
            ans = min(ans, solve((n + x) / 3) + abs(x) * d + b);
        }
    }
    for (int x = -4; x <= 4; ++x) {
        if ((n + x) % 5 == 0 && n + x >= 0 && (n + x) / 5 < n) {
            ans = min(ans, solve((n + x) / 5) + abs(x) * d + c);
        }
    }
    if (ans / d >= n) {
        ans = d * n;
    }
    return mapa[n] = ans;
    
}

void solve() {
    mapa.clear();

    ll n;
    cin >> n;
    cin >> a >> b >> c >> d;

    ll res = solve(n);
    cout << res << endl;
}   


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


pair<ll, ll> get_first_last(ll x){
    ll first = x % 10, last = x % 10;
    while(x != 0){
        last = x % 10;
        x /= 10;
    }
    return {first, last};
}

void solve(long long N){
    map<pair<ll, ll>, ll> count;
    for(ll a = 1; a <= N; ++a){
        if(a % 10 == 0){ continue; }
        count[get_first_last(a)]++;
    }
    ll ans = 0;
    for(ll a = 1; a <= N; ++a){
        if(a % 10 == 0){ continue; }
        const auto p = get_first_last(a);
        ans += count[make_pair(p.second, p.first)];
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> robot;
  for (int i = 0; i < n; i++) {
    int x, l;
    cin >> x >> l;
    robot.emplace_back(x, l);
  }
  sort(robot.begin(), robot.end());
  int ans = 0, xmax = -2000000000;
  for (auto r : robot) {
    if (r.first - r.second >= xmax) {
      ans++;
      xmax = r.first + r.second;
    } else {
      xmax = min(xmax, r.first + r.second);
    }
  }
  cout << ans << endl;
}


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

int main(){
	long a,b,k;
	cin>>a>>b>>k;
	a -= k;
	if(a < 0){b+=a;a = 0;}
	if(b < 0)b=0;
	cout << a << " " << b << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int len(int x){
	int r = 0;
	while(x) r++, x /= 10;
	return r;
}
int main(){
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	int sum = 0, best = 0;
	auto much = [&](int d){
		multiset<int> divs;
		for(int i = 0; i < n; i++) if(a[i] % d) divs.insert(a[i] % d);
		long long ans = 0;
		while(divs.size() >= 2){
			int u = *divs.begin(); divs.erase(divs.begin());
			int v = *(--divs.end()); divs.erase(--divs.end());
			int canv = min(d - v, u);
			v += canv;
			u -= canv;
			ans += canv;
			if(v < d) divs.insert(v);
			if(u > 0) divs.insert(u);
		}
		return ans;
	};
	for(int i = 0; i < n; i++) sum += a[i];
	int ans = 0;
	for(int i = 1; i*i <= sum; i++){
		if(sum % i == 0){
			if(much(i) <= k) ans = max(ans, i);
			if(much(sum/i) <= k) ans = max(ans, sum / i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * Main method
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int size = in.nextInt();
		int[] heap = new int[size];
		for (int i = 0; i < size; i++) {
			heap[i] = in.nextInt();
		}
		for (int i = 0; i < size; i++) {
			System.out.println("node " + (i + 1) + ": key = " + heap[i] + ", " + getParent(heap, i) + getLeft(heap, i)
					+ getRight(heap, i));
		}
	}

	/**
	 * returns the parent key of the element in the given heap at the given index
	 */
	public static String getParent(int[] heap, int i) {
		int par = (i - 1) / 2;
		if (par >= 0 && i != 0) {
			return "parent key = " + heap[par] + ", ";
		} else {
			return "";
		}
	}

	/**
	 * returns the left child key of the element in the given heap at the given
	 * index
	 */
	public static String getLeft(int[] heap, int i) {
		int left = i * 2 + 1;
		if (left < heap.length) {
			return "left key = " + heap[left] + ", ";
		} else {
			return "";
		}
	}

	/**
	 * returns the right child key of the element in the given heap at the given
	 * index
	 */
	public static String getRight(int[] heap, int i) {
		int right = i * 2 + 2;
		if (right < heap.length) {
			return "right key = " + heap[right] + ", ";
		} else {
			return "";
		}
	}
}


Measured memory_bytes: 27516
floor = []

for i in range(120):
    floor.append(0)

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    floor[30 * (b - 2) + 10 * (f - 2) + (r - 2)] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print("", str(floor[30 * (i - 1) + 10 * (j - 1) + (k - 1)]),end="")
        print("")
    if i < 3:
        print("#" * 20)


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<LL,LL>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;
typedef unsigned long long ULL;

pii memo[3010][3010];
LL v[3010];
int n;

pii dp(int i, int j)
{
	auto &dpm = memo[i][j];
	if(dpm != mp((LL)-1,(LL)-1))
		return dpm;
	if(i == j){
		if(n%2 == 0){
			dpm = {0,v[i]};
			
			return dpm;
		}
		else
			return dpm = {v[i],0};
	}

	auto x = dp(i+1,j);
	auto y = dp(i,j-1);

	if((j-i+1)%2 == 0){
		if(n%2 == 0){  // maximiza fi
			x.fi += v[i];
			y.fi += v[j];

			if(x.fi-x.se > y.fi-y.se)
				dpm = x;
			else
				dpm = y;

		}
		else{  // minimiza se
			x.se += v[i];
			y.se += v[j];

			if(x.fi-x.se < y.fi-y.se)
				dpm = x;
			else
				dpm = y;
		}
	}
	else{
		if(n%2 == 0){  // minimiza se
			x.se += v[i];
			y.se += v[j];

			if(x.fi-x.se < y.fi-y.se)
				dpm = x;
			else
				dpm = y;
		}
		else{// maximiza fi
			x.fi += v[i];
			y.fi += v[j];

			if(x.fi-x.se > y.fi-y.se)
				dpm = x;
			else
				dpm = y;
			}
	}
	// cout << i+1 << " " << j+1 << " " << dpm.fi << " " << dpm.se << endl;
	return dpm;
}
int main(void)
{
	fastIO();

	cin >> n;
	FOR(i,0,n)
		cin >> v[i];

	FOR(i,0,n)
		FOR(j,0,n)
			memo[i][j] = mp(-1,-1);

	pii ans = dp(0,n-1);
	cout << ans.fi - ans.se << endl;


	
	
}

Measured memory_bytes: 141952
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_072
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] ps = ReadInts();
            int cnt = 0;
            for(int i = 0; i < n - 1; i++)
            {
                if (ps[i] == i + 1)
                {
                    int temp = ps[i];
                    ps[i] = ps[i + 1];
                    ps[i + 1] = temp;
                    cnt++;
                }
            }
            if (ps[n - 1] == n) cnt++;
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 18912
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                int tmp = gcd(i,j);
                tmp = gcd(tmp, k);
                ans += tmp;
            }
        }
    }
    cout << ans << endl; 
    return 0;
}





Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
int N;
int A[100010];
int ans;
int two;
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		int tmp;
		std::cin >> tmp;
		A[tmp]++;
	}
	for (int i = 0; i <= 100000; i++) {
		if (A[i]%2==1) {
			ans++;
		}
		else if (A[i] > 0) {
			ans++;
			two++;
		}
	}
	if (two % 2 == 1)ans--;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 768
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int k;
    cin >> k;
    ll ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += (ll)gcd(a, gcd(b, c));
            }
        }
    }
    cout << ans << "\n";
}



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

using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using gmap = cc_hash_table<T, T, hash<T> >;

//INSERT ABOVE HERE
signed AGC023_A(){
  using ll = long long;
  int n;
  scanf("%d",&n);
  vector<ll> a(n);
  for(int i=0;i<n;i++) scanf("%lld",&a[i]);

  map<ll, ll> m;
  ll ans=0,s=0;
  m[s]++;
  for(int i=0;i<n;i++){
    s+=a[i];
    ans+=m[s];
    m[s]++;
  }

  printf("%lld\n",ans);
  return 0;
}

signed main(){
  AGC023_A();
  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 511;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, x, y, z, d[N][N], sum, a[N][N];
queue < pii > q;

inline bool in (int x, int y) {
	return x > 0 && y > 0 && x <= n && y <= n;
}


inline void opt () {
	while (sz(q)) {
		int x = q.front().f, y = q.front().s;
		q.pop();
		for (int i = 0; i < 4; ++i) { 
			int tox = x + dx[i], toy = y + dy[i];
			if (in(tox, toy) && d[tox][toy] > d[x][y] + a[tox][toy]) {
				d[tox][toy] = d[x][y] + a[tox][toy];
				q.push({tox, toy});
			}
		}
			
	}
}

main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 
		for (int j = 1; j <= n; ++j) {
			if (i == 1 || j == 1 || i == n || j == n) {
				d[i][j] = 1;
				q.push({i, j});
			} else
				d[i][j] = inf; 
			a[i][j] = 1;
		}

	opt();
	for (int i = 1; i <= n*n; ++i) {
		scanf("%d", &z);
		x = (z + n - 1) / n; 
		y = z % n;
		if (!y)
			y = n;
		sum += --d[x][y];
		a[x][y] = 0;
		q.push({x, y});
		opt();
	}

	cout << sum << endl;

}



Measured memory_bytes: 5700
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned int MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned int> dp(K + 1);
    dp[0] = 1;
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        for(unsigned long j{K}; j > a; --j)dp[j] += dp[j] > dp[j - a - 1] ? -dp[j - a - 1] : MOD - dp[j - a - 1];
    }
    for(unsigned long i{0}; i < N; ++i)partial_sum(dp.begin(), dp.end(), dp.begin(), [](auto i, auto j){return (i + j) % MOD;});
    cout << dp.back() << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include <clocale>
#include<cmath>
#include<sstream>
#include<set>
#include<stack>
using namespace std;
const int INF=0x3f3f3f3f;
const int MX=1e4+10;
typedef long long ll;
typedef pair<int ,int> p;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)printf("YES\n");
	else printf("NO\n");
    system("pause");
    return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int sum = 0;
  for(int i = 0; i < n-1; i++){
    sum += l[i];
  }
  if(sum > l[n-1]) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  int n, q, a, b;
  cin >> n>>q;
  vector<int> par(n);
  par[0] = 0;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    par[b - 1] = a - 1;
  }

  vector<int> px(n, 0);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    px[a - 1] += b;
  }
  vector<int> ans(n);
  ans[0] = px[0];

  for (int i = 1; i < n; i++) {
    ans[i] = ans[par[i]] + px[i];
  }

  for (int i = 0; i < n; i++)
  {
    cout << ans[i] << " ";
  }


  return 0;
}


Measured memory_bytes: 4736
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
    
a,b = map(int,input().split())

aset = set(divisor(a))
bset = set(divisor(b))

cset = aset & bset
clist = list(cset)
"""
if len(clist) == 1:
    print(1)
    exit()

coprime = [1]
coprime.append(clist[1])

#print(clist)

for j in range(2,len(clist)):
    for k in range(1,len(coprime)):
        if clist[j] % coprime[k] == 0:
            break
    else:
        coprime.append(clist[j])

#print(coprime)
print(len(coprime))
"""

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

cop = 1
for j in range(1,len(clist)):
    if is_prime(clist[j]) == True:
        cop += 1

print(cop)

Measured memory_bytes: 5120
#include <stdio.h>
int main(void) {
	int r, c, cell, row_sum, total, i, j;
	const char *fmt;

	scanf("%d %d", &r, &c);
	int col_sum[c];

	for (i = 0; i < c; i++)
		col_sum[i] = 0;
	for (total = i = 0; i < r; i++) {
		for (fmt = "%d", row_sum = j = 0; j < c; j++) {
			scanf("%d", &cell);
			printf(fmt, cell);
			row_sum += cell;
			col_sum[j] += cell;
			fmt = " %d";
		}
		printf(" %d\n", row_sum);
		total += row_sum;
	}
	for (fmt = "%d", i = 0; i < c; i++) {
		printf(fmt, col_sum[i]);
		fmt = " %d";
	}
	printf(" %d\n", total);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    string s;
    cin >>s;
    if (s == "Sunny") mes("Cloudy");
    if (s == "Cloudy") mes("Rainy");
    if (s == "Rainy") mes("Sunny");
    
    

}


Measured memory_bytes: 3532
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min, Reverse};
#[allow(unused)]
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        a: char,
    }
    if 'a' <= a && a <= 'z' {
        println!("{}", 'a');
    } else {
        println!("{}", 'A');
    }
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
//#define mod 998244353
using namespace std;
int check(string s,int l,int r)
{
	int n=r-l+1,i,flag=1;
	for(i=0;i<n/2;i++)
	{
		if(s[i+l]!=s[r-i])
		{
			flag=0;
			break;
		}
	}
	return flag;
}


int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j;
    cin>>n;
    ll a[n];
    map<ll,ll>m;
    map<ll,ll>::iterator it;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	m[a[i]]++;
	}
	ll x=0;
	for(it=m.begin();it!=m.end();it++)
	{
		x=x+(it->se)*(it->se-1)/2;
	}
	for(i=0;i<n;i++)
	{
		if(m.find(a[i])==m.end())
		cout<<x<<"\n";
		else
		{
			int y=m[a[i]];
			cout<<x-(y-1)<<"\n";
		}
		
		
	}
    
    
    
    
    
    
    

}

Measured memory_bytes: 11136
#include<stdio.h>
int main(void) {
	int a, b, c, m[12],top=0,second=0,thread=0;
	for (size_t i = 0; i < 10; i++)
	{
		scanf("%d", &a);
		if (a > top)
		{
			thread = second;
			second = top;
			top = a;
		}
		else
		{
			if (a>second)
			{
				thread = second;
				second = a;
			}
			else
			{
				if (a>thread)
				{
					thread = a;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n", top, second, thread);
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>

using namespace std;
int main()
{

    long long int n,i,three=0,five=0,sum=0,ans;

    cin>>n;

    for(i=3;i<=n;i=i+3)
    {
        three+=i;
    }

     for(i=5;i<=n;i=i+5)
    {

        if(i%3 !=0)
        {
            five+=i;
        }

    }

    sum=(n*(n+1))/2;


    ans=sum-(three+five);

    cout<<ans;

    return 0;
}


Measured memory_bytes: 3168
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, M, memo[112345];

int main() {

	scanf("%d%d", &N, &M);

	rep(i, M) {
		int L, R;
		scanf("%d%d", &L, &R);
		memo[L-1]++;
		memo[R]--;
	}

	rep(i, N) {
		memo[i + 1] += memo[i];
	}

	int ans = 0;
	rep(i, N) {
		if (memo[i] == M) ans++;
	}

	printf("%d\n", ans);

	return 0;
}


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

struct www_t{
  int d;
  int f;  //0-shop/1-house
  int g;
  int h;
};

bool asc(www_t left,www_t right) {
    return left.d == right.d ? left.f < right.f : left.d < right.d;
}

int main(){
  long dd,n,m,sum,gg;
  scanf ("%ld",&dd);
  while(dd){
    sum=0;
    scanf ("%ld",&n);
    scanf ("%ld",&m);
    vector<www_t> a(n+m+1);
    a[0].d=0;
    a[0].f=0;
    for(int t=1;t<n;t++){
      scanf ("%d",&a[t].d);
      a[t].f=0;
    }
    a[n].d=dd;
    a[n].f=0;
    for(int t=n+1;t<n+m+1;t++){
      scanf ("%d",&a[t].d);
      a[t].f=1;
    }
    sort(a.begin(), a.end(),asc);
    gg=0;
    for(int t=0;t<n+m+1;t++){
      if(a[t].f==0){
        gg=t;
      }
      else{
        a[t].g=gg;
      }
    }
    for(int t=n+m;t>=0;t--){
      if(a[t].f==0){
        gg=t;
      }
      else{
        a[t].h=gg;
      }
    }
    long xx,yy;
    for(int t=0;t<n+m+1;t++){
      if(a[t].f==1){
        xx=a[a[t].g].d;
        yy=a[a[t].h].d;
        if(a[t].d-xx<yy-a[t].d){
          sum+=a[t].d-xx;
        }
        else{
          sum+=yy-a[t].d;
        }
      }
    }
    printf("%ld\n",sum);
    scanf ("%ld",&dd);
  }
}



Measured memory_bytes: 4724
function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);
    var q = parseInt(input[2],10);
    input[1] = input[1].split(" ");
    input[3] = input[3].split(" ");
    var s = Array(n),t = Array(q);
    for(var i = 0;i < n;i++){
        s[i] = parseInt(input[1][i],10);
    }
    for(var i = 0;i < q;i++){
        t[i] = parseInt(input[3][i],10);
    }
    var count = 0;

    for(var i = 0;i < q;i++){
        var j;
        for(j = 0;j < n;j++){
           if(s[j] == t[i])
                break;
        }
        if(j < n)
            count++;
    }
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 17232
#include <iostream>
#include <stack>

using namespace std;

stack<int> s;
int a[31];
int f(int n){
  if(n){
    for(int i=n;i>0;--i){
      if(s.empty()||s.top()>=i){
	s.push(i);f(n-i);s.pop();
      }
    }
  }
  else{
    if(!s.empty()){
      stack<int> t(s);
      int b=t.size();
      for(int i=b-1;i>=0;--i){
	a[i]=t.top();t.pop();
      }
      cout<<a[0];
      for(int i=1;i<b;++i) cout<<' '<<a[i];
      cout<<endl;
    }
  }
  return 0;
}
int main(){
  int n;
  while(cin>>n,n){
    f(n);
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

    unsigned long long ans=0;
    int pre_index=-1,index;
    rep(i,t.length()){
        char _t=t[i];
        auto it=s.find(_t,pre_index+1);

        if(it==string::npos){
            it=s.find(_t,0);
            if(it==string::npos){
                cout<<"-1"<<endl;
                exit(0);
            }else{
                index=(int)it;
                ans+=index+s.length()-pre_index;
            }
        }else{
            index=(int)it;
            ans+=index-pre_index;
        }
        pre_index=index;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int s, w; cin >> s >> w;
    if(w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
struct node {
    vector<int> v;
    node() {}
    node(int x) { v.eb(x); trace(v); }
    node operator+(const node& oth) {
        node r;
        for(int i : v) r.v.eb(i);
        for(int i : oth.v) r.v.eb(i);
        // merge(all(v), all(oth.v), r.v.begin());
        sort(all(r.v));
        trace(v, oth.v, r.v);
        return r;
    }
    int query(int x) {
        int j = ub(all(v), x) - v.begin();
        return v.size() - j;
    }
};
template <class node>
struct seg_tree {
    vector<node> t;
    int n;
    seg_tree() {}
    void build(vector<int>& a) {
        n = a.size();
        t.resize(2 * n);
        for (int i = 0; i < n; i++)
            t[i + n] = node(a[i]);
        for (int i = n - 1; i > 0; i--)
            t[i] = t[i << 1] + t[i << 1 | 1];
    }
    void update(int p, int x) {  // on 0-indexed p
        for (t[p += n] = node(x); p >>= 1;)
            t[p] = t[p << 1] + t[p << 1 | 1];
    }
    int query(int l, int r) {  // interval [l,r]
        int res = 0, x = r;
        for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
            if (l & 1) res += t[l++].query(x);
            if (r & 1) res += t[--r].query(x);
        }
        return res;
    }
};
void solve(int test) {
    seg_tree<node> st;
    int n, q;
    cin >> n >> q;
    vector<int> a(n), nxt(n, 1e9);
    map<int, int> ahead;
    for (int& e : a) cin >> e;
    for (int i = n - 1; i >= 0; i--) {
        auto it = ahead.find(a[i]);
        if (it != ahead.end())
            nxt[i] = it->se;
        ahead[a[i]] = i;
    }
    st.build(nxt);
    trace(nxt);
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        int res = st.query(l, r);
        cout << res << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
}


Measured memory_bytes: 117472
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 100000 + 5;
ll a[maxn];
ll b[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	for (int i = 0; i < n + 1; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++){
		if (b[i] >= a[i]) {
			ans += a[i];
			b[i] -= a[i];
			if (b[i] >= a[i + 1]){
				ans += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				ans += b[i];
				a[i + 1] -= b[i];
			}
		}
		else{
			ans += b[i];
		}
	}
	cout << ans << endl;

	//system("pause");
	return 0;
}


Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	n := len(s)

	ans := make([]int, n)

	l := 0
	r := 0
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			r++
			continue
		}
		ans[i] += r >> 1
		ans[i-1] += r - (r >> 1)
		r = 0
	}
	for i := n - 1; i >= 0; i-- {
		if s[i] == 'L' {
			l++
			continue
		}
		ans[i] += l >> 1
		ans[i+1] += l - (l >> 1)
		l = 0
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(writer, ans[i])
		if i < n-1 {
			fmt.Fprint(writer, " ")
			continue
		}
		fmt.Fprintln(writer, "")
	}

	writer.Flush()
}


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

int main() {
	int n;
	cin >> n;
	if(n == 1)
	{
		cout << "Hello World" << endl;
	}
	else if(n == 2)
	{
		int a,b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
a=[]
for i in range(N):
    c,d=map(int,input().split())
    a.append((c,d))
#xについてソート
a.sort()
count = 0
for x,y in a:
    count += y
    if count>=K:
        print(x)
        exit()

Measured memory_bytes: 16940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

string S;
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> S;
    int cnt = 0;
    int l = 0;
    rep(i, S.length()) {
        if ('T'==S[i] && cnt ==0) l++;
        else if ('T'==S[i]) cnt--;
        else cnt++;
    }
    cout << 2 * l << endl;

    return 0;
}




Measured memory_bytes: 848
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    
    string a[2];
    string ans = "No";
    if(n%2 == 0){
        for(int i = 0; i < n/2; i++){
            a[0] += s[i];
        }
        for(int i = n/2; i < n; i++){
            a[1]+= s[i];
        }
        if(a[0] == a[1]){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const ll M = 1e3+30 , N= 100400 , MOD = 1e9+7 , OO = 1e10;
ll m ,n ,k , x, y , dp[N] , bla ,c=1,cnt ,ans,sum , a[N] , ok=1 ;
int main(){

cin >> n  >> k ;
for(int i=k;i<=(n+k-1);i++){
  cin >> a[i];
}
for(int i=0;i<=(n+k-1);i++) {
    if(i==k) dp[i] = 0;
    else{
        dp[i] = OO;

    }}

for(int i=k+1;i<=(n+k-1);i++){
   for(int j=1;j<=k;j++){
        dp[i] = min(dp[i] , dp[i - j] + abs(a[i - j]  - a[i]));
     }
   }

cout << dp[n+k-1];
return 0;
}
/*
6 15= max
6 5
5 6
6 4
6 6
3 5
7 2
*/


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int dy[4] = {1,0,-1,0}; // n e s w
int dx[4] = {0,1,0,-1};
char m[21][21];
int cnt;

void bfs(int sx, int sy, int w, int h)
{
	rep(i,0,4) {
		int nx = sx + dx[i];
		int ny = sy + dy[i];
		if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
		if (m[ny][nx] == '.') {
			m[ny][nx] = '@';
			cnt++;
			bfs(nx, ny, w, h);
		}
	}
}

int main()
{
	while(1) {
		int w, h;
		cin >> w >> h;
		if (!w && !h) break;
		int sx, sy;
		cnt = 0;
		rep(i,0,h) rep(j,0,w) {
			cin >> m[i][j];
			if (m[i][j] == '@') {
				cnt++;
				sx = j;
				sy = i;
			}
		}
		//rep(i,0,h) { rep(j,0,w) cout << m[i][j]; cout << endl; }
		bfs(sx, sy, w, h);
		cout << cnt << endl;
	}	

	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int a,b,c;	
        cin>>a>>b>>c;
        if(a==b && a==c && b==c) {cout<<"No\n"; return 0;}
      	else if(a==b || a==c || b==c) {cout<<"Yes\n"; return 0;}
      	else{
        	cout<<"No\n";
        }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    rep(i, n) cin >> a[i];
    rep(i, n-1){
        a[i+1] += a[i];
    }
    rep(i, m) cin >> b[i];
    rep(i, m-1){
        b[i+1] += b[i];
    }

    int ans = upper_bound(b, b+m, k) - b;
    // printf("a: %d, b: %d\n", 0, ans);
    rep(i, n){
        if(a[i]>k) break;
        int tmp = upper_bound(b, b+m, k-a[i]) - b;
        // printf("a: %d, b: %d\n", i+1, tmp);
        chmax(ans, tmp+i+1);
    }
    
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A;
    for(int i=0; i<N; ++i){
        long a; cin >> a;
        A.push_back(a);
    }

    make_heap(A.begin(), A.end());

    for(int i=0; i< M; ++i){
        long max_ = A.front();
        max_ = max_/2;
        pop_heap(A.begin(), A.end());
        A.pop_back();
        A.push_back(max_);
        push_heap(A.begin(), A.end());
    }

    long long res = accumulate(A.begin(), A.end(), (long long) 0);
    cout << res << endl;
}


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

class Main {
	static long[][] dp;

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

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

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

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

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

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

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

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

}


Measured memory_bytes: 142712
import sys
input=sys.stdin.readline
ab=[]
n,m=map(int,input().split())
for i in range(m):
	a,b=map(int,input().split())
	ab.append((a-1,b-1))
ab.sort(key=lambda x:x[1])
pre_b=-1
cnt=0
for a,b in ab:
	if a>=pre_b:
		cnt+=1
		pre_b=b
print(cnt)




Measured memory_bytes: 18184