akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

int main() {
  string s;
  cin >> s;
  
  if(s=="RRR")
    cout << 3 << endl;
  else if(s=="RRS" || s=="SRR")
    cout << 2 << endl;
  else if(s=="RSS" || s=="RSR" || s=="SSR" || s=="SRS")
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
    int n, m, l;
    int i, j, k;
    long int A[100][100] = {0}, B[100][100] = {0}, C[100][100] = {0};
    
    scanf("%d %d %d", &n, &m, &l);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
                scanf("%lld", &A[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
                scanf("%lld", &B[i][j]);
        }
    }   
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%lld", C[i][j]);
            if(j == l-1){
                printf("\n");
            }
            else{
                printf(" ");
            }
        }
    }
    return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int r; cin >> r;
	cout << double(2*r*M_PI) << endl;
	return 0;
}

Measured memory_bytes: 3780
from math import *

a, b, h, m = map(int, input().split())

h = h*30 + m*30/60
m *= 6
deg = abs(h-m)
deg = min(360-deg, deg)

print((a**2+b**2-2*a*b*cos(deg/180*3.141592653589793238462))**0.5)

Measured memory_bytes: 9504
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vii v(n,vi(3));
    rep(i, 0, n)
    {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    int dp[n + 1][3];
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    rep(i, 1, n + 1)
    {
        rep(j, 0, 3)
        {
            dp[i][j] = -intlimit;
        }
    }
    rep(i, 0, n)
    {
        dp[i + 1][0] = v[i][0] + max(dp[i][1], dp[i][2]);
        dp[i + 1][1] = v[i][1] + max(dp[i][0], dp[i][2]);
        dp[i + 1][2] = v[i][2] + max(dp[i][1], dp[i][0]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]});
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int S1,S2,S3,S;
  cin >> S;
  S1=S%10,S2=(S%100-S1)/10,S3=(S%1000-10*S2-S1)/100;
  cout<< S1+S2+S3 << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    int N;
    double a= 0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if(i%3 !=0 && i%5 != 0){
            a += i;
            //cout << i <<"\n";
        }
    }
    cout << setprecision(100)<<a;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    if (N%2 == 0) {
        if (2*K > N) {
            cout << -1 << endl;
            return 0;
        }
        vector<vector<int>> ans;
        for (int i = 0; i < N/2; i++) {
            ans.push_back({K+N/2+i, K+2*N-1-2*i, K+3*N-1-i});
        }
        for (int i = 0; i < N/2; i++) {
            ans.push_back({K+i, K+2*N-2-2*i, K+3*N-1-N/2-i});
        }
        for (vector<int> a : ans) {
            cout << a[0] << " " << a[1] << " " << a[2] << "\n";
        }
    }
    else if (N%2 == 1) {
        if (2*K > N+1) {
            cout << -1 << endl;
            return 0;
        }
        vector<vector<int>> ans;
        for (int i = 0; i < (N+1)/2; i++) {
            ans.push_back({K+(N-1)/2+i, K+2*N-1-2*i, K+3*N-1-i});
        }
        for (int i = 0; i < (N-1)/2; i++) {
            ans.push_back({K+i, K+2*N-2-2*i, K+3*N-1-(N+1)/2-i});
        }
        for (vector<int> a : ans) {
            cout << a[0] << " " << a[1] << " " << a[2] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 8368
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
lli dp[S];
int main()
{
    fast
    // test
    {
        lli n;
        cin>>n;
 
            for(lli a=1;a<=100;a++)
            {
                for(lli b=1;b<=100;b++)
                {
                    for(lli c=1;c<=100;c++)
                    {
                        lli no=((pow((a+b),2))+(pow((b+c),2))+(pow((c+a),2)));
                        if(no<S&&no%2==0)
                        {
                            no=no/2;
                            dp[no]++;
                        }
                       
                    }
                }
            }
            for(lli i=1;i<=n;i++)
            {
                cout<<dp[i]<<"\n";
            }
        }
        
    }

//a+b=a?b+2?(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;

int main(){
    int M;
    cin>>M;
    cout<<48-M<<"\n";
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int MAX_VALUE = 1'000'000'000;

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  int rest = s % MAX_VALUE + 1;
  for (int i = 0; i < k; i++) {
    cout << s << endl;
  }
  for (int i = k; i < n; i++) {
    cout << rest << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ln '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
#define cad static_cast<long double>
#define deb(z) cout << "// " << #z << " = " << z << '\n';
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;


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

#ifdef _DEBUG
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int h, a; cin >> h >> a;
	cout << cai(ceil(1.0 * h / a)) << '\n';

	return 0;
}


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

#define DIV 998244353

long long N, S;
long long A[3005];
long long dp[3005][3005];

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

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

	dp[0][0] = modpow(2, N);
	for(long long i = 0; i < N; i++) {
		for(long long j = 0; j < 3005; j++) {
			//そのまま
			dp[i+1][j] += dp[i][j];
			dp[i+1][j] %= DIV;

			//A[i]を使う
			if(j + A[i] <= S) {
				dp[i+1][j+A[i]] += dp[i][j] * modpow(2, DIV-2);
				dp[i+1][j+A[i]] %= DIV;
			}
		}
	}
	cout << dp[N][S] << endl;

}



Measured memory_bytes: 74100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0;
    while(n) {
        ans += n % 10;
        n /= 10;
    }
    if (ans == 1) ans = 10;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    string s;
    cin >> s;
    vector<int> X,Y;
    int disx,disy;
    cin >> disx >> disy;
    ll N = s.size();
    ll turn = 0;
    ll d1;
    ll ct=0;
    bool first = true;
    for(int i=0;i<N;i++){
        if(s[i]=='T'){
            if(turn==0){
                if(first){
                    d1 = ct;
                    first = false;
                }
                else X.push_back(ct);
                ct = 0;
                turn = 1;
            }
            else{
                Y.push_back(ct);
                ct = 0;
                turn = 0;
            }
        }
        else ct++;
    }
    if(ct!=0){
        if(turn==0) {
            if(first) d1 = ct;
            else X.push_back(ct);
        }
        else Y.push_back(ct);
    }

    vector<vector<int>> dpx(X.size()+10,vector<int>(16010,0));
    vector<vector<int>> dpy(Y.size()+10,vector<int>(16010,0));
    int margin = 8000;
    dpx[0][margin+d1]=1;
    dpy[0][margin]=1;


    for(int i=0;i<X.size();i++){
        for(int j=0;j<2*margin;j++){
            if(dpx[i][j]==1){
                dpx[i+1][j-X[i]]=1;
                dpx[i+1][j+X[i]]=1;
            }
        }
    }

    for(int i=0;i<Y.size();i++){
        for(int j=0;j<2*margin;j++){
            if(dpy[i][j]==1){
                dpy[i+1][j-Y[i]]=1;
                dpy[i+1][j+Y[i]]=1;
            }
        }
    }

    if(dpx[X.size()][margin+disx]==1 && dpy[Y.size()][margin+disy]==1){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 497920
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# グラフが単純⇔グラフがループや多重辺をもたない
# グラフが連結⇔グラフの任意の２頂点に対し、それらを結ぶパス(辺)が存在
# 1 - 3 - 2
# 1 - 3
# |   |
# 2 - 4

# ある整数Sが存在して、任意の頂点についてその頂点に隣接する頂点の番号の値の和はSとなる
# このSは都合の良いもので設定できる

# まず全部繋ぐ N = 5の時
# 5: 1 2 3 4
# 4: 1 2 3 5
# 3: 1 2 4 5
# 2: 1 3 4 5
# 1: 2 3 4 5
# sumから何かを引いたら何かになる

N = getN()
dist = set()
if N % 2 == 0:
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if i != j and i + j != (N + 1):
                dist.add((min(i, j), max(i, j)))
if N % 2 != 0:
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if i != j and i + j != N:
                dist.add((min(i, j), max(i, j)))

dist = list(dist)
print(len(dist))
for a, b in dist:
    print(a, b)


Measured memory_bytes: 11212
#include <cstdio>
#include <string>
using namespace std;
int main() {
	int n;
		scanf("%d", &n);
		int array[n];
		for (int i=0; i < n; i++) {
			scanf("%d", &array[i]);
		}
		for (int j=n-1; j > 0; j--) {
			printf("%d ", array[j]);
		}
		printf("%d\n", array[0]);
}


Measured memory_bytes: 2668
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

typedef struct{
	double x;
	double y;
}point;

void Printp(point a){
	printf("%lf %lf\n", a.x, a.y);
}

void koch(int d, point p, point q){
	if(d==0) return;
	
	point s, u, t;
	//calculation
	s.x=(2*p.x+q.x)/3.0;
	s.y=(2*p.y+q.y)/3.0;
	t.x=(p.x+2*q.x)/3.0;
	t.y=(p.y+2*q.y)/3.0;
		
	double ang=M_PI*60/180.0;
	u.x=(t.x-s.x)*cos(ang) - (t.y-s.y)*sin(ang) +s.x;
	u.y=(t.x-s.x)*sin(ang) + (t.y-s.y)*cos(ang) +s.y;
	
	koch(d-1, p, s);
	Printp(s);
	koch(d-1, s, u);
	Printp(u);
	koch(d-1, u, t);
	Printp(t);
	koch(d-1, t, q);
}

int main(){
	int n;
	scanf(" %d", &n);
	
	point s1,s2;
	s1.x=0; s1.y=0;
	s2.x=100; s2.y=0;
	
	Printp(s1);
	koch(n, s1, s2);
	Printp(s2);
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		System.out.println(s.substring(0,5) + " " + s.substring(6, 13) +" " + s.substring(14, 19));
		
		scan.close();

	}

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double pt_ln_dst(double a, double b, double c, double px, double py){
    return abs(a*px + b*py + c)/sqrt(a*a + b*b);
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    int l = -1, r = -1;
    rep(i, S.length()-1) if(S[i] == S[i+1]){l = i+1; r = i+2;}
    rep(i, S.length()-2) if(S[i] == S[i+2]){l = i+1; r = i+3;}
    cout << l << " " << r << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;
  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(200000);
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int l;
      cin >> l;
      uf.unite(i, 100000 + l - 1);
    }
  }
  bool ok = true;
  REP(i, n) {
    if (!uf.same(0, i)) ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 1792
import numpy as np
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())

flag=True
sum=0
sorted_index=np.argsort(b)
for i in sorted_index:
  sum+=a[i]
  if sum>b[i]:
    flag=False
    break
    
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 43968
N=int(input())
SP=[[0 for i in range(3)] for j in range(N)]
for x in range(N):
    SP[x][0],SP[x][1]= input().split()
    SP[x][1] =int(SP[x][1])
    SP[x][2]=x+1

SP.sort(key=lambda x:(x[0],-x[1]))

for x in range(N):
    print(SP[x][2])

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

int main(){
  vector<int> vec(3);
  for(int i = 0; i < 3; i++){
  cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());

  for(int j = 0; j<vec.size()-1;j++){
    cout << vec.at(j) << " ";
   }

  cout << vec.at(vec.size()-1) << endl;

}


Measured memory_bytes: 3152
n = int(input())
for i in range(10**3):
    if n == i*(i+1)//2:
        x = i
        break
else:
    print("No")
    exit()
ans = [[] for i in range(x+1)]
app = 0
for i in range(1,x+1):
    for j in range(i):
        app += 1
        ans[j].append(app)
    ans[i].extend([k for k in range(i*(i-1)//2+1,i*(i+1)//2+1)])
print("Yes")
print(x+1)
for ansarr in ans:
    print(x, *ansarr, sep = " ")

Measured memory_bytes: 12552
#include <vector>
#include <iostream>

using namespace std;

int MaxDistance(int a, int b, int c){
    int md=0;
    int td1, td2, td3;

    td1=a-b;
    td2=a-c;
    td3=b-c;

    if(td1<0)td1*=-1;
    if(td2<0)td2*=-1;
    if(td3<0)td3*=-1;

    md = td1;
    if(md < td2){
        md = td2;
    }
    if(md < td3){
        md = td3;
    }

    return md;
}

int main(){
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    cout << MaxDistance(A1, A2, A3) << endl;

    return 0;
}


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

int main() 
{
    char s[100], r[100];
    int count = 0;

    scanf("%s", s);
    int len = strlen(s);

    for (int i=0; i<len/2; i++) {
        if (s[i] != s[len-i-1]) count++;
    }

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


    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define max 2001

int mm[max];

int main(void){
    int n,x,y;
    map<string, int> m;

    cin >> n >> x >> y;

    x -= 1;
    y -= 1;
    for(int i=0;i<n-1;i++){
        for(int k=1;k<n;k++){
            if(k > i){
                int nn = k-i;
                
                nn = (nn < ( abs(k-y) + abs(x-i) +1 ) ) ? nn : abs(k-y) + abs(x-i) +1;
                

                if(nn > 0 && nn <= n-1) mm[nn-1] ++;
            }
        }
    }
    
    for(int i=0;i<n-1;i++) cout << mm[i] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int K, T;
	cin >> K >> T;
	vector<int> a(T);
	rep(i,T) cin >> a[i];
	sort(all(a));
	int mx = 0;
	for(int i = 0; i < a.size(); i++) {
		mx = max(mx, a[i]);
	}

	if(K-mx >= mx-1) {
		cout << 0 << endl;
	}
	else {
		cout << mx - (K-mx+1) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut uf = UnionFind::new(n);
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        uf.unite(a, b);
    }

    let mut max = 0;
    for i in 0..n {
        let root = uf.find(i);
        max = cmp::max(max, uf.sizes[root]);
    }
    println!("{}", max);
}
pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    size: usize,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            size: n,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;
        self.size -= 1;
        true
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5172
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      
      Console.WriteLine(A*B);
    
    }
    
  }

}

Measured memory_bytes: 27524
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

struct UnionFind
{
	int n;
	std::vector<int> par,size;
	UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
		std::iota(par.begin(),par.end(),0);
	}
	int find(int x) {
		if(par[x]==x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x=find(x);y=find(y);
		if(x==y) return;
		if(size[x]<size[y]) std::swap(x,y);
		size[x]+=size[y];
		par[y]=x;
	}
};


int main() {
	int n,m;
	std::cin >> n >> m;
	UnionFind uf(n);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		uf.unite(a,b);
	}
	std::set<int> set;
	rep(i,n) set.emplace(uf.find(i));
	print((int)set.size()-1);
}


Measured memory_bytes: 7780
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto & x : a)
        cin >> x;
    int cnt = 0;
    for (int i = 0; i < n; i += 2) {
        cnt += a[i]%2;
    }
    cout << cnt << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


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

int main() {
	long long X;
	int ans=0;
	cin >> X;

	if (X / 500 > 0) {
		ans += (X / 500) * 1000;
		if ((X % 500) / 5 > 0) {
			ans += ((X % 500) / 5) * 5;
		}
	}
	else
		ans += (X / 5) * 5;

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
k=10000
for i in a:
    ans+=b[i-1]
    if k==i-1:
        ans+=c[i-2]
    k=i
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
long long maxa=(1e16)+1000;
long long V[55];
long long K;
long long T[55];
long long baga[55];
long long maxop(int N,int st)
{
    long long nr=0;
    bool ok;
    for(int i=1;i<=N;i++)baga[i]=0;
    for(int i=1;i<st;i++)
        V[i]=T[i];
    for(int i=st;i<=N;i++)V[i]=maxa;
    do
    {
        ok=0;
        for(int i=1;i<=N;i++)
        {
            V[i]+=baga[i];
            if(V[i]>=N)
            {
                nr+=V[i]/N;ok=1;
            }
        }
        for(int i=1;i<=N;i++)
        {
            baga[i]=0;
            for(int j=1;j<=N;j++)
            {
                if(i!=j)
                {
                    baga[i]+=V[j]/N;
                }
            }
        }
        for(int i=1;i<=N;i++)
        {
            V[i]%=N;
        }
    }
    while(ok);
    return nr;
}
int main()
{
    cin>>K;
    for(int i=1;i<=K;i++)cin>>T[i];
    cout<<maxop(K,K+1);
    return 0;
}


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

const int INF = 100000000;
typedef pair<int,int> P;

char maze[20][21];
int N, M;
//int sx, sy;
//int gx, gy;
int mx = 0;

int d[20][21];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

void bfs(int sx, int sy) {
    queue<P> que;
    rep(i,N) {
        rep(j,M) {
            d[i][j] = INF;
        }
    }
    que.push(P(sx,sy));
    d[sx][sy] = 0;
    
    while(que.size()) {
        P p = que.front();
        que.pop();
        //if(p.first == gx && p.second == gy)
            //break;
        
        for(int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            
            if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                mx = max(mx,d[nx][ny]);
            }
        }
    }
    
    //return d[gx][gy];
}

int main() {
    cin >> N >> M;
    rep(i,N) {
        rep(j,M) {
            cin >> maze[i][j];
        }
    }
    
    rep(i,N) {
        rep(j,M) {
            if(maze[i][j] != '#')
               bfs(i,j);
        }
    }
    
    cout << mx << endl;
    
    
    return 0;
}




Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const long long infinity=0x3f3f3f3f;
const int maxn=3000+10;
int n;
int f[maxn][maxn];
int x,y,z;
int a,b;
int c,d;
int main()
{
    memset(f,infinity,sizeof(f));
    scanf("%d%d%d",&n,&a,&b);
    f[0][0]=0;
    
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&x,&y,&z);
		c=1000-x,d=1000-y;
		for(int j=c;j>=0;j--){
			for(int k=d;k>=0;k--){
				f[j+x][k+y]=min(f[j][k]+z,f[j+x][k+y]);
			}
		} 
	}
