akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);

    if(A*B>C*D)
    {
        printf("%d ",A*B);
    }
     else if(A*B<C*D)
    {
        printf("%d ",C*D);
    }
     else
    {
        printf("%d ",A*B);
    }



}


Measured memory_bytes: 128
#include<stdio.h>

int main (void)

{
	int n;
	int hi[10];
	int max[3] = {0};
	
	for(n = 0; n < 10; n++){
		scanf("%d", &hi[n]);
	}
	
	for(n = 0; n < 10; n++){
		if(hi[n] >= max[2]){
			max[2] = hi[n];
			if(hi[n] >= max[1]){
				max[2] = max[1];
				max[1] = hi[n];
				if(hi[n] >= max[0]){
					max[1] = max[0];
					max[0] = hi[n];
				}
			}
		}
	}
	printf("%d\n%d\n%d\n", max[0], max[1], max[2]);
	
	return(0);
}

Measured memory_bytes: 600
class Array
  def round_robin_scheduling(q)
    time = 0
    while !empty? do
      time += [first[1].to_i, q].min
      first[1] = first[1].to_i - [first[1].to_i, q].min
      first[1] == 0 ? (puts [shift[0], time].join(" ")) : (self << shift)
    end
  end
end

n, q = gets.split.map(&:to_i)
schedules = []
n.times do
  schedules << gets.split
end
schedules.round_robin_scheduling(q)



Measured memory_bytes: 15836
using System;

namespace Character
{
    class Counting_Characters
    {
        static void Main(string[] args)
        {
            var line = "";
            var count = new int[26];
            while ((line = Console.ReadLine()) != null )
            {
                var array =line.ToLower().ToCharArray();
                for (int i = 0; i < array.Length; i++)
                    if (char.IsLetter(array[i]))
                        if (char.IsLower(array[i])) count[array[i] - 97]++;
            }
            for (int i = 0; i < 26; i++)
                Console.WriteLine((char)(i + 97) + " : " + count[i]);
        }
    }
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL); 
	int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (n); ++i) 
  	cin >> a[i];
  int ans[n];
  for (int i = 0; i < (n); ++i) 
  	ans[a[i]-1] = i+1;
  for (int i = 0; i < (n); ++i) 
	cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 4404
int Max (int n, int x[]);
int Min (int n, int x[]);
long long int Sum (int n, int x[]);

main() {
    int n;
    int a[10000];
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    printf("%d %d %lld\n", Min(n,a), Max(n,a), Sum(n,a));
}

int Max (int n, int x[]) {
    int max = x[0];
    for (int j = 1; j < n; j++) {
        if (x[j] > max) max = x[j];
    }
    return max;
}

int Min (int n, int x[]) {
    int min = x[0];
    for (int k = 1; k < n; k++) {
        if (x[k] < min) min = x[k];
    }
    return min;
}

long long int Sum (int n, int x[]) {
    long long int sum = x[0];
    for (int l = 1; l < n; l++) {
        sum += x[l];
    }
    return sum;
}


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

typedef long long ll;

ll MOD = 1e9+7;

ll bigMod(ll a, ll b, ll m){
	a%=m;
	ll ret = 1;
	while (b>0){
		if(b&1)	ret = ret*a%m;
		a=a*a%m;
		b>>=1;
	}
	return ret;
}

ll modInv(ll a, ll p){
	return bigMod(a, p-2, p);
}


ll nCr(ll n, ll r, ll p){
	r = min(r, n-r);
	ll ret = 1;
	for (int i = 1; i <= r; ++i){
		ret = ret*n%p;
		n--;
		ret = ret * modInv(i, p) %p;
	}
	return ret;
}

int main(){
	ll n, a, b;	cin >> n >> a >> b;
	ll ans = bigMod(2, n, MOD);
	ans--;
	ans = (ans+MOD) % MOD;
	ans -= nCr(n, a, MOD);
	ans = (ans+MOD) % MOD;
	ans -= nCr(n, b, MOD);
	ans = (ans+MOD) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#146_F
n, m = map(int, input().split())
s = input()[::-1]
ans = []

flg = True
cur = 0
while cur < n and flg:
    for to in range(cur + m, cur, -1):
        if to > n:
            continue
            
        if s[to] == '0':
            ans.append(to - cur)
            cur = to
            break
        
        if to == cur + 1:
            flg = False

if flg:
    print(*ans[::-1])
else:
    print(-1)

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

long long up[510][510];
long long down[510][510];
long long a[510][510];
int h, w;

int main(){
  cin >> h >> w;

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

  up[0][0] = 1;
  for(int i = 0;i < w;i++){
    if(i != 0){
      up[0][i] = up[0][i-1]+1;
    }

    for(int j = 1;j < h;j++){
      up[j][i] = up[0][i] * (j+1);
    }
  }

  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      down[i][j] = up[h-i-1][w-j-1];
    }
  }

  long long ans = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      ans += up[i][j] * down[i][j] * a[i][j];
    }
  }

  cout << ans << endl;

  return 0;
}





