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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  map<string,int> m;
  rep(i,n){
    string s; cin>>s;
    m[s]++;
  }
  int ma=0;
  vector<string> ans;
  for(auto e:m){
    chmax(ma,e.second);
  }
  for(auto e:m){
    if(ma==e.second) ans.push_back(e.first);
  }
  vsort(ans);
  rep(i,ans.size()) cout<<ans[i]<<endl;
}

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

int main(){
  int N,K,cnt=0,j;
  cin >> N >> K;
  double ans=0;
  for(int i=1;i<=N;i++){
    j=i;
    while(1){
      if(j>=K){
        ans+=pow(0.5,cnt)/N;
        cnt=0;
        break;
      }
      j*=2;
      cnt++;
    }
  }
  cout << setprecision(13) << ans << endl;
}

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

    ll n,m,sum=0;
     cin>>n>>m;
     vector<ll>v(m);
     for(int i=0;i<m;i++){
         cin>>v[i];
         sum+=v[i];
     }
     if(sum>n) cout<<-1<<endl;
     else cout<<n-sum<<endl;

 return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>

int main(){
  int a;
  int b;
scanf("%d",&a);
scanf("%d",&b);
if(a>1&&a<101){
  if(b>1&&b<101){
    a--;
    b--;
    int c = a*b;
    printf("%d\n",c);
  }
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 5050;
int a[MAXN], dp1[MAXN][MAXN], dp2[MAXN][MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	rep (i, 1, n) {
		cin >> a[i];
		a[i] = min(a[i], k); 
	}
	dp1[0][0] = 1;
	rep (i, 0, n - 1) {
		rep (j, 0, k - 1) if (dp1[i][j]) {
			dp1[i + 1][j] = 1;
			if (j + a[i + 1] < k) {
				dp1[i + 1][j + a[i + 1]] = 1;
			}
		}
	}
	dp2[n + 1][0] = 1;
	per (i, n + 1, 2) {
		rep (j, 0, k - 1) if (dp2[i][j]) {
			dp2[i - 1][j] = 1;
			if (j + a[i - 1] < k) {
				dp2[i - 1][j + a[i - 1]] = 1;
			}
		}
	}
	rep (i, 1, n + 1) {
		rep (j, 1, k) {
			dp2[i][j] += dp2[i][j - 1];
		}
	}
	int ans = 0;
	rep (i, 1, n) {
		int l = max(0, k - a[i]), r = k - 1;
		bool flag = true;
		rep (j, 0, k - 1) if (dp1[i - 1][j]) {
			int nl = max(0, l - j), nr = r - j;
			if (dp2[i + 1][nr] - (nl ? dp2[i + 1][nl - 1] : 0)) flag = false;
		}
		ans += flag;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 198912
package main

import (
	"fmt"
)

func main() {
	var n, q int
	fmt.Scan(&n, &q)
	var s string
	fmt.Scan(&s)
	sum := make([]int, n)
	for i:=0; i<n-1; i++ {
		if string(s[i]) == "A" && string(s[i+1]) == "C" {
			sum[i+1] = sum[i] + 1
		} else {
			sum[i+1] = sum[i]
		}
	}
	for i:=0; i<q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(sum[r-1]-sum[l-1])
	}
}

Measured memory_bytes: 6144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String word;
        try {
            word = reader.readLine();
            int num = Integer.parseInt(word);
            int ans = num * num * num;
            System.out.println(ans);
        } catch (IOException e) {
            // TODO ????????????????????? catch ????????????
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // TODO ????????????????????? catch ????????????
                e.printStackTrace();
            }
        }
         
         
    }
}

Measured memory_bytes: 24328
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;

ll MOD = 1000000007;

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

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



