akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

//-----------------------------------------------------------------------------

int n;
ll h;
vector<ll> v;
ll ma=0;

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

	cin>>n>>h;
	REP(i,n) {
		ll a,b;cin>>a>>b;
		ma=max(ma,a);
		v.pb(b);
	}
	sort(ALL(v));
	reverse(ALL(v));
	int cnt=0;
	REP(i,v.size()) {
		if(v[i]<ma) break;
		cnt++;
		h-=v[i];
		if(h<=0) {
			cout<<cnt<<endl;
			return 0;
		}
	}
	cnt+=h/ma+!!(h%ma);
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    s = input().strip()
    s = s.replace("BC", "D")
    ac = 0
    ans = 0
    
    for i in range(len(s)):
        if s[i] == 'A':
            ac += 1
        elif s[i] == 'D':
            ans += ac
        else:
            ac = 0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int K, A, B; cin >> K >> A >> B;
  //vector<int> vec(N);

  int ans = 0;
  
  while(true) {
    ans += K;
    if(ans>=A && ans<=B) {
      cout << "OK" << endl;
      return 0;
    }
    if(ans > B) {
      cout << "NG" << endl;
      return 0;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3584
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val y = sc.nextInt()
    val z = sc.nextInt()
    println(problem161a(x, y, z))
}

fun problem161a(x: Int, y: Int, z: Int): String {
    var a = y
    var b = x
    var c = z
    return "$c $b $a"
}

Measured memory_bytes: 29608
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int cnt=0;
    int cnt2=0;
    rep(i,n){
        if(s[i]=='c'){
            cout<<"No"<<endl;
        }
        else if(s[i]=='a'){
            if(cnt<a+b){
                cnt++;
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
        else{
            if(cnt<a+b&&cnt2<b){
                cnt++;
                cnt2++;
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
    }
}

Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main(){
  int n, t;

  scanf("%d", &n);

  list<int> lis;
  for(int i = 0; i < n; i++){
    scanf("%d", &t);
    if(i % 2 == 0)
      lis.push_back(t);
    else
      lis.push_front(t);
  }

  if(n % 2 == 1){
    for(auto itr = lis.rbegin(); itr != lis.rend(); itr++)
      printf("%d ", *itr);
  }else{
    for(auto itr = lis.begin(); itr != lis.end(); itr++){
      printf("%d ", *itr);
    }
  }
  printf("\n");

  return 0;
}
  


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define mx 100
using namespace std;
int n, m, q, sum;
int a[mx], b[mx], c[mx], d[mx], A[11];
inline void bf(int, int);
inline void get();
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    get();
    return 0;
}
inline void get() {
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    bf(1, 1);
    cout << sum << endl;
}
inline void bf(int cur, int cnt) {
    if (cnt == 11) {
        int tmp = 0;
        for (int i = 1; i <= q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                tmp += d[i];
            }
        }
        sum = max(sum, tmp);
        return;
    }
    for (int i = cur; i <= m; i++) {
        A[cnt] = i;
        bf(i, cnt + 1);
    }
}

Measured memory_bytes: 3660
N,M = map(int,input().split())
para = []
for i in range(M):
    a,b = map(int,input().split())
    para.append([a,b,i])
para.sort(key = lambda x:(x[0],x[1]))
ans = []
memo = [-1 for i in range(N+1)]
for i in range(M):
    if memo[para[i][0]] == -1 :
        cnt = 1
        a = format(para[i][0]).zfill(6) + format(cnt).zfill(6)
        ans.append([a,para[i][2]]) 
        memo[para[i][0]] = 0
    else : 
        cnt += 1
        a = format(para[i][0]).zfill(6) + format(cnt).zfill(6)
        ans.append([a,para[i][2]]) 
ans.sort(key=lambda x:x[1])
for i in range(M):
    print(ans[i][0])

Measured memory_bytes: 42176
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE

signed solve(){
  Int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b>d){
    cout<<"No"<<endl;
    return 0;
  }
  if(a<b){
    cout<<"No"<<endl;
    return 0;
  }
  a%=b;
  d%=b;
  if(a>c){
    cout<<"No"<<endl;
    return 0;
  }
  if(c>=b-1){
    cout<<"Yes"<<endl;
    return 0;
  }
  Int x=__gcd(b,d);
  a%=x;
  Int e=(b-a)/x*x;
  while(e>=b) e-=x;
  while(e+x<b) e+=x;
  if(e>c){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}
signed main(){
  Int T;
  cin>>T;
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

struct UnionFind{
  std::vector<int> parent;
  UnionFind(int N) : parent(N) { for(int i = 0; i < N; ++i){ this->Root(i) = i; } }

  int& Root(int id){
    if(this->parent[id] == id){ return this->parent[id]; }
    else{ return this->parent[id] = this->Root(this->parent[id]); }
  }
  int Find(int id){ return this->Root(id); }

  bool Unite(int lhs, int rhs){
    if(this->Root(lhs) != this->Root(rhs)){ this->parent[this->Root(rhs)] = this->Root(lhs); return true; }
    return false;
  }

};

int main(void)
{
  int N;
  std::cin >> N;

  std::vector<std::pair<int, long long int> > x(N), y(N);
  for(int i = 0; i < N; ++i){
    long long int a, b;
    std::cin >> a >> b;
    x[i] = std::make_pair(i, a);
    y[i] = std::make_pair(i, b);
  }

  std::sort(x.begin(), x.end(), [](auto const& lhs, auto const& rhs){ return lhs.second < rhs.second; });
  std::sort(y.begin(), y.end(), [](auto const& lhs, auto const& rhs){ return lhs.second < rhs.second; });

  struct Cost{ long long int cost; int left; int right; };
  std::vector<Cost> cost((N-1)*2);
  for(int i = 0; i < N-1; ++i){
    cost[i*2] = {x[i+1].second-x[i].second, x[i].first, x[i+1].first};
    cost[i*2+1] = {y[i+1].second-y[i].second, y[i].first, y[i+1].first};
  }
  std::sort(cost.begin(), cost.end(), [](auto const& lhs, auto const& rhs){ return lhs.cost < rhs.cost; });

  UnionFind unionFind(N);
  long long int sumCost = 0;

  for(auto it = cost.begin(), end = cost.end(); it != end; ++it){
    if(unionFind.Find(it->left) != unionFind.Find(it->right)){
      unionFind.Unite(it->left, it->right);
      sumCost += it->cost;
    }
  }

  std::cout << sumCost << std::endl;

  return 0;
}



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

int main(){
  int A,B,M;
  cin>>A>>B>>M;
  
  vector<int>a(A+100,0);
  vector<int>b(B+100,0);
  int m1,m2,m3;
  //int disc[A+1][B+1];
  //vector<vector<int>> disc(A+10, vector<int>(B+10,0));
  int mina=100000;
  for(int i=0;i<A;i++){
    cin>>a[i];
    mina=min(mina,a[i]);
  }
  int minb=100000;
  for(int i=0;i<B;i++){
    cin>>b[i];
    minb=min(minb,b[i]);
  }
  
  //割引券の入力
  int ansx=200000;
  for(int i=0;i<M;i++){
    cin>>m1>>m2>>m3;
    ansx=min(ansx,a[m1-1]+b[m2-1]-m3);
  }
  int ans=min(ansx,mina+minb);
  cout<<ans<<endl;
  return 0;
}

      

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

int main() {
  int n;
  cin >> n;
  vector<map<int, int>> m(2, map<int, int>());
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    m[i % 2][e]++;
  }
  vector<vector<pair<int, int>>> v(2, vector<pair<int, int>>());
  for (int i = 0; i < 2; i++) {
    v[i].push_back({0, 0});
    for (auto e : m[i]) {
      v[i].push_back({-e.second, e.first});
    }
    sort(begin(v[i]), end(v[i]));
  }
  cout << n + (v[0][0].second == v[1][0].second ? min(v[0][0].first + v[1][1].first, v[0][1].first + v[1][0].first)
                                                : v[0][0].first + v[1][0].first)
       << endl;
}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 3e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;
const double eps = 1e-9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
ll n, a[N];

int main () {
	boost ();
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	int how = 0, ans = 1;
	for (int i = 2;i <= n;i ++) {
		if (how == 1) {
			if (a[i] < a[i - 1]) ans ++, how = 0;					
		} else if (how == -1) {
			if (a[i] > a[i - 1]) ans ++, how = 0;			
		}	else {
			if (a[i] > a[i - 1]) how = 1;
			else if (a[i] < a[i - 1]) how = -1;
		}
	}
	cout << ans;
	return 0;
}

                

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

a, b, c = Is()
if a*c <= b:
    print(c)
else:
    print(b//a)


Measured memory_bytes: 63340
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F = list(map(int, sys.stdin.readline().split()))

waters = set()
for a, b in itertools.product(range(31), repeat=2):
    w = A * a * 100 + B * b * 100
    if w <= F:
        waters.add(w)
waters.remove(0)
waters = list(waters)
waters.sort()

dp = [0] * (F + 1)
dp[0] = 1
for i in range(F + 1):
    if i + C < len(dp):
        dp[i + C] |= dp[i]
    if i + D < len(dp):
        dp[i + D] |= dp[i]
sugars = [i for i, s in enumerate(dp) if s]
sugars.sort()

ans_w = waters[0]
ans_s = 0
msw = 0
s = 0
for w in waters:
    while s < len(sugars) and sugars[s] * 100 <= E * w and w + sugars[s] <= F:
        s += 1
    if s - 1 < 0:
        continue
    sw = sugars[s - 1] / (w + sugars[s - 1])
    if sw > msw:
        msw = sw
        ans_w = w
        ans_s = sugars[s - 1]
print(ans_w + ans_s, ans_s)


Measured memory_bytes: 15660
fun main(args: Array<String>){
    val trycase = 1900
    val surecase = 100
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    println((trycase * m + surecase * (n - m)) * exponent(2, m))
}
fun exponent(base:Int, exp:Int):Int {
    return when(exp){
        0 -> 1
        1 -> base
        else -> exponent(base, exp / 2).let{it * it} * exponent(base, exp % 2)
    }
}


Measured memory_bytes: 38000
object Main {
	val s = new java.util.Scanner(System.in)
	def main(args: Array[String]) {
		val n, m = s.nextInt;
		var r = new Array[Int](n);

		for (_ <- 1 to m) {
			val a, b = s.nextInt
			r(a - 1) += 1;
			r(b - 1) += 1;
		}
		for (i <- r)
			println(i)
	}
}


Measured memory_bytes: 27320
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    for(int i=0;i<=1250;i++){
        int x = i*0.08;
        int y = i*0.1;
        if(x==a && y==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}



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

using namespace std;


int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int a, newb;
  string b;
  cin >> a >> b;
  newb = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  cout << (long long int)(a * newb / 100) << '\n';
  return 0;
}


Measured memory_bytes: 3576
def main():
    x, y = map(int, input().split())
    if y == 0:
        if x <= 0:
            ans = -x
        else:
            ans = x + 1
    elif y > 0:
        if x <= -y:
            ans = -y-x+1
        elif -y < x < 0:
            ans = x+y+1
        elif 0 <= x <= y:
            ans = y-x
        else:
            ans = x-y+2
    else:
        if x <= y:
            ans = y-x
        elif y < x < 0:
            ans = -y + x + 2
        elif 0 <= x <= -y:
            ans = -y-x+1
        else:
            ans = y+x+1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
#define vv(a) vector< vector<a> >
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
ll x=n%10;
if(x==3)
{
    cout<<"bon"<<endl;
}else if(x==0||x==1||x==8||x==6)
{
    cout<<"pon"<<endl;
}else
{
    cout<<"hon"<<endl;
}
return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    ll T; cin >> T;
    vector<ll> t(n); 
    for (int i = 0; i < n; i++) cin >> t[i];
    t.emplace_back(linf);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(t[i + 1] - t[i], T);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3968
import java.io.IOException;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			PriorityQueue<P> pq = new PriorityQueue<P>();
			for (int i = 0; i < n; i++) {
				int m = scanner.nextInt();
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				pq.offer(new P(true, m, a));
				pq.offer(new P(false, m, b));
			}
			String ans = "OK";
			int sum = 0;
			while (!pq.isEmpty()) {
				P p = pq.poll();
				if (p.b) {
					sum += p.m;
					if (sum > 150) {
						ans = "NG";
						break;
					}
				} else
					sum -= p.m;
			}
			System.out.println(ans);
		}
	}

	class P implements Comparable<P> {
		boolean b;
		int m, t;

		public P(boolean b, int m, int t) {
			super();
			this.b = b;
			this.m = m;
			this.t = t;
		}

		@Override
		public String toString() {
			return "P [b=" + b + ", m=" + m + ", t=" + t + "]";
		}

		@Override
		public int compareTo(P o) {
			if (this.t == o.t)
				return this.b ? 1 : 0;
			return this.t - o.t;
		}

	}
}