Measured memory_bytes: 9108
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn =  1e5+10;

char str[maxn];
int s[maxn];
int main(){
    //frein;
    scanf("%s", str);
    int len = strlen(str);
    for(int i = 0; i < len; i++){
        s[i] = str[i]-'0';
    }
    int m = len/2;
    int r = m+(len%2), l = m-1;
    while(s[l] == s[m] && s[r] == s[m] && r < len){
        l--;
        r++;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 768
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

bool palindrome(string& s, int begin, int end) {
  while (begin <= end) {
    if (s[begin] != s[end]) {
      return false;
    }
    ++begin;
    --end;
  }
  return true;
}

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  string s;
  cin >> s;

  int mid = (s.size() - 1) / 2;

  if (palindrome(s, 0, mid - 1) && palindrome(s, mid + 1, s.size() - 1) && palindrome(s, 0, s.size() - 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<Pl> vec;
  for(int i = 0; i < n; i++){
    int a;
    ll b;
    cin >> a >> b;
    vec.pb(mk(a, b));
  }
  sort(vec.begin(), vec.end());
  cout << vec[n - 1].first + vec[n - 1].second << endl;
	return 0;
}


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

using namespace std;

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

    int ans = 1e9;
    for (int i = -100; i < 101; i++) {
        int calc = 0;
        for (int j : v) {
            calc += pow(j - i, 2);
        }
        if (calc < ans) ans = calc;
    }
    cout << ans;
}


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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int pop_count(int 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);
}

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string S[1000];
    vector<pair<int, int>> pos;
    pair<int, int> ps, pg;
    for(int i=0; i<H; i++){
        cin >> S[i];
        for(int j=0; j<W; j++){
            if(S[i][j] == 's') ps = {i, j};
            if(S[i][j] == 'e') pg = {i, j};
            if(S[i][j] == 'a') pos.emplace_back(i, j);
        }
    }
    int KK = pos.size();

    const int64_t INF = 1e15;
    int64_t dist[20][20], grid_dist[1000][1000], toS[20], toG[20];
    const int dx[] = {-1, 1, 0, 0};
    const int dy[] = {0, 0, -1, 1};
    auto inside = [&](int i, int j){ return 0<=i && i<H && 0<=j && j<W && S[i][j] != '#'; };

    for(int k=0; k<KK; k++){
        for(int i=0; i<H; i++) for(int j=0; j<W; j++) grid_dist[i][j] = INF;
        queue<pair<int, int>> que;
        grid_dist[pos[k].first][pos[k].second] = 0;
        que.push(pos[k]);
        while(que.size()){
            auto p = que.front(); que.pop();
            int i = p.first, j = p.second;
            for(int t=0; t<4; t++){
                int x = i + dx[t], y = j + dy[t];
                if(inside(x, y) && grid_dist[x][y] == INF){
                    grid_dist[x][y] = grid_dist[i][j] + 1;
                    que.emplace(x, y);
                }
            }
        }
        toS[k] = grid_dist[ps.first][ps.second];
        toG[k] = grid_dist[pg.first][pg.second];
        for(int l=0; l<KK; l++) dist[k][l] = grid_dist[pos[l].first][pos[l].second];
    }

    static int64_t dp[1<<20][20];
    for(int i=0; i<(1<<KK); i++) for(int k=0; k<KK; k++) dp[i][k] = INF;
    for(int k=0; k<KK; k++) dp[1<<k][k] = toS[k];
    for(int i=0; i<(1<<KK); i++) for(int k=0; k<KK; k++) for(int t=0; t<KK; t++) if(!nth_bit(i, t)){
        chmin(dp[i+(1<<t)][t], dp[i][k] + dist[k][t]);
    }

    int64_t ans = INF;
    for(int i=0; i<(1<<KK); i++) if(pop_count(i) >= K) for(int k=0; k<KK; k++) chmin(ans, dp[i][k] + toG[k]);
    if(ans >= INF) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 175748
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,m; cin >> n >> m;
    string s; cin >> s;
    int now = 0;
    vector<int> ans;
    reverse(ALL(s));
    while(now < n){
        bool can = false;
        for(int i = m; i >= 1; i--){
            if(now + i <= n && s[now + i] == '0'){
                can = true;
                now += i;
                ans.push_back(i);
            }
            if(can) break;
        }
        if(!can){
            cout << "-1" << endl;
            return 0;
        }
    }
    reverse(ALL(ans));
    int l = ans.size();
    rep(i, l) printf("%d%c", ans[i], i==l-1? '\n' : ' ');
}

Measured memory_bytes: 1144
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            WriteLine(N * (N - 1) / 2);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(100000)
import numpy as np

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])


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


import numpy as np

directions = list(map(np.array, directions))


def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())
s=acinput()
s=sorted(s)
#H, W = acinput()

#field = []

