akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

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

	std::vector<int> aList(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	int rank=0;

	for(int i=0; i<n; i++)
		rank= (rank < aList[i])? aList[i] : rank;

	std::vector<int> rankList(rank+1, 0);

	for(int i=0; i<n; i++)
		rankList[aList[i]]++;

	long long ans= 1;
	long long mod= 998244353;

	for(int i= rank; i>0; i--){
		long long conv= 1;
		for(int j=0; j< rankList[i]; j++)
			conv= (conv*rankList[i-1])%mod;

		ans= (ans*conv)%mod;
	}

	if(rankList[0]!=1 || aList[0]!=0)
		ans=0;

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

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

void print_num(int n){
	if(n<10) cout<<"00000"<<n;
	else if(n<100) cout<<"0000"<<n;
	else if(n<1000) cout<<"000"<<n;
	else if(n<10000) cout<<"00"<<n;
	else if(n<100000) cout<<"0"<<n;
	else cout<<n;
}

int main() {
	int n,m;cin>>n>>m;
	int p[N],y[N];
	pii yp[N];
	rep(i,m){
		cin>>p[i]>>y[i];
		yp[i]=pii(y[i],p[i]);
	}
	sort(yp,yp+m);
	int pc[N];	// pref to count
	rep(i,N) pc[i]=0;
	map<int,int> yo;
	rep(i,m){
		int ty=yp[i].first;
		int tp=yp[i].second;
		pc[tp]++;
		yo[ty]=pc[tp];
	}
	rep(i,m){
		print_num(p[i]);
		print_num(yo[y[i]]);
		cout<<endl;
	}
}


Measured memory_bytes: 8192
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        int M = Input.nextInt();
        char A[][] = new char[N + 2][M + 2];
        String S[] = new String[N];
        for (int I = 0; I < N; I++) {
            S[I] = Input.next();
        }
try{
        for (int R = 0; R < A.length; R++) {
            for (int C = 0; C < A[0].length; C++) {
                if ((R >= 1 && C >= 1) && (R < N + 1 && C < M + 1)) {
                    A[R][C] = S[R - 1].charAt(C - 1);
                } else {
                A[R][C]='#';}
                System.out.print(A[R][C]);
            }
            System.out.println("");
        }
}catch(Exception e){}
    }
}

//Learn Before You Earn


Measured memory_bytes: 26452
T = list(input())
N = len(T)

for i in range(0, N-1):
    if T[i]+T[i+1] == "P?":
        T[i+1] = "D"
    elif T[i]+T[i+1] == "?D":
        T[i] = "P"
    elif T[i]+T[i+1] == "??":
        T[i] = "P"
        T[i+1] = "D"
    elif T[i] == "?":
        T[i] = "D"

if T[N-1] == "?":
    T[N-1] = "D"

print("".join(T))


Measured memory_bytes: 10816
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string s;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	cin >> s;
	int dem=0;
	for (int i=0; i+1<s.size(); i++)
	if (s[i]==s[i+1]) 
	{
		dem++;
		if (dem==2)
		{
			cout << "Yes";
			return 0;
		}
	}
	else
	{
		dem=0;
	}
	cout << "No";
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
    ll N;
    cin >> N;
    ll dig = ceil(log(N * 25.0 / 26.0 + 1) / log(26.0));

    string ans;
    N -= (pow(26, dig - 1) - 1) * 26 / 25 + 1;
    for (ll i = 0; i < dig; ++i) {
        ll mod = N % 26;
        N /= 26;

        ans = (char)(mod + 97) + ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3944
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	m := map[uint8]int{}

	for i:=0; i<4; i++ {
		m[s[i]] += 1
	}

	for _,v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")

}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve102(int n) {
    vector<int> v(n,0);
    vector<int> w(n,0);
    int k;
    REP(i,n) {
        REP(j,n) {
            cin >> k;
            printf("%5d", k);
            v[i] += k;
            w[j] += k;
        }
        printf("%5d\n", v[i]);
    }
    REP(i,n) {
        printf("%5d", w[i]);
    }
    printf("%5d\n", accumulate(ALL(v), 0));
}