Measured memory_bytes: 42840
N = int(input())
S = input()
T = input()
ans = 3 if S[0] == T[0] else 6
for i in range(1, N):
    if S[i-1] == T[i-1]:
        ans *= 2
    elif S[i] == S[i-1]:
        pass
    else:
        ans *= 1 if S[i] == T[i] else 3
print(ans % (10**9+7))

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

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int max_x = -100, min_y = 100;

  for ( int i = 0; i < N; i++ ) {
    int x;
    cin >> x;
    max_x = max( max_x, x );
  }
  for ( int i = 0; i < M; i++ ) {
    int y;
    cin >> y;
    min_y = min( min_y, y );
  }
  if ( max_x < min_y && max_x < Y && X < min_y )
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

 //   Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    int t = cin.nextInt();
    int a = cin.nextInt();

    double[] temp = new double[n];

    for (int i=0;i<n;i++) {
      double tem = t - 0.006 * cin.nextInt();
      temp[i] = Math.abs(tem - a);
    }
    int pos = 0;
    double min = Integer.MAX_VALUE;
    for (int i=0;i<n;i++) {
      if (temp[i]<min) {
        pos = i;
        min = temp[i];
      }
    }
    System.out.println(pos+1);
  }

}

Measured memory_bytes: 22868
arr=[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]
n=int(input())
n-=1
print(arr[n])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> a(w,vector<int>(h,0));
  rep(i,n){
    int f,g,hh;
    cin >> f >> g >> hh;
    if (hh==1){
      rep(j,h){
        rep(k,w){
          if (k<f) a[k][j]=1;
        }
      }
    }
    if (hh==2){
      rep(j,h){
        rep(k,w){
          if (k>=f) a[k][j]=1;
        }
      }
    }
    if (hh==3){
      rep(j,h){
        rep(k,w){
          if (j<g) a[k][j]=1;
        }
      }
    }
    if (hh==4){
      rep(j,h){
        rep(k,w){
          if (j>=g) a[k][j]=1;
        }
      }
    }
  }
  int ans=0;
  rep(i,h){
    rep(j,w){
      if (a[j][i]==0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 400200
using namespace std;

char T[maxn]; int n;
bool vis[maxn][2];
int dp[maxn][2];
int DP(int pos, bool op){
	if (pos > n) return 0;
	if (vis[pos][op]) return dp[pos][op];
	vis[pos][op] = 1;
	int& ans = dp[pos][op];
	if (T[pos] == 'D') return ans = DP(pos + 1, 0) + 1 + ((op == 1) ? 1 : 0);
	if (T[pos] == 'P') return ans = DP(pos + 1, 1);
	return ans = max(DP(pos + 1, 0) + 1 + ((op == 1) ? 1 : 0), DP(pos + 1, 1));
}

void find_ans(int pos, bool op){	
	if (pos > n) return; 
	int ans = dp[pos][op];
	if (T[pos] == 'D') {find_ans(pos + 1, 0); return;}
	if (T[pos] == 'P') {find_ans(pos + 1, 1); return;}
	if (ans == DP(pos + 1, 0) + 1 + ((op == 1) ? 1 : 0)) {T[pos] = 'D', find_ans(pos + 1, 0); return;}
	T[pos] = 'P', find_ans(pos + 1, 1); return; 
}

int main(){
	scanf("%s", T + 1);
	n = strlen(T + 1);
	DP(1, 0);
	find_ans(1, 0);
	printf("%s", T + 1);
	return 0;
}

Measured memory_bytes: 15272
a,b,c=map(int,input().split())
t=min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c),abs(b-c)+abs(a-b),abs(a-b)+abs(c-a),abs(a-c)+abs(b-a),abs(c-b)+abs(a-c))
print(t)

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i=0; i<M; i++) cin >> A[i];

  int to_z = 0;
  int to_n = 0;
  int x = X;
  while (true) {
    x++;
    if (find(A.begin(), A.end(), x) != A.end())
      to_n++;
    if (x == N) break;
  }
  x = X;
  while (true) {
    x--;
    if (find(A.begin(), A.end(), x) != A.end())
      to_z++;
    if (x == 0) break;
  }

  cout << min(to_z, to_n) << endl;

  return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    int n = s.size();
    for(int i = 0; i < n; i++) {
        if(s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	s := ""

	if sc.Scan() {
		s = sc.Text()
	}

	num := 0
	for _, r := range s {
		if r == rune('1') {
			num++
		}
	}

	fmt.Println(num)

}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	Scanner sc = new Scanner(System.in);
	Person [][] PersonArray = new Person[3][8];
	Person [] PersonArray2 = new Person[6];
	
	void input(){
		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 8 ; j++){
				PersonArray[i][j] = new Person(sc.nextInt() , sc.next()); 
			}
		}
	}
	
	void sort(){
		Arrays.sort(PersonArray[0]);
		Arrays.sort(PersonArray[1]);
		Arrays.sort(PersonArray[2]);
	}
	
	void sort2(){
		PersonArray2[0] = new Person(PersonArray[0][2].Number , PersonArray[0][2].Time);
		PersonArray2[1] = new Person(PersonArray[0][3].Number , PersonArray[0][3].Time);
		PersonArray2[2] = new Person(PersonArray[1][2].Number , PersonArray[1][2].Time);
		PersonArray2[3] = new Person(PersonArray[1][3].Number , PersonArray[1][3].Time);
		PersonArray2[4] = new Person(PersonArray[2][2].Number , PersonArray[2][2].Time);
		PersonArray2[5] = new Person(PersonArray[2][3].Number , PersonArray[2][3].Time);
		Arrays.sort(PersonArray2);
	}
	
	void output(){
		System.out.println(PersonArray[0][0]);
		System.out.println(PersonArray[0][1]);
		System.out.println(PersonArray[1][0]);
		System.out.println(PersonArray[1][1]);
		System.out.println(PersonArray[2][0]);
		System.out.println(PersonArray[2][1]);
		System.out.println(PersonArray2[0]);
		System.out.println(PersonArray2[1]);
	}
	
	void doIt(){
		input();
		sort();
		sort2();
		output();
	}
	
	public static void main(String[] args){
		new Main().doIt();
	}
	
	class Person implements Comparable<Person>{
		int Number;
		String Time;
		Person(int Number , String Time){
			this.Number = Number;
			this.Time = Time;	
		}
		
		@Override
		public int compareTo(Person p){
			return Time.compareTo(p.Time);
		}
		
		@Override
		public String toString(){
			return Number + " " + Time;
		}
		
	}
	
}