#for i in range(H):
#    field.append(list(input()))

res = s[-1]

v=10**9
res2=res
for ss in s:
    if abs(ss-res/2)<v:
        v = abs(ss-res/2)
        res2=ss

print(s[-1],res2)




Measured memory_bytes: 23020
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()

    return "x" * len(s)


print(main())





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



int main(){
    int N;
    cin >> N;
    vector<int> DP(N+1,-1);
    DP[0] = 0;
    for(int i = 0; i < N;i++){
        
        if(DP[i+1]!=-1)DP[i+1] = min(DP[i+1],DP[i] + 1);
        else DP[i+1] = DP[i] + 1;
        
        for(int j = 6; i < N;j*=6){
            if(i+j > N)break;
            if(DP[i+j]!=-1)DP[i+j] = min(DP[i+j],DP[i] + 1);
            else DP[i+j] = DP[i] + 1;
        }   
        
        for(int j = 9; i < N;j*=9){
            if(i+j > N)break;
            if(DP[i+j]!=-1)DP[i+j] = min(DP[i+j],DP[i] + 1);
            else DP[i+j] = DP[i] + 1;
        }  
        
    }
    int cont = 0;
    for(int i = 0; i < N;i++){
        cont = i;
        if(DP[N - cont]!=0)break;
    }
    
    //cout << DP[N]  << endl;
    //cout << cont << endl;
    cout << DP[N-cont] + cont << endl;
    
    
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long

//io_method
void print(int n){ cout << n << endl; }
int input() {int t; cin >> t; return t;}

//main------------------------------------------------------------------------------------------

struct fenwick{
    vector<int> bit;
    int s;

    fenwick(int n){
        s = n;
        rep(i,0,n+1) bit.push_back(0);
    }

    int sum(int i){
        if(i < 1) return 0;
        return bit[i] + sum(i - (i & -i));
    }

    void add(int i, int x){
        if(i > s) return; 
        bit[i] += x;
        add(i +(i & -i), x);
    }


};

signed main(){
    
    int h,w;
    cin >> h >> w;

    int ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            char tmp; cin >> tmp;
            if(tmp == '#') ans++;
        }
    }

    cout << (ans == (h + w - 1) ? "Possible" : "Impossible" )<< endl;

    
    



}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.length()+1;
    long ans=0;
    int l = 0, r = 0;
    if(S[0]=='<'){ans++;l=1;}
    else{ans++;r=1;}
    for(int i=1;i<N-1;i++){
        if(S[i]=='<'){
            if(S[i-1]=='<'){
                l++;
                ans+=l;
            }
            else{
                r=0;
                l=1;
                ans++;
            }
        }
        else{
            if(S[i-1]=='>'){
                ans+=r;
                r++;
                if(l<r)ans++;
            }
            else{
                r=1;
               // ans++;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll gcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
template <typename T>
T lcm(T x, T y) {
    return x / gcd(max(x,y), min(x,y)) * y;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll long long
const int MAXN = 2e5+5;
int a[MAXN];
int main()
{   
    int k,n;
    cin>>k>>n;
    for(int i = 1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ans = INT_MAX;
    for(int i = 1;i<n;i++)
    {
        int j = i+1;
        ans = min(ans,max(a[j] - a[i],(k - (a[j] - a[i]))));
    }
    ans = min(ans,max(a[n]-a[1],(k - (a[n]-a[1]))));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
sum_a = 0
for i in range(n):
    if i%2==0:
        continue
    else:
        sum_a += a[i]
x1 = s-2*sum_a
ans = [x1]
for i in range(1,n):
    if i==n-1:
        x = 2*a[i]-ans[0]
    else:
        x = 2*a[i-1] - ans[i-1] 
    ans.append(x)
print(*ans)
 

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

int main(void)
{
	char str[1 << 15];
	char *tpos;
	int count;

	while (~scanf("%s", str)){
		count = 0;
		tpos = str;
		while ((tpos = strstr(tpos, "JOI")) != NULL){
			count++;
			tpos++;
		}
		printf("%d\n", count);
		count = 0;
		tpos = str;
		while ((tpos = strstr(tpos, "IOI")) != NULL){
			count++;
			tpos++;
		}
		printf("%d\n", count);
	}

	return (0);
}

Measured memory_bytes: 568
n,k = map(int,input().split())
s = input()
if len(s) == 1:
    print(0)
    exit()

ans = 0
c = 0
for i in range(1,n):
    if s[i] == s[i-1]:
        ans += 1
    else:
        c += 1

if c == 1:
    print(n-1)
    exit()


t = -1
left = s[0]
q = -1
for i in range(1,n):
    if s[i] != left:
        t += 1
        left = s[i]
    if t == 1 and k > 0:
        k -= 1
        ans += 2
        t = -1

if t == 0 and k > 0:
    ans += 1
print(ans)


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> high(n);
    rep(i,n) cin >> high[i];
    int ans = 0;
    vector<bool> tow(n,true);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        if(high[a] > high[b]) tow[b] = false;
        else if(high[a] < high[b]) tow[a] = false;
        else{
            tow[a] = false;
            tow[b] = false;
        }
    }
    rep(i,n){
        if(tow[i] == true) ans++;
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 3788
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if (x == 0):
    if (k % 2 == 0):
        ans = 0
    else:
        ans = d
else:
    if ((k * d) > abs(x)):
        y = abs(x) // d
        ans = abs(abs(x) - y * d)
        if ((k - y) % 2 == 1):
            ans = abs(d - ans)
    else:
        ans = abs(x) - k * d


print(ans)

Measured memory_bytes: 9180
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    k = int(input().rstrip('\n'))
    x = list(map(int, input().rstrip('\n').split()))
    t = 0
    for v in x:
        t += (min(v, abs(k - v)) * 2)
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
#define ll long long
#define int ll
#define el '\n'
template<class T> bool inline rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool inline rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);

int n,m; cin>>n>>m;
string over; cin>>over;
vv<int> dp(n+1,INFLL); dp[n]=0;
vv<int> ch(n+1,-1); 
auto cmp=[&](int a, int b){
	return make_pair(dp[a], a) < make_pair(dp[b], b);
};
set<int, decltype(cmp)> s(cmp);
s.insert(n);
for(int i=n-1;i>=0;--i){
	if(over[i]=='1')
		continue;
	while(!s.empty() && *s.begin() > i + m){
		s.erase(s.begin());
	}
	if(s.empty()) continue;
	int idx = *s.begin();
	dp[i] = dp[idx] + 1;
	ch[i] = idx - i;
	//DDD(i, dp[i], ch[i])
	s.insert(i);
}
if(ch[0]==-1){
	cout<<-1<<el;
} else{
	for(int i=0;i<n;){
		cout<<ch[i]<<' ';
		i += ch[i];
	}

}


return 0;
}


Measured memory_bytes: 5760
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#include "boost/multiprecision/cpp_int.hpp"
typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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




int main(){fastio
    LL n,m;cin>>n>>m;
    while(m--){
        LL c;cin>>c;
        n-=c;
    }
    cout<<(n>=0?n:-1)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

typedef long long ll;

#define BLACK 0
#define WHITE 1

int n, m, p;
int board[7][7][7];
bool check() {
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      for (int z = 0; z < n; z++) {
	if (board[x][y][z] == -1) continue;
	for (int dx = -1; dx <= 1; dx++) {
	  for (int dy = -1; dy <= 1; dy++) {
	    for (int dz = -1; dz <= 1; dz++) {
	      if (dx == 0 && dy == 0 && dz == 0) continue;
	      int cnt = 1;
	      int px = x, py = y, pz = z;
	      int nx, ny, nz;
	      nx = px; ny = py; nz = pz;
	      for (int t = 0; t < n; t++) {
		nx += dx;
		ny += dy;
		nz += dz;
		if (nx < 0 || ny < 0 || nz < 0 ||
		    nx >= n || ny >= n || nz >= n) break;
		if (board[nx][ny][nz] != -1 && board[nx][ny][nz] == board[px][py][pz]) {
		  cnt++;
		  if (cnt >= m) {
		    // cout << dx << " " << dy << " " << dz << endl;
		    // cout << nx << " " << ny << " " << nz << endl;
		    return true;
		  }
		}else {
		  px = nx; py = ny; pz = nz;
		  cnt = 1;
		}
	      }
	    }
	  }
	}
      }
    }
  }

  return false;
}

int main() {
  while (true) {
    cin >> n >> m >> p;
    if (n == 0 && m == 0 && p == 0) break;

    memset(board, -1, sizeof(board));
    bool turn = true;
    int ansturn = -1, ansnum = 0;
    for (int i = 0; i < p; i++) {
      int x, y;
      cin >> x >> y;
      x--; y--;
      bool empf = true;
      for (int j = 0; j < n; j++) {
	if (board[x][y][j] != -1) {
	  empf = false;
	  if (j > 0) board[x][y][j-1] = turn;
	  break;
	}
      }
      if (empf) {
	board[x][y][n-1] = turn;
      }
      if (check() && ansturn == -1) {
	if (turn) {
	  ansturn = turn;
	  ansnum = i+1;
	}else {
	  ansturn = turn;
	  ansnum = i+1;
	}
      }
      turn = !turn;
    }
    // for (int z = 0; z < n; z++) {
    //   for (int x = 0; x < n; x++) {
    // 	for (int y = 0; y < n; y++) {
    // 	  cout << board[x][y][z] << " ";
    // 	}
    // 	cout << endl;
    //   }
    //   cout << endl;
    // }
    if (ansturn != -1) {
      if (ansturn) {
	cout << "Black " << ansnum << endl;
      }else {
	cout << "White " << ansnum << endl;
      }
    }else {
      cout << "Draw" << endl;
    }
  }
}

Measured memory_bytes: 3072
#include <stdio.h>

struct Dice
{
	int n[6];
};

Dice InputDice()
{
	Dice d;
	for(int i = 0; i < 6; ++i)
	{
		scanf("%d", &d.n[i]);
	}
	
	return d;
}

Dice SetDice(int a, int b, int c, int d, int e, int f)
{
	Dice dice;
	dice.n[0] = a;
	dice.n[1] = b;
	dice.n[2] = c;
	dice.n[3] = d;
	dice.n[4] = e;
	dice.n[5] = f;
	
	return dice;
}

Dice Roll(Dice dice, char dir)
{
	switch(dir)
	{
		case 'N':
			return SetDice(dice.n[1], dice.n[5], dice.n[2], dice.n[3], dice.n[0], dice.n[4]);
		case 'S':
			return SetDice(dice.n[4], dice.n[0], dice.n[2], dice.n[3], dice.n[5], dice.n[1]);
		case 'W':
			return SetDice(dice.n[2], dice.n[1], dice.n[5], dice.n[0], dice.n[4], dice.n[3]);
		case 'E':
			return SetDice(dice.n[3], dice.n[1], dice.n[0], dice.n[5], dice.n[4], dice.n[2]);
	}
}

bool IsSame(Dice a, Dice b)
{
	for(int i = 0; i < 6; ++i)
	{
		if(a.n[i] != b.n[i])
		{
			return false;
		}
	}
	
	return true;
}

bool IsEqual(Dice a, Dice b)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		b = Roll(b, cmd[i]);
		if(IsSame(a, b))
		{
			return true;
		}
	}
	
	return false;
}

int FindSide(Dice a, int top, int front)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		a = Roll(a, cmd[i]);
		if(a.n[0] == top && a.n[1] == front)
		{
			return a.n[2];
		}
	}
	
	return -1;
}

