akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[100]={};
  a[0]=2;
  a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int n;rd(n);
    string s;rd(s);
    int w=0,bad=0;
    fo(i,0,n-1){
        if(s[i]=='W')w++;
    }
    rf(i,n-1,n-w){
        if(s[i]=='R')bad++;
    }   
    cout<<bad<<endl;
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;
ll t,n,m,k;
ll i,j;
ll a[500005], b[500005];
vector<ll>v;
int32_t main(){
    cin>>n;
    ll ans=0;
    for(ll x=1;x<=sqrt(n);x++){
        for(ll y=1; y<=sqrt(n);y++){
            for(ll z=1;z<=sqrt(n);z++){
                k=x*x+y*y+z*z+y*z+y*x+z*x;
                if(k<=n) a[k]++;
            }
        }
    }
    for(i=1;i<=n;i++ ) cout<<a[i]<<"\n";

    return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>

int main(int argc, const char * argv[]) {

    
    long N,M,ans,amari; //S,c
    scanf("%ld",&N);
    scanf("%ld",&M);
    
    //Sのが大きい?
    if(2*N>=M){
        ans = M/2;
        printf("%ld\n",ans);
    }else{
        ans = N;
        amari = M-2*N;
        if(amari >= 4){
            ans += amari/4;
        }
        printf("%ld\n",ans);
    }

    return 0;
}

Measured memory_bytes: 128
def CheckNum(n, x, i):
	x = i
	if x % 3 == 0:
		print(" %d"%(i), end="")
		return 2, i, x
	return 1, i, x

def Include3(n, x, i):
	if x % 10 == 3:
		print(" %d"%(i), end="")
		return 2, i, x
	x = int(x/10)
	if x != 0:
		return 1, i, x
	return 2, i, x

def EndCheckNum(n, x, i):
	i += 1
	if i <= n:
		return 0, i, x
	print("")
	return 3, i, x
	
def call(n):
	counter = 0
	i = 1
	x = 1
	func = [CheckNum, Include3, EndCheckNum]
	while counter != 3:
		counter, i, x = func[counter](n, x, i)

n = int(input())
call(n)

Measured memory_bytes: 5880
#coding:utf-8
#1_7_A
class Node():
    def __init__(self, node_id, children):
        self.node_id = node_id
        self.parent = -1
        self.depth = 0
        self.typ = "root"
        self.children = children

    def set_child(self, child):
        """ Overwrite child's attribute """
        child.parent = self.node_id
        child.depth = self.depth + 1
        if child.children:
            child.typ = "internal node"
        else:
            child.typ = "leaf"

    def set_children(self, tree):
        """ Repeat set_child starting from root node """
        stack = []
        stack.append(self.node_id)

        while stack:
            node = tree[stack.pop()]
            for child_id in node.children:
                node.set_child(tree[child_id])
            stack.extend(node.children)

n = int(input())
tree = [None for i in range(n)]
children = []
for i in range(n):
    info = list(map(int, input().split()))
    tree[info[0]] = Node(info[0], info[2:])
    children.extend(info[2:])

root_id = (set([x for x in range(n)]) - set(children)).pop()

tree[root_id].set_children(tree)

for node in tree:
    print("node {}: parent = {}, depth = {}, {}, {}".format(node.node_id, node.parent, node.depth, node.typ, node.children))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, Q;
    string S;

    cin >> N >> Q;
    cin >> S;

    vector<ll> L(Q);
    vector<ll> R(Q);

    REP(i, Q){
        cin >> L[i] >> R[i];
    }

    vector<ll> A(N+1);

    ll count = 0;
    A[0] = 0;
    A[1] = 0;
    for(ll i=2; i<=N; i++){
        if((S[i-2] == 'A') && (S[i-1] == 'C')) count ++;
        A[i] = count;
    }
    
    REP(i, Q){
        ll ans = A[R[i]] - A[L[i]-1];
        if((S[L[i]-2] == 'A') && (S[L[i]-1] == 'C')) ans--;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut a: usize,
        mut b: usize,
        mut c: usize,
        k: usize,
    }
    for _ in 0..k {
        if b <= a {
            b *= 2;
            continue;
        }
        if c <= b {
            c *= 2;
            continue;
        }
    }
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int nextTime(int t, int c, int s, int f)
{
    t = max(t,s);
    if(t%f != 0)
    {
        t = f*(t/f)+f;
    }
    return t+c;
}

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n-1; ++i)
    {
        int c,s,f;
        cin >> c >> s >> f;
        for(int j = 0; j <= i; ++j)
        {
            vec[j] = nextTime(vec[j],c,s,f);
        }
    }
    for(int i = 0; i < n; ++i)
    {
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	int mod = 1000000007;

	static public int diff(int[] a, int i, int j) {
		return Math.abs(a[i] - a[j]);
	}

	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();

		int[][] a = new int[n][3];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int[][] dp = new int[n + 1][3];

		for (int i = 1; i <= n; i++) {
			dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1][0];
			dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + a[i - 1][1];
			dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + a[i - 1][2];
		}

		out.print(Math.max(dp[n][0], Math.max(dp[n][1], dp[n][2])));
		/*
		 * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //
		 * read input as long double d = sc.nextDouble(); // read input as double String
		 * str = sc.next(); // read input as String String s = sc.nextLine(); // read
		 * whole line as String
		 * 
		 * int result = 3*n; out.println(result); // print via PrintWriter
		 */

		// Stop writing your solution here. -------------------------------------
		out.close();
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	// --------------------------------------------------------
}