//	cout<<f[3*a][3*b]<<endl;
	int ans=infinity;
	int g=min(1000/x,1000/y);
	for(int i=1;i<=g;i++){
		ans=min(ans,f[i*a][i*b]);
	}
	
	if(ans!=infinity)
	printf("%d",ans);
	else printf("-1");

	return 0;
}

Measured memory_bytes: 35584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] left = new int[N];
		int[] right = new int[N];
		for(int i = 0; i < N; i++) {
			left[i] = Integer.parseInt(sc.next());
			right[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		int seat = 0;
		for(int i = 0; i < N; i++) {
			seat += right[i] - left[i] + 1;
		}
		System.out.println(seat);
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>

using namespace std;


int main() {
	int n;
	cin >> n;
	int a[n];

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

	int max_abs = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			max_abs = max(abs(a[i] - a[j]) , max_abs);
		}
	}

	cout << max_abs << endl;


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef pair< int , int > Pi;

Pi operator+(const Pi& a,const Pi& b){
  return Pi( a.first + b.first, a.second + b.second);
}
Pi operator-(const Pi& a,const Pi& b){
  return Pi( a.first - b.first, a.second - b.second);
}

bool isfoo7(Pi* target, Pi* star, Pi shift, int n, int m){
  for(int i = 1; i < m; i++){      
    if(!binary_search( star, star + n, target[i] + shift)) return false;
  }
  return true;
}

int main()
{
  int m, n;
  Pi target[200], star[1000];
  Pi shift;


  while(scanf("%d", &m), m){
    for(int i = 0; i < m; i++){
      scanf("%d %d", &target[i].first, &target[i].second);
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
      scanf("%d %d", &star[i].first, &star[i].second);
    }

    sort( target, target + m);
    sort( star, star + n);

    for(int i = 0; i < n; i++){
      shift = star[i] - target[0];
      if(isfoo7( target, star, shift, n, m)) break;
    }
    printf("%d %d\n", shift.first, shift.second);
  }
  return(0);
}

Measured memory_bytes: 1036
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn=100+10;
char cmd[20];
int d;
int n;
struct Node
{
    int key;
    Node* left;
    Node* right;
};
int cnt;
Node *root=NULL;
void in_order(Node *p)
{
    if(p==NULL) return;
     in_order(p->left);
     printf(" %d",p->key);
    in_order(p->right);
}
void pre_order(Node *p)
{
     if(p==NULL) return;
     printf(" %d",p->key);
      pre_order(p->left);
    pre_order(p->right);
}
void print()
{
    in_order(root);
    printf("\n");
    pre_order(root);
    printf("\n");
}
void post_delete(Node *p)
{
     if(p==NULL) return;
    post_delete(p->left);
    post_delete(p->right);
    free(p);
}
void insert(int k)
{
   Node * node=(Node *)malloc(sizeof(Node));
   node->key=k;
   node->left=NULL;
   node->right=NULL;

   Node *p=NULL;
   Node *q=root;
   while(q!=NULL)
   {
       p=q;
       if(p->key>k)
       {
           q=q->left;
       }
       else q=q->right;
   }
   if(p==NULL)
   {
        root=node;
   }
   else if(p->key>k)
   {
       p->left=node;
   }
   else p->right=node;

}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {

        scanf("%s",cmd);
        switch(cmd[0])
        {
        case 'i':
        {
            scanf("%d",&d);
            insert(d);
            break;
        }
        case 'p':
        {
            print();
            break;

        }
        }
    }
    post_delete(root);
    return 0;
}

