akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], b[n];
    vector<pair<int, pair<int, int> > > c;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        c.push_back({a[i], {0, i}}); c.push_back({b[i], {1, i}});
    }
    sort(c.begin(), c.end());
    long long ans = min(accumulate(a, a+n, 0LL), accumulate(b, b+n, 0LL));
    bool chosen[2][n];
    memset(chosen, false, sizeof chosen);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += c[i].first;
        chosen[c[i].second.first][c[i].second.second] = true;
    }
    if (sum >= ans) { cout << ans << endl; return 0; }
    for (int i = 0; i < n; i++)
        if (chosen[0][i] && chosen[1][i]) { cout << sum << endl; return 0; }

    for (int i = 0; i < n; i++) {
        if (chosen[0][i]) {
            int d = b[i] == c[n].first ? c[n+1].first - a[i] : c[n].first - a[i];
            ans = min(ans, sum + d);
        }
        if (chosen[1][i]) {
            int d = a[i] == c[n].first ? c[n+1].first - b[i] : c[n].first - b[i];
            ans = min(ans, sum + d);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5364
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto V = RDR.ARR;

	long[long] memo;
	long f(long l, long r, long[] arr, long remain)
	{
		if (l > r || remain == 0)
		{
			/*if (memo.get(-1, long.min) != long.min)
			{
				return memo[-1];
			}*/
			auto index = MAKE_IDX(arr);
			long ans;
			foreach (i; index)
			{
				if (arr[i] < 0 && remain > 0)
				{
					--remain;
					continue;
				}
				ans += arr[i];
			}
			//memo[-1] = ans;
			return ans;
		}

		auto key = remain * 10^^8 + l * 10^^4 + r;
		if (memo.get(key, long.min) != long.min)
		{
			return memo[key];
		}

		auto ans1 = f(l+1, r, arr ~ V[l], remain-1);
		auto ans2 = f(l, r-1, arr ~ V[r], remain-1);
		auto ans3 = f(r+1, r, arr, remain);
		long ans = max(max(ans1, ans2), ans3);
		memo[key] = ans;
		//debug writeln(ans);
		return ans;
	}

	auto ans = f(0, N-1, [], K);

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 1404
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int p = 0;
        int m = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if(a[i] < 0) m++;
            else p++;
        }
        Arrays.sort(a);
        StringBuilder sb = new StringBuilder();
        int t;
        if(p == 0){
            t = a[n-1];
            for (int i = 0; i < n-1; i++) {
                sb.append(t + " " + a[i] + "\n");
                t -= a[i];
            }
        }else if(m == 0){
            if(2 < p){
                t = a[0];
                for (int i = 1; i < n-1; i++) {
                    sb.append(t + " " + a[i] + "\n");
                    t -= a[i];
                }
                sb.append(a[n-1] + " " + t + "\n");
                t = a[n-1] - t;
            }else{
                sb.append(a[n-1] + " " + a[n-2] + "\n");
                t = a[n-1] - a[n-2];
            }
        }else if(p == 1){
            t = a[n-1];
            for (int i = 0; i < n-1; i++) {
                sb.append(t + " " + a[i] + "\n");
                t -= a[i];
            }
        }else{
            t = a[0];
            for (int i = m; i < n-1; i++) {
                sb.append(t + " " + a[i] + "\n");
                t -= a[i];
            }
            sb.append(a[n-1] + " " + t + "\n");
            t = a[n-1] - t;
            for (int i = 1; i < m; i++) {
                sb.append(t + " " + a[i] + "\n");
                t -= a[i];
            }
        }
        System.out.println(t);
        System.out.print(sb.toString());
        sc.close();

    }

}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int 
#define mp make_pair
#define pb push_back
#define f first
#define s second



int32_t main()
{
     IOS; 
     
     int n;
     
     cin>>n;
     
     string s[n+5];
     
     for(int i=1;i<=n;i++)
     {
          cin>>s[i];
     }
     
     for(int i=1;i<=n;i++)
     {
          for(int j=1;j<i;j++)
          {
               if(s[i]==s[j])
               {
                    cout<<"No";
                    return 0;
               }
          }
          if(i!=1)
          {
               int y=s[i-1].size();
               
               y--;
               
               if(s[i][0]!=s[i-1][y])
               {
                    cout<<"No";
                    return 0;
               }
          }
     }
     cout<<"Yes";
     return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        int[] pqr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(pqr.Sum() - pqr.Max());
    }
}

