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

int main(){
    int n;
    priority_queue<double, vector<double>, greater<double>> pq;
    cin >> n;
    for(int i = 0;i < n;i++){
        double v;
        cin >> v;
        pq.push(v);
    }
    for(int i = 0;i < n-1;i++){
        double a,b;
        a = pq.top();
        pq.pop();
        b = pq.top();
        pq.pop();
        pq.push((a+b)/2);
    }
    double ans = pq.top();
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                count++;
            }
        }
        return count;
    }
}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;

const int N = 110;

int n, a[N], ans;

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

Measured memory_bytes: 256
r, c = map(int, input().split())

# initialize matrix
matrixA = []

# compute sum of row
for _ in range(r):
    row_list = list(map(int, input().split()))
    row_list.append(sum(row_list))
    matrixA.append(row_list)

# compute sum of column
col_sum = []
for i in range(c+1):
    tmp_sum = 0
    for j in range(r):
        tmp_sum += matrixA[j][i]
    col_sum.append(tmp_sum)

# add sum row
matrixA.append(col_sum)

# output
for k in range(r+1):
    for l in range(c+1):
        print(matrixA[k][l], end='')
        if l < c:
            print(' ', end='')
    print('')



Measured memory_bytes: 6720
#include<stdio.h>

#define RTC(a, b, c) (a*a+b*b == c*c)