int main()
{
	Dice D = InputDice();
	
	int N;
	scanf("%d", &N);
	for(int i = 0; i < N; ++i)
	{
		int top, front;
		scanf("%d%d", &top, &front);
		
		printf("%d\n", FindSide(D, top, front));
	}

    return 0;
}



Measured memory_bytes: 2680
S = input()
a=0
if S=='SUN':
    a=7
elif S=="MON":
    a=6
elif S=='TUE':
    a=5
elif S=="WED":
    a=4
elif S=='THU':
    a=3
elif S=="FRI":
    a=2
else:
    a=1

print(a)

Measured memory_bytes: 38256
<>=~$";@c=(($H=$`-2)*($W=$'-2),(0)x9);map$H+3>($a=$`+$_%3)&$a>2&$W+3>($b=$'+$_/3|0)&$b>2&&$c[$$a{$b}]--*$c[++$$a{$b}]++,!//..8for<>;print"@c"

Measured memory_bytes: 245504
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 1e9, mod = 1e9+7;
int const mxn = 1e3+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
///////////////////////////////////
long long n,ans;
long long dp[mxn*30];
vector <pair <pair <int ,int > , pair <int ,int > > > vec;
//////////////////////////////////



int main(){
	cin>>n;
	for (int i= 0;i<n;i++){
		int w , m , v;
		cin>>w>>m>>v;
		vec.push_back({{w+m,v} , {w,m}});
	}
	sort(vec.begin() , vec.end());
	for (int i = 1;i<=n;i++){
		int w = vec[i-1].S.F , m = vec[i-1].S.S , v = vec[i-1].F.S;
		for(int j = 20000;j>=0;j--){
			if (j<=m)
				dp[j+w] = max(dp[j+w] , dp[j]+v);
			ans = max(ans, dp[j+w]);
		}
	}
	cout<<ans;	
}
/*
3
2 2 20
2 1 30
3 1 40
*/