int main() {
    int n;
    while(cin >> n, n) {
        solve102(n);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,b,i,a;
string s;

int main()
{
    ios
        scanf("%d",&n);
        int a=0,cnt=0;
        while(a<n){
            a=10*a+7;
            cnt++;
        }

        if(n%2==0 || n%5==0) {
           printf("-1\n");
            return 0;
        }
        while(a%n!=0){
            a=a%n;
            a=a*10+7;
            cnt++;

           // cout<<a<<endl;
        }
        printf("%d\n",cnt);

}



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

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

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

	string s;
	cin>>s;
	if (s[1] == 'B')
		cout<<"ARC";
	else
		cout<<"ABC";
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//æ˜‡é †

using namespace std;

const int mod=1e9+7;

signed dis(int x1,int y1, int x2, int y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

bool isDigit(char c){
    return '0' <= c && c <= '9';
}

signed main(){
    SPEED;
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    rep(i,a)
    {
        if(!isDigit(s[i]))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a]!='-')
    {
        cout << "No" << endl;
        return 0;
    }
    for(int i = a + 1; i < a + 1 + b; ++i)
    {
         if(!isDigit(s[i]))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final String END_OF_DATASET = "#";

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                ArrayList<Plant> plants = new ArrayList<>();
                while(n-- > 0) {
                    String name    = scn.next();
                    int cost       = scn.nextInt();
                    int firstTime  = scn.nextInt() + scn.nextInt() + scn.nextInt();
                    int latterTime = scn.nextInt() + scn.nextInt();
                    int amount     = scn.nextInt();
                    int price      = scn.nextInt();
                    int count      = scn.nextInt();

                    double profit     = amount * price * count - cost;
                    double efficiency = profit / (firstTime + latterTime * count);

                    plants.add(new Plant(name, efficiency));
                }

                Collections.sort(plants);
                for(Plant plant : plants) {
                    System.out.println(plant);
                }
                System.out.println(END_OF_DATASET);
            }
        }
    }
}

class Plant implements Comparable<Plant> {
    private String name;
    private double efficiency;

    public Plant(String name, double efficiency) {
        this.name       = name;
        this.efficiency = efficiency;
    }

    public int compareTo(Plant another) {
        int rslt;
        if(this.efficiency < another.efficiency) {
            rslt = 1;
        } else if(this.efficiency > another.efficiency) {
            rslt = -1;
        } else {
            rslt = this.name.compareTo(another.name);
        }
        return rslt;
    }

    @Override
    public String toString() {
        return name;
    }
}

Measured memory_bytes: 48588
//*****************************believer******************************//
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef map<ll,ll> mi;
 
#define f first
#define ss second
#define ins insert
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define pq priority_queue
#define sqr(n) floor(sqrt(n))
#define sz(v) ((ll)(v.size()))
#define trav(a,x) for (auto& a: x)
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define mem(a) memset(a, -1, sizeof (a))
#define ssort(v) sort((v).begin(),(v).end())
#define rsort(v) sort((v).rbegin(),(v).rend())
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define foo(i,a,b) for (ll i = (a); i < (b); ++i)
#define foor(i,a,b) for (ll i = (a); i >= (b); --i)


///basically in this ques we will try to find the tail probability;
///memset can not be used to fill the double values because meemset fill starting N
///n bits number basically but size of double greater than one that is why it fill garbagevalue
// so we need to intialise it seperaterly;
const ll N=2e5+100;
ll n;
double a[3005];
double dp[3005][3005];

double solve(ll x,ll tail)
{
    
    if(x==0)
    return (tail)?1:a[0];
    
    if(dp[x][tail]!=-1)
    return dp[x][tail];
    
    double ans1=0;
    if(tail)
    ans1+=(1-a[x])*solve(x-1,tail-1)+a[x]*solve(x-1,tail);
    else
    ans1+=a[x]*solve(x-1,tail);
    
    return dp[x][tail]=ans1;
    
}


int main()
{
    cin>>n;
    foo(i,0,n)
    cin>>a[i];
    
    foo(i,0,3005)
    foo(j,0,3005)
    dp[i][j]=-1;
    
    ll tail=n/2;
    double ans=solve(n-1,tail);
    cout<<fixed<<setprecision(10)<<ans<<"\n";
}