Measured memory_bytes: 18828
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=205,mod=998244353;
typedef long long LL;
int n,tot;
LL ans,f[N][N],g[N][N];

struct P
{
	int x,y;

	P operator - (P t) {return (P){x-t.x,y-t.y};}
	int operator * (P t) {return -t.x*y+x*t.y;}
} dat[N],p[N],tmp;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int sqr(int x)
{
	return x*x;
}

int dis(P a,P b)
{
	return sqr(a.x-b.x)+sqr(a.y-b.y);
}

bool cmp(P a,P b)
{
	int x=(a-tmp)*(b-tmp);
	return !x?(dis(a,tmp)<dis(b,tmp)):x>0;
}

bool check(P a,P b,P c,P d)
{
	int t=abs((a-c)*(b-c));
	int s=abs((a-c)*(d-c))+abs((b-a)*(d-a))+abs((c-b)*(d-b));
	return t==s && ((a-c)*(d-c));
}

void solve(int x)
{
	p[tot=1]=tmp=dat[x];
	rep(i,1,n) if(i!=x)
		if(dat[i].y>dat[x].y || (dat[i].y==dat[x].y && dat[i].x>=dat[x].x))
			p[++tot]=dat[i];
	sort(p+2,p+1+tot,cmp);
	rep(i,2,tot-1) rep(j,i+1,tot)
	{
		g[i][j]=1;
		rep(k,i+1,j-1)
			if(check(p[i],p[j],tmp,p[k]))
				g[i][j]=g[i][j]*2%mod;
	}
	rep(i,1,tot) rep(j,1,tot) f[i][j]=0;
	rep(i,2,tot)
	{
		f[1][i]=1;
		rep(j,2,i-1) if((p[i]-tmp)*(p[j]-tmp)==0) f[1][i]=f[1][i]*2%mod;
	}
	rep(i,1,tot-2)
		rep(j,i+1,tot-1)
			rep(k,j+1,tot)
				if((p[k]-p[j])*(p[i]-p[j])>0)
					f[j][k]=(f[j][k]+g[j][k]*f[i][j])%mod;
	rep(i,2,tot-1) rep(j,i+1,tot) 
		if((tmp-p[j])*(p[i]-p[j])>0) ans=(ans+f[i][j])%mod;
}