Measured memory_bytes: 26244
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 出力
		System.out.println( a % 2 == 1 && b % 2 == 1 ? "Odd" : "Even");
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    int[] p;

    int get(int x) {
        if (p[x] != x) p[x] = get(p[x]);
        return p[x];
    }


    private void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        if (m == n - 1) {
            out.println(0);
            return;
        }
        int[] a = new int[n];
        p = new int[n];
        for (int i = 0; i < n; i++) p[i] = i;
        for (int i = 0; i < n; i++) a[i] = nextInt();
        for (int i = 0; i < m; i++) {
            int x = nextInt();
            int y = nextInt();
            p[get(x)] = get(y);
        }
        int[] min = new int[n];
        Arrays.fill(min, -1);
        for (int i = 0; i < n; i++) {
            int j = get(i);
            if (min[j] == -1 || a[min[j]] > a[i]) min[j] = i;
        }
        long s = 0;
        int k = (n - m - 1) * 2;
        for (int i = 0; i < n; i++) {
            if (p[i] == i) {
//                System.out.println(i + " " + a[min[i]]);
                s += a[min[i]];
                k--;
                a[min[i]] = Integer.MAX_VALUE;
            }
        }
        Arrays.sort(a);
        for (int i = 0; i < n; i++) {
            if (k == 0) break;
            if (a[i] == Integer.MAX_VALUE) {
                out.println("Impossible");
                return;
            }
            s += a[i];
            k--;
        }
        out.println(s);
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 50504
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	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[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
 ios::sync_with_stdio(false);

ll T;
cin>>T;
rep(pp,T){
ll n;
cin>>n;
if(n<=4){cout<<0<<endl;
continue;}
ll t=0;
if(n%2==1)t++;

n=(n-5)/2;
ll pown[15];
pown[0]=1;
for(int o=1;o<=14;o++){
	pown[o]=pown[o-1]*n;
	pown[o]%=MOD;
}

ll val=1;
val*=(n+2)*(n+3);
val%=MOD;
val*=(n+4);
val%=MOD;
val*=(n+5);
val%=MOD;

ll val2=0;

ll ke[24]={14983768800,42793104060,49565868948,31370183973,12299108485,3184474795,561796179,68078724,5587140,297120,9248,128,1362160800,6046779060,10121451228,8647376943,4339493095,1383099625,291875409,41410404,3913980,236640,8288,128};

for(int i=0;i<=23;i++){
	ke[i]%=MOD;
}
for(int i=0;i<=11;i++){
	int j=i;
	if(t)j+=12;
	val2+=ke[j]*pown[i];
	val2%=MOD;
}
val=val*val2;
val%=MOD;

val*=modinv(163459296000, MOD);
val%=MOD;



cout<<val<<endl;
}











return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll com(ll n, ll r){
	ll ret = 1;
	for(ll i = n - r + 1; i <= n; i++){
		ret *= i;
		ret %= mod;
	}
    for(ll i = 1LL; i <= r; i++){
    	ret *= modpow(i, mod - 2);
    	ret %= mod;
    }
    return ret;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2LL, n) - 1LL;
    ans -= com(n, a);
    ans -= com(n, b);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 2e5 + 5;

char s[N];
long long n,ans,cnt;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1 ; i <= n ; i++) {
    if (s[i] == 'B')
      cnt++;
    else
      ans += cnt;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  int Z=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(p[i]+p[j]>p[N-1]){
        Z+=(N-1-j);
      }
      else{
        int A=lower_bound(p.begin(),p.end(),p[i]+p[j])-p.begin();
        Z+=(A-j-1);
      }
    }
  }
  cout<<Z<<endl;
}

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