Measured memory_bytes: 74456
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
long long a[N] , b[N];
long long s1 = 0 , s2 = 0;
vector <long long> g;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
    }
    for(int i=1;i<=n;i++){
        if(a[i] >= b[i]){
            s1 += a[i] - b[i];
        }
        else{
            if(a[i] % 2 == b[i] % 2)
                s2 += (b[i] - a[i]) / 2ll;
            else{
                g.push_back( (b[i] - a[i] + 1) / 2ll );
            }
        }
    }
    sort(g.begin() , g.end());
    reverse(g.begin() , g.end());
    long long z = 0;
    for(int i=0;i<(int)g.size();i++){
        if(s2){
            s2--;
            s2 += max(0ll , g[i] - z);
            z -= min(g[i] , z);
        }
        else{
            if(i == (int)g.size() - 1){
                if(s1 == 0){
                    cout<<"No"<<endl;
                    return 0;
                }
                s1 += 2;
                s2 += max(0ll , g[i] - z);
                z -= min(g[i] , z);
            }
            else{
                s2 += max(0ll , g[i] - z);
                z -= min(g[i] , z);
                z++;
            }
        }
    }
    if(s2 < s1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
 
public class Main{
  public static int[] dp;
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s = sc.nextLine().split(" ");
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(s[i]);
    }
    
    int dp[] = new int[N];
    dp[0] = 0;
    
    for(int i = 1; i<N; i++){
      if(i == 1){
        dp[i] += Math.abs(num[0] - num[1]);
      }else{
        int a = Math.abs(num[i] - num[i-1]) + dp[i-1];
        int b = Math.abs(num[i] - num[i-2]) + dp[i-2];
        dp[i] = (a > b ? b : a);
      }
    }
    System.out.println(dp[N-1]);
  }
}


Measured memory_bytes: 36368
#include<stdio.h>
int main(void) {
	int a, b, c;
	int box[10000];
	int i;

	scanf("%d", &a);
	scanf("%d", &b);

	c = 3 * a + b;

	

	int ans = 0;

	ans = c / 2;

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

//t回で倒せる？ hはsorted
bool is_ok(vector<ll> h, ll n, ll t, ll a, ll b){
  REP(i,n) h[i] -= b*t;
  ll cnt = 0;
  REP(i,n){
    if(h[i] <= 0) return true;
    cnt += (h[i]+a-b-1)/(a-b);
    if(cnt>t) return false;
  }
  return true;
}

int main(){
  ll n,a,b; cin >> n >> a >> b;
  vector<ll> h(n);
  REP(i,n) cin >> h[i];
  sort(ALL(h),greater<ll>());
  ll ng = 0;
  ll ok = (h[0]+b-1)/b;
  while(ok-ng !=1){
    ll mid = (ok+ng)/2;
    if(is_ok(h,n,mid,a,b)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
const int mod = 1'000'000'007;
int add(int a, int b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
int mul(int a, int b){
	return 1ll * a * b % mod;
}
int pwr(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a))
		if(b&1)
			r = mul(r, a);
	return r;
}
const int maxn = 2000'001;
int fact[maxn], ifact[maxn];
void init(){
	fact[0] = 1;
	for(int i = 1; i < maxn; i++) 
		fact[i] = mul(fact[i - 1], i);
	ifact[maxn - 1] = pwr(fact[maxn - 1], mod - 2);
	for(int i = maxn - 2; i >= 0; i--)
		ifact[i] = mul(ifact[i + 1], i + 1);
}
int ncr(int n, int r){
	if(n < r) return 0;
	return mul(fact[n], mul(ifact[r], ifact[n - r]));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	init();
	int k;
	cin >> k;
	string s;
	cin >> s;
	int len_s = s.size();
	int len = k + len_s;
	int ans = 0;
	for(int i = len_s; i <= len; i++){
		ans = add(ans, mul(mul(ncr(i - 1, len_s - 1), pwr(25, i - len_s)), pwr(26, len - i)));
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 19900
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  string S;
  cin >> N >> S;
  for(int i = 0; i < S.size(); i++){
    cout << ((char)(((S.at(i) - 'A' + N) % 26) + 'A'));
  }
  cout << endl;
  return 0;
}

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

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int x,y,z;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>x>>y>>z;
	cout<<z<<sp<<x<<sp<<y;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String s = sc.next();
		if (s.startsWith(s.substring(s.length()-1))) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 22612
use std::io::Read;
use itertools::Itertools;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let d: usize = iterator.next().unwrap().parse().unwrap();
    let c: Vec<isize> = (0..26).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let mut s: Vec<Vec<isize>> = vec![vec![0; 26]; d];
    for i in 0..d {
        for j in 0..26 {
            s[i][j] = iterator.next().unwrap().parse().unwrap();
        }
    }

    let mut t: Vec<usize> = vec![0; d];
    for i in 0..d {
        let mut m: isize = 0;
        for j in 0..26 {
            if s[i][j] > m {
                m = s[i][j];
                t[i] = j + 1;
            }
        }
    }
    return t.iter().join("\n");
}


Measured memory_bytes: 2332
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




ll s[55], p[55];

ll dfs(ll n, ll x){
    if(n == 0){
        if(x <= 0) return 0;
        return 1;
    }
    if(x <= 1 + s[n - 1]) return dfs(n - 1,x - 1);
    return p[n - 1] + 1 + dfs(n - 1, x - 2 - s[n - 1]);
}

int main() {
    ll n, x;
    cin >> n >> x;
    s[0] = 1;
    p[0] = 1;
    REP(i, n){
        s[i + 1] = s[i] * 2 + 3;
        p[i + 1] = p[i] * 2 + 1;
    }
    cout << dfs(n, x) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vl v(n);
	//multiset <ll> s;
	for(ll i=0;i<n;i++){
		cin>>v[i];
	}
	sort(all(v));
	ll c=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n-1;j++){
			ll ans=lower_bound(v.begin()+j+1,v.end(),v[i]+v[j])-v.begin()-j-1;
			//cout<<ans<<"\n";
			c+=ans;
		}
	}
	cout<<c<<"\n";
}

Measured memory_bytes: 3672
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
    const LL lim = 100000;
    LL n, q;
    cin >> n;
    V<LL> v(lim+1, 0);
    LL i = 0;
    while (i++ < n) {
        LL a;
        cin >> a;
        v[a]++;
    }
    cin >> q;
    V<LL> b(q), c(q);
    i = 0;
    while (i < q) {
        cin >> b[i] >> c[i];
        i++;
    }
    LL sum = 0;
    i = 1;
    while (i <= lim) {
        sum += i * v[i];
        i++;
    }

    i = 0;
    while (i < q) {
        sum = sum - b[i] * v[b[i]] + c[i] * v[b[i]];
        v[c[i]] += v[b[i]];
        v[b[i]] = 0;
        col(sum);
        i++;
    }

    return 0;
}


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