int main(void)
{
    int n;
    scanf("%d", &n);
    while(n--){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        puts(RTC(a, b, c) || RTC(a, c, b) || RTC(b, a, c) || RTC(b, c, a) ||
             RTC(c, a, b) || RTC(c, b, a) ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    rep(i,N)cin>>S[i];
    bool flag = false;
    for(int i = 0; i < N; i++){
        if(S[i]=='Y')flag = true;
    }
    if(flag){
        cout<<"Four"<<endl;
    }else{
        cout<<"Three"<<endl;
    }
}

Measured memory_bytes: 256
def resolve():
  S = list(input())
  T = list(input())
  count = 0

  for i in range(len(S)):
    if S[i] != T[i]:
      count += 1
      # temp = S[i]
      # for j, s in enumerate(S[i:]):
      #   if s == S[i]:
      #     print(S)
      #     S[i] = s
      #     S[i+j] = temp
      #     count += 1
  print(count)

if __name__ == "__main__":
  resolve()

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

int main(){
    int h,w,inf=10000,ans=0;
    char tmp;
    cin>>h>>w;
    vector<vector<int>> a(h+2,vector<int>(w+2));
    for(int i=0;i<h+2;i++){
        a[i][0]=inf;
        a[i][w+1]=inf;
    }
    for(int j=0;j<w+2;j++){
        a[0][j]=inf;
        a[h+1][j]=inf;
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            cin>>tmp;
            if(tmp=='#'){a[i][j]=0;}
            else{a[i][j]=min(a[i-1][j],a[i][j-1])+1;}
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=w;j>0;j--){
            a[i][j]=min(min(a[i-1][j],a[i][j+1])+1,a[i][j]);
        }
    }
    for(int i=h;i>0;i--){
        for(int j=1;j<w+1;j++){
            a[i][j]=min(min(a[i+1][j],a[i][j-1])+1,a[i][j]);
        }
    }
    for(int i=h;i>0;i--){
        for(int j=w;j>0;j--){
            a[i][j]=min(min(a[i+1][j],a[i][j+1])+1,a[i][j]);
            ans=max(a[i][j],ans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;

using namespace std;

ll power(ll a, ll n) {
    if (n == 0) {
        return 1LL;
    }
    ll half = power(a, n / 2) % MOD;
    ll p = (half * half) % MOD;
    if (n % 2 != 0) {
        return (p * a) % MOD;
    } else {
        return p;
    }
}

ll comb(ll n, ll r) {
    ll ans = 1;
    for (int i = 0; i < r; i++) {
        ans = ans * power(i + 1, MOD - 2) % MOD;
        ans = ans * (n - i) % MOD;
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    ll n, a, b;
    cin >> n >> a >> b;
    // cout << power(2LL, n) << endl;
    // cout << comb(n, a) << endl;
    ll ans = power(2LL, n) - 1 - comb(n, a) - comb(n, b);

    // debug
    while (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
s = input()
#s = [x for x in s]

ans = 0
t = []
for bit in range(1<<(len(s))):
  for i in range(len(s)):
    if bit & 1<<i and bit & 1<<(len(s)-1):
      t.append([bin(bit)[3:]])
      

p = [p[0] for p in set(map(tuple,t))]
for q in p:
  t = ''
  for i in range(len(q)):
    if q[i] == '1':
      t += s[i] + '+'
    else:
      t += s[i]
  t += s[-1]
  ans += sum(list(map(int,t.split('+'))))
  
print(ans)

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

using namespace std;

int N;
int A[1000];

bool solve()
{
    int x=A[0]/2;
    int y=A[0]-x;
    int a=x;
    int b=y;
    int c=1;
    for(int i=0; i<N; i++)
    {
        if(a>0 && a+y==A[i])
            a--;
        else if(b>0 && b+x==A[i])
            b--;
        else if(c>0 && A[i]==max(x, y))
            c--;
        else if(A[i]<max(x, y)+1)
            return false;
    }
    return a==0 && b==0 && c==0;
}

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d", A+i);
    sort(A, A+N, greater<int>());
    if(solve())
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
}


Measured memory_bytes: 384
#include <cctype>
#include <algorithm>
#include <cstdio>
typedef long long int64;
using namespace std;
inline int read(int f = 1, int x = 0, char ch = '-')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x; 
}
const int N = 1e5+5;
int s[N], d[N];
int64 n, m;
int main()
{
    n = read();
    for(int i = n; i; --i) s[i] = read(), m += s[i];
    if(m%(n*(n+1)/2)) return puts("NO"), 0;
    m /= n*(n+1)/2; 
    for(int i = n-1; i; --i) d[i] = s[i+1]-s[i]; d[n] = s[1]-s[n];
    for(int i = n; i; --i) if((m+d[i])%n||m+d[i] < 0) return puts("NO"), 0;
    puts("YES");
    return 0;
}
/*
2
99998 1
*/

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

using namespace std;

#define m2(x) ((x) * (x))
#define mp(a, b) make_pair(a, b)
#define ms(a, w) memset(a, w, sizeof(a))
#define fi first
#define se second

typedef long long LL;
typedef pair <int, int> ii;

const int MAXN = 200000 + 10;
const int INF = 1000000001;
const int MOD = 1000000000 + 7;
const int MAX = 200000;

int fac[MAXN], ifac[MAXN];
int a[MAXN];
int ans[MAXN];
int p[MAXN];

int C (int n, int m) {
	return (LL)fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int main () {
//	ios::sync_with_stdio(false);
//	freopen("1.in", "r", stdin);
//	freopen("CirclesGame.out", "w", stdout);
	int n;
	scanf("%d", &n);
	n++;
	int x, y;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (p[a[i]]) {
			x = p[a[i]];
			y = i;
		}
		else
			p[a[i]] = i;
	}
	ifac[0] = ifac[1] = fac[0] = 1;
	for (int i = 2; i <= n; i++)
		ifac[i] = LL(MOD - MOD / i) * ifac[MOD % i] % MOD;
	for (int i = 1; i <= n; i++) {
		fac[i] = (LL)fac[i - 1] * i % MOD;
		ifac[i] = (LL)ifac[i - 1] * ifac[i] % MOD;
	}
	for (int i = 1; i <= n; i++)
		ans[i] = C(n, i);
	for (int i = 0; i <= x - 1 + n - y; i++)
		(ans[i + 1] += MOD - C(x - 1 + n - y, i)) %= MOD;
	for (int i = 1; i <= n; i++)
		printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 3200
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int g = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        List<Integer> c = new ArrayList<>();
        for (int i = 0; i < d; i++) {
            p.add(sc.nextInt());
            c.add(sc.nextInt());
        }

        int minProgram = Integer.MAX_VALUE;
        for (int i = 0; i < Math.pow(2, d); i++) {
            int score = 0;
            int program = 0;
            // 完全に解く問題と全く解かない問題を決定
            for (int j = 0; j <= d; j++) {
                if (((i >> j) & 1) == 1) {
                    score += 100 * (j + 1) * p.get(j) + c.get(j);
                    program += p.get(j);
                }
            }
            // スコアがGより小さい場合、中途半端に解く問題が必要になる
            // 解いてない問題のうち、もっとも高い配点の問題を加点する
            if (score < g) {
                for (int j = d - 1; j >= 0; j--) {
                    if (((i >> j) & 1) == 1) {
                        continue;
                    }
                    for (int k = 0; k < p.get(j) - 1; k++) {
                        score += 100 * (j + 1);
                        program++;
                        if (score >= g) {
                            break;
                        }
                    }
                    break;
                }
            }
            if (score >= g && program < minProgram) {
                minProgram = program;
            }
        }
        System.out.println(minProgram);
    }

}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a; string s;
  IN(a, s);
  if (a >= 3200) OUTL(s);
  else OUTL("red");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin >> n;
	for(int i=0; 7*i<=n; ++i){
		if((n-7*i)%4 == 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
li=[[] for _ in range(n)]
ans=0

for i in range(m):
    a,b=map(int,input().split())
    li[a-1].append(h[b-1])
    li[b-1].append(h[a-1])

for j in range(n):
    if len(li[j])==0:
        ans+=1
    elif h[j]>max(li[j]):
        ans+=1

print(ans)
    

Measured memory_bytes: 23116
import java.util.*;

class Main {

    final static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            int n = sc.nextInt();
            if (n == 0) break;
            
            String[] s = new String[n];
            String[][] tmp = new String[n][];
            for (int i = 0; i < n; ++i) {
                s[i] = sc.next();
            }
            
            Map<String, Set<String>> map = new HashMap<String, Set<String>>();
            for (int i = 0; i < n; ++i) {
                tmp[i] = s[i].split("[:.,]");
                String key = tmp[i][0];
                Set<String> set = new HashSet<String>();
                for (int j = 1; j < tmp[i].length; ++j) {
                    set.add(tmp[i][j]);
                }
                map.put(key, set);
            }
            
            Set<String> set = map.get(tmp[0][0]);
            boolean f = false;
            do {
                f = false;
                String[] sana = new String[set.size()];
                sana = set.toArray(sana);
                for (String key: sana) {
                    if (map.containsKey(key)) {
                        f = true;
                        Set<String> siro = map.get(key);
                        set.remove(key);
                        for (String t: siro) {
                            set.add(t);
                        }
                    }
                }
            } while (f);
                        
            System.out.println(set.size());
        }
    }
}


Measured memory_bytes: 46160
# https://atcoder.jp/contests/abc131/tasks/abc131_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N, L = map(int, input().split())
    apples = [L + i for i in range(N)]
    total = sum(apples)

    rm = 0
    if apples[0] >= 0:
        rm = apples[0]
    else:
        for i in range(N):
            rm = apples[i]
            if rm == 0:
                break
    total -= rm
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


//vector<vector<int>> ve;

int gcd(int a, int b) {
    // if(ve[a-1][b-1] != -1){
    //   ve[a-1][b-1]
    // }

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

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int k;
    cin >> k;
    //vec.assign(k, vector<int>(k, -1));


    ll ans = 0;

    FOR(a, 1, k){
      FOR(b, 1, k){
        FOR(c, 1, k){
          ans += (gcd(gcd(a, b), c));
        }
      }
    }


    cout << ans << "\n"; 

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[100000],A,ans=1,MOD=998244353,a;
ll f(ll n,ll x){
    if(x==0)return 1;
    if(x%2==0)return f(n,x/2)*f(n,x/2)%MOD;
    return n*f(n,x-1)%MOD;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i==0&&a!=0){
            cout<<0<<endl;
            return 0;
        }
        A=max(A,a);
        s[a]++;
    }
    if(s[0]>1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<A;i++){
        ans*=f(s[i],s[i+1]);
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();

        String ans = "";
        while (true) {
            if (N % 2 == 0) {
                ans = "0" + ans;
                N = (N) / -2;
            } else {
                ans = "1" + ans;
                N = (N - 1) / -2;
            }
            if (N == 0) {
                System.out.println(ans);
                break;
            }
        }

    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int x[1000000];

int quicksort( int x[], int left, int right ) {
	
	int i, j, pivot, temp;
	
	i = left;
	j = right;
	
	pivot = x[(left+right)/2];
	
	while (1) {
	
		while ( x[i] < pivot ) { i++; }
		
		while ( pivot < x[j] ) { j--; }
		
		if ( i >= j ) { break; }
		
		temp = x[i];
		x[i] = x[j];
		x[j] = temp;
		
		i++;
		j--;
		
	}
	
	if ( left < i - 1 ) { quicksort( x, left, i - 1 ); }
	if ( j + 1 < right ) { quicksort( x, j + 1, right ); }
	
	return 0;
		
}

int main( void ) {

	int t, n, k, i, j, sum;
	
	scanf( "%d", &t );
	
	for ( i = 0; i < t; i++ ) {
	
		scanf( "%d %d", &n, &k );
		
		sum = 0;
	
		for ( j = 0; j < n; j++ ) { scanf( "%d", &x[j] ); }
		for ( j = 0; j < n - 1; j++ ) { x[j] = x[j+1] - x[j]; }
	
		quicksort( x, 0, n - 2 );
		
		for ( j = 0; j < n - k; j++ ) { sum += x[j]; }
		
		printf( "%d\n", sum );
		
	}
	
	return 0;

}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin>>s;
  n=s.size();
  int no,ne;
  ne=n/2;
  if(n%2==0) no=n/2;
  else no=(n/2)+1;
  int a=0,b=0;
  for(int i=0; i<n ; i++){
    if(i%2==0){
      if(s.at(i)=='1') a++;//奇数番目にある1の数を数える
    }
    else{
      if(s.at(i)=='1') b++;//偶数番目にある1の数を数える
    } 
  }
  cout<<min(no-a+b, ne+a-b)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string S,T;
    vector<string> V;
    cin >> S >> T;
    
    for ( int i = S.length()-T.length(); i >= 0; i-- ) {
        
        string s = S.substr( i, T.length() );
        
        bool is_match = true;
        for ( int j = 0; j < s.length(); j++ ) {
            if ( s[j] == '?' ) { continue; }
            if ( s[j] != T[j] ) { is_match = false; break; }
        }
        
        if ( is_match ) {            
            string ans = S;
            ans.replace( i, T.length(), T );
            for ( int i = 0; i < ans.length(); i++ ) {
                if ( ans[i] == '?' ) { ans.replace( i, 1, "a" ); }
            }
            V.push_back(ans);
            break;
        }        
    }
    
    if ( V.size() == 0 ) { cout << "UNRESTORABLE" << endl; }
    else {
        sort( V.begin(), V.end() );
        cout << V[0] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin
import scala.util.control.Breaks

/**
  * Created by wintermaples on 2017/06/20.
  */
object Main {

  def main(args : Array[String]) : Unit = {
    val b = new Breaks

    stdin.getLines().map(_.toInt).foreach(weight => {
      val sb = new StringBuilder
      val weightBinary = Integer.toBinaryString(weight)
      for (i <- 0 until weightBinary.length) {
        if (weightBinary.charAt(weightBinary.length - i - 1) == '1') {
          sb.append(String.valueOf( Math.pow(2, i).asInstanceOf[Int] )).append(" ")
        }
      }
      if (sb.length > 0)
        sb.deleteCharAt(sb.length - 1)

      println(sb.toString())
    })
  }

}

Measured memory_bytes: 43548
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define P pair<ll, int>
using namespace std;

vector<vector<int>> tree;

vector<ll> getDist(int s, map<pair<int, int>, ll> fee, int N) {
    vector<ll> dist(N + 1, 1e18);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, s});
    while (!que.empty()) {
        int u = que.top().second;
        int d = que.top().first;
        que.pop();
        if (d > dist[u])
            continue;

        for (int v : tree[u]) {
            if (dist[v] > dist[u] + fee[{u, v}]) {
                dist[v] = dist[u] + fee[{u, v}];
                que.push({dist[v], v});
            }
        }
    }

    return dist;
}

int main() {
    int N, M, s, t;
    cin >> N >> M >> s >> t;
    tree.resize(N + 1);
    map<pair<int, int>, ll> yen, snuuk;
    for (int i = 0; i < M; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        tree[u].push_back(v);
        tree[v].push_back(u);
        yen[{u, v}] = a;
        yen[{v, u}] = a;
        snuuk[{u, v}] = b;
        snuuk[{v, u}] = b;
    }

    vector<ll> yenDist = getDist(s, yen, N);
    vector<ll> snuukDist = getDist(t, snuuk, N);
    vector<ll> ans(N);
    for (int i = N - 1; i >= 0; i--) {
        if (i == N - 1) {
            ans[i] = yenDist[N] + snuukDist[N];
        } else {
            ans[i] = min(ans[i + 1], yenDist[i + 1] + snuukDist[i + 1]);
        }
    }

    ll ini = 1e15;
    for (ll a : ans) {
        cout << ini - a << endl;
    }
}


Measured memory_bytes: 46400
#include<cstdio>
#include<cstring>
using namespace std;
char st[11000];
int main()
{
	bool bk=true;
	scanf("%s",st+1);
	for(int i=1;i<=strlen(st+1);i++)
	{
		if(st[i]=='C')
		{
			for(int j=i+1;j<=strlen(st+1);j++)
			{
				if(st[j]=='F')bk=false;
			}
		}
	}
	if(bk==false)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define x first
#define y second

int solve(vector<pair<int,int> >& p,
	  set<pair<int,int> >& sp,
	  int i, 
	  int j){
  int dx = p[j].x - p[i].x;
  int dy = p[j].y - p[i].y;
  pair<int,int> n1 = make_pair( p[j].x-dy, p[j].y+dx );
  pair<int,int> n2 = make_pair( p[i].x-dy, p[i].y+dx );
  if(sp.find(n1) != sp.end() && sp.find(n2) != sp.end() )
    return dx*dx + dy*dy;
  else 
    return 0;
}


int main(){
  while(1){
    int n; cin >> n;
    if(n==0)break;
    
    vector<pair<int,int> > point(n);
    set<pair<int,int> > sp;
    for(int i=0; i<n; i++){
      cin >> point[i].x >> point[i].y;
      sp.insert(point[i]);
    }

    sort(point.begin(),point.end());
    int ans=0;
    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
	int tmp = solve(point,sp,i,j);
	ans = max(ans,tmp);
	//	cout << tmp << endl;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll h, w;
    cin >> h >> w;
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> box(h,vector<ll> (w,0));
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    ll k = 1;
    for (int i = 0; i < h; i++)
    {
        if (i % 2 == 0)
        {
            for (ll j = 0; j < w; j++)
            {
                if (a[k - 1] == 0)
                    k++;
                box[i][j] = k;
                a[k - 1]--;
            }
        }
        if (i % 2 != 0)
        {
            for (ll j = w - 1; 0 <= j; j--)
            {
                if (a[k - 1] == 0)
                    k++;
               box[i][j] = k;
                a[k - 1]--;
            }
        }
    }
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            cout << box[i][j] << (j == w - 1 ? "\n" : " ");
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  scanf("%lld", &n);
  string s="zabcdefghijklmnopqrstuvwxy",res="";
  while(n>26)
  {
    res=s[n%26]+res;
    if(n%26==0)
    n=n/26-1;
    else
    n=n/26;
  }
  res=s[n%26]+res;
  printf("%s", res.c_str());
}

Measured memory_bytes: 3724
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxn 200005
#define maxm 1000006
#define maxc 1000000007
#define pii pair <int,int>
#define Task ""
#define double long double
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
const double Pi = acos(-1);
using namespace std;
int n,dem[26];
string a[maxn];
long long ans;
struct Trie
{
    Trie *next[26];
    int cnt[26];
    Trie()
    {
        FOR(i,0,25) next[i] = NULL,cnt[i] = 0;
    }
}*t;
bool temp(string a,string b)
{
    return a.size() < b.size();
}
int main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    t = new Trie();
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1,a+n+1,temp);
    while (n)
    {
        string s = a[n--];
        cin >> s;
        int sz = s.size();
        Trie *cur = t;
        bool ok = 1;
        FOR(i,0,sz-1) ++dem[s[i] - 'a'];
        FORD(i,sz-1,1)
        {
            int nx = s[i] - 'a';
            if (cur -> next[nx] == NULL)
            {
                ok = 0;
                break;
            }
            cur = cur -> next[nx];

        }
        if (ok)
        {
            ans += cur -> cnt[s[0] - 'a'];
        }
        cur = t;
        FORD(i,sz-1,0)
        {
            int nx = s[i] - 'a';
            if (cur -> next[nx] == NULL)
            {
                cur -> next[nx] = new Trie();
            }
            FOR(j,0,25)
            {
                if (dem[j]) ++cur -> cnt[j];
            }
            --dem[nx];
            cur = cur -> next[nx];
        }
    }
    cout << ans;
    return 0;
}


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

int n,dp[300005][5],arr[300005][5];

int main()
{
	cin >> n;
	for(int i=0;i<n;i++) 
	for(int j=0;j<3;j++)
	scanf("%d",&arr[i][j]);
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					dp[i+1][k] = max(dp[i+1][k],dp[i][j]+arr[i][k]);
				}
			}
		}
	}
	int res = max(dp[n][0],dp[n][1]);
	res = max(res,dp[n][2]);
	printf("%d\n",res);
	
	return 0;
} 

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int P, M, C;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> P >> M >> C;
    int ans = P + M + C;
    cout << ans << endl;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,x,r;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a==0)
	{
		r=(b/x)+1;
	}	else
		r=(b/x)-(a-1)/x;
		
		printf("%lld",r);
		return 0;
}

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