Measured memory_bytes: 13396
n = int(input())
lis = list(map(int, input().split()))

count = 0
for i in range(n-1):
    if lis[i] > lis[i+1]:
        dif = lis[i] - lis[i+1]
        count += dif
        lis[i+1] += dif
print(count)

Measured memory_bytes: 32224
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= 5) {
            System.out.println(0);
        }else if(a <= 12){
            System.out.println(b/2);
        } else{
            System.out.println(b);
        }


        sc.close();
    }

    
static class Mathalgo{
    static int n;
    static long MOD = 1000000007;
    static int MAX = 510000;
    static long[] finv = new long[MAX];
    static long[] inv = new long[MAX];
    static long[] fac = new long[MAX];

    public static String make_bi_nari(int nbit, int num_to_binary) {
        String res = Integer.toBinaryString(num_to_binary);
        while(res.length() != nbit){
            res = "0" + res;
        }
        return res;
    }


    public static long fib(int x) {
        long[] fib = new long[x+1];
        fib[0] = 0; fib[1] = 1;
        for (int i = 2; i <= x; i++) {
            fib[i] = fib[i-1] + fib[i-2];
        }
        return fib[x];
    }

    public static int ManhattanDist(int x, int y, int xx, int yy) {
        return(Math.abs(xx-x) + Math.abs(yy-y));
    }

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

    static void nCkmake() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[(int)MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    static long nCk(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long gcd_long(long a, long b) {
        if (a < b) {
            long x = a;
            a = b;
            b = x;
        }
        if (b == 0) {
            return a;
        }else{
            return gcd_long(b, a%b);
        }
    }

    public static long lcm_long(long a, long b) {
        long gcd = gcd_long(a,b);
        return a/gcd*b;
    }

    public static long GyakuGenMOD(long a) {
        return RepSquareMethod(a, MOD-2);
    }
    
    public static long factmod(int a) {
        long[] fact = new long[a+1];
        fact[0] = fact[1] = 1;
        for (int i = 2; i <= a; i++) {
            fact[i] = (fact[i-1]*i)%MOD;
        }
        return fact[a];
    }

    public static long RepSquareMethod(long a, long n) { // a^n
        long ans = 1;
        while (n > 0) {
            if ( n % 2 == 1) {
                ans = (ans * a) % MOD;
            }
            a = (a*a)%MOD;
            n/=2;
        }
        return ans;
    }
}
}




Measured memory_bytes: 21844
import math
 
a, b, h, m = map(int, input().split())
a_h = h*30 + m*0.5
a_m = m* 6
angle = abs(a_h-a_m)
 
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))))


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;

int main(int argc, char ** argv) {
	int N; scanf("%d", &N);
	printf("%d\n", (N*(N+1))/2);
	return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[s.length()];
    c = s.toCharArray();
    Arrays.sort(c);

    for(int i = 0; i < s.length()-1; i++) {
      if(c[i] == c[i+1]) {
        System.out.println("no");
        return;
      }
    }
    System.out.println("yes");
  }
}


Measured memory_bytes: 23124
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        List<String> list = new ArrayList<>();
        for (int i = s.length - 1, c = 0; i >= 0; i--) {
            if (s[i] == 'B') {
                c++;
            } else if (0 < c) {
                c--;
            } else {
                list.add(0, String.valueOf(s[i]));
            }
        }
        System.out.println(String.join("", list));
    }
}

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