int main(void) {

	int  N,i;
	long no,size;
	scanf("%d",&N);

    size=(long)pow(10,9);
	char  *A;

	A=(char*)malloc(size);
	if(A==0) return 1;
	memset(A,0x00,size);

	for(i=0;i<N-1;i++) {
		scanf("%ld ",&no);
		if(A[no]){printf("NO");goto END;}
		A[no]=0x01;
	}
	scanf("%ld",&no);
	if(A[no]) printf("NO");
	else      printf("YES");
END:
	 free(A);
	 return 0;
}


Measured memory_bytes: 976768
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        long long int a,b;
        long long int s[105];
        for(int i=0;i<n;i++)
            scanf("%lld",&s[i]);
        sort(s,s+n);
        a=s[0];
        b=s[n-1];
        printf("%lld\n",b-a);
    }
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    int a[500], b[500];
    int64_t s = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        s += a[i];
    }
    
    vector<int64_t> cand;
    for(int64_t i=1;i*i<=s;i++){
        if(s % i == 0){
            cand.push_back(i);
            if(i*i < s) cand.push_back(s/i);
        }
    }
    sort(cand.rbegin(), cand.rend());

    for(auto c:cand){
        for(int i=0;i<n;i++){
            b[i] = a[i] % c;
            if(b[i] < 0) b[i] += c;
        }
        sort(b, b+n);
        int l=-1, r=n;
        int val = 0, cnt = 0;
        while(r-l > 1){
            if(val >= 0){
                l++;
                val -= b[l];
                cnt += b[l];
            }else{
                r--;
                val += c-b[r];
                cnt += c-b[r];
            }
        }
        if(cnt <= 2*k){
            cout << c << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int K;
    string S;
    cin >> K >> S;
    if(K < S.size())
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    else
    {
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
A,B,C,D=map(int,input().split())
import fractions
CD=C*D//(fractions.gcd(C,D))
l=[]
for i in [C,D,CD]:
    if A%i==0:
        l.append(B//i-A//i+1)
    else:
        l.append(B//i-A//i)
print(B-A+1-l[0]-l[1]+l[2])


Measured memory_bytes: 5432
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
  char a;
  cin >> a;
  
  if(a >= 'a' && a <= 'z'){
    cout << "a" << endl;
  }
  else if(a >= 'A' && a <= 'Z'){
    cout << "A" << endl;
  }
  
  
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);


const int mod = 1e9+7;

struct Mod{
  int n;
  Mod() : n(0) {;}
  Mod(int m) : n(m){
    if(n>=mod) n%=mod;
    else if (n<0) n = (n%mod+mod)%mod;
  }
  operator int() {return n;}
};

Mod operator+=(Mod &a, Mod b) { a.n += b.n; if(a.n>=mod) a.n-=mod; return a; }
Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if(a.n<0) a.n += mod; return a; }
Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % mod; return a; }
Mod operator+(Mod a, Mod b) { return a+=b; }
Mod operator-(Mod a, Mod b) { return a-=b; }
Mod operator*(Mod a, Mod b) { return a*=b; }
Mod operator^(Mod a, int n) {
  if (n==0) return Mod(1);
  Mod res = (a*a) ^ (n/2);
  if (n%2) res = res * a;
  return res;
}
ll inv(ll a, ll p){
  return (a==1 ? 1 : (1-p*inv(p%a, a)) / a + p);
}
Mod operator/(Mod a, Mod b) { return a * Mod(inv(b.n, mod)); }
Mod fact[200005], factinv[200005];

void init(){
  fact[0] = Mod(1); factinv[0] = Mod(1);
  REP(i, 200004){
    fact[i+1] = fact[i] * Mod(i+1);
    factinv[i+1] = factinv[i] / Mod(i+1);
  }
}
Mod comb(int a, int b) {
  return fact[a] * factinv[b] * factinv[a-b];
}


int main(){
  int n, k;
  cin >> n >> k;
  init();
  for(int i=1; i<k+1; i++){
    if(n-k+1<i) { cout << 0 << endl; continue; }
    cout << int(comb(k-1, i-1) * comb(n-k+1, i)) % mod << endl;
  }
}

Measured memory_bytes: 1792
import bisect
n=int(input())
li=[int(i) for i in input().split()]
li.sort()

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        a=li[i]
        b=li[j]
        c=bisect.bisect_left(li,a+b)
        ans+=c-j-1
                  
print(ans)
        


Measured memory_bytes: 45484
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


int H[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	int ans = N * (N - 1) / 2;
	print(ans);
}



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

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

  auto ok = [&](){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        vector<int> B = A;
        swap(B[i],B[j]);
        bool f = true;
        for(int k = 0; k < n; ++k){
          if(B[k] != k+1){
            f = false;
            break;
          }
        }
        if(f){
          return true;
        }
      }
    }
    return false;
  };

  if(ok()) puts("YES");
  else puts("NO");
}