Measured memory_bytes: 61464
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
inline void err(){
	cout<< -1<<endl;
	exit(0);
}
inline void add_edge(int u,int v){
	cout<<u<<" "<<v<<endl;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s; cin>>s;
	int n=s.length();
	s="0"+s;

	if(s[1]=='0') {
		err();
	}
	//cout<<s<<endl;
	for(int i=1; i<=n; i++) {
		if(s[i]!=s[n-i]) {
			//	cout<<s[i]<<" "<<s[n-i]<<endl;
			//cout<<i<<" "<<n-i<<endl;
			err();
		}
	}
	int root=1;
	int last=2;
	s[n]='1';
	for(int i=2; i<=n; i++) {
		if(s[i]=='1') {
			add_edge(i,root);
			while(last!=i) {

				add_edge(last,i);
				last++;
			}
			last++;
			root=i;
		}
	}
	//add_edge(root,last);


	return 0;
}


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

int main(){
  string S;
  cin >> S;
  bool Fumi = true;
  for(int i = 0; i < S.size(); i++){
    if((i+1)%2==1){
      if(S[i] == 'L'){
        Fumi = false;
        break;
      }
    }else{
      if(S[i] == 'R'){
        Fumi = false;
        break;
      }
    }
  }
  if(Fumi) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second

void solve() {
    int d, g;
    cin >> d >> g;
    int P[10], C[10];
    rep(i, d) cin >> P[i] >> C[i];
    int ans = 1010101;
    rep(bit, 1 << d) {
        int ret = 0;
        int score = 0;
        int maxi = 0;
        rep(i, d) {
            if (bit >> i & 1) {
                score += (i + 1) * 100 * P[i] + C[i];
                ret += P[i];
            }
            else {
                maxi = i;
            }
        }
        bool flag = 0;
        rep(i, P[maxi]) {
            if (score >= g) {
                flag = 1;
                break;
            }
            score += (maxi + 1) * 100;
            ret++;
        }
        if(flag) ans = min(ans, ret);
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ret = 0
memo = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        memo[i][j] = gcd(i, j)


for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ret += memo[memo[i][j]][k]



print(ret)

Measured memory_bytes: 78640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<61;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define print(x) cout<<x<<endl;
#define wait int xxxxxxx;cin>>xxxxxxx;
//vector< vector<int> > v (max1, vector<in t>(max2) );

int a[100];
int main(){
	int n,ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (i == 0)continue;
		if (a[i] == a[i - 1]) {
			a[i] = -1;
			ans++;
		}
	}
	print(ans);
	wait;
	return 0;
}

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

int main() {
    int N, K;
    int h[(int)1e+5];
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(h[i] >= K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-05 04:06:48
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int64 t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  int64 d1 = (a1 - b1) * t1;
  int64 d2 = (a2 - b2) * t2;

  if (d1 + d2 == 0) {
    cout << "infinity" << endl;
    return 0;
  }

  if (d1 > 0 && d2 >= 0 || d1 < 0 && d2 <= 0) {
    cout << 0 << endl;
    return 0;
  }

  if (d1 == 0 && d2 != 0) { 
    cout << 1 << endl;
    return 0;
  }

  if (abs(d1) > abs(d2)) {
    cout << 0 << endl;
  } else {
    int64 ans = abs(d1) / (abs(d2) - abs(d1)) * 2 + 1;
    if (abs(d1) % (abs(d2) - abs(d1)) == 0) --ans;
    cout << ans << endl;
  }

  return 0;
}

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

alpha = [chr(x) for x in range(97, 123)]

def N_to_al(N, res):
  x = N // 26
  r = N % 26
  res += alpha[r-1]
  
  if r == 0:
    x = x - 1
  if x > 0:
    return N_to_al(x, res)
  else:
    return res

res = N_to_al(N, "")
res = res[::-1]
print(res)

Measured memory_bytes: 9180
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> transform(int N, vector<int> A, vector<int> perm) {
	vector<int> ans(N);
	for (int i = 0; i < N; ++i) {
		ans[i] = A[perm[i]];
	}
	return ans;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, D, A;
	cin >> N >> D >> A;
	vector<int> X(N), H(N), perm(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> H[i];
		perm[i] = i;
	}
	sort(perm.begin(), perm.end(), [&](int i, int j) { return X[i] < X[j]; });
	X = transform(N, X, perm);
	H = transform(N, H, perm);
	vector<long long> diff(N + 1);
	long long cursum = 0, ans = 0;
	for (int i = 0; i < N; ++i) {
		cursum += diff[i];
		if (cursum < H[i]) {
			long long req = (H[i] - cursum + A - 1) / A;
			cursum += req * A;
			diff[i] += req * A;
			ans += req;
			int ptr = lower_bound(X.begin(), X.end(), X[i] + 2 * D + 1) - X.begin();
			diff[ptr] -= req * A;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
 
int main()
{
    int a,b,c;
  	cin>>a>>b>>c;
  	if(c>a&&c<b)
      cout<<"Yes"<<endl;
 	else if(c>b&&c<a)
      cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9+7;

signed main(){
  string N;
  cin >> N;
  
  if( N.back() == '2' || N.back() == '4' || N.back() == '5' || N.back() == '7' || N.back() == '9' ){
    cout << "hon" << endl;
  }else if( N.back() == '0' || N.back() == '1' || N.back() == '6' || N.back() == '8' ){
    cout << "pon" << endl;
  }else cout << "bon" << endl;
  
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		init();
		while (true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			System.out.println(solve(n));
		}
	}
	
	static int[] tri;
	static int[] quad;
	static int[] minQuad;
	static int[] minQuad2;

	static void init(){
		tri = new int[1500];
		
		for(int i = 1; i < tri.length; i++){
			tri[i] = i*(i + 1)/2;
		}
		
		quad = new int[200];
		quad[1] = 1;
		for(int i = 2; i < quad.length; i++){
			quad[i] = quad[i - 1] + tri[i];
//			System.out.println("i = "+i+" quad "+quad[i]);
		}
		
		minQuad = new int[1000001];
		minQuad2 = new int[1000001];
		Arrays.fill(minQuad, Integer.MAX_VALUE);
		Arrays.fill(minQuad2, Integer.MAX_VALUE);
		
		minQuad[0] = 0;
		minQuad2[0] = 0;
		
		for(int i = 1; i < minQuad.length ; i++){
			for(int j = 1; j < quad.length; j++){
				if(quad[j] > i){
					break;
				}
				
				else if(quad[j] == i){
					minQuad[i] = 1;
				}
				else {
					minQuad[i] = Math.min(minQuad[i], minQuad[quad[j]]+minQuad[i-quad[j]]);
				}
			}
			
			for(int j = 1; j < quad.length; j++){
				if(quad[j] > i){
					break;
				}
				else if(quad[j]%2 == 0){
					continue;
				}
				else if(quad[j] == i){
					minQuad2[i] = 1;
				}
				else {
					minQuad2[i] = Math.min(minQuad2[i], minQuad2[quad[j]]+minQuad2[i-quad[j]]);
					
//					if(i == 20)System.out.println("j = "+j+" (quad[j]="+quad[j]+") "+minQuad2[quad[j]]+"+"+minQuad2[i-quad[j]]);
				}
			}
			
//			if(i < 100){
//				System.out.print(minQuad2[i]+" ");
//			}
		}
	}
	
	static String solve(int n){
		
		return minQuad[n]+" "+minQuad2[n];
	}
}


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

const int maxn = 1e5;

int a[3][maxn];

int dp[maxn][3];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n ; i++)
    {
        scanf("%d %d %d",&a[0][i],&a[1][i],&a[2][i]);
    }
    for(int i = 0; i < 3; i++)
        dp[1][i] = a[i][1];
    for(int i = 2; i <= n; i++)
    {
        for(int last = 0; last <= 2; last++)
        {
            for(int at = 0; at <= 2; at++)
            {
                if(at == last)
                    continue;
                dp[i][at] = max(dp[i][at], dp[i-1][last] + a[at][i]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 3; i++)
    {
        ans = max(ans, dp[n][i]);
    }
    printf("%d\n",ans);

    return 0;
}

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

int main() {
  
  int n, k;
  cin >> n >>k;
  
  int a = 1;
  
  for(int i = 0; i < n; i++){
    if( a * 2 < a + k ){
      a *= 2;  
    }
    
    else{
      a += k;
    }
  }
  
  cout <<a <<endl;
  
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[200031] = {};
    Scs(s);
    ll ans = 0;
    int n = strlen(s);
    int tmp = 0;
    Rep(i,n){
        if( s[i] == 'W' ){
            ans += tmp;
        }else{
            tmp++;
        }
    }
    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
const int mod=1e9+7;
ll sum,pw=1,n,k;
ll dp[2000005];
void init()
{
	for(int i=1;i<=n;i++)dp[i]=dp[i-1]+i-1,dp[i]%=mod;
}
signed main()
{
//	for(int i=1;i<=100;i++)pw=pw*10%mod;
	cin>>n>>k;
	n++;
	init();
	for(ll i=k;i<=n;i++)
	{
		sum+=(dp[n]-dp[n-i]-dp[i]+1ll+mod)%mod;
		sum%=mod;
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 5096
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<ll> A(N);
  for(int i=0;i<N;i++) std::cin >> A[i];
  ll dp[N][N][2];
  for(int i=0;i<N;i++) dp[i][i][0] = A[i], dp[i][i][1] = -A[i];
  for(int w=1;w<N;w++){
    for(int i=0;i+w<N;i++){
      dp[i][i+w][0] = max(dp[i+1][i+w][1]+A[i], dp[i][i+w-1][1]+A[i+w]);
      dp[i][i+w][1] = min(dp[i+1][i+w][0]-A[i], dp[i][i+w-1][0]-A[i+w]);
    }
  }
  std::cout << dp[0][N-1][0] << '\n';
  return 0;
}


Measured memory_bytes: 140544
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => {
            get().parse::<$t>().unwrap()
        };
        () => {
            get!(i64)
        };
    }

    let n = get!();
    let a = get!();
    let b = get!();
    let c = get!();
    let mut xs = vec![];
    for _ in 0..n {
        xs.push(get!());
    }
    xs.sort();

    fn foo(a: i64, b: i64, c: i64, i: usize, xs: &[i64], ys: &mut [i64]) -> i64 {
        if i == xs.len() {
            if ys.iter().any(|y| *y == 0) {
                return std::i64::MAX;
            }
            let mp: i64 = ys.iter().filter(|y| **y > 1).map(|y| *y - 1).sum();
            return mp * 10 + a.abs() + b.abs() + c.abs();
        }
        let mut mp = foo(a, b, c, i + 1, xs, ys);
        for j in 0..3 {
            ys[j] += 1;
            let (a, b, c) = match j {
                0 => (a - xs[i], b, c),
                1 => (a, b - xs[i], c),
                _ => (a, b, c - xs[i]),
            };
            let tmp = foo(a, b, c, i + 1, xs, ys);
            if tmp < mp {
                mp = tmp;
            }
            ys[j] -= 1;
        }
        mp
    }

    let mut ys = vec![0; 3];
    let ans = foo(a, b, c, 0, &xs, &mut ys);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#define  NIL -1
#define N 100000

int getDepth(int);


struct Node{
  int p;
  int l;
  int r;
  int s;
  int h;
  
}Node;

 struct Node T[N];

int getDepth(int u){
  int d=0;
   
  
 for(;T[u].p != NIL; d++) u=T[u].p;
  
  return d;
}
void setHeight(int n){
  int d,i,j;
  for(i=0;i<n;i++){
   
    if(T[i].r == NIL && T[i].l == NIL){
      T[i].h == 0;
      for(j = i,d = 1;j != NIL; d++){
	j = T[j].p;
	if(T[j].h < d) T[j].h = d;
	
      }
    }
  }
 
}

int main(){
  int i;
  int j;
  int n = 0;
  int v  =0;
  int d = 0;
  int c = 0;
  int l = 0;
  scanf("%d",&n);
 
 for(i=0;i<n;i++) {
   
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
    T[i].s=NIL;
  }
  
 for(i=0;i<n;i++){
   scanf("%d %d %d",&v,&d,&c);
   if( d!= NIL && c ==NIL){
     T[v].l = d;
     T[d].p = v;
   }
   if(c != NIL && d == NIL){
    T[v].r = c; 
    T[c].p = v;
   }
   if(d != NIL && c != NIL){
     T[v].l = d;
     T[d].p = v;
     T[v].r = c; 
     T[c].p = v;
     T[d].s = c;
     T[c].s = d;
   }
 }
 
 
 
   
 for(i=0;i<n;i++){
  
   printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,T[i].s);
   if(T[i].r == NIL && T[i].l == NIL) printf("degree = 0, ");
   
else if(T[i].r == NIL || T[i].l == NIL) printf("degree = 1, ");
  
   else printf("degree = 2, ");
   setHeight(n);
   printf("depth = %d, height = %d,",getDepth(i),T[i].h);

   if(T[i].p == NIL) printf(" root\n");

   else if(T[i].l == NIL && T[i].r == NIL) printf(" leaf\n");

   else printf(" internal node\n");
   
  
 }
return 0;
}

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

int main(){
    int a, b, c;
    long long ans = 0;
    scanf("%d %d %d", &a, &b, &c);
    
    int val = min(c, b);
    c -= val;
    b -= val;
    ans += 2 * val;

    val = min(c, a);
    c -= val;
    a -= val;
    ans += val;

    ans += b;
    if(c != 0) ans++;
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int group(int x)
{
    int g;
    if (x==2)
        g=3;
    else if (x==4 || x==6 || x==9 || x==11)
        g=2;
    else
        g=1;
    return g;
}
int main()
{
    int x{};
    int y{};
    cin >> x >> y;
    if (group(x)==group(y))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    left, right = 0, N-1
    for _ in range(M):
        l, r = map(int, input().split())
        left = max(left, l-1)
        right = min(right, r-1)
    
    print(max(0, right - left + 1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {

    int i,K,N;
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long a[200000],sum=0;

    cin>>N>>K;

    for(i=0;i<N;i++)
    {
        cin>>a[i];
    }
    sort(a,a+N);

    for(i=0;i<N-K;i++)
    {
        sum += a[i];
    }

    cout<<sum;



}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)cin >> a.at(i);
    int ans = 0;
    while(true){
        bool judge = true;
        for(int i = 0;i < n;i++){
            if(a.at(i) % 2 == 0)a.at(i)/=2;
            else judge = false;
        }
        if(judge)ans++;
        else break;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int k;

	cin >> k;

	vector <long long int> a(2*k+1, -1);

	a[0] = 0;
	int i;
	for (i = 1; i <= k; i++) {
		a[i] = ((10 * a[i-1]) + 7) % k;
		// cout << a[i] << "\n";
		if (!a[i]) {
			break;
		}
	}

	if (a[i] == 0)
		cout << i << "\n";
	else
		cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 18828
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	int ac = 0;
	int pn = 0;
	vector<vector<string>> res(n);
	rep(i, m) {
		int ind;
		string jud;
		cin >> ind >> jud;
		res[ind - 1].push_back(jud);
	}

	rep(i, n) {
		int s = res[i].size();
		int tmp = 0;
		bool ok = false;
		rep(j, s) {
			if (res[i][j] == "AC") {
				ok = true;
				ac++;
				break;
			}
			if (res[i][j] == "WA") tmp++;
		}
		if (ok) pn += tmp;
	}

	dunk(ac);
	dunk(pn);
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int input[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            input[i][j] = 0;
        }
    }
    char temp;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> temp;
            if (temp == '#') {
                input[i][j] = 9;
                for (int k = -1; k <= 1; ++k) {
                    for (int l = -1; l <= 1; ++l) {
                        if (i + k < 0 || i + k >= H) continue;
                        if (j + l < 0 || j + l >= W) continue;
                        ++input[i + k][j + l];
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (input[i][j] >= 9) {
                cout << '#';
            } else {
                cout << input[i][j];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		string s;
		cin >> s;
		int q;
		cin >> q;
		vector<int> reverse;
		string y;
		int c = 0;
		rep(i,0,q){
			int t;
			cin >>t;
			if(t==1){
				c++;
			}
			else{
				int f;
				cin >> f;
				char t;
				cin >> t;
				if(f==2 and c%2==0) s.pb(t);
				else if(f==1 and c%2) s.pb(t);
				else y.pb(t);
			}
		}
		if(c%2){
			rep(i,0,sz(s)) cout<<s[sz(s)-i-1];
			cout<<y;
		}
		else{
			rep(i,0,sz(y)) cout<<y[sz(y)-i-1];
			cout<<s;
		}
	}
}

Measured memory_bytes: 980
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int R = sc.nextInt();

        System.out.println(solve(R));

        sc.close();
    }

    static String solve(int R) {
        if (R < 1200) {
            return "ABC";
        } else if (R < 2800) {
            return "ARC";
        } else {
            return "AGC";
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int N;  cin>>N;
  ll sum=0;
  rep(i,1,N+1){
    if(i%3!=0 && i%5!=0) sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int h,w,l,r,a[600][600],f[600][600],ft[600],sx[300000],sy[300000],fx[300000],fy[300000],st,x;
bool di,las;
inline void adds(int a1,int b1,int a2,int b2){
	st++;
	sx[st]=a1;
	sy[st]=b1;
	fx[st]=a2;
	fy[st]=b2;
}
int main(){
	scanf("%d%d",&h,&w);
	fo(i,1,h)
		fo(j,1,w){
			scanf("%d",&a[i][j]);
			if (a[i][j]&1) f[i][++ft[i]]=j;
		}
	di=0;las=0;
	fo(i,1,h)
		if (di){
			r=ft[i];
			if (las){
				r--;
				las=0;
			}
			int j;
			for(j=r;j-1>=1;j-=2){
				//fd(k,f[i][j]-1,f[i][j+1]) adds(i,k+1,i,k);
				fd(k,f[i][j]-1,f[i][j-1]) adds(i,k+1,i,k);
			}
			if (j==1){
				if (i==h) break;
				for(x=i+1;x<=h;x++) if (ft[x]) break;
				if (x>h) break;	
				if (f[x][1]<=f[i][1]){
					fd(k,f[i][1]-1,f[x][1]) adds(i,k+1,i,k);
					fo(k,i+1,x) adds(k-1,f[x][1],k,f[x][1]);
				}else{
					fo(k,i+1,x) adds(k-1,f[i][1],k,f[i][1]);
					fo(k,f[i][1]+1,f[x][1]) adds(x,k-1,x,k);
				}							
				di=0;//w=0;
				las=1;
				i=x-1;//i=x 
			}
		}else{
			l=1;
			if (las){
				l++;
				las=0;
			}
			int j;			
			for(j=l;j+1<=ft[i];j+=2){
				fo(k,f[i][j]+1,f[i][j+1]) adds(i,k-1,i,k);
			}
			if (j==ft[i]){
				//if (i==h) break;
				for(x=i+1;x<=h;x++) if (ft[x]) break;
				if (x>h) break;
				if (f[x][ft[x]]<=f[i][ft[i]]){
					fo(k,i+1,x) adds(k-1,f[i][ft[i]],k,f[i][ft[i]]);
					fd(k,f[i][ft[i]]-1,f[x][ft[x]]) adds(x,k+1,x,k);				
				}else{
					fo(k,f[i][ft[i]]+1,f[x][ft[x]]) adds(i,k-1,i,k);
					fo(k,i+1,x) adds(k-1,f[x][ft[x]],k,f[x][ft[x]]);
				}
				di=1;//w=1
				las=1;
				i=x-1;//i=x 				
			}
		}
	printf("%d\n",st);
	fo(i,1,st) printf("%d %d %d %d\n",sx[i],sy[i],fx[i],fy[i]); 
	return 0;
} 

Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;

set<char>st;
bool alpa[26];

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = -1;
	for (int i = 0; i <= n - 2; i++)
	{
		int chk = 0;
		for (int j = 0; j <= i; j++)
		{
			st.insert(s[j]);
		}
		for (int t = i + 1; t < n; t++)
			if (st.find(s[t]) != st.end())
			{
				if (!alpa[s[t] - 'a'])
				{
					chk++;
					alpa[s[t] - 'a'] = true;
				}
			}
		if (ans < chk)
			ans = chk;
		st.clear();
		memset(alpa, false, sizeof(alpa));
		
	}
	cout << ans;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[110];
int main()
{
	cin>>str;
	int len=strlen(str);
	int left=0,right=len-1;
	while(left<=right)
	{
		if(str[left]==str[right])
		{
			++left;
			--right;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	left=0,right=(len-1)/2-1;
	while(left<=right)
	{
		if(str[left]==str[right])
		{
			++left;
			--right;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	left=(len+3)/2-1,right=len-1;
	while(left<=right)
	{
		if(str[left]==str[right])
		{
			++left;
			--right;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)


int main() {
	int a, b, c; cin >> a >> b >> c;
	if ( a == b || b == c || c == a ) {
		if (a == b && b == c) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	
	vi res(n + 1);
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int cd = abs(i - j);
			cd = min(cd, abs(i - x) + 1 + abs(j - y));
			cd = min(cd, abs(i - y) + 1 + abs(j - x));
			res[cd]++;
			
		}
	}
	for (int i = 1; i < n; i++)
		cout << res[i] << "\n";
	return 0;
}

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

int main(){
  int n,a,b,num_a,num_b;
  cin >> n;
  int p[n+2];
  cin >> a >> b;
  for (int i=0;i<n;++i){
    cin >> p[i];
  }
  p[n] = a;
  p[n+1] = b;
  sort(p, p+n+2);
  for(int i=n+1;i>=0;--i) {
    if(p[i]==b){
      num_b = i;      
      break;
    }
  }
  
  for(int i=num_b;i>=0;--i) {
    if(p[i]==a){
      num_a = i;
      break;
    }
  }
  cout << min({num_a, num_b-num_a-1, n-num_b+1}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Point {
	int u;
	int v;
};

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

	vector<Point> ps(n);
	bool is_odd = false;
	bool is_first = true;
	for (auto& p : ps) {
		int x, y; cin >> x >> y;
		p.u = x + y;
		p.v = x - y;
		if (is_first) {
			is_odd = (p.u) & 1;
			is_first = false;
		}
		if (is_odd != (bool)(p.u & 1)) {
			cout << -1 << endl;
			return 0;
		}
	}

	if (!is_odd) {
		cout << 32 << endl;
	}
	else {
		cout << 31 << endl;
	}

	if (!is_odd) {
		cout << 1 << " ";
	}
	FOR_DW(i, 30, 0) {
		cout << (1 << i) << " ";
	}
	cout << endl;

	for (auto& p : ps) {
		// R: + +
		// U: + -
		// D: - +
		// L: - -
		if (!is_odd) {
			cout << "R";
			p.u--;
			p.v--;
		}

		uint32_t u = p.u + ((1U << 31) - 1);
		uint32_t v = p.v + ((1U << 31) - 1);
		u >>= 1;
		v >>= 1;
		FOR_DW(i, 30, 0) {
			bool is_uplus = (u & (1 << i));
			bool is_vplus = (v & (1 << i));

			if (is_uplus && is_vplus) {
				cout << "R";
			}
			if (is_uplus && !is_vplus) {
				cout << "U";
			}
			if (!is_uplus && is_vplus) {
				cout << "D";
			}
			if (!is_uplus && !is_vplus) {
				cout << "L";
			}
		}
		cout << endl;
	}

	return 0;
}


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

const int mod=1000000007;
int fa[200001],n,t,sz,X,Y,inv[200010],jc[200010],C[200001],ans,f[200001],g[200001],G[200001];
vector<int> v[200001],c[200001];
struct node{int c,v;}a[200001];
struct node2{int ord,v;}A[200001];

bool cmp(node a,node b) {return a.v<b.v;}
bool cmp2(node2 a,node2 b) {return a.v<b.v;}
int ask(int x) {return fa[x]==x?x:fa[x]=ask(fa[x]);}
int nxt(int x,int c) {if (a[x+1].c==c) return g[x]; return x+1;}

void unite(int x,int y)
{
	int p=ask(x),q=ask(y);
	if (p==q) return;
	if (v[p].size()<v[q].size()) t=p,p=q,q=t;
	int sz=v[q].size(); fa[q]=p;
	for (int j=0; j<sz; j++) v[p].push_back(v[q][j]);
	v[q].clear();
}

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

int main()
{
	scanf("%d%d%d",&n,&X,&Y);
	jc[0]=1;
	for (int i=1; i<=n; i++) jc[i]=1ll*i*jc[i-1]%mod;
	inv[n]=quickmi(jc[n],mod-2);
	for (int i=n; i; i--) inv[i-1]=1ll*i*inv[i]%mod;
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i].c,&a[i].v),A[i].ord=i,A[i].v=a[i].c;
	sort(A+1,A+1+n,cmp2); A[0].v=-1; int cnt=0;
	for (int i=1; i<=n; i++)
		if (A[i].v!=A[i-1].v) a[A[i].ord].c=(++cnt);
		else a[A[i].ord].c=cnt;
	sort(a+1,a+1+n,cmp);
	g[n]=n+1;
	for (int i=n-1; i; i--) g[i]=nxt(i+1,a[i+1].c);
	for (int i=1; i<=cnt; i++) c[i].clear();
	for (int i=1; i<=n; i++) c[a[i].c].push_back(i);
	for (int i=1; i<=cnt; i++)
	{
		sz=c[i].size(); G[c[i][sz-1]]=n+1;
		for (int j=0; j<sz-1; j++) G[c[i][j]]=c[i][j+1];
	}
	for (int i=1; i<=n; i++) fa[i]=i,v[i].clear(),v[i].push_back(i),f[i]=0;
	for (int i=1; i<=n; i++)
		if (fa[i]==i)
		{
			for (int j=i+1; j<=n&&a[j].v+a[i].v<=Y; j=nxt(j,a[i].c))
				{if (!f[i]) f[i]=j; unite(i,j);}
			if (f[i]) {for (int j=G[i]; j<=n&&a[j].v+a[f[i]].v<=Y; j=G[j]) unite(i,j);}
		}
	for (int i=1; i<=cnt; i++)
	{
		sz=c[i].size();
		for (int j=1; j<sz; j++)
			if (a[c[i][j]].v+a[c[i][0]].v<=X) unite(c[i][j],c[i][0]);
	}
	memset(C,0,sizeof(C));
	ans=1;
	for (int i=1; i<=n; i++)
		if (fa[i]==i) 
		{
			sz=v[i].size();
			for (int j=0; j<sz; j++) C[a[v[i][j]].c]++;
			ans=1ll*ans*jc[sz]%mod;
			for (int j=0; j<sz; j++) ans=1ll*ans*inv[C[a[v[i][j]].c]]%mod,C[a[v[i][j]].c]=0;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 29948
N = int(input())
hs = list(map(int,input().split()))

metrix = [0]*N
metrix[0] = 0
metrix[1] = abs(hs[1]-hs[0])

for i in range(2,N):
    metrix[i] = min(metrix[i-1]+abs(hs[i]-hs[i-1]),abs(metrix[i-2]+abs(hs[i]-hs[i-2])))
print(metrix[-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e4+10,mod=1e9+7;
typedef long long ll;
ll d,dp[N][102][3][3];
string k;
int solve(int i=0,int sum=0,bool f=0,bool x=0){
    if(i==k.length()){
        if(sum==0 && x)return 1;
        return 0;
    }
    ll &ret=dp[i][sum][f][x];
    if(~ret)return ret;

    int num;
    if(!f)num=k[i]-'0';
    else num=9;
    ret=0;
    for(int j=0;j<=num;j++){
        bool flag=f;
        if(j<num)flag=1;
        int tmp=sum;
        tmp+=j;
        tmp%=d;
        if(x==0 && j!=0)
            ret+=solve(i+1,tmp,flag,1);
        else
            ret+=solve(i+1,tmp,flag,x);

        ret%=mod;
    }
    return ret%mod;
}
int main(){
    Elhabashy
    input();
    cin>>k>>d;
    memset(dp,-1,sizeof dp);
    cout<<solve()%mod<<endl;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int B[2*E5+1];	

void solve() {
	vector<pair<int,int>> vec;
	int N;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		int x;
		cin >> x;
		vec.pb(make_pair(x,i));
	}
	sort(vec.begin(),vec.end());
	for (int i = 0; i <= (N-1)/2; ++i) {
		B[vec[i].second] = vec[(N-1)/2+1].first;
	}
	for (int i = (N-1)/2+1; i < N; ++i) {
		B[vec[i].second] = vec[(N-1)/2].first;
	}

	for (int i = 1; i <= N; ++i) {
		cout << B[i] << '\n';
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

int main()
{
	int r[200000], i, maxv = -1000000000, minv, n;
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> r[i];
	}

	minv = r[0];
	for (i = 1;i < n;i++) {
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}

	cout << maxv << endl;

	return 0;

}


Measured memory_bytes: 3856
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


m = int(input())
s = 0
l = 0
for i in range(m):
    d,c = map(int, input().split())
    s += c*d
    l += c
val = s + 9*l
ans = (val-18)//9 + int((val-18)%9!=0)
print(ans)

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

int main(){
    int N; cin >> N;
    vector<pair<int, int>> job;
    for (int i = 0; i < N; i++)
    {
        int a, b; cin >> a >> b;
        job.push_back(make_pair(b, a));
    }
    sort(job.begin(), job.end());
    long long time = 0;
    for(auto i : job){
        time += i.second;
        if(time>i.first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  sort(a.begin(), a.begin());
  for (int j = 0; j < (n+2)/3; ++j) a[n] ^= a[j] ^ a[j + n/3] ^ a[j + n/3*2];
  cout << (a[n] ? "No" : "Yes");
  return 0;
}
	

Measured memory_bytes: 640