Measured memory_bytes: 384
#include <cstdio>
#include <utility>
using namespace std;

pair<long long, long long> extended_gcd(long long a, long long b) {
    if (b == 0) return { 1, 0 };
    auto t = extended_gcd(b, a % b);
    return { t.second, t.first - t.second * (a / b) };
}

inline long long modinv(long long a, long long m) {
    return (extended_gcd(a, m).first % m + m) % m;
}

const int MOD = 1000000007;
int fact[4000001], factinv[4000001];

inline int comb(int n, int m) {
    if (m < 0 || m > n) return 0;
    return ((long long)fact[n] * factinv[m] % MOD) * factinv[n - m] % MOD;
}

int n, k;
int d[2001][2001];

int main() {
    scanf("%d %d", &n, &k);
    if (k == 1) {
        printf("1\n");
        return 0;
    }

    fact[0] = factinv[0] = 1;
    for (int i = 1; i <= n * k; ++i) {
        fact[i] = (long long)fact[i - 1] * i % MOD;
    }
    factinv[n * k] = modinv(fact[n * k], MOD);
    for (int i = n * k; i > 1; --i) {
        factinv[i - 1] = (long long)factinv[i] * i % MOD;
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            if (i == 0 && j == 0) {
                d[i][j] = 1;
                continue;
            }
            d[i][j] = ((i > 0 ? d[i - 1][j] : 0) + (long long)d[i][j - 1] * comb(i + j * (k - 1) - 1, k - 2)) % MOD;
        }
    }

    int ans = d[n][n];
    for (int i = 2; i <= n; ++i) {
        ans = (long long)ans * i % MOD;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 47104
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		List<Long> aList = new ArrayList<>();
		
		List<Long> gcdList = new ArrayList<>();

		int countOne = 0;
		int countTwo = 0;

		for (int i = 0; i < n; i++) {
			long a = sc.nextInt();
			aList.add(a);
		}

		long prevGcd = aList.get(0);
		for (int i = 0; i < n; i++) {
			long a = aList.get(i);
			prevGcd = gcd(a, prevGcd);
			gcdList.add(prevGcd);
		}
		// System.out.println("gcdList "+gcdList);

		long tmpGcd=gcdList.get(n-2);
		long rightGcd = aList.get(n-1);
		long maxResult = tmpGcd;
		// System.out.println("maxResult "+maxResult);
		// System.out.println(" ");

		for (int i = n-2; i >=1; i--) {
			long curGcd;
			long leftGcd = gcdList.get(i-1);
			rightGcd = gcd(rightGcd, aList.get(i+1));
			curGcd = gcd(leftGcd,rightGcd);
			maxResult = Math.max(maxResult, curGcd);
			
			// System.out.println("aList.get(i) "+aList.get(i+1));
			// System.out.println("leftGcd "+leftGcd);
			// System.out.println("rightGcd "+rightGcd);
			// System.out.println("curGcd "+curGcd);
			// System.out.println("maxResult "+maxResult);
			// System.out.println(" ");
		}

		// i=0が仲間はずれのパターンだけ
		rightGcd = gcd(rightGcd, aList.get(1));
		maxResult = Math.max(maxResult, rightGcd);
		// System.out.println("aList.get(1) "+aList.get(1));
		// System.out.println("rightGcd "+rightGcd);
		// System.out.println("maxResult "+maxResult);

		System.out.println(maxResult);


	}

	private static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}