Measured memory_bytes: 3620
N=int(input())

if N<=1000:
    ans=1000-N
    print(ans)
    exit()
elif N<=2000:
    ans=2000-N
    print(ans)
    exit()
elif N<=3000:
    ans=3000-N
    print(ans)
    exit()
elif N<=4000:
    ans=4000-N
    print(ans)
    exit()
elif N<=5000:
    ans=5000-N
    print(ans)
    exit()
elif N<=6000:
    ans=6000-N
    print(ans)
    exit()
elif N<=7000:
    ans=7000-N
    print(ans)
    exit()
elif N<=8000:
    ans=8000-N
    print(ans)
    exit()
elif N<=9000:
    ans=9000-N
    print(ans)
    exit()
else:
    ans=10000-N
    print(ans)
    exit()

Measured memory_bytes: 9232
import numpy as np
n, h =[int(i) for i in input().split()]
a = np.empty(n)
b = np.empty(n)
for i in range(n):
    a[i], b[i] = [int(i) for i in input().split()]
sort_b = np.sort(b)
max_a = np.max(a)
b_big = sort_b[sort_b>max_a]
b_sum = np.sum(b_big)
if b_sum >= h:
    ret = np.sum(b_big[::-1].cumsum() <h) + 1 
else:
    ret = b_big.shape[0]
    ret += np.ceil((h -b_sum)/max_a)
