akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,x;
    cin>>n>>x;
    
    ll ans = 0;
    
    vector<ll> a(n);
    cin >> a[0];
    ll diff = 0;
    for(int i=1; i<n; i++){
        cin >> a[i];
        if(a[i-1]+a[i]>x){
            diff = a[i-1]+a[i] - x;
            ans += diff;
            if(a[i]<diff)a[i]=0;
            else a[i] -= diff;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
import sys

N,Y = map(int,input().split())

for i in reversed(range(N+1)):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        k = N - i - j
        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = input()
    ans = 0
    tmp = 0
    acgt = ['A', 'C', 'G', 'T']
    for s in S:
        if s in acgt:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,count = 0;
    cin >> n;
    vector<int>v(n);

    for(int i = 0;i < n;i++)
        cin >> v[i];
    
    sort(v.begin(),v.end());

    for(int i = v[n/2-1];i < v[n/2];i++){
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,p,q;
vl a;

int main(){
	cin>>n>>p>>q;
	a=vl(n);
	ll sum=0,res;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		a[i]=p*(q-i)-a[i];
	}
	sort(a.rbegin(),a.rend());
	res=sum;
	for(int i=0;i<n;i++){
		sum+=a[i];
		res=max(res,sum+p*i*(i+1));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> e(n);
    rep(i, 0, n - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }

    ll q, k;
    cin >> q >> k;
    k--;

    ll dist[n] = {};
    bool reached[n] = {};
    queue<ll> que;
    que.push(k);
    reached[k] = true;
    while (!que.empty()) {
        ll nowpos = que.front();
        que.pop();
        rep(i, 0, (int)e[nowpos].size()) {
            ll nextpos = e[nowpos][i].first;
            ll nextcost = e[nowpos][i].second;
            if (reached[nextpos]) continue;
            dist[nextpos] = dist[nowpos] + nextcost;
            reached[nextpos] = true;
            que.push(nextpos);
        }
    }

    rep(i, 0, q) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int a,d=0,i;
    string b;
    cin>>a>>b;
    fr(i,sl(b))
    {
        if(b[i]!='.')
        {
            d+=(b[i]-'0');
            d*=10;
        }
    }
    d/=10;
    //cout<<d<<endl;
    d*=a;
    d/=100;
    cout<<d;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
a = list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N):
    b[a[i]] = i + 1
l = [i for i in range(N + 2)]
r = [i for i in range(N + 2)]
ans = 0
for i in range(N, 0, -1):
    m = b[i]
    x = l[m]
    y = r[m]
    ans += (m - x + 1) * (y - m + 1) * i
    r[x - 1] = y
    l[y + 1] = x
print(ans)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, A, B;
int main() {
    std::cin >> N >> A >> B;
    
    long long ans = 0;
    for(int i=1; i<=N; ++i) {
        std::string str = std::to_string(i);
        int sum = 0;
        EACH(it, str) {

            sum += (int)(*it - '0');
        }
        if(sum >= A && sum <= B) {
            ans += i;
        }
    }
    std::cout << ans << std::endl;
}

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

int main() {

    int n, d;
    scanf("%d", &n);
    int arr[n];

    for (int i = 0; i < n; i++) {
        scanf("%d", &d);
        arr[i] = d;
    }

    for (int j = 0; j < n - 1; j++) {
        for (int k = j + 1; k < n; k++) {
            if (arr[j] > arr[k]) {
                int temp = arr[j];
                arr[j] = arr[k];
                arr[k] = temp;
            }
        }

    }

    int cnt = 1;
    int before = arr[0];
    for (int x = 1; x < n; x++) {
        if (before != arr[x]) {
            cnt++;
            before = arr[x];
        }
    }

    printf("%d", cnt);

    return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    string s;
    cin >> s;
    if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	for (int i = 1; i < 10; i++)
	    for (int j = 1; j < 10; j++)
	    {
		if (i*j == n)
		{
		    WriteLine("Yes");
		    return;
		}
	    }
	WriteLine("No");
    }
}


Measured memory_bytes: 13140
#include<iostream>

using namespace std;

int main(){

	char s[200000];

	scanf("%s",&s);

	int start = 0,end = 0;
	bool b = true;
	for (int i = 0; s[i] != '\0' ; i++)	{
		if (b == true && s[i] == 'A'){
			start = i;
			b = false;
		}else if (b == false && s[i] == 'Z'){
			end = i;		
		}
		
	}
	cout << end - start +1<< endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i,n){
    int p;
    cin >> p;
    p--;
    b.at(p)=i+1;
  }
  rep(i,n){
    if(i==n-1){
      cout << b.at(i)<<endl;
    }else{
    cout <<b.at(i)<<" ";
    }
  }
}




Measured memory_bytes: 1280
N=int(input())
M,A,R,C,H=0,0,0,0,0
S=""
for i in range(N):
    S=input()
    if S[0]=="M":
        M+=1
        continue
    if S[0]=="A":
        A+=1
        continue
    if S[0]=="R":
        R+=1
        continue
    if S[0]=="C":
        C+=1
        continue
    if S[0]=="H":
        H+=1
        continue
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H)