int main() {
  int N; cin >> N;
  long long sum = 0;
  vector<long> A(N+1,0); for (int i = 0; i < N+1; i++) cin >> A.at(i);
  vector<long> B(N,0); for (int i = 0; i < N; i++) cin >> B.at(i);
  
  for (int i = 0; i < N; i ++){
    if (A.at(i) + A.at(i+1) <= B.at(i)) {
      sum += A.at(i) + A.at(i+1);
      A.at(i) = 0;
      A.at(i+1) = 0;
    }else{
      sum += B.at(i);
      if (A.at(i) <= B.at(i)) A.at(i+1) = A.at(i+1) - (B.at(i) - A.at(i));
      A.at(i) = 0;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
#define ll long long
#define vll vector <long long>
#define pi 2*acos(0.0)
using namespace std;
const int mod =  1000000007;


void solve(){
    int s,ss;
    cin>>s>>ss;
    if(s<ss*2)cout<<0<<endl;
    else cout<<s-(ss*2)<<endl;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}




Measured memory_bytes: 3660
import itertools
n,m,q=map(int,input().split())
l=[list(map(int,input().split()))for i in range(q)]
y=0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
 x=0
 for a,b,c,d in l:
  if i[b-1]-i[a-1]==c:x+=d
 y=max(y,x)
print(y)

Measured memory_bytes: 9152
#include <iostream>

using namespace std;

int main()
{

    int test;   cin >> test;
    int AC = 0, WA = 0, TLE = 0, RE = 0;

    string stat;
    for (int i = 0; i < test; i++){

        cin >> stat;
        if (stat == "AC"){AC++;}
        if (stat == "WA"){WA++;}
        if (stat == "TLE"){TLE++;}
        if (stat == "RE"){RE++;}
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

    return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
//#include<cstdlib>
#include<cstring>

#define MAX_LEN 1000

int c[MAX_LEN+1][MAX_LEN+1]; // length of longest common subsequence

void p(){
    printf("\ntest\n");
}

int max(int a, int b){
    return a > b ? a : b;
}

int LCS(char *s1, char *s2){
    int i, j,   l, m;
    l = strlen(s1);
    m = strlen(s2);
    //printf("l:%d m:%d", l, m);
    
    for (i = 0; i < l; i++) {
        c[i][0] = 0;
     }
    
    for (j = 0; j < m; j++) {
        c[0][j] = 0;
    }
    
    
    for (i = 1; i < l+1; i++) {
        for (j = 1; j < m+1; j++) {
            if (s1[i-1] == s2[j-1]) {
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i][j-1], c[i-1][j]);
            }
            //printf("c[%d][%d]:%d\n", i, j, c[i][j]);
        }
    }
    
    
    return c[l][m];
}

int main(){
    int i, n;
    char s1[MAX_LEN+1], s2[MAX_LEN+1];
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf(" %s", s1);
        scanf(" %s", s2);
        //printf("%s\n%s\n", s1, s2);
        printf("%d\n", LCS(s1, s2));
    }
    
    return 0;
}



Measured memory_bytes: 6608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    for(int i=0;i<=1000000000;i++){
        if(abs(a-i)==abs(b-i)){
            printf("%d\n",i);
            return 0;
        }

    }
    printf("IMPOSSIBLE\n");
    return 0;


}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
int sanada[114];
signed main() {
	int n, a, b,cnta=0,cntb=0,cntc=0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> sanada[i];
	for (int i = 0; i < n; i++) {
		if (sanada[i] <= a)cnta++;
		else if (sanada[i] > a&&sanada[i] <= b)cntb++;
		else cntc++;
	}
	cout << min({ cnta,cntb,cntc }) << endl;
	ll
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l[11], N, ans = 1e9, belong[11], cost[4], tong[4], to[4];
void cnt(){
	cost[1] = cost[2] = cost[3] = 0;
	tong[1] = tong[2] = tong[3] = 0;
	for(int i = 1;i <= N; i++){
		tong[belong[i]]++;
		cost[belong[i]] += l[i];
	}
	int sum = 0;
	for(int i = 1;i <= 3; i++){
		if(tong[i] == 0)return ;
		sum += max(tong[i] - 1, 0) * 10 + abs(cost[i] - to[i]);
	}
	ans = min(ans, sum);
}
void dfs(int lev){
	if(lev == N + 1){
		cnt();
		return ;
	}
	for(int i = 0;i <= 3; i++){
		belong[lev] = i;
		dfs(lev + 1);
	}
}
int main(){
	cin>>N>>to[1]>>to[2]>>to[3];
	for(int i = 1;i <= N; i++){
		cin>>l[i];
	}
	dfs(1);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import copy

class Dice:
    def __init__(self,numbers): 
        self.numbers=numbers

    def movement(self,direction):
        tmp=copy.copy(self.numbers)
        if(direction=="E"):
            self.numbers[0]=tmp[3]
            self.numbers[2]=tmp[0]
            self.numbers[3]=tmp[5]
            self.numbers[5]=tmp[2]
        elif(direction=="S"):
            self.numbers[0]=tmp[4]
            self.numbers[1]=tmp[0]
            self.numbers[4]=tmp[5]
            self.numbers[5]=tmp[1]
        elif(direction=="W"):
            self.numbers[0]=tmp[2]
            self.numbers[2]=tmp[5]
            self.numbers[3]=tmp[0]
            self.numbers[5]=tmp[3]
        elif(direction=="N"):
            self.numbers[0]=tmp[1]
            self.numbers[1]=tmp[5]
            self.numbers[4]=tmp[0]
            self.numbers[5]=tmp[4]
    
    def top(self):
        return self.numbers[0]

numbers=list(map(int,input().split(" ")))
d=Dice(numbers)

comms=list(input())
for comm in comms:
    d.movement(comm)

print(d.top())


Measured memory_bytes: 6344
#include<stdio.h>

int main(){

    long l,r;
    scanf("%ld %ld",&l,&r);

    int min = 2019;
    for(long i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){
            if((i*j)%2019<min){
                min=(i*j)%2019;
            }
            if(j-i>2019)break;
        }
        if(r-l>2019)break;
    }
    printf("%ld\n",min);

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  set<int> A;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A.insert(tmp);
  }
  if (N == A.size()) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  
  long long int N, tmp1, tmp2;
  std::vector<std::pair<long long int, long long int> > jobs;
  
  scanf("%lld", &N);
  for(int i = 0; i < N; i++){
    scanf("%lld%lld", &tmp1, &tmp2);
    jobs.push_back(std::make_pair(tmp2, tmp1));
  }
  std::sort(jobs.begin(), jobs.end());
  
  int flag = 1;
  if(jobs[0].first < jobs[0].second){
    flag = 0;
  }
  for(int i = 1; i < N && flag == 1; i++){
    jobs[i].second = jobs[i-1].second + jobs[i].second;
    if(jobs[i].first < jobs[i].second){
      flag = 0;
    }
  }
  
  if(flag == 1){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 6384
# coding: utf-8
# Your code here!

h,w = map(int,input().split())

if h%3==0 or w%3==0:
    print(0)
    exit()


ah = h//3
aw = h//3
ans = h*w
if ah:
    ans = min(ans,w)
if aw:
    ans = min(ans,h)

for i in range(1,w):
    x = h*i
    if w-i>1:
        y = ((w-i)//2)*h
        z = h*(w-i)-y
        ans =min(ans,max(x,y,z)-min(x,y,z))
    if h>1:
        y = (h//2)*(w-i)
        z = h*(w-i)-y
        ans =min(ans,max(x,y,z)-min(x,y,z))
for i in range(1,h):
    x = w*i
    if h-i>1:
        y = ((h-i)//2)*w
        z = w*(h-i)-y
        ans =min(ans,max(x,y,z)-min(x,y,z))
    if w>1:
        y = (w//2)*(h-i)
        z = w*(h-i)-y
        ans =min(ans,max(x,y,z)-min(x,y,z))

print(ans)
    

Measured memory_bytes: 42864
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
//int vis[N];
bool sortcol(const vector<int>& v1,
	const vector<int>& v2) {
	return v1[0] < v2[0];
}

int32_t  main() {

	IOS;
  
	int N, M, X;

	cin >> N >> M >> X;

	vector< vector<int>> v(N, vector<int>(M+ 1));

	for (int i = 0; i < N; i++) {

		for (int j = 0; j < M + 1; j++) {

			cin >> v[i][j];

		}
	}

	int tot = 1 << N; //total subset 2^N  example 2^3
	int cost = INT_MAX;
	for (int mask = 0; mask < tot; mask++) { //iterate ever subset  example now loop 2^2 100
		int total = 0;
		vector<int> check(M);
		for (int i = 0; i < N; i++) { //check the i-th element in the subset is present or not 
			int f = 1 << i; // exmaple: check from 2^0 001
			if ((mask&f) != 0) {      //               010
				total += v[i][0];									// 100 bingo			
								
				for (int k = 0; k < M; k++) {

					check[k] += v[i][k+1];

				}
			}
		}

		bool flag = false;
		for (int j = 0; j < M; j++) {
			if (check[j] < X) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			cost = min(cost, total);
		}
	}
	if (cost == INT_MAX)
		cost = -1;
	cout << cost << endl;
}

Measured memory_bytes: 3152
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)

#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define siz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__)
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

// #define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(int,n,k);
  in(string,S);
  int slen=siz(S);
  char init = S[0];
  char last = S[slen-1];
  VI x;
  if(init=='0') x.emb(0);
  int c=1;
  fou(i,1,slen){
    if(S[i]==S[i-1]) c++;
    else{
      x.emb(c);
      c=1;
    }
  }x.emb(c);
  if(last=='0') x.emb(0);
  int xlen = siz(x);
  int zero = xlen/2;
  int one = zero+1;
  int ans=0;
  if(zero<=k) ans=slen;
  else{
    int sumup=k*2+1;
    for(int i=0;i+2*k<xlen;i+=2){
      int sum=0;
      fou(j,i,i+2*k+1) sum+=x[j];
      maxi(ans,sum);
    }
  }
  out(ans);
}

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

int main() {
	int N;
	cin >> N;
	int pro = 0;
	bool gray = false;
	bool brown = false;
	bool green = false;
	bool water = false;
	bool blue = false;
	bool yellow = false;
	bool orange = false;
	bool red = false;
	for(int i = 0;i < N;i++){
		int test = 0;
		cin >> test;
		if(test < 400){
			gray = true;
			continue;
		}
		if(test < 800){
			brown = true;
			continue;
		}
		if(test < 1200){
			green = true;
			continue;
		}
		if(test < 1600){
			water = true;
			continue;
		}
		if(test < 2000){
			blue = true;
			continue;
		}
		if(test < 2400){
			yellow = true;
			continue;
		}
		if(test < 2800){
			orange = true;
			continue;
		}
		if(test < 3200){
			red = true;
			continue;
		}
		else{
			pro++;
			continue;
		}
	}
	int color = 0;
	if(gray)color++;
	if(brown)color++;
	if(green)color++;
	if(water)color++;
	if(blue)color++;
	if(yellow)color++;
	if(orange)color++;
	if(red)color++;
	cout << max(1,color) << " " << color + pro << endl;
}

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

using namespace std;
typedef long long int ll;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int result = 0;
    for(int num = 0; num <= 999; num++)
    {
        int num1 = num / 100;
        int num2 = num / 10 - num1 * 10;
        int num3 = num % 10;
        int p1 = -1;
        int p2 = -1;
        int p3 = -1;
        for(int i = 0; i < N; i++)
        {
            if(S[i] - '0' == num1)
            {
                p1 = i;
                break;
            }
        }
        if(p1 == -1)
        {
            continue;
        }
        for(int i = p1 + 1; i < N; i++)
        {
            if(S[i] - '0' == num2)
            {
                p2 = i;
                break;
            }
        }
        if(p2 == -1)
        {
            continue;
        }
        for(int i = p2 + 1; i < N; i++)
        {
            if(S[i] - '0' == num3)
            {
                p3 = i;
                break;
            }
        }
        if(p3 == -1)
        {
            continue;
        }
        result++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)1e5;
const int DEP = 17;

int dat[N+5];
int tab[N+5][DEP+1];

int main(){
    int n; scanf("%d", &n);
    REP(i,1,n) scanf("%d", dat+i);
    dat[n+1] = (int)2e9 + 10;
    int l; scanf("%d", &l);
    //
    for(int i=1,j=2; i<=n; i++){
        for(; dat[j] - dat[i] <= l; j++);
        tab[i][0] = j-1;
    }
    // build
    REP(j,1,DEP) REP(i,1,n) tab[i][j] = tab[ tab[i][j-1] ][j-1];
    // do
    int q; scanf("%d", &q);
    FOR(xxx,q){
        int a,b; scanf("%d %d", &a, &b);
        if(a > b) swap(a,b);
        //
        int res = 0;
        REV(j,DEP,0) if(tab[a][j] < b){
            res += 1 << j;
            a = tab[a][j];
        }
        res += 1;
        // print
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 8192
from __future__ import division, print_function
from sys import stdin
from math import sqrt
while True:
    n = int(stdin.readline())
    if n == 0:
        break
    data = [float(s) for s in stdin.readline().split()]
    m = sum(data) / len(data)
    print('{:.4f}'.format(sqrt(sum((s-m)**2 for s in data) / n)))

Measured memory_bytes: 4508
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   vector <int> t(n);
   rep(i,n) cin >> t[i];
   int m;
   cin >> m;
   vector <int> p(m);
   vector <int> x(m);
   rep(i,m) cin >> p[i] >> x[i];

   int maxtime = 0;
   rep(i,n) maxtime += t[i];

   int tmptime = 0;
   rep(i,m){
      tmptime = maxtime - (t[p[i]-1] - x[i]);
      cout << tmptime << endl;      

   }


   return 0;
}

Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	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();
		}
		boolean gu[] = new boolean[N];
		Arrays.fill(gu,false);
		int count = 0;
		for(int j=0;j<N;j++) {
			if(A[j]%2==0) {
				gu[j] = true;
				count ++;
			}
		}
//		for(int k=0;k<N;k++) {
//			System.out.println(gu[k]);
//		}
		int count2 = 0;
		for(int k=0;k<N;k++) {
			if(gu[k]) {
				if(A[k]%3==0||A[k]%5==0) {
					count2 ++;
				}
			}
		}
		if(count==count2) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	}
}

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

sys.setrecursionlimit(100000)


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap

@mt
def slv(N, C):
    C_ = [-1]
    for c in C:
        if C_[-1] == c:
            continue
        C_.append(c)
    
    C = C_

    mod = 10**9 + 7
    S = defaultdict(lambda: 0)
    ans = 1
    for c in C:
        ans = (ans + S[c]) % mod
        S[c] = ans

    return ans


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 33588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,count=0;
  cin>>N;
  vector<ll> a(N),v(N);
  for(ll i=0;i<N;i++){
    cin>>a.at(i);
  }
  for(ll i=0;i<N;i++){
    v.at(a.at(i)-1)++;
  }
  for(ll i=0;i<N;i++){
    if(v.at(i)>=2){count+=v.at(i)*(v.at(i)-1)/2;}
  }
  for(ll i=0;i<N;i++){
    if(v.at(a.at(i)-1)>1){
    count-=v.at(a.at(i)-1)-1;
    cout<<count<<endl;
    count+=v.at(a.at(i)-1)-1;
    }else{cout<<count<<endl;}
  }
}

Measured memory_bytes: 5760
#include<stdio.h>

int nextInt();

int N, H[100], ans, h, i;
char f;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		H[i]=nextInt();
	}
	for(h=100; h>=1; h--){
		f=0;
		for(i=0; i<N; i++){
			if(H[i]==h){
				if(!f){ans++;}
				f=1;
				H[i]--;
			}else{
				f=0;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

using mint = atcoder::modint998244353;
struct S {
    mint val;
    int sz;
};
struct F {
    mint a, b;
};
S e() {
    return {mint(0), 0};
}

S mapping(F f, S x) {
    x.val = x.val * f.a + f.b * x.sz;
    return x;
}

F composition(F l, F r) {
    return {r.a * l.a, r.b * l.a + l.b};
}

F id() {
    return {1, 0};
}

S op(S a, S b) {
    return {a.val + b.val, a.sz + b.sz};
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    vector<S> a(N);
    for(int i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        a[i].val = mint(tmp);
        a[i].sz = 1;
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    for(int q = 0; q < Q; q++) {
        ll t;
        cin >> t;
        if(t == 0) {
            ll l, r, b, c;
            cin >> l >> r >> b >> c;
            seg.apply(l, r, {b, c});
        } else {
            ll l, r;
            cin >> l >> r;
            auto ans = seg.prod(l, r);
            cout << ans.val.val() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19632
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-8-4
//Author：HarryBlackCat

ll gcd(ll a,ll b){
	return b ? gcd(b,a % b) : a;
}

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

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	ll n;
	while(~rl(n)){
		pr(lcm(n,2));
	} 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
ll gcd(ll a,ll b){
    if(b==1) return 1;
    else if(a%b==0) return b;
    return gcd(b,a%b);
}

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

ll solve(ll a,ll b,ll c){
    return a/b + a/c - a/lcm(b,c);
}

int main(){
    ll A,B,C,D;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    printf("%lld",B-A+1-(solve(B,C,D)-solve(A-1,C,D)));
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int q;
  while (cin >> q, q != -1) {
    double x = q / 2.;
    while (!(abs(x * x * x - q) - 0.00001 * q < -1e-10)) {
      x = x - (x * x * x - q) / (3. * x * x);
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3252
n = input()
num = int(n)
len = len(n)

if (len == 1):
    print(n)
    exit
elif(len == 2):
    print(9)
    exit
elif(len == 3):
    print(9 + num-100+1)
    exit
elif(len == 4):
    print(909)
    exit
elif(len==5):
    print(909 + num-10000+1)
    exit
elif(len==6):
    print(90909)
    exit

Measured memory_bytes: 3060
const main = (inputs) => {
  var N = inputs[0].split(" ")[0]-0;
  var L = inputs[0].split(" ")[1]-0;

  var apples = [];
  var min = 500;
  var sum = 0;
  for(var i=0;i<N;i++){
    apples.push(i+L);
    sum += i+L;
    if(Math.abs(min) > Math.abs(i+L)){
      min = i+L;
    }
  }
  console.log(sum-min);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 7372
#include<stdio.h>
int main(){
  int i,N,j;
  int a[100];
  scanf("%d",&N);
  for(i=N-1;i>=0;i--){
    scanf("%d",&a[i]);
  }
  for(j=0;j<=N-1;j++){
  if(j == N - 1) {
    printf("%d\n",a[j]);
  }
  else{
    printf("%d ", a[j]);
  }
  }
     return 0;
}

Measured memory_bytes: 2680