struct info {
    int length, start;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    S.push_back('1');
    int zero_cnt = 0;
    vector<info> code;
    info tmp;
    tmp.length = 0;
    tmp.start = 0;
    code.push_back(tmp);
    for (int i = 0; i <= N; i++) {
        if (S[i] == '0') {
            zero_cnt++;
        }
        else if (S[i] == '1' && zero_cnt > 0) {
            info now;
            now.length = zero_cnt;
            now.start = i - zero_cnt;
            code.push_back(now);
            zero_cnt = 0;
        }
    }
    tmp.length = 0;
    tmp.start = N;
    code.push_back(tmp);
    if (code.size() - 2 <= K) {
        cout << N << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 1; i < code.size() - K; i++) {
        int now_ans = code[i + K].start - 1 - (code[i - 1].start + code[i - 1].length) + 1;
        ans = max(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>

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

	int max = -1, min = 100000;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		max = std::max(a, max);
		min = std::min(a, min);
	}

	std::cout << max - min << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{int a,b;
scanf("%d %d",&a,&b);
if(a,b==1||2||3 && a!=b)
{
if(a==1 && b==2)
 printf("3\n");
if(a==1 && b==3)
 printf("2\n");
if(a==2 && b==3)
 printf("1\n");
if(a==2 && b==1)
 printf("3\n");
if(a==3 && b==1)
 printf("2\n");
 if(a==3 && b==2)
 printf("1\n");
 }
 return 0;
 }


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 105
using namespace std;
int n,sum,A[li];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		sum+=A[i];
	}
	if(sum%10!=0){
		printf("%d\n",sum);
		return 0;
	}
	sort(A+1,A+n+1);
	for(int i=1;i<=n;i++){
		if(A[i]%10!=0){
			sum-=A[i];
			printf("%d\n",sum);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    vector<int> a(3);
    for(int i=0;i<3;i++) cin >> a[i];
    sort(all(a));
    if((a[0] == a[1]) && (a[1] != a[2])) cout << "Yes\n";
    else if((a[1] == a[2]) && (a[1] != a[0])) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=1000005;
const int mod=998244353;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int pre[MAXN],inv[MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int n,m;
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();m=read();
	int ans=0;
	for(int i=0,j=0;i<=n&&j<=m;i++,j++)if(i!=0||j!=0)
	{
		int val=1LL*max(i,j)*pow_mod(i+j,mod-2)%mod;
		int down=1LL*inv[n+m]*pre[i+j]%mod*C(n+m-i-j,n-i)%mod*inv[i]%mod*inv[j]%mod;
		ad(ans,1LL*val*down%mod);
	}pr2((1LL*ans*pre[n]%mod*pre[m]%mod+max(n,m))%mod);
	return 0;
}


Measured memory_bytes: 7936
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<lint> G[200050]; // MAX_V,隣接リスト
lint root;

lint parent[20][200050]; // logMAX_V,MAX_V
lint depth[200050];

void LCAdfs(lint v,lint p,lint d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()) if(G[v][i]!=p) LCAdfs(G[v][i],v,d+1);
}

void LCAinit(lint V){
    LCAdfs(root,-1,0);
    for(int k=0;k+1<20;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

lint LCA(lint u,lint v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<20;k++){
        if((depth[v]-depth[u])>>k&1) v=parent[k][v];
    }
    if(u==v) return u;
    for(int k=20-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<int> path(int s,int t){
    int lca=LCA(s,t);
    vector<int> ps,pt;
    int now=s;
    while(true){
        if(now==lca) break;
        ps.push_back(now);
        now=parent[0][now];
    }
    now=t;
    while(true){
        pt.push_back(now);
        if(now==lca) break;
        now=parent[0][now];
    }
    reverse(pt.begin(),pt.end());
    ps.insert(ps.end(),pt.begin(),pt.end());
    return ps;
}

vector<pint> edge[MAX_N];
bool reach[MAX_N];
lint dis[MAX_N];

void dfs(int now,lint sum){
    if(reach[now]) return;
    reach[now]=true;
    dis[now]=sum;
    rep(i,edge[now].size()){
        dfs(edge[now][i].fi,sum+edge[now][i].se);
    }
}


int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edge[u].push_back(pint(v,w));
        edge[v].push_back(pint(u,w));
    }
    LCAinit(N);
    dfs(0,0);
    int Q,K;
    cin >> Q >> K;
    K--;
    rep(i,Q){
        int x,y;
        cin >> x >> y;
        x--,y--;
        int lca=LCA(x,K);
        lint ans=dis[x]+dis[K]-2*dis[lca];
        lca=LCA(K,y);
        ans+=dis[K]+dis[y]-2*dis[lca];
        cout << ans << endl;
    }
}

Measured memory_bytes: 41328
#include<cstdio>
#include<algorithm>
using namespace std;

#define INF (1<<12)

typedef struct{
  int cost,time;
}T;

int n,m;
T dp[111][111];

void init();
void warshall();

int main(){
  int a,b,cost,time;
  int k;
  int p,q,r;
  
  while(true){
    
    scanf(" %d %d",&n,&m);
    if(n == 0 && m == 0)break;
    
    // 初期処理
    init();
    
    for(int i=0;i<n;i++){
      scanf(" %d %d %d %d",&a,&b,&cost,&time);
      dp[a][b].cost = cost;
      dp[a][b].time = time;
      dp[b][a].cost = cost;
      dp[b][a].time = time;
    }
    
    warshall();
    
    scanf(" %d",&k);
    for(int i=0;i<k;i++){
      scanf(" %d %d %d",&p,&q,&r);
      if(r){
	printf("%d\n",dp[p][q].time);
      } else {
	printf("%d\n",dp[p][q].cost);
      }
    }
  }
  
  return 0;
}

void init(){
  
  for(int i=0;i<=m;i++){
    for(int j=0;j<=m;j++){
      if(i==j){
	// 今いるところから今いるところまではcost,timeともに0
	dp[i][j].cost = 0;
	dp[i][j].time = 0;
      } else {
	// 他はINF
	dp[i][j].cost = INF;
	dp[i][j].time = INF;
      }
    }
  }
  
  return;
}

void warshall(){
  
  for(int k=1;k<=m;k++){
    for(int i=1;i<=m;i++){
      for(int j=1;j<=m;j++){
	dp[i][j].cost = min(dp[i][j].cost,dp[i][k].cost + dp[k][j].cost);
	dp[i][j].time = min(dp[i][j].time,dp[i][k].time + dp[k][j].time);
      }
    }
  }
  
  return;
}

Measured memory_bytes: 2664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
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;
}

typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<P> V;
    REP(i,N){
        int a;
        cin >> a;
        V.push_back(P(a,i+1));
    }
    so(V);
    REP(i,N){
        if(i != 0)cout << " ";
        cout << V[i].second;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

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

int main(){
    fast_io


    int n, q;
    cin>>n>>q;

    string str;
    cin>>str;

    vector<int> s(n+1, 0);
    rep(i,n){
        if(i+1<n && str[i]=='A'&&str[i+1]=='C') s[i+1]=s[i]+1;
        else s[i+1]=s[i];
    }

    rep(i, q){
        int l, r;
        cin>>l>>r;
        l--, r--;
        cout<<s[r]-s[l]<<endl;
    }


    return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void chmax(int& a, int b) {
  if (a < b) a = b;
}
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  string c;
  cin >> c;
  int nR = 0;
  int nW = 0;
  REP(i, n) {
    if (c[i] == 'R') nR++;
  }
  nW = n - nR;
  int ans = 0;
  REP(i, nR) {
    if (c[i] == 'W') ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
    int n, ans = 0;  cin >> n;
    int a[n];
    rep(i,n)  cin >> a[i];

    while (true) {
        bool flag = false;
        rep(i,n) {
            if (a[i] % 2 != 0) {
                flag = true;
                break;
            }
        }
        if (flag)  break;
        rep(i,n)  a[i] /= 2;
        ans++;
    }

    cout << ans << endl;
}

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

typedef long long ll;

typedef pair<ll, pair<int, int> > p;

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

    string S;
    cin >> S;

    vector<int> x(26);

    for(int i = 0; i < S.length(); i++) {
        x[S[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++) {
        if(x[i] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  if(100<=N && N<=111){
    printf("111\n");
    return 0;
  }

  for(int i=1;i<=8;i++){
    if(100*i+10*i+i<N && N<=100*(i+1)+10*(i+1)+i+1){
      printf("%d\n",100*(i+1)+10*(i+1)+i+1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 128
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Data Type ----------------------------------------------------------------

#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Stl ----------------------------------------------------------------------

#define ff                  first
#define ss                  second
#define pb                  push_back
#define eb                  emplace_back
#define vll                 vector<ll>
#define vvl                 vector<vll>
#define pll                 pair<ll,ll>
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Extra --------------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print(any)          for(auto &i:any) cout<<i<<" "; nl;
#define precise(a)          cout<<fixed<<setprecision(a)
#define nl                  std::cout<<'\n'
#define INF                 LLONG_MAX
#define endl                '\n'

// Template -----------------------------------------------------------------

template <typename T> 
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U> 
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a,U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream& operator >> (istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >> (istream &in, pair<T,U> &a) {
    in >> a.ff >> a.ss; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, x, y;
    inp(n,x,y);

    vll ans(n+1);
    loop(i,1,n+1)
    {
        loop(j,i+1,n+1)
        {
            ll z = abs(j-i);
            z = min(z,abs(i-x)+1+abs(j-y));
            z = min(z,abs(j-x)+1+abs(i-y));
            ans[z]++;
        }
    }
    loop(i,1,n) std::cout<<ans[i]<<"\n";
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif
    
    fast;
    int t = 1;
    loop(i,1,t+1)
    solve(i);
    return 0;
}

Measured memory_bytes: 256