int main()
{
	n=getint();
	rep(i,1,n)
		dat[i].x=getint(),dat[i].y=getint();
	rep(i,1,n)
		solve(i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	arr := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	k := scanInt()

	fmt.Fprintln(wr, arr[k-1])
}


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

using namespace std;

int main(){
  long long int a,b[100010],c[100010],d;
  
  cin >> a;
  
  for(int i=0;i<=a;i++)
    cin >> b[i];
  
  for(int i=0;i<a;i++)
    cin >> c[i];
  
   d=0;
  for(int i=0;i<a;i++){
    
    if(b[i]>=c[i]) d+=c[i];
    
    else{
      if(b[i]+b[i+1] <= c[i]){
        d += (b[i]+b[i+1]);
        
        b[i+1] = 0;
      }
      else if(b[i] +b[i+1] >c[i]){
        d += c[i];
        
        b[i+1] -= (c[i]-b[i]);
      }
    }
  }
  
  cout << d << endl;
}


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

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

using namespace std;

int main(){
	int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
	while(1){
		c-=b;
		if(c<=0) return puts("Yes"),0;
		a-=d;
		if(a<=0) return puts("No"),0;
	}
	return 0;
}


Measured memory_bytes: 3660
/*author : Yashvardhan
Friday, May 31, 2019
10:13 AM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
const int N = 100005;

int arr[N];
int segt[4*N];

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

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

void build(int v, int tl, int tr){
	//debug(v,tl,tr);
	if(tl == tr){
		segt[v] = arr[tl];
	}	
	else{
		int tm = (tl + tr) / 2;
		build(2 * v, tl, tm);
		build(2 * v + 1, tm + 1, tr);
		segt[v] = gcd(segt[2 * v], segt[2 * v + 1]);
	}
	
}

int query(int v, int tl, int tr, int l, int r){
	//debug(v,tl,tr);
	if(l > tr || r < tl) return 0;
	if(l <= tl && r >= tr) return segt[v];
	int tm = (tl+tr)/2;
	return gcd(query(2*v,tl,tm,l,r),query(2*v+1,tm+1,tr,l,r));
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;

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

	build(1,0,n-1);

	int ans = -1;
	for(int i = 1; i < n - 1 ; i++){
		ans = max(gcd(query(1,0,n-1,0,i-1),query(1,0,n-1,i+1,n-1)), ans);
	}

	ans = max(ans,query(1,0,n-1,1,n-1));
	ans = max(ans,query(1,0,n-1,0,n-2));

	cout<<ans<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 3072
#include <iostream>

int main()
{
    int N, C[20], V[20];
    std::cin >> N;

    for (int i = 0; i < N; ++i)
    {
        std::cin >> V[i];
    }

    for (int i = 0; i < N; ++i)
    {
        std::cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        if (V[i] >= C[i])
        {
            ans += V[i] - C[i];
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# for i in A:
# 	if x-i-1 < 0:
# 		minus.append(x-i-1)
# 	elif x-i-1 == 0:
# 		zero.append(0)
# 	else:
# 		plus.append(-(x-i-1))
# if len(zero) + minus and len(zero) > plus:
# 	print(sum(plus)+sum(minus))
# else:
# 	len(minus) > len(zero) and 
B = [x-i-1 for i, x in enumerate(A)]
B.sort()
# print(B)
B = [abs(x-B[len(B)//2]) for x in B]
# print(B)
print(sum(B))
# print(sum(B)-abs(B[len(B)//2])*N)


Measured memory_bytes: 28284
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial

def main():
    data = list(input())
    num = len(data)

    move_dic = [0 for i in range(num)]

    now_ind = 0
    count_l = 0
    count_r = 0

    while now_ind < num:
        if data[now_ind] == 'R':
            while data[now_ind] == 'R':
                count_r += 1
                now_ind += 1
            for i in range(count_r)[::-1]:
                move_dic[now_ind - count_r + i] = count_r - i
                # print(now_ind, count_r)
            # now_ind += count_r
            count_r = 0
            count_l = 0
        else:
            count_l -= 1
            move_dic[now_ind] = count_l
            now_ind += 1

    # print(move_dic)

    ans_list = [0 for i in range(num)]
    for i in range(num):
        if move_dic[i] > 0:
            if move_dic[i] % 2:
                ans = i + 1 + move_dic[i] - 1
            else:
                ans = i + 1 + move_dic[i]
        else:
            aaa = abs(move_dic[i])
            if aaa % 2:
                ans = i + 1 + move_dic[i] + 1
            else:
                ans = i + 1 + move_dic[i]
        ans_list[i] = ans

    # print(ans_list)
    ans_data = Counter(ans_list)
    for i in range(1, num + 1):
        print(ans_data[i], end='')
        if i == num:
            print()
        else:
            print(' ',end='')




if __name__ == '__main__':
    main()


Measured memory_bytes: 78072
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin >> A[i];
    }
    SORT(A);
    ll ans = 0;
    REP(i, N){
        ans += A[i*2+N];
    }
    pr(ans);
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int value[1005];
int main() {
    long long n;
    cin >> n;
    string s;
    do {
        s = (char)((n - 1) % 26 + 'a') + s;
        n = (n-1) / 26;
    } while (n > 0);
    cout << s << endl;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())
A = []
B = []
pt = [[] for i in range(N)]
for i in range(M):
	a, b =  map(int, input().split())
	a -=1
	b -=1
	pt[a].append(b)
	pt[b].append(a)
n=N
res_list = [-1] * N
def bfs(v):
    d=[-1]*n
    d[v]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    d[j]=c
                    q1.append(j)
                    res_list[j]=i
        q=q1
        c+=1
    return d
res = bfs(0)

no = 'No'
yes ='Yes'
if -1 in res:
	print(no)
else:
	print(yes)
	
for i,x in enumerate(res_list):
	if i==0:
		continue
	print(x+1)


Measured memory_bytes: 34756