print(int(ret))

Measured memory_bytes: 22816
#include <iostream>
#include <string>

using namespace std;

string a;
int rj;

int main () {

cin >> a;

if (a=="SAT")
	rj = 1;
if (a=="SUN")
	rj = 7;
if (a=="MON")
	rj = 6;
if (a=="TUE")
	rj = 5;
if (a=="WED")
	rj = 4;
if (a=="THU")
	rj = 3;
if (a=="FRI")
	rj = 2; 


cout << rj;


return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
#include<chrono>
#include <fstream>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

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

	x = x;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x);

		y = y >> 1;
		x = (x * x);
	}
	return res;
}


/*ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}*/

ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}
ll sum_digit(ll n)
{
	ll ans = 0;
	while (n)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll gp(ll r, ll n)
{
	return (pow(r, n) - 1) / (r - 1);
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> arr(n,0);
	f(i,0,n)
	{
		cin>>arr[i];
	}	
	ll ans=0;
	f(i,1,n)
	{
		if(arr[i]<arr[i-1])
		{
			ans+=arr[i-1]-arr[i];
			arr[i]=arr[i-1];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint X, K, D;
  cin >> X >> K >> D;
  lint t = abs(X) / D;
  if(t > K) {
    cout << abs(X) - D*K << endl;
  } else {
    lint m = abs(X) - t*D;
    if(t%2 == K%2) cout << m << endl;
    else cout << -(m - D) << endl;
  }
}

Measured memory_bytes: 3648
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  string org,chg;
  cin >> org >> chg;
  bool flg = true;
  
  for(ii=0;ii<org.size();ii++){
    if(org[ii] != chg[ii]){
      flg = false;
    }
  }

  if(flg){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n, x, t; cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main(){
	map<string, int> mp;
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++){
		string s; cin >> s;
		mp[s]++;
	}
	int m; scanf("%d", &m);
	for(int i = 0; i < m; i++){
		string s; cin >> s;
		mp[s]--;
	}
	int res = 0;
	for(auto it = begin(mp); it != end(mp); it++) res = max(res, it -> second);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200001];

int main(){
	memset(a, 0, sizeof(a));
	int n, k;
	cin >> n >> k;
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	//sort(a, a+n);
	double temp = 0, mx = 0, index = 0;
	for(int i = 0; i < n;i++){
		if(index < k){
			temp += a[i];
			index++;
		} else {
			temp -= a[i - k];
			temp += a[i];
			//index--;
		}
		if(mx < temp){
			mx = temp;
		}
	}
	//cout << endl;
	mx = (mx + k)/2;
	printf("%.12f\n", mx);
	return 0;
} 

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  int ans=0;

  for(int i=0; i<M; i++){
    cin >>A.at(i);
  }

  for(int i=0; i<M; i++){
    ans=ans+A.at(i);
  }

  if(ans>N){
    cout << -1 << endl;
  }
  else{
    cout << N-ans << endl;
  }

return 0;
}


Measured memory_bytes: 3640
// Problem: A - Plural Form
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;

int getIInput() {
	cout.flush();
	#ifdef LOCAL
	return generateLocalInputOrAnythingYouWant();
	#else
	int x;
	cin>>x;
	return x;
	#endif
}

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	string s;
	cin>>s;
	if(s.back()=='s'){
		s+="es";
	}
	else s+="s";
	
	cout<<s<<"\n";
    return;
}
// how r u bro

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int beki(int x) {
    int counter=0;
    while(x%2==0) {
        x/=2;
        counter++;
    }
    return counter;
}

int main() {
    int N;
    cin>>N;
    vi a(N);
    rep(i,N) cin>>a[i];
    rep(i,N) {
        a[i]=beki(a[i]);
    }
    sort(a.rbegin(),a.rend());
    int counter=0;
    rep(i,N) {
        counter+=a[i];
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256