int main(void)
{
	int a, b, i, j, q;
	string str, command, tmp_str, p;

	cin >> str;
	cin >> q;
	
	for (i = 0; i < q; i++) {
		cin >> command;
		if (command == "print") {
			cin >> a;
			cin >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (command == "reverse") {
			cin >> a;
			cin >> b;
			tmp_str = str;
			for (j = 0; j <= b - a; j++) {
				str[a + j] = tmp_str[b - j];
			}
		}
		else if (command == "replace") {
			cin >> a;
			cin >> b;
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	}
}


Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, k;
  cin>>n>>k;
  LL a[n];
  LL sum[n+1];
  LL psum[n+1];
  sum[0]=0;
  psum[0]=0;
  REP(i, n){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i];
    psum[i+1]=psum[i]+max((LL)0, a[i]);
  }
  if(n==1){
    cout<<max((LL)0, a[0])<<endl;
    return 0;
  }
  //REP(i, n+1) ECHO(sum[i]);
  //REP(i, n+1) ECHO(psum[i]);

  LL ans=0;
  LL work;
  REP(i, n-k+1){
    work = sum[i+k]-sum[i] +psum[i]+ (psum[n]-psum[i+k]);
    ans=max(ans, work);
    work = psum[i]+ (psum[n]-psum[i+k]);
    ans=max(ans, work);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i=0; i<S.size(); i++){
    int count = 0;
    int j = i;
    while(j<S.size()){
      if(S.at(j) == 'A' ||S.at(j) == 'T' ||S.at(j) == 'G' ||S.at(j) == 'C'){
        count++;
        j++;
        if(j == S.size()){
        ans = max(ans,count);
        break;
        } 
        continue;
      }
      if(j == S.size() - 1){
        ans = max(ans,count);
        break;
      }        
      if(S.at(j) != 'A' ||S.at(j) != 'T' ||S.at(j) != 'G' ||S.at(j) != 'C'){
        ans = max(ans,count);
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

long long v1[300000] = {0};
long long v2[300000] = {0};
vector<P> v;

int main() {
  long long H, W, M;
  map<pair<long long, long long>, long long> mp;
  cin >> H >> W >> M;
  rep(i, M) {
    long long x, y;
    cin >> x >> y;
    x--;y--;
    mp[{x, y}] = 1;
    mp[{y, x}] = 1;
    v1[x] += 1;
    v2[y] += 1;
    v.push_back({x, y});
  }
  long long m1 = 0, m2 = 0;
  vector<long long> k1, k2;

  rep(i, H) {
    m1 = max(m1, v1[i]);
  }
  rep(i, H) {
    if(m1 == v1[i]) {
      k1.push_back(i);
    }
  }

  rep(i, W) {
    m2 = max(m2, v2[i]);
  }
  rep(i, W) {
    if(m2 == v2[i]) {
      k2.push_back(i);
    }
  }

  long long temp = k1.size() * k2.size();
  rep(i, v.size()) {
    long long x = v[i].first;
    long long y = v[i].second;
    long long cntx = upper_bound(k1.begin(), k1.end(), x) - lower_bound(k1.begin(), k1.end(), x);
    long long cnty = upper_bound(k2.begin(), k2.end(), y) - lower_bound(k2.begin(), k2.end(), y);
    if(cntx >= 1 && cnty >= 1) {
      temp--;
    }
  }
  long long ans;
  if(temp > 0) ans = m1 + m2;
  else ans = m1 + m2 - 1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 58924
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ADividingAString {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        string s;
        in>>s;
        int n=s.length();
        s+="!!!";
        int ans=0,a=1;
        vector<int> v;
        fr(i,n){
            if(s[i]==s[i+1]){
                ++a;
            }
            else{
                ans+=(a/3)*2;
                if(a%3) v.push_back(a%3);
                a=1;
            }
        }
        fr(i,v.size()){
            if((v[i]==2)&&(i!=v.size()-1)&&(v[i+1]==2)) ans+=3,++i;
            else ++ans;
        }
        out<<ans<<endl;
    }
};

int main() {
    ADividingAString solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1552
_, *a = map(int, open(0).read().split())
ans = [0] * 4
for v in a:
    ans[v % 4] += 1

if (ans[0] >= ans[1] + ans[3]) or (ans[0] == ans[1] + ans[3] - 1 and ans[2] == 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14052
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

#from collections import defaultdict
import heapq
n,m,s = inm()
ST = 51*(n+1)
dst = [{} for i in range(n+1)]
for i in range(m):
    uu,vv,aa,bb = inm()
    dst[uu][vv] = (aa,bb)
    dst[vv][uu] = (aa,bb)
s = min(s,ST-1)
c = [-1]
d = [-1]
for i in range(n):
    cc,dd = inm()
    c.append(cc)
    d.append(dd)

dst2 = [[] for i in range((n+1)*ST)]
for u in range(1,n+1):
    for p in range(ST-c[u]):
        dst2[u*ST+p].append((u*ST+p+c[u], d[u]))
    for v in dst[u]:
        m = dst[u][v][0]
        t = dst[u][v][1]
        for p in range(m,ST):
            dst2[u*ST+p].append((v*ST+p-m,t))

if DBG:
    print("dst2)")
    for u,p in [(1,50),(2,50),(1,3)]:
        #z,pp = dst2[u*ST+p]
        ddprint("u {u} p {p} d2 {dst2[u*ST+p]}")
        for z in dst2[u*ST+p]:
            ddprint("v {z[0]//ST} q {z[0]%ST} t {z[1]}")

cost = [BIG]*((n+1)*ST)
q = [(0,1*ST+s)]
while len(q)>0:
    dd,u = heapq.heappop(q)
    if cost[u]<=dd:
        continue
    cost[u] = dd
    for v,t in dst2[u]:
        heapq.heappush(q,(dd+t, v))

if DBG:
    print("cost) ST {ST} s {s}")
    for u,p in [(2,204),(3,154),(4,154)]:
        ddprint("u {u} p {p} suf {u*ST+p} cost {cost[u*ST+p]}")

ddprint(cost)
ans = [BIG]*(n+1)
for i in range(2,n+1):
    ans[i] = min(cost[i*ST:(i+1)*ST])
    #ddprint(f"i {i} i*ST {i*ST}")
    ddprint(cost[i*ST:(i+1)*ST])
for i in range(2,n+1):
    print(ans[i])


Measured memory_bytes: 139152
n,h = map(int, input().split())
al = []
bl = []
for _ in range(n):
    a,b = map(int, input().split())
    al.append(a)
    bl.append(b)

al.sort(reverse=True)
bl.sort(reverse=True)

amax = al[0]
ans = 0
rem = h
for b in bl:
    if b >= amax:
        rem -= b
        ans += 1
    else:
        break
    if rem <= 0:
        print(ans)
        exit()

cnt = (rem-1)//amax + 1
ans += cnt
print(ans)

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

int N, M; 
vector<int> adj[100005];
int par[100005], dist[100005];

void BFS() {
  queue<int> q;
  q.push(1);
  memset(dist, 0x3f3f3f3f, sizeof(dist));
  dist[1] = 0;
  while(!q.empty()) {
    int u = q.front();
    q.pop();
    for(int v : adj[u]) {
      if(dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        par[v] = u;
        q.push(v);
      }
    }
  }
  for(int i = 2; i <= N; i++) {
    if(par[i] == 0) {
      cout << "No\n";
      exit(0);
    }
  }
  cout << "Yes\n";
  for(int i = 2; i <= N; i++) {
    cout << par[i] << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> M;
  int u, v;
  for(int i = 1; i <= M; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  BFS();
}

Measured memory_bytes: 10804
# coding: utf-8

# import sys
# input = sys.stdin.readline

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

AB = [list(map(int, input().split())) for __ in range(N)]
AB.sort(key=lambda x : x[0])

k = 0
ans = 0
while M > 0:
    if M > AB[k][1]:
        M -= AB[k][1]
        ans += AB[k][0] * AB[k][1]
    else:
        ans += AB[k][0] * M
        break
    
    k += 1

print(ans)



Measured memory_bytes: 29020
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N,M,R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++)
    {
        cin >> r[i];
    }
    int INF = 100000000;
    vector<vector<int>> d(N,vector<int>(N,INF));
    for(int i = 0; i < M; i++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        d[a-1][b-1] = c;
        d[b-1][a-1] = c;
    }
    for(int k = 0; k < N; k++)
    {
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    sort(r.begin(),r.end());
    int ans = 300000000;
    do
    {
        int tmp = 0;
        for(int i = 0; i < R-1; i++)
        {
            tmp += d[r[i]-1][r[i+1]-1];
        }
        ans = min(ans, tmp);
    } while (next_permutation(r.begin(),r.end()));
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
#define mp make_pair
const int Maxx = 1e5 + 7;
const int Inf = 1e9 + 7;
int n;
int a[Maxx];
 
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int t = a[n] / 2;
	int min = Inf;
	int p;
	for(int i = 1; i <= n; i++) {
		if(abs(a[i] - t) <= min) {
			min = abs(a[i] - t);
			p = a[i];
		}
	}
	if(n == 2) printf("%d %d\n", a[2], a[1]);
	else printf("%d %d\n", a[n], p);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// five elements

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vii vector<pair<ll, ll>>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define inf 1e18
#define mod 1000000007
#define ii pair<ll,ll>
#define sw(v)      cout << endl;                                                                \
  for(auto u:v) {cout << u << " ";}                                     \
  cout << endl;
  
  /*
  ll ml(ll a, ll b){
  	return ( (a%mod)*(b%mod) )%mod;
  }
ll fp(ll num,ll g)
{
    if(g==0)return 1;
    if(g%2==1)return ml(num,fp(ml(num,num) ,g/2) );
    return fp( ml(num,num),g/2);
}
ll d(ll a, ll b) {//a/b
	return a*fp(b, mod - 2) % mod;
}
ll pm(ll f[] , ll n, ll r){
	return d(  f[n] , f[n-r] );
}
ll cm(ll f[] , ll n , ll r ){
		return d( f[n] , ml( f[r],f[n-r] ) );
	}
*/
ll val( ll a, ll b , ll x){
	
	return (a*x)/b - a*(x/b);
}

int main(){
	ll a,b,n;cin>>a>>b>>n;
	c1( a*min(n,b-1)/b )
}


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

#define mp              make_pair
#define pb              push_back
#define ff              first
#define ss              second
#define inc(A,B)        A=(A+(B))%MOD
#define mul(A,B)        (ll(A)*ll(B)%ll(MOD))
#define sub(a,b)        (((a)-(b)+MOD)%MOD)

typedef pair < int ,int > pii;
typedef long long ll;
typedef complex < ll > pt;

const int MAX_N = 100005;
const int MOD = 1e9 + 7;

int n, exponent;
int memo[MAX_N];

void update ( int &cant, int nextCant ) {
  if ( cant == -1 )
    cant = nextCant;
  else
    cant = min ( cant, nextCant );
}

void fillFor ( int num ) {
  for ( int i = 0; i <= n-num; ++i )
    if ( memo[i] != -1 )
      update ( memo[i+num], memo[i]+1 );
}

void doForExp ( int exponent, int bas ) {

  do {
    bas *= exponent;
    fillFor ( bas );
  } while ( bas <= n/exponent );
}

int main() {

//  freopen ( "in.txt" , "r" , stdin );
//  freopen ( "out.txt" , "w" , stdout );

  memset ( memo, -1, sizeof memo );
  scanf ( "%d", &n );

  memo[0] = 0;
  doForExp ( 6, 1 );
  doForExp ( 9, 1 );
  fillFor ( 1 );

  printf ( "%d\n", memo[n] );

  return 0;

}


Measured memory_bytes: 640
K=int(input())

N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(N[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint k; cin >> k;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> b(n); for (auto&& e : b) cin >> e;
  sort(begin(a), end(a));
  sort(rbegin(b), rend(b));
  auto chk = [&](lint x) -> bool {
    lint s = 0;
    for (int i = 0; i < n; ++i) {
      s += max<lint>(a[i] - x / b[i], 0);
    }
    return s <= k;
  };
  lint ng = -1, ok = 1e18;
  while (ok - ng > 1) {
    lint mid = (ng + ok) / 2;
    (chk(mid) ? ok : ng) = mid;
  }
  cout << ok << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int top = s[0] - '0';
    bool flag = true;
    rep(i, n - 1) if(s[i + 1] != '9') flag = false;
    if (flag) cout << top + (n - 1) * 9 << endl;
    else cout <<  top + (n - 1) * 9 - 1<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#define endl '\n'
using namespace std;
int l[27],cnt;
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++)
        l[(int)s[i]]++;
    for(int i = 97; i<123; i++)
            if(!l[i]){cout<<(char)i<<endl;return 0;}
    puts("None");
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
  int r, g, b, n;
  scanf("%d %d %d %d", &r, &g, &b, &n);
  long long ans = 0;
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      int rpg = i * r + g * j;
      if (rpg <= n) {
        if ((n - rpg) % b == 0) {
          ans++;
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

const int N = 1005;
string ans;

vector<string> three =
{
"..a",
"..a",
"bb."
};

vector<string> four =
{
"aabc",
"ddbc",
"efgg",
"efhh"
};

vector<string> five =
{
"..abc",
"..abc",
"ddeef",
"ggh.f",
"iihjj"
};

vector<string> six =
{
"...abc",
"...abc",
"ddee.f",
"..gghf",
"iij.h.",
"kkj.ll"
};


vector<string> seven =
{
"....abc",
"....abc",
"....def",
"....def",
"gghh..i",
"jjkk..i",
"llmmnn."
};



vector<vector<string>> nums = {three, three, three, three, four, five, six, seven};

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

    int n;
    cin>>n;

    if (n <= 2) {
        cout<<-1<<endl;
        return 0;
    }
    if (n == 3) {
        for (int i=0; i<3; i++)     cout<<three[i]<<endl;
        return 0;
    }

    vector<string> ans(n, string(n, '.'));

    int left = n, ii = 0;
    while (left > 7) {
        for (int i=0; i<4; i++)
            for (int j=0; j<4; j++)
                ans[ii+i][ii+j] = four[i][j];
        ii += 4;
        left -= 4;
    }

    assert(left > 3);
    assert(nums[left].size() == left);


    for (int i=0; i<left; i++)
        for (int j=0; j<left; j++)
            ans[ii+i][ii+j] = nums[left][i][j];

    for (int i=0; i<n; i++)
        cout<<ans[i]<<"\n";
}


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

int N, K, C;
vector<int> sub(const string &S) {
    int N = S.size();
    int cur = 0, last = - C - 1;
    vector<int> res(N+1, 0);
    rep(i, N) {
        if(i - last > C && S[i] == 'o') ++cur, last = i;
        res[i+1] = cur;
    }
    return res;
}

void solve(const string &S) {
    const auto &left = sub(S);
    string T = S;
    reverse(T.begin(), T.end());
    const auto &right = sub(T);
    rep(i, N) {
        if(S[i] == 'x') continue;
        if(left[i] + right[N-i-1] < K) cout << i+1 << endl;
    }
}

int main() {
    string S;
    cin >> N >> K >> C >> S;
    solve(S);
    return 0;
}

Measured memory_bytes: 3588
s = int(input())
check = ""
count = 1
result = [s]
while check != "OK":
    if s % 2 == 0:
        s = s/2
    else:
        s = 3*s + 1
    count += 1
    s = int(s)
    result.append(s)
    for i in range(len(result)-1):
        if result[i] == s:
            check = "OK"
        else:
            pass
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#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>
#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<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<57;
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};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;
vvi a;

int main(){
	cin>>n;
	a=vvi(n,vi(26));
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		for(int j=0;j<s.size();j++) a[i][s[j]-'a']++;
	}
	string res;
	for(int i=0;i<26;i++){
		int M=inf;
		for(int j=0;j<n;j++) M=min(M,a[j][i]);
		for(int j=0;j<M;j++) res+='a'+i;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n,h;
    cin>>n;
    int ans=0;
    vector<int>v(n);
    for(int i=0; i<n; i++){
        cin>>h;
        v.at(i)=h;
        ans++;
        for(int k=0; k<i; k++){
            if(h==v.at(k)){
                ans--;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
const double PI = 3.141592653589793238460;

  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif

}


int main()
{
   c_p_c();
    string s;
    cin>>s;
    int ms=INT_MIN;int cnt=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        {
            cnt++;
           continue;

        }
        else
        {
            ms=max(cnt,ms);
            cnt=0;
        }
        
    }
      ms=max(cnt,ms);
    cout<<ms;
    
    return 0;

}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
S = input()
hi_s = "hi"

if len(S)%2!=0:
  print("No")
else:
  flg = 0
  for i in range(int(len(S)/2)):
    if S[(2*i):(2*i+2)]=="hi":
      pass
    else:
      flg = flg + 1

  if flg==0:
    print("Yes")
  else:
    print("No")

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

using namespace std;

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

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//std::ios::sync_with_stdio(false);
int get(int a,int b,int c){
	int ans=b/c;
	ans-=a/c;
	if(a%c==0){
		ans++;
	}
	return ans;

}
main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int a,b,c,d,val,ans;
	cin>>a>>b>>c>>d;
	ans=b-a+1;
	ans-=get(a,b,c);
	ans-=get(a,b,d);
	val=c*d/(__gcd(c,d));
	ans+=get(a,b,val);
	cout<<ans<<endl;
	return 0;
} 
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ii pair<long long,long long>
long long r,c;
stack<long long> st;
vector<pair<long long,long long> > ans;
long long change(long long x,long long y)
{
	if(y==0)
	{
		return x;
	}
	else if(x==r)
	{
	return r+y;
	}
	else if(y==c)
	{
		return r+c+(r-x);
	}
	return 2*r+c+(c-y);
}
int main()
{
	long long n;
	cin >> r >> c >> n;
	for(long long i=1;i<=n;i++)
	{
		long long x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1!=0 && y1!=0 && x1!=r && y1!=c)
		continue;
		if(x2!=0 && y2!=0 && x2!=r && y2!=c)
		continue;
		ans.push_back(ii(change(x1,y1),i));
		ans.push_back(ii(change(x2,y2),i));
	}
	sort(ans.begin(),ans.end());
	for(long long i=0;i<ans.size();i++)
	{
		if(!st.empty())
		{
			if(st.top()==ans[i].second)
			st.pop();
			else
			st.push(ans[i].second);
		}
		else
		{
			st.push(ans[i].second);
		}
	}
	if(st.empty())
	cout << "YES" << "\n";
	else
	cout << "NO" << "\n";
}

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

typedef long long ll;

int main(void)
{
    ll N;
    cin >> N;
    ll a,i;
    a = (int)sqrt(N);
    for(i = a; i >= 1; i--) {
        if(N%i==0) {
            ll w;
            w = i-1+N/i-1;
            cout << w << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, d;
	cin >> n >> d;

	int ans=0;
	for(int i=0; i<n; ++i){
		long long x, y;
		cin >> x >> y;
		if(x*x+y*y<=d*d) ++ans;
	} 

	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int A[3000];
ll dp[3000][3000];
bool rd[3000][3000];

ll f(int i, int j) {
    if(i == j) return A[i];
    if(rd[i][j]) return dp[i][j];
    rd[i][j] = 1;
    return dp[i][j] = max(A[i] - f(i + 1, j), A[j] - f(i, j - 1));
    
}

int main() {
    int n; cin >> n;
    
    for(int i = 0; i < n; ++i)
        cin >> A[i];
        
    cout << f(0, n - 1);
    return 0;
}

Measured memory_bytes: 78464
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

int main()
{
    const string kEndOfText = "END_OF_TEXT";

    string src;
    cin >> src;
    transform(src.begin(), src.end(), src.begin(), ToUpper());

    int count = 0;
    string buf;
    while(true)
    {
        cin >> buf;
        if(buf == kEndOfText){ break; }

        transform(buf.begin(), buf.end(), buf.begin(), ToUpper());
        if(buf == src){ count++; }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3160
import sys
# inputを高速化する。
input = sys.stdin.readline

n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**10
cost=[INF]*(n+1)
cost[0]=0

for i in range(0,n):
    for j in range(1,min(k+1,n-i)):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[n-1])

Measured memory_bytes: 52444
class Dice:
    def __init__(self):
        self.up = 1
        self.under = 6
        self.N = 5
        self.W = 4
        self.E = 3
        self.S = 2

    def roll(self, d):#d => direction
        if d == "N":
            tmp = self.up
            self.up = self.S
            self.S = self.under
            self.under = self.N
            self.N = tmp
        elif d == "W":
            tmp = self.up
            self.up = self.E
            self.E = self.under
            self.under = self.W
            self.W = tmp
        elif d == "E":
            tmp = self.up
            self.up = self.W
            self.W = self.under
            self.under = self.E
            self.E = tmp
        elif d == "S":
            tmp = self.up
            self.up = self.N
            self.N = self.under
            self.under = self.S
            self.S = tmp

    def getUpward(self):
        return self.up

    def setRoll(self,up,under,N,W,E,S):
        self.up = up
        self.under = under
        self.N = N
        self.W = W
        self.E = E
        self.S = S

    def rotate(self):#crockwise
        tmp = self.S
        self.S = self.E
        self.E = self.N
        self.N = self.W
        self.W = tmp

    def getE(self, up, S):
        '''
        
        :param up:num 
        :param S: num
        :return: num
        '''
        count = 0
        while True:
            if self.up == up:
                break
            if count != 3:
                self.roll("N")
                count += 1
            else:
                self.roll("E")
        while True:
            if self.S == S:
                break
            self.rotate()
        return self.E



myd = Dice()
myd.up, myd.S, myd.E, myd.W, myd.N, myd.under = map(int,input().split())
n = int(input())
for i in range(n):
    up, S = map(int,input().split())
    print(myd.getE(up,S))

Measured memory_bytes: 7740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 100005;
int flag[N];
LL cnt[2];
using graph = VVI;

void dfs(const graph &g, int node, int parity) {
	auto conn = g[node];
	for (auto to : conn) {
		if (flag[to] & (1 << parity))continue;
		cnt[parity]++;
		flag[to] |= (1 << parity);
		dfs(g, to, 1 - parity);
	}
	return;
}

int main() {
	LL n, m;
	cin >> n >> m;
	graph g(n);
	REP(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	dfs(g, 0, 0);
	if (flag[0] == 3)cout << (n*(n - 1LL)) / 2 - m << endl;
	else cout << cnt[0] * cnt[1] - m << endl;
	return 0;
}

Measured memory_bytes: 10752
n = int(input())
a = [int(input()) for _ in range(n)]
button = [1] + [0] * (n - 1)
i = 0
count = 0
for _ in range(n):
    count += 1
    if button[i] == 1:
        button[i] = 0
        button[a[i] - 1] = 1
        i = a[i] - 1
    else:
        print(-1)
    if button[1] == 1:
        print(count)
        exit()
print(-1)


Measured memory_bytes: 8620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,i,j,h,sum = 0;
    cin>>h>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum+=a;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    string x;
    cin >> x;

    int mx = 0;
    int now = 0;
    for(auto &&c : x) {
        now += (c == 'T' ? 1 : -1);
        chmax(mx, now);
    }

    cout << mx * 2 << endl;

    return 0;
}

Measured memory_bytes: 3724
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            int min = a;
            int max = b;
            if (max < min)
            {



                min = b;
                max = a;
            }
            for(int k=0 ; k < max; k++)
            {
                Console.Write(min);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
import sys
input = sys.stdin.readline

def main():
    N=int(input())
    H=list(map(int,input().split()))
    s=0
    flag=0
    if N==1:
        flag=0
    else:
        for i in range(0,N-1):
            if H[i]>H[i+1]:
                s+=H[i]-H[i+1]
                if s>1:
                    flag=1
            elif H[i]<H[i+1]:
                s=0
    if flag==0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 14168
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	
	vector<pair<int64_t, int64_t>> a(2 * n);
	
	for(int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		
		a[i * 2].first = a[i * 2 + 1].first = x;
		a[i * 2].second = a[i * 2 + 1].second = y;
	}
	
	vector<int> c(2 * n);
	c[0] = c[1] = c[2] = c[3] = 1;
	sort(c.begin(), c.end());
	
	int64_t ans = -1;
	
	do {
		int64_t t, b, l, r;
		bool f = false;
		
		for(int i = 0; i < 2 * n; ++i) {
			if(c[i]) {
				if(!f) {
					t = b = a[i].second;
					l = r = a[i].first;
					f = true;
				} else {
					t = min(t, a[i].second);
					b = max(b, a[i].second);
					l = min(l, a[i].first);
					r = max(r, a[i].first);
				}
			}
		}
		
		int cnt = 0;
		
		for(int i = 0; i < 2 * n; i += 2) {
			if(l <= a[i].first && a[i].first <= r && t <= a[i].second && a[i].second <= b) {
				cnt++;	
			}
		}
		
		if(cnt >= k) {
			if(ans == -1) {
				ans = (r - l) * (b - t);
			} else {
				ans = min(ans, (r - l) * (b - t));
			}
		}
		
	} while(next_permutation(c.begin(), c.end()));
	
	cout << ans << endl;
	
	return 0;
}

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

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

using namespace std;
typedef long long ll;

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

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


    int K, N;
    cin >> K;
    cin >> N;
    int P[N];
    REP(i, N){
      cin >> P[i];
    }

    int max = 0;
    REP(i, N){
      if(i==N-1){
        if((K-P[N-1]+P[0]) > max){
          max = (K-P[N-1]+P[0]);
        }
      }else if(P[i+1]-P[i] > max){
          max = P[i+1]-P[i];
      }
    }

    cout << K-max  << "\n"; 

    return 0;
}

Measured memory_bytes: 1024