int main(){

    ll N; cin >> N;

    vector<ll > vec;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    sort(vec.rbegin(), vec.rend());

    ll ans = 0;

    for(ll i = 0; i < N; i++){
        if(i == 0) ans = vec[0];
        else ans = lcm(ans, vec[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 50
void build(){

}
LL k;
void init(){
  k = getint();
}
LL ans[ N ];
void con( LL nd ){
  LL res = N - nd;
  for( int i = 0 ; i < res ; i ++ )
    ans[ i ] = res - 1;
  for( int i = res ; i < N ; i ++ )
    ans[ i ] = N + res;
}
void solve(){
  LL bs = k % N;
  con( bs );
  for( int i = 0 ; i < N ; i ++ )
    ans[ i ] += k / N;
  printf( "%d\n" , N );
  for( int i = 0 ; i < N ; i ++ )
    printf( "%lld%c" , ans[ i ] , " \n"[ i + 1 == N ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
def c(l, t):
    from math import cos, sin
    return l * cos(t), l * sin(t)


def d(a, b, c, d):
    return ((a - c)**2 + (b - d)**2)**0.5


def solve(string):
    from math import pi
    a, b, h, m = map(int, string.split())
    return str(d(*c(a, (h + m / 60) / 6 * pi), *c(b, m / 30 * pi)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9516
n = int(input())
from itertools import product as pd
from collections import defaultdict as dd
dic = dd(lambda: [])
for i in range(n):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    dic[i] += [[x-1, y]]

def not_contradict(cand, lis, dic):
  for pair in lis:
    id, tf_c = pair
    if cand[id] != tf_c:
      return False
  else:
    return True

max_num = 0
for cand in pd([0, 1], repeat=n):
#  print(list(cand))
  for i, tf in enumerate(cand):
    if tf == 1:
      lis = dic[i]
      if not_contradict(cand, lis, dic) == False:
        break
  else:
    max_num = max(sum(cand), max_num)
print(max_num)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String t = sc.next();
		sc.close();
		int n = t.length();
		if(n == 2) {
			if(t.charAt(0) == t.charAt(1)) {
				System.out.println("1 2");
			}else {
				System.out.println("-1 -1");
			}
			System.exit(0);
		}
		for(int i = 0; i < n - 2; i++) {
			char c0 = t.charAt(i);
			char c1 = t.charAt(i + 1);
			char c2 = t.charAt(i + 2);
			int[] k = new int[26];
			k[(int)(c0 - 'a')]++;
			k[(int)(c1 - 'a')]++;
			k[(int)(c2 - 'a')]++;
			Arrays.sort(k);
			if(k[25] == 2) {
				System.out.printf("%d %d\n", i + 1, i + 3);
				System.exit(0);
			}
		}
		System.out.println("-1 -1");
	}
}

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

int64_t attack(int64_t h){
  if(h==1){
    return 1;
  }
  else{
    return 1+ 2*attack(h/2);
  }
}

int main(){
  int64_t H;
  cin >> H;

  cout << attack(H) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

H=INT()
A=LIST()+[None]*(H*2)

for i in range(H):
    node=i+1
    key=A[i]
    parent=node//2
    left=node*2
    right=node*2+1
    print('node '+str(node)+': key = '+str(key)+', ', end='')
    if parent!=0:
        print('parent key = '+str(A[parent-1])+', ', end='')
    if A[left-1] is not None:
        print('left key = '+str(A[left-1])+', ', end='')
    if A[right-1] is not None:
        print('right key = '+str(A[right-1])+', ', end='')
    print('')



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

typedef long long int ll;

int main () {

	ll a, b;
	cin >> a >> b;

	ll p = max(a, b);
	ll q = min(a, b);

	if (q==1 && p==2) {
		cout << 3 << endl;
	}
	else if (q==1 && p==3) {
		cout << 2 << endl;
	}
	else if (q==2 && p==3) {
		cout << 1 << endl;
	}
}

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

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        que.push(tmp);
    }

    while(m--){
        ll tp = que.top();
        que.pop();
        tp /= 2;
        que.push(tp);
    }
    ll ans = 0;
    while(!que.empty()){
        ll tmp = que.top();
        ans += tmp;
        que.pop();
    }

     cout << ans << endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int i,int c){
  if(i==NIL)return;
  D[i]=c;
  setDepth(T[i].left,c+1);
  setDepth(T[i].right,c+1);
}

int setHeight(int i){
  int h1=0,h2=0;
  if(T[i].left!=NIL)h1=setHeight(T[i].left)+1;
  if(T[i].right!=NIL)h2=setHeight(T[i].right)+1;
  return H[i]=(h1>h2?h1:h2);
}

int getSibling(int i){
  if(T[i].parent==NIL)return NIL;
  if(T[T[i].parent].left!=i && T[T[i].parent].left!=NIL)
    return T[T[i].parent].left;
  if(T[T[i].parent].right!=i && T[T[i].parent].right!=NIL)
    return T[T[i].parent].right;
  return NIL;
}

void display(int i){
  printf("node %d: ",i);
  printf("parent = %d, ",T[i].parent);
  printf("sibling = %d, ",getSibling(i));
  int deg=0;
  if(T[i].left != NIL)deg++;
  if(T[i].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[i]);
  printf("height = %d, ",H[i]);

  if(T[i].parent==NIL)printf("root\n");
  else if(T[i].left==NIL && T[i].right==NIL)printf("leaf\n");
  else {printf("internal node\n");}
}

int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)T[i].parent=NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }

  for(i=0;i<n;i++)if(T[i].parent==NIL)root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)display(i);

  return 0;

}
  





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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



int main() {
	LL N; cin >> N;
	vector<int>a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	using PII = pair<int, int>;
	vector<PII>b(N);
	int sub = 1000000;
	int id = 0;
	FOR(i, 0, N) {
		b[i] = PII(abs(sum - N * a[i]), i);
		if (sub > b[i].first) {
			sub = b[i].first;
			id = i;
		}
	}

	cout << id << endl;

	return 0;
}


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

ll gcd(ll a,ll b){
  if(a%b==0) return b;
  else return(gcd(b,a%b));
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  ll a,b;
  cin >>a >> b;
  ll ans = lcm(a,b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<ll>a(n), b(n), c(n);
    REP(i, n)scanf("%lld", &a[i]); sort(ALL(a));
    REP(i, n)scanf("%lld", &b[i]); sort(ALL(b));
    REP(i, n)scanf("%lld", &c[i]); sort(ALL(c));

    ll cnt = 0;
    REP(i, n) {
        cnt += (lower_bound(ALL(a), b[i]) - a.begin()) * (c.end() - upper_bound(ALL(c), b[i]));
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2560
H,W,K = map(int,input().split())

c = []
ans = 0

for i in range(H):
    tmp =list(input())
    c.append(tmp)

for i in range(2**H):
    for j in range(2**W):
        now = 0
        for x in range(H):
            for y in range(W):
                if (i >> x) & 1 and (j >> y) & 1:
                    if c[x][y] == "#":
                        now += 1

        if now == K:
            ans += 1

print (ans)

Measured memory_bytes: 9144
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class SegTree:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.query: 区間[l, r)の値を得る
    """
 
    def __init__(self, n, func, init):
        """
        :param n: 要素数(0-indexed)
        :param func: 値の操作に使う関数(min, max, add, gcdなど)
        :param init: 要素の初期値(単位元)
        """
        self.n = n
        self.func = func
        self.init = init
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [self.init] * (n2 << 1)
 
    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = self.func(x, self.tree[i ^ 1])
            i >>= 1
 
    def query(self, a, b):
        """
        [a, b)の値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        l = a + self.n2
        r = b + self.n2
        s = self.init
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.tree[r])
            if l & 1:
                s = self.func(s, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1
        return s

N = INT()
phrases = []
for i in range(N):
    l, r, p = MAP()
    phrases.append((l, r, p))
M = INT()
melody = [0] * M
for i in range(M):
    melody[i] = INT()

mxm = max(melody)
dp = [SegTree(mxm+1, max, 0) for i in range(N+1)]
for i in range(1, N+1):
    l, r, p = phrases[i-1]
    for j in range(mxm+1):
        # 上からの遷移
        mx = dp[i-1].query(j, j+1)
        l2, r2 = max(0, j-r), max(0, j-l+1)
        # 取ってこれる範囲があれば、左上と左からの遷移をする
        if not (l2 == r2 == 0):
            mx = max(
                mx,
                dp[i-1].query(l2, r2) + p,
                dp[i].query(l2, r2) + p,
            )
        dp[i].update(j, mx)

ans = [0] * M
for i, mel in enumerate(melody):
    ans[i] = dp[N].query(mel, mel+1)
if min(ans) == 0:
    print(-1)
else:
    [print(a) for a in ans]



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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }

  ll ans = 0;
  for (auto &r : m) {
    ans += (ll)r.second * (r.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A;cin>>A;
  for(int i=sqrt(A);;i--){
    if(A%i==0){
      int ans=log10(A/i);
      cout<<ans+1<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3860
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        String[] s = r.ss();
        int n = Int(s[0]+s[1]);
        println(n%(int)Math.sqrt(n) == 0 ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        print(o+"\n");
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    vector<string> w {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cout << 7 - (ALL (find, w, S) - w.begin()) << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

bool comp(string a,string b){
    return a < b;
}

int main(){
    ll n,maxi = 0;
    unordered_map<string,ll>mp;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
        maxi = max(maxi,mp[s]);
    }
    vector<string>ans;
    for(auto x:mp){
        if(x.second == maxi)ans.push_back(x.first);
    }
    sort(all(ans),comp);
    for(auto x:ans)cout<<x<<endl;
}

Measured memory_bytes: 26692
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      s[i]='9';
      continue;
    }
    if(s[i]=='9') s[i]='1';
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n,a,b; cin >> n>>a>>b;
	int t = n-a;
	int nn = t / b;
	cout << t - b * nn;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  sc.nextLine();
  for(int i=0;i<n;i++){
  String po=sc.nextLine();
    System.out.println(po);System.out.println(po);
  }
}
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint a,b,k; cin>>k>>a>>b;

	if(a>=k) return puts("1"),0;

	if(a<=b) return puts("-1"),0;

	printf("%lld\n",(k-a+(a-b)-1)/(a-b)*2+1);

	return 0;
}


Measured memory_bytes: 256
N = int(input())
if N >=82:
    print("No")

elif (N % 9 == 0):
    print("Yes")
elif (N % 8 == 0) and (N <= 72):
    print("Yes")
elif (N % 7 == 0) and (N <= 63):
    print("Yes")
elif (N % 6 == 0) and (N <= 54):
    print("Yes")
elif (N % 5 == 0) and (N <= 45):
    print("Yes")
elif (N % 4 == 0) and (N <= 36):
    print("Yes")
elif (N % 3 == 0) and (N <= 27):
    print("Yes")
elif (N % 2 == 0) and (N <= 18):
    print("Yes")
elif N<= 9:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int N,D,X[20][20],S=0;
  scanf("%d %d",&N,&D);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=D;j++){
      scanf("%d",&X[i][j]);
    }
  }
  int d,p;
  for(int i=1;i<N;i++){
    for(int j=i+1;j<=N;j++){
      d=0;
      for(int k=1;k<=D;k++){
        d+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      p=0;
      while(p*p<d) p++;
      if(p*p==d) S++;
    }
  }
  printf("%d\n",S);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
//#include "rail.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e16;
const long long MOD = 1e9+7;
const int MX=100015;
int a,b,c,d,e,f;
pii dp[3003][1503];
bool fuck(pii x,pii y){
    double d1=(x.S+0.0)/(x.S+x.F);
    double d2=(y.S+0.0)/(y.S+y.F);
//    if(x.F+x.S==0)cout<<y.F<<" "<<y.S<<endl;
    if(d1<=d2){R 1;}
    else R 0;
}
pii DP(int x,int y){
    if(x+y>f||y>1500)R {a*100,0};
    pii &ret=dp[x][y];
    if(ret.F!=-1)R ret;
    ret={a*100,0};
    if(x*e>=100*y){
        ret={x,y};
    }
    if(ret.F+ret.S==0)ret={a*100,0};
    pii p;
    p=DP(x,y+c);
    if(fuck(ret,p)){
        ret=p;
    }
    p=DP(x,y+d);
    if(fuck(ret,p)){
        ret=p;
    }
    p=DP(x+(100*a),y);
    if(fuck(ret,p)){
        ret=p;
    }
    p=DP(x+(100*b),y);
    if(fuck(ret,p)){
        ret=p;
    }
    R ret;
}
int main(){

    MEM(dp,-1);
    cin>>a>>b>>c>>d>>e>>f;
    cout<<DP(0,0).F+DP(0,0).S<<" "<<DP(0,0).S;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
vector< ll > divisor(ll n) {  //約数の列挙
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    int n;
    std::cin >> n;
    int ans=0;
    rep(i,n){
        if(divisor(i+1).size()==8&&i%2==0){
            ans++;
        //    std::cout << i+1 << std::endl;
        }
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 256
sentence=input()
list=[]
list=sentence.split()
c=[]
k=0
l=0
for i in range(len(list)):
    c.append(0)
    m=len(list[i])
    if(m>k):
        k=len(list[i])
        max=list[i]
for i in range(len(list)):
    for j in range(len(list)):
        if(i!=j and list[i]==list[j]):
            c[i]=c[i]+1
for i in range(len(c)):
    if(c[i]>l):
        l=i
print("%s %s"%(list[l],max))

Measured memory_bytes: 7348
#include<iostream>
#include<stdio.h>
#include<stack>
using namespace std;
int main()
{
	stack<char> S;
	char c;
	while(scanf("%c",&c)!=EOF&&c!='\n')
	{
		if(S.empty())
		{
			S.push(c);
			continue;
		}
		char cc=S.top();
		S.push(c);
		
		if(c=='T'&&cc=='S')
		{
			S.pop();S.pop();
		}
	}
	cout<<S.size();
	
	return 0;
 } 

Measured memory_bytes: 512
// C - Good Sequence
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using vi = vector<int>;

int main(){
	int N; cin>>N;
	vi C(N+1);//count, 1 origin
	int ans = 0;
	rp(i, 0, N){
		int a; cin>>a;
		if(a<=N) C[a]++; else ans++;
	}
	rp(a, 1, N+1) ans += C[a] - (C[a]<a? 0: a);
	cout<< ans <<endl;
}

Measured memory_bytes: 640
using System;
using System.Diagnostics;

namespace atcode
{
    class Program
    {

        static void Main(string[] args)
        {

            string charString = "abcdefghijklmnopqrstuvwxyz";
            
            string inputS = Console.ReadLine().Trim();

            if(inputS == "z") { return; }

            int inputindex = charString.IndexOf(inputS);
            if(inputindex < 0) { return;  }

            int nextIndex = inputindex + 1;

            string nextShar = charString.Substring(nextIndex, 1);

            Console.WriteLine(nextShar);
//            Debug.WriteLine(nextShar);
        }
    }
}


Measured memory_bytes: 13280
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v._size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v._size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }

        

        

        

        void solve1(){
            cin >> n;
            string s1,s2;
            cin >> s1 >> s2;
            if(s1 == s2){
                cout << "0\n";
                return;
            }
            int len1 = 0, len2 = 0;
            for(int i=0;i < n; i++){
                if(s1[i] == '1') len1++;
                if(s2[i] == '1') len2++;
            }
            if(len1 != len2) {cout << "-1\n"; return;}
        }


        void solve(){
            cin >> n;
            ll arr[n+1];
            ll total = 0;
            for(int i=1; i <= n; i++){
                cin >> arr[i];
                total ^= (arr[i]);
            }

            for(int i=1; i<= n; i++){
                cout << (arr[i] ^ total ) << " "; 
            }

           
        }



       
    


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

           
            

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  if(n%2==0){
    for(int i=n-1;i>=1;i-=2){
      cout << a[i] << ' ';
    }
    for(int i=0;i<n;i+=2){
      cout << a[i] << ' ';
    }
    cout << endl;
  }
  else{
    for(int i=n-1;i>=0;i-=2){
      cout << a[i] << ' ';
    }
    for(int i=1;i<n;i+=2){
      cout << a[i] << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp              make_pair
#define sz(a)           a.size()
#define mods(a, m)          ((a % m + m) % m)
#define md(a)               mods(a, MOD)
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)     for (int i = b; i < e; i++)
#define forr(i, b, e)     for (int  i = b; i < e; i++)
#define endl '\n'
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;
typedef long double       ld;

typedef pair<int, int>  ii;
typedef pair<int,ii> iii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const int MOD = 1e9+7;
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 1000003 
double arr[tam];
int v[tam];
double dp[tam];
int main()
{    
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    forr(i,0,n)
    cin>>v[i];
    double ant=0;
    forr(i,0,n)
    {
        arr[i]=(v[i]+1.0)/2.0;
        dp[i]=ant+arr[i];
        ant=dp[i];
    }
    double maxx=dp[k-1];
    forr(i,k,n)
    {
        maxx=max(maxx,dp[i]-dp[i-k]);
    }
    printf("%.8lf",maxx);

}   
// PLUS ULTRA!


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long int lli;

int main() {
    lli N, H, W;
    cin >> N >> H >> W;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int Ai, Bi;
        cin >> Ai >> Bi;
        if (Ai >= H && Bi >= W) {
            ans++;
        }
    }

    cout << ans << endl;
}


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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DEBUG(X) { cerr << #X << " = " << (X) << '\n'; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << '\n'; }
#define sz(x) ((int)(x).size())
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const ll mod = 1e9 + 7;
ll a[300005], sum, n;
ll num;
int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	rep(i, 0, 61)
	{
	    num = 0;
	    rep(j, 1, n) num += ((a[j] & (1ll << i)) > 0);
	    //DEBUG(num);
	    sum = (sum + ((((num * 1ll * (n - num)) % mod) * ((1ll << i) % mod)) % mod)) % mod;
	}
	cout << sum;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N;
    string X;
    cin >> N >> X;

    bitset<200000> b(X);
    ll c  = b.count();
    ll mc = 0;
    ll pc = 0;
    rep(i, N) {
        ll t = X[i] - '0';
        if (c - 1 != 0) mc = (mc * 2 + t) % (c - 1);
        pc = (pc * 2 + t) % (c + 1);
    }

    vec<ll> f(N + 1, 0);
    vec<ll> popcount(N + 1, 0);

    for (ll i = 1; i <= N; ++i) {
        popcount[i] = popcount[i / 2] + i % 2;
        f[i]        = f[i % popcount[i]] + 1;
    }

    vec<ll> mpow2(N + 1, 1);
    vec<ll> ppow2(N + 1, 1);
    for (ll i = 1; i <= N; ++i) {
        if (c - 1 != 0) mpow2[i] = mpow2[i - 1] * 2 % (c - 1);
        ppow2[i] = ppow2[i - 1] * 2 % (c + 1);
    }

    rep(i, N) {
        ll t = X[i] - '0';
        if (t == 1) {
            if (c - 1 == 0) {
                cout << 0 << endl;
            } else {
                ll nt = mc;
                nt -= mpow2[N - 1 - i];
                nt += c-1;
                nt %= (c - 1);
                cout << f[nt] + 1 << endl;
            }
        } else {
            ll nt = pc;
            nt += ppow2[N - 1 - i];
            nt %= (c + 1);
            cout << f[nt] + 1 << endl;
        }
    }
}


Measured memory_bytes: 9948
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	int maxi = max(max(a, b), c);
	int sum = a + b + c;
	if (maxi % 2 == sum % 2) cout << (3 * maxi - a - b - c) / 2 << endl;
	else cout << (3 * (maxi + 1) - a - b - c) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = abs(a[n - 1] - w);
    if (n != 1) ans = max(ans, abs(a[n - 2] - a[n - 1]));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s1, s2;
    int n1, n2;
    cin >> s1 >> s2 >> n1 >> n2;
    string t;
    cin >> t;
    if (!s1.compare(t)) n1--;
    if (!s2.compare(t)) n2--;
    cout << n1 << " " << n2;
    return 0;
} 

Measured memory_bytes: 256
/*
strcmp(s, t)の戻り値は、s>tのときに正。
*/
/*s<tとなる確率が高いのはsを昇順、tを降順に
ソートしたときが忘れがち*/

#include<stdio.h>
#include<string.h>

void norSort(char *p);
void revSort(char *p);


int main(void)
{
  char s[100+1] = {0};
  char t[100+1] = {0};

  scanf("%s", s); scanf("%s", t);
  norSort(s);
  revSort(t);
  if(strcmp(s, t) < 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

void norSort(char *p)
{
  int i,j;
  char buffer = 0;
  for(i=0; i<strlen(p)-1; i++){
    for(j=i+1; j<strlen(p); j++){
      if(p[i] > p[j]){
        buffer = p[i];
        p[i] = p[j];
        p[j] = buffer;
      }
    }
  }
  return ;
}

void revSort(char *p)
{
  int i,j;
  char buffer = 0;
  for(i=0; i<strlen(p)-1; i++){
    for(j=i+1; j<strlen(p); j++){
      if(p[i] < p[j]){
        buffer = p[i];
        p[i] = p[j];
        p[j] = buffer;
      }
    }
  }
  return ;
}


Measured memory_bytes: 128
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main(){
int N,L;
cin>>N>>L;
string S[N];
rep(i,N){
  cin>>S[i];
}
sort(S,S+N);
string ans="";
rep(i,N){
  ans+=S[i];
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3640
import sys

# import bisect
from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

import heapq


class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class PriorityQueue:

    def __init__(self, x=[], desc=False):
        if desc:
            for i in range(len(x)):
                x[i] = Reverse(x[i])
        self._desc = desc
        self._container = x
        heapq.heapify(self._container)

    @property
    def is_empty(self):
        return not self._container

    def pop(self):
        if self._desc:
            return heapq.heappop(self._container).val
        else:
            return heapq.heappop(self._container)

    def push(self, item):
        if self._desc:
            heapq.heappush(self._container, Reverse(item))
        else:
            heapq.heappush(self._container, item)

    def top(self):
        if self._desc:
            return self._container[0].val
        else:
            return self._container[0]

    def sum(self):
        return sum(self._container)

    def __len__(self):
        return len(self._container)


def main():
    x, y, a, b, c = list(map(int, readline().split()))
    p = list(map(int, readline().split()))
    q = list(map(int, readline().split()))
    r = list(map(int, readline().split()))

    p.sort()
    q.sort()
    r = PriorityQueue(r,desc=True)

    eat = p[-x:]
    eat.extend(q[-y:])
    eat = PriorityQueue(eat)

    while eat.top() < r.top():
        _ = eat.pop()
        eat.push(r.pop())
        c -= 1
        if c == 0:
            break

    print(eat.sum())





if __name__ == '__main__':
    main()


Measured memory_bytes: 123628
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int a , b , x , y ;
    cin >> a >> b >> x >> y ; 
    int height = y - b ; 
    int width = x - a ;
    for(int i = 0; i < height; i++){
        cout << 'U' ;
    }
    for(int i = 0; i < width; i++){
        cout << 'R' ; 
    }
    for(int i = 0; i < height; i++){
        cout << 'D' ;
    }
    for(int i = 0; i < width; i++){
        cout << 'L' ; 
    }
    cout << 'L' ;
    for(int i = 0; i < height + 1; i++){
        cout << 'U' ; 
    }
    for(int i = 0; i < width + 1; i++){
        cout << 'R' ; 
    }
    cout << 'D' ; 
    cout << 'R' ; 
    for(int i = 0; i < height + 1; i++){
        cout << 'D' ;
    }
    for(int i = 0; i < width + 1; i++){
        cout << 'L' ; 
    }
    cout << 'U' ; 
    cout << endl;
    return 0; 
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

struct fast_combination {
    fast_combination(i64 n, i64 num, int mod_) :fac(num+1, 0), finv(num+1, 0), inv(num+1, 0), mod_(mod_) {
        fac[0] = fac[1] = n;
        finv[0] = finv[1] = 1;
        inv[1] = 1;

        for (i64 i=2; i<=num; ++i) {
            fac[i] = fac[i-1] * (n-i+1) % mod_;
            inv[i] = mod_ - inv[mod_%i] * (mod_/i) % mod_;
            finv[i] = finv[i-1] * inv[i] % mod_;
        }
    }

    int64_t operator()(int k) {
        //cout << "  " << fac[k] << " "<< finv[k] << endl;
        return fac[k] * finv[k] % mod_;
    }

    std::vector<int64_t> fac, finv, inv;
    int mod_;
};
/*
i64 all_pattern(i64 n) {
    int ans = 1;
    while (n > 30) {
        ans <<= 30;
        n -= 30;
        ans %= mod;
    }
    for (int i=0; i<n; ++i) {
        ans <<= 1;
        ans %= mod;
    }
    return --ans;
}
*/
i64 all_pattern(i64 a, i64 b, i64 mod_) {
    i64 res = 1;
    for (a %= mod_; b; a = a * a % mod_, b >>= 1)
        if (b & 1) res = res * a % mod_;
    return --res;
}

int main(int argc, char **argv) {
    i64 n, a, b;
    cin >> n >> a >> b;

    fast_combination comb(n, 200000, mod);

    i64 all = all_pattern(2, n, mod);
    i64 ans = all;
    ans -= comb(a);
    if (ans < 0) ans +=mod;

    ans -= comb(b);
    if (ans < 0) ans += mod;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5500