Measured memory_bytes: 62428
// Problem : N - Slimes
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_n
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e18
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 402

//Solution

int n,a[N],dp[N][N],pre[N];

void solve(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) dp[i][j] = inf;
        dp[i][i] = 0;
    }
    pre[0] = a[0];
    for(int i=1;i<n;i++) pre[i] = pre[i-1]+a[i];
    for(int i=0;i<n-1;i++) dp[i][i+1] = a[i]+a[i+1];
    for(int l=3;l<=n;l++){
        for(int i=0;i<=n-l;i++){
            int j = i+l-1;
            for(int k=i;k<j;k++) dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]);
            dp[i][j] += (pre[j]-(i-1 >= 0 ? pre[i-1] : 0));
        }
    }
    cout<<dp[0][n-1];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if( a!= b && b != c && c != a ){
    cout << 3 << endl;
    return 0;
  }else if( a == b && b == c ){
    cout << 1 << endl;
  }else{
    cout << 2 << endl;
  }
}

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

#define ll long long
#define ull unsigned long long

int main(void) {
    ll N, K;
    ll c = 0;
    map<ll, ll> m;
    cin >> N >> K;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        m[temp] += 1;
    }
    if(m.size() <= K) {
        cout << 0 << endl;
    } else {
        ll sum = 0;
        vector<pair<ll, ll>> l;
        copy(m.begin(), m.end(), back_inserter(l));
        sort(l.begin(), l.end(), [](pair<ll, ll> &a, pair<ll, ll> &b) { return a.second < b.second; });
        for(auto &i: vector<pair<ll, ll>>(l.begin(), l.end() - K)) sum += i.second;
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())
#define ten(n) ((int)1e##n)
using ll = long long;

const int MOD = ten(9) + 7;
const int N = ten(4);

// O(N)
ll inverse[N];
void init_inverse() {
	inverse[1] = 1;
	for (int i = 2; i < N; i++) inverse[i] = (MOD - MOD / i) * inverse[MOD%i] % MOD;
}

// O(N)
ll fact[N], infact[N];
void init_fast_fact() {
	init_inverse();
	fact[0] = fact[1] = 1;
	for (int i = 2; i < N; i++) fact[i] = fact[i - 1] * i % MOD;
	infact[0] = infact[1] = 1;
	for (int i = 2; i < N; i++) infact[i] = infact[i - 1] * inverse[i] % MOD;
}

// O(1)
ll fast_nCk(int n, int k) {
	if (n < 0 || k < 0) return 0;
	if (k > n) return 0;
	ll ret = fact[n] * infact[k] % MOD * infact[n - k] % MOD;
	return ret;
}