Measured memory_bytes: 3064
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let w = stdin.lock().gets().into_bytes();
    let mut count = vec![0; 26];
    for c in w.iter() {
        count[(c - b'a') as usize] += 1;
    }
    if count.into_iter().all(|x| x % 2 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll N,Q;
ll dp[100005];
string S;

int main(){

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

cin>>N>>Q>>S;

dp[0]=0;
rep1(i,N){
	if(S[i]=='C'){
		if(S[i-1]=='A') dp[i]=dp[i-1]+1;
		else dp[i]=dp[i-1];
	}else{
		dp[i]=dp[i-1];
	}
}

cout<<endl;
rep(i,Q){
	ll l,r;
	cin>>l>>r;
	l--; r--;
	ll ans;
	if(l-1>=0){
		ans=dp[r]-dp[l-1];
		if(S[l-1]=='A'&&S[l]=='C') ans--;
	}else{
		ans=dp[r];
	}
	cout<<ans<<endl;
}

}
	


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

int main(){
    int n;
    int i=0;
    cin>>n;
    while(i<n){
        i++;
        if(i%3==0){
            cout<<" "<<i;
            continue;
        }
        int x=i;
        while(x){
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<math.h>
using namespace std;

int kaijou(int a);
int junban(int n, int list[]);

int main() {
    int n;
    int p[10], q[10];

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

    int a = junban(n, p);
    int b = junban(n, q);
    
    cout << abs(a - b) << endl;
    return 0;
}

int kaijou(int a){
    int ans = 1;
    for(int i = 2;i <= a;i++){
        ans *= i;
    }
    return ans;
}

int junban(int n, int list[]){
    int a = 0;
    int used[10];
    for(int i = 0;i < n;i++){
        int min = 0;
        for(int j = 0;j < i;j++){
            if(used[j] < list[i]) min++;
        }
        int k = kaijou(n - i - 1);
        a += k * (list[i] - min);
        used[i] = list[i];
    }
    return a;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

set<int>s;
int c[400010];
struct node {
	int s,t,x;
};
node a[400010];
bool cmp(node a,node b) {
	return a.x<b.x;
}
int ans[400010];
inline int read() {
	int x=0;
	char c=getchar();
	for(; isdigit(c); c=getchar()) x=x*10+c-'0';
	return x;
}
int main() {
	int n=read(),q=read();
	up(i,1,n) {
		a[i].s=read();
		a[i].t=read();
		a[i].x=read();
	}
	sort(a+1,a+1+n,cmp);
	up(i,1,q) {
		int x=read();
		s.insert(x);
		c[i]=x;
	}

	up(i,1,n) {
		auto l=s.lower_bound(a[i].s-a[i].x);
		auto r=s.lower_bound(a[i].t-a[i].x);

		for(auto o=l; o!=r; o++)ans[lower_bound(c+1,c+1+q,*o)-c]=a[i].x;
		s.erase(l,r);

		if(s.empty())break;
	}
	up(i,1,q)
	if(ans[i]==0)pr(-1,'\n');
	else pr(ans[i],'\n');
}


Measured memory_bytes: 15360
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int N, L;
	int i;
	int absmin = 9999999;
	int apple[300];
	int sum = 0;
	cin >> N >> L;

	for (i = 0; i < N; ++i) {
		apple[i] = L + i;
		sum += apple[i];
	}

	for (i = 0; i < N; ++i) {
		if (abs(apple[i]) < abs(absmin)) {
			absmin = apple[i];
		}
		//cout << absmin << endl;
	}

	cout << sum - absmin << endl;





}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;



int main() {
    int n, a;
    int odds = 0;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (a % 2) odds++;
    }
    
    if (odds % 2) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 888
@D=0..<>;$_[0]=$_[$i=1]=$_[2]=$\=2;/ /,$D[$`]^=$D[$']^=$D[$`]^=$D[$'],$i-$`&&$i-$'||($i=$`+$'-$i),$\+=!$_[$D[$i-1]]+++!$_[$D[$i+1]]++for<>;print

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

bool data[101][101] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int W, H, N;
    cin >> W >> H >> N;

    for(int i = 0; i < N; ++i){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
            case 1 :
                for(int j = 0; j < x; ++j){
                    for(int k = 0; k <= H; ++k){
                        data[j][k] = true;
                    }
                }
                break;
            case 2:
                for(int j = x + 1; j <= W; ++j){
                    for(int k = 0; k <= H; ++k){
                        data[j][k] = true;
                    }
                }
                break;
            case 3 :
                for(int j = 0; j <= W; ++j){
                    for(int k = 0; k < y; ++k){
                        data[j][k] = true;
                    }
                }
                break;
            case 4:
                for(int j = 0; j <= W; ++j){
                    for(int k = y + 1; k <= H; ++k){
                        data[j][k] = true;
                    }
                }
                break;
        }
    }

    int ans = 0;
    for(int i = 0; i < W; ++i){
        for(int j = 0; j < H; ++j){
            if(!data[i][j] && !data[i + 1][j] &&
             !data[i][j + 1] && !data[i + 1][j + 1])
                ++ans;
                /*
            if(!data[i][j]){
                cout << i << " " << j << endl;
            }*/
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
double a,b;
while(scanf("%lf %lf\n",&a,&b)!=EOF){
if(a<35.5 && b<71){
printf("AAA\n");
}
else if(a<37.5 && b<77){
printf("AA\n");
}
else if(a<40 && b<83){
printf("A\n");
}
else if(a<43 && b<89){
printf("B\n");
}
else if(a<50 && b<105){
printf("C\n");
}
else if(a<55 && b<116){
printf("D\n");
}
else if(a<70 && b<148){
printf("E\n");
}
else{
printf("NA\n");
}
}
return 0;
}








Measured memory_bytes: 2108
class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            x, y = y, x
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        self.size[x] += self.size[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]
      
from collections import Counter


def abc049_d():
    n, k, l = map(int, input().split())

    road = UnionFind(n)
    for i in range(k):
        p, q = map(int, input().split())
        road.unite(p - 1, q - 1)

    rail = UnionFind(n)
    for i in range(l):
        r, s = map(int, input().split())
        rail.unite(r - 1, s - 1)

    set1 = []
    for i in range(n):
        set1.append((road.find(i), rail.find(i)))
    c = Counter(set1)
    ans = []
    for i in range(n):
        ans.append(c[(road.find(i), rail.find(i))])
    print(*ans)


if __name__ == '__main__':
    abc049_d()


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

#define len(x) (int)(x).size()
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define pb push_back
#define all(x) (x).begin() , (x).end()
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
    int n;
    cin >> n;
    vector < int > a(2*n);
    for(auto &i : a)cin >> i;
    sort(all(a));

    ll ans = 0;
    for(int f = 0; f < 2*n; f+=2){
        ans+=a[f];
    }
    cout <<ans;
    return 0;
}
/*
4 3
1 2 1 2 7
1 3 2 1 8
2 3 3 2 6
 6
*/


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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    // 取り除く橋の本数をなるべく少なくするため
    // 要望に応えられなくなるギリギリまで我慢する
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> abPairs(M);
    for (int i = 0; i < M; ++i)
    {
        int ai = Cin(), bi = Cin();
        abPairs[i] = { ai, bi };
    }
    sort(abPairs.begin(), abPairs.end(),
        [](const pair<int, int> &p1, const pair<int, int> &p2){ return p1.second < p2.second; });
    int ans = 0;
    int lastDeleted = 0;
    for (int i = 0; i < M; ++i)
    {
        const auto abPair = abPairs[i];
        // 最後に取り除いた橋で要望達成できていない場合
        if (lastDeleted < abPair.first)
        {
            // なるべくギリギリの橋を取り除く（次以降の要望になるべく応えられるようにするため）
            ++ans;
            lastDeleted = abPair.second - 1;
        }
        // 要望達成できているならば，これ以上何もしない
        else
        {
            continue;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	
	rep(i, 1000) {
		int H, W;
		cin >> H >> W;

		if (H == 0 || W == 0)continue;

		rep(i, H) {
			rep(j, W) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>

int main(void)
{
    int A, B, C;
    int MAX;
    
    
    scanf("%d %d %d", &A, &B, &C);
    
    if(A>B)
    {
        if(A>C)
        {
            MAX = A;
            A = 0;
        }
        else
        {
            MAX = C;
            C = 0;
        }
    }
    else
    {
        if(B>C)
        {
            MAX = B;
            B = 0;
        }
        else
        {
            MAX = C;
            C = 0;
        }
    }
    
    printf("%d\n", MAX*10+A+B+C);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,a;
    cin>>n>>m;
    long long int z=0;
    for(long long int i=1;i<=m;i++)
    {
        cin>>a;
        z=z+a;
    }
    if(z>n)
    {
        cout<<"-1"<<endl;
    }
    if(z==n)
    {
        cout<<"0"<<endl;
    }
    if(z<n)
    {
        cout<<n-z<<endl;
    }

    return 0;
}





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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n >> m;
    char a[n][n], b[m][m];

    rep (i, n) {
      rep (j, n) {
        cin >> a[i][j];
      }
    }
    rep (i, m) {
      rep (j, m) {
        cin >> b[i][j];
      }
    }

    rep (i, n) {
      rep (j, n) {
        if (i + m - 1 < n && j + m - 1 < n) {
          bool flag = true;
          rep (k, m) {
            rep (l, m) {
              if (a[i + k][j + l] != b[k][l]) flag = false;
            }
          }
          if (flag) {
            cout << "Yes" << '\n';
            return 0;
          }
        }
      }
    }
    cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,q,h,i,j,k,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> q;
	cin >> s;
	vector<ll>		aa(n+1);
	vector<ll>		l(q),r(q);
	c = 0;
	for(i=2;i<=n;i++) {
		if (s[i-2]=='A' && s[i-1]=='C') c++;
		aa[i] = c;
	}
	for(i=0;i<q;i++) cin >> l[i] >> r[i];
	for(i=0;i<q;i++) {
		ans = aa[r[i]] - aa[l[i]];
		//if (aa[l[i]-1] != aa[l[i]]) ans--;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 5868
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=s;i<e;i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef long long LL;
const LL mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int> > p(m);
    REP(i, m){
       cin >> p[i].first >> p[i].second;
       p[i].second--;
    }
    sort(all(p));
    vector<int> L(n), R(n);
    REP(i, n){
        L[i] = i;
        R[i] = i;
    }
    REP(i, m){
        int y = p[i].second;
        L[y] = min(L[y], L[y+1]);
        L[y+1] = min(L[y], L[y+1]);
        R[y] = max(R[y], R[y+1]);
        R[y+1] = max(R[y], R[y+1]);
    }
    REP(i, n){
        cout << R[i]-L[i]+1 << (i==n-1 ? "\n":" ");
    }
}



Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(max({a,b,c})==7){
		if(min({a,b,c})==5){
			if(a+b+c-max({a,b,c})-min({a,b,c})==5){
				cout<<"YES"<<endl;
			}
			else{
				cout<<"NO"<<endl;
			}
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		System.out.println(
		A.substring(0, 1).toUpperCase()
		+ B.substring(0, 1).toUpperCase()
		+ C.substring(0, 1).toUpperCase()
		);
	}
}


Measured memory_bytes: 21972
#include <stdio.h>

int main() {
    int n, ct = 0;
    char s[105];
    scanf("%d", &n);
    scanf("%s", &s);
    if (n % 2 != 0) {
        printf("No");
        return 0;
    }
    int half = n / 2;
    for (int i = 0; i < half; i++) {
        if (s[i] == s[i + half]) {
            ct++;
        }
    }
    if (ct == half) {
        printf("Yes");
    } else {
        printf("No");
    }
}

Measured memory_bytes: 1668
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Bug Hunt
public class Main{

	int line, bug, INVALID = -1;
	Map<Character, R> array;
	
	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	class R{
		int n;
		Map<Integer, Integer> val;
		public R(int n) {
			this.n = n;
			val = new HashMap<Integer, Integer>();
		}
		int get(int x){
			if(x<0||n<=x||!val.containsKey(x))return INVALID;
			return val.get(x);
		}
		int assign(int x, int v){
//			System.out.println("Assign:"+x+" V:"+v);
			if(x<0||n<=x||v==INVALID)return INVALID;
			val.put(x, v);
			return 1;
		}
	}
	
	void program(){
//		System.out.println("Line:" + line);
		char name = get();
		get();
		int e = exp();
//		System.out.println("Left e:"+e);
		char ch = get();
		if(ch!='='){
			array.put(name, new R(e));
			return;
		}
		if(e==INVALID){
			bug = line; return;
		}
		
		int val = exp();
//		System.out.println("E:"+e+" Val:"+val);
		int res = array.get(name).assign(e, val);
//		System.out.println("Res:"+res);
		if(res==INVALID)bug = line;
	}
	int exp(){
		char ch = get();
//		System.out.println("Exp:"+ch);
		if(Character.isDigit(ch)){
			int x = ch-'0';
			for(;;){
				ch = get();
				if(!Character.isDigit(ch))break;
				x = x*10+ch-'0';
			}
			return x;
		}
		char name = ch;
		get();
//		System.out.println(get());
		
		int e = exp();
//		System.out.println("AA:"+s[id]);
		get();
		
		return array.get(name).get(e);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			String str = sc.next();
			if(".".equals(str))break;
			line = 1; bug = 0;
			array = new HashMap<Character, R>();
			for(;;){
				s = (str+"$").toCharArray();
				id = 0;
				if(bug==0)program();
				str = sc.next();
				if(".".equals(str))break;
				line++;
			}
			System.out.println(bug);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
//答え見たよ！！！
#include<stdio.h>
#define INFINITY 9999999

struct Neighborhood{
  int dist;//結ばれた2つのノードの距離
  int no;//辺の番号
};

int main(){
  int i, j;
  //入力
  int N, M;//N:頂点の数 M:辺の数
  //制約条件によりNは100以下Mは1000以下
  scanf("%d %d", &N, &M);
  int a[1001], b[1001], c[1001];//a[0], b[0], c[0]は使わない
  for(i=1; i<=M; i++)
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  //入力ここまで
  int dist[101][101];//最短距離
  //初期値の設定
  for(j=1; j<=N; j++){
    for(i=1; i<=N; i++){
      if(i==j){
        dist[i][j] = 0;
      }else{
        dist[i][j] = INFINITY;
      }
    }
  }
  
  struct Neighborhood nbh[101][101];
  for(i=1; i<=100; i++){
    for(j=1; j<=100; j++){
      nbh[i][j].dist = 0;
      nbh[i][j].no = 0;
    }
  }
  //頂点が直接結ばれているならばを距離と辺の番号を代入
  for(i=1; i<=M; i++){
    nbh[a[i]][b[i]].dist = c[i];
    nbh[b[i]][a[i]].dist = c[i];
    nbh[a[i]][b[i]].no = i;
    nbh[b[i]][a[i]].no = i;
  }
  
  //各頂点を始点とした最短経路をDijkstra法で求め、
  //それぞれの辺が最短経路に含まれるかをみる
  int s;//スタートとして使用
  int t;//暫定的な起点として使用
  int from[101]={};//点sを起点とする最短距離において、各頂点に対しどの辺から来たかを代入する
  int fix[101];//各頂点について値が確定したら1、そうでないなら0
  int temp_min;//最小値を記録
  int min_vtx;//最小値をもつ頂点
  int cnt;//N-1回最短距離を確定させるためのカウンター
  int use[1001];//各辺について最短経路として使われたら1
  for(s=1; s<N; s++){
    for(i=1; i<=N; i++)
      fix[i] = 0;
    fix[s] = 1;
    t = s;
    for(cnt=1; cnt<N; cnt++){
      //このときdist(s,t)は確定していることに注意
      //頂点tに隣り合っていてなおかつ確定していない場所をすべて探索する
      for(i=1; i<=N; i++){
        if(nbh[t][i].dist && !fix[i]){
	  if(dist[s][i] > dist[s][t] + nbh[t][i].dist){
	    dist[s][i] = dist[s][t] + nbh[t][i].dist;
	    from[i] = nbh[t][i].no;
	  }
        }
      }
      //このとき未確定の頂点のうち距離が最小のものが確定する
      temp_min = 9999;
      for(i=1; i<=N; i++){
        if(!fix[i] && dist[s][i] < temp_min){
          temp_min = dist[s][i];
          min_vtx = i;
        }
      }
      fix[min_vtx] = 1;
      t = min_vtx;
      //printf("%d->%d : %d\n", s, min_vtx, temp_min);
    }
    //頂点s始点のすべての最短距離が出たので使われた経路を記録する
    for(i=1; i<=N; i++)
      use[from[i]] = 1;
  }
  //すべての頂点を始点とした最短距離を探索し終わったので
  int ans = 0;//最短経路に含まれない辺の本数を数え上げる
  for(i=1; i<=M; i++){
    if(!use[i])
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int w,a,b;
    scanf("%d%d%d",&w,&a,&b);
    if (b-(a+w)>0)
    printf("%d",b-(a+w));
    else if ((b+w)>=a) printf("0");
    else printf("%d",a-(b+w));
    return 0;
}

Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
namespace fastio{
	template<typename tn> void read(tn &a){
	    tn x=0,f=1;char c=' ';
	    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
	    a=x*f;
	}
	template<typename tn> void print(tn a){
	    if(a<0) putchar('-'),a=-a;
	    if(a>9) print(a/10);
	    putchar(a%10+'0');
	}
};
using namespace fastio;
long long a,b,n;
int main(){
	read(a);
	read(b);
	read(n);
	long long d=min(b-1,n);
	long long ans=a*d/b;
	print(ans);
	puts("");
	return 0;
}

Measured memory_bytes: 3624
import std.stdio;
import std.string;
import std.array;
import std.range;
import std.random;
import std.algorithm;
import std.conv;

void main(){
    auto nk = readln().chomp().split().map!(to!int).array();
    auto as = readln().chomp().split().map!(to!int).array();
    auto k = nk[1];
    auto n = nk[0];
    solve(n, k).writeln();
}

int solve(int n, int k){
    if((n - 1) % (k - 1) == 0){
        return (n - 1) / (k - 1);
    }else{
        return (n - 1) / (k - 1) + 1;
    }
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

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

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool graph[101][101];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
char c[10][10];
bool visited[10][10];
char math[1010][1010];
ll res2[101010][101];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	rep(i, 60) {
		ll x = 0;
		rep(j, n) {
			if (a[j] >> i & 1)x++;
		}
		ll now = x * (n - x) % MOD;
		rep(j, i) {
			now = now * 2 % MOD;
		}
		ans += now;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000100
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
ll W;
ll w[105];
int v[105];
ll dp[105][100100];
int main(){
	cin >> N >> W;
	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=100000;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0ll;
	for(int i=0;i<N;i++){
		for(int j=0;j<=100000;j++){
			if(dp[i][j]!=INF)chmin(dp[i+1][j],dp[i][j]);
			if(j>=v[i]&&dp[i][j-v[i]]!=INF)chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
		}
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=100000;j++){
			//cout << dp[i+1][j] << ' ';
			if(dp[i+1][j]==INF)continue;
			if(dp[i+1][j]<=W)chmax(ans,j);
		}
		//cout << endl;
	}
	cout << ans << endl;
	return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int size = 0;
  int ma = -1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
      size++;
    } else {
      if (ma < size) {
        ma = size;
        size = 0;
      }
    }
  }
  int ans = max(size,ma);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=10**9+7
K=int(input())
S=list(ns())
N=K+len(S)

class My_pow():
    def __init__(self,n,r,p):
        self.pow=[0]*r
        self.pow[0]=1
        for i in range(1,r):
            self.pow[i]=(self.pow[i-1]*n)%p
    
    def clc_pow(self,r):
        return self.pow[r]

            
class My_comb(): 
    def __init__(self,MOD,Nmax):
        self.p=MOD
        self.fact=[1,1]
        self.factinv=[1,1]
        self.inv=[0,1]
        for i in range(2,Nmax+1):
            self.fact.append((self.fact[-1]*i)%self.p)
            self.inv.append((-self.inv[self.p%i]*(self.p//i))%self.p)
            self.factinv.append((self.factinv[-1]*self.inv[-1])%self.p)


    def comb(self,n,r):
        if(r<0) or (n<r):
            return 0
        r=min(r,n-r)
        return self.fact[n]*self.factinv[r]*self.factinv[n-r]%self.p 


my_comb=My_comb(mod,2*(10**6))
my_pow26=My_pow(26,K+5,mod)
my_pow25=My_pow(25,K+5,mod)

ans=0
for i in range(K+1):
    now =(my_pow26.clc_pow(K-i)*my_pow25.clc_pow(i))
    now *=my_comb.comb(i+len(S)-1,len(S)-1)
    ans += now
    ans%=mod

print(ans)
    
    





Measured memory_bytes: 286276
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, k, d[9];
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	while(1){
		string s = to_string(n);
		bool num[10] = {0};
		for (int i = 0; i < s.size(); i++) {
			num[s[i]-'0'] = 1;
		}
		bool conti = 0;
		for (int i = 0; i < k; i++) {
			if(num[d[i]]) conti = 1;
		}
		if(!conti) break;
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
	
	int count = 0, a, b = 0, min = 9;
	int c[5];
	int save =0;
	for (int i = 0; i <5; i++){
		scanf("%d", &a);
		c[i] = a;
		if(((a%10) < min) && (a%10) != 0){
			min = (a%10);
		}
			
	}
	
	for (int j = 0; j < 5; j++){
		if((c[j]%10) == min){
			if(save > 0){
					b = 10 - (c[j]%10);
					count = count+b+c[j];
			}
			else{
			count = count + c[j];}
			//printf("A-----%d ----", count);
			save++;
		}
		else if((c[j]%10) != 0){
			b = 10 - (c[j]%10);
			count = count+b+c[j];
			//printf("B-----%d ----", count);
		}
		else{
			count = count + c[j];
	//	printf("C-----%d ----", count);
		}
			
			
		
	}
	
	printf("%d", count);
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N;
int mx = 0,sum = 0;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	
	REP(i,N){
		int x;
		cin >> x;
		if(x > mx){
			sum += mx;
			mx = x;
		}else{
			sum += x;
		}
	}

	if(mx < sum){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,y,fuku,nito,natu;
int main(){
  scanf("%d %d",&n,&y);
  for(int i=0;i<=n;i++){
    natu = i*1000;
    for(int j=0;j<=(n-i);j++){
      int k = n-i-j;
      fuku = k*10000;
      nito = j*5000;
      if(y == fuku+nito+natu && k >= 0){
        printf("%d %d %d",k,j,i);
        return 0;
      }
    }
  }
  printf("%d %d %d",-1,-1,-1);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  int a=0,b=0;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    if(a<x){
      a=x;b=y;
    }
  }
  cout<<a+b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 1; ll z = 0, o = 1;
vl flag, color, D; vll path;
ll binarySearch(vl V, ll key) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = V.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		if (V[mid] >= key) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	ll Q;
	cin >> Q;
	for (k = 0; k < Q; k++) {
		ll a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		if (a + 1 >= b) {
			cout << a*2 - 2 << endl;
		}
		else {
			ll P = sqrt(a*b);
			if (P * P >= a * b)P--;
			if (P * (P + 1) < a * b) {
				cout << 2 * P - 1 << endl;
			}
			else cout << 2 * P - 2 << endl;
		}
	}
}

Measured memory_bytes: 256
n,x=map(int,input().split())
minn=19999
for i in range (n):
    c,t=map(int,input().split())
    if t > x:
        continue
    else :
        if c<minn:
            minn=c
if minn<19999 :
    print(minn)
else :
    print("TLE")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    FOR(i,n,999)
      if (i / 100 == i / 10 % 10 && i / 100 == i % 10) {
        cout << i;
        return 0;
      }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
 
typedef long long ll;
 
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
typedef long long ll;
const int INF = 1001001001;

/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 


///////////////////////////////////////////////////////////////////////////


int main() {

    string str;
    int N[4];
    cin >> str;
    for (int i = 0; i < 4; ++i) {
        N[i] = (int)(str[i] - '0');
    }

    
    rep(i,(1<<3)){
        bitset<3> s(i);
        ll ans = N[0];
        rep(j,3){
            if(s.test(j)){
                ans += N[j+1];
            }
            else{
                ans -= N[j+1];            
            }
        }
        if(ans == 7){
            cout << N[0];
            rep(k,3){
                if(s.test(k)) cout << "+";
                else cout << "-";
                cout << N[k+1];
            }
            cout << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];
    
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<int> s;
    rep(i, X) s.push_back(p[i]);
    rep(i, Y) s.push_back(q[i]);
    rep(i, C) s.push_back(r[i]);
    sort(s.rbegin(), s.rend());
    int sum = 0;
    rep(i, X + Y) sum += s[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 8816