//O(1)
ll pseudo_catalan(int a, int b, int c) {
	if (c == a - 1) b--, c--;
	if (c == b - 1) a--, c--;
	ll ret = fast_nCk(a + b - 2, a - 1) - fast_nCk(a + b - 2, c - 1);
	if (ret < 0) ret += MOD;
	return ret;
}

int solve(int n, int m) {
	// O(n) にできるが、今回は十分に大きい定数回回している
	init_fast_fact();

	// https://oeis.org/A126087
	// magic[i] = i回タイプした時、文字列が空になるようなキーの押し方の個数
	// O(n)
	vector<ll> magic = { 1, 1, 3 };
	for (int i = 3; i <= n; i++) {
		ll tmp = 3 * (i + 1) * magic[i - 1] + 8 * (i - 2) * magic[i - 2] - 24 * (i - 2) * magic[i - 3];
		magic.push_back(tmp % MOD * inverse[i + 1] % MOD);
		if (magic[i] < 0) magic[i] += MOD;
	}

	// 2の累乗
	// O(n)
	vector<ll> power_of_2;
	power_of_2.push_back(1);
	FOR(i, n) power_of_2.push_back(power_of_2.back() * 2 % MOD);

	ll ans = 0;
	FOR(s, n) {
		// ループ内はO(1)
		//
		// |------|X|-------|
		// <------>^<------->
		//    |    |    |
		//    s    | rem - 1
		//         s回目(0-indexed)
		//
		// 前半s回のタイプ後、文字列の長さが0
		// s+1回目、最初の文字を打つ
		// 後半、s+2回目以降は、文字列が空にならないよう注意しながらタイピング
		// こうすると重複せず数え上げられる
		//
		// 前半はmagicに係数が入っているので、後半のs+2回目以降のタイプの仕方について数え上げればよい

		const int rem = n - s; //後 rem 回タイプ出来る
		if (rem < m) continue;
		if ((rem - m) % 2 != 0) continue;

		const int B = (rem - m) / 2; // s+2回目以降のバックスペースの回数
		const int A = rem - B; // s+2回目以降タイプする文字列 (= {0,1}をタイプする回数)

		const ll a1 = B == 0 ? 1 : pseudo_catalan(A , B + 1, B); //カタラン数の計算方法と同じやつ
		// バックスペースで消される文字列は{0,1}のどっちでもいいので、 2^B	を掛ける
		const ll s_ans = a1 * power_of_2[B] % MOD * magic[s] % MOD;
		ans += s_ans;
	}

	return int(ans % MOD);
}

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int m = sz(s);
	int ans = solve(n, m);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
N,M,X = map(int,input().split())
list_a = list(map(int,input().split()))
goal_0 = 0
goal_N = 0
for i in list_a:
    if i > X:
        break
    goal_0 += 1
for i in list_a[::-1]:
    if i < X:
        break
    goal_N += 1
print(min(goal_0,goal_N))


Measured memory_bytes: 3060
N = int(input())
work = [list(map(int,input().split())) for _ in range(N)]
work.sort(key=lambda x:x[1])
Time = 0
ans = 'Yes'
for i in range(N):
  Time += work[i][0]
  if Time > work[i][1]:
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 53788
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next(), m = next();
  var k = next();
  var a = nexts(n);
  var b = nexts(m);
  var t = 0;
  for(var i = 0; i < a.length; i++){
    t += a[i];
    if(t > k){
      t -= a[i];
      break;
    }
  }
  var ans = i;
  for(var j = 0; j < b.length; j++){
    t += b[j];
    while(t > k && i > 0){
      t -= a[--i];
    }
    if(t > k)break;
    if(ans < i+j+1)ans = i+j+1;
  }
  return ans;
}

Measured memory_bytes: 77204
#include<bits/stdc++.h>
using namespace std;
#define MAXN	5005
#define MAXV	1000
#define P	1200007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct Hash_Table {
	vector <long long> value[P];
	vector <int> cnt[P];
	int query(long long val) {
		int head = val % P;
		for (unsigned i = 0; i < value[head].size(); i++)
			if (value[head][i] == val) return cnt[head][i];
		return 0;
	}
	void modify(long long val, int delta) {
		int head = val % P;
		for (unsigned i = 0; i < value[head].size(); i++)
			if (value[head][i] == val) {
				cnt[head][i] += delta;
				return;
			}
		value[head].push_back(val);
		cnt[head].push_back(delta);
	}
} cnt;
int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN];
long long Hash(int a, int b, int c, int d) {
	long long ans = a;
	ans = ans * MAXV + b;
	ans = ans * MAXV + c;
	ans = ans * MAXV + d;
	return ans;
}
int Count(int a, int b, int c, int d) {
	return cnt.query(Hash(a, b, c, d));
}
void Modify(int a, int b, int c, int d, int x) {
	cnt.modify(Hash(a, b, c, d), x);
	cnt.modify(Hash(d, a, b, c), x);
	cnt.modify(Hash(c, d, a, b), x);
	cnt.modify(Hash(b, c, d, a), x);
}
long long Query(int a, int b, int c, int d, int A, int B, int C, int D) {
	long long ans = 1;
	ans *= Count(a, A, B, b);
	Modify(a, A, B, b, -1);
	ans *= Count(b, B, C, c);
	Modify(b, B, C, c, -1);
	ans *= Count(c, C, D, d);
	Modify(c, C, D, d, -1);
	ans *= Count(d, D, A, a);
	Modify(a, A, B, b, 1);
	Modify(b, B, C, c, 1);
	Modify(c, C, D, d, 1);
	return ans;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]), read(b[i]), read(c[i]), read(d[i]);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			Modify(a[j], b[j], c[j], d[j], -1);
			ans += Query(a[i], b[i], c[i], d[i], d[j], c[j], b[j], a[j]);
			ans += Query(a[i], b[i], c[i], d[i], a[j], d[j], c[j], b[j]);
			ans += Query(a[i], b[i], c[i], d[i], b[j], a[j], d[j], c[j]);
			ans += Query(a[i], b[i], c[i], d[i], c[j], b[j], a[j], d[j]);
			Modify(a[j], b[j], c[j], d[j], 1);
		}
		Modify(a[i], b[i], c[i], d[i], 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 160896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  string s;
  cin >> n >> k >> s;

  vector<pii> a;
  rep(i, n) {
    int cnt = 1;
    while (i < n-1 && s[i] == s[i+1]) {
      i++;
      cnt++;
    }
    a.push_back({cnt, s[i]-'0'});
  }

  auto f = [&](ll i) {
    return !a[i].second;
  };

  ll right = 0;
  ll cnt = 0;
  ll sum = 0;
  ll ans = 0;
  // [left, right)
  rep(left, a.size()) {
    while (right < a.size() && cnt + f(right) <= k) {
      cnt += f(right);
      sum += a[right].first;
      right++;
      //cerr << left << " " << right << endl;
      //cerr << "  " << cnt << " " << sum << endl;
    }

    cmax(ans, sum);

    if (right == left) right++;
    else {
      cnt -= f(left);
      sum -= a[left].first;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	priority_queue<long long> pro;
	for(int i=0;i<n;i++){
		long long hoge;
		cin>>hoge;
		pro.push(hoge);
	}

	for(int i=0;i<m;i++){
		long long hoge=pro.top();
		pro.pop();
		hoge/=2;
		pro.push(hoge);
	}

	long long ans=0;

	while(!pro.empty()){
		ans+=pro.top();
		pro.pop();
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()
{
    showoff;
    string s;
    cin >> s;
    if(s == "SUN")cout << 7;
    else if(s == "MON")cout << 6;
    else if(s == "TUE")cout << 5;
    else if(s == "WED")cout << 4;
    else if(s == "THU")cout << 3;
    else if(s == "FRI")cout << 2;
    else if(s == "SAT")cout << 1;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;
#define MAX 200005
vector <ll> adj[MAX];
bool visited[MAX];
ll ct;

void dfs(ll src)
{
	ct++;
	visited[src]=false;
	for(auto value:adj[src])
		if(visited[value])
			dfs(value);
}
void solve()
{
	ll n,m,u,v; cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	memset(visited,true,sizeof(visited));
	ll maxm=-inf;
	for(ll i=1;i<=n;i++)
	{
		if(visited[i])
		{
			ct=0;
			dfs(i);
			maxm=max(maxm,ct);
		}
	}
	cout<<maxm;
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


Measured memory_bytes: 21092
#include<iostream>
#include<vector>
 
using namespace std;
 
const int MAXV=(int) 2e5+2;
 
struct edge{
    int to;
};
 
vector <edge> G[MAXV];
int counter[MAXV];
int p[MAXV];
 
int search( int i, int count ){
    if( counter[i]<0 ){
        if( p[i] > 0 ) count += p[i];
        counter[i]=count;
    }
    for( auto& e:G[i] ){
        if( counter[e.to]<0 ){
            search( e.to, count );
        }
    }
    return 0;
}
 
int main(){
    int N,Q;
    cin >> N >> Q;

    int a[N], b[N];
    int ptmp,xtmp;

    for(int i=0; i<=N; i++){
        counter[i]=-1;
        p[i] = 0;
    }
 
    for(int i=0; i<N-1; i++){
        cin >> a[i] >> b[i];
        edge e = { b[i] };
        G[a[i]].push_back(e);
        e = { a[i] };
        G[b[i]].push_back(e);
    }

    for(int i=0; i<Q; i++){
        cin >> ptmp >> xtmp;
        p[ptmp]+=xtmp;
    }

    search( 1, 0 );

    for(int i=1; i<=N; i++){
        cout << counter[i];
        if( i<N ) cout << " ";
    }
    cout << endl;

    return 0;
}
 

Measured memory_bytes: 22656