akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, in;
	cin >> n;
	ll ans = 0;
	rep(i, n){
		cin >> in;
		ans += in - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    cnt = 1
    for i in range(N):
        if A[i] == cnt:
            cnt += 1
        else:
            ans += 1

    if A.count(1) == 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 77516
#include <stdio.h>

int main(void) {
    int N, K, S, A[100005], i;
    scanf("%d%d%d", &N, &K, &S);
    for (i=1; i<=K; i++) A[i]=S;
    for (i=K+1; i<=N; i++) {
        if (S!=1000000000) A[i]=S+1;
        else A[i]=1;
    }
    for (i=1; i<=N; i++) {
        printf("%d", A[i]);
        if (i!=N) printf(" ");
    }
    return 0;
}


Measured memory_bytes: 1664
n = gets.chomp.to_i
a1 = gets.chomp.split(" ").map(&:to_i)
a2 = gets.chomp.split(" ").map(&:to_i)

ans = 0
for i in 0..n-1 do
    tmp = 0
    for j in 0..i do
        tmp += a1[j]
    end
    for j in i..n-1 do
        tmp += a2[j]
    end
    ans = [ans, tmp].max
end

puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
typedef long long ll;

const int maxn = 100;
int a[maxn], n; 
bool check() {
	for (int i = 1; i < n; i++) if (a[i] > a[i + 1]) return false; return true;
}
std::vector<std::pair<int,int> >ans;
int main() {
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	scanf("%d",&n);
	for (int i = 1; i<= n; i++){
		//std::cerr << '>';
		scanf("%d", &a[i]);
	} 
		
	//for (int i = 1; i <= n; i++) std::cerr << a[i] << ' '; std::cerr << std::endl;
	if (check()) return 0 * puts("0");
	int maxp = 1, minp = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] > a[maxp]) maxp = i;
		if (a[i] < a[minp]) minp = i;
	}
	if (a[minp] + a[maxp] > 0) {
		ans.push_back(std::make_pair(maxp, 1)); 
		ans.push_back(std::make_pair(maxp, 1));
		for (int i = 2; i <= n; i++) {
			ans.push_back(std::make_pair(i - 1, i));
			ans.push_back(std::make_pair(i - 1, i));
		}
	}
	else {
		ans.push_back(std::make_pair(minp, n)); 
		ans.push_back(std::make_pair(minp, n));
		for (int i = n; i > 1; i--) {
			ans.push_back(std::make_pair(i, i - 1));
			ans.push_back(std::make_pair(i, i - 1));
		}
	}
	printf("%d\n", ans.size());
	for (int i = 0; i < ans.size(); i++) {
		printf("%d %d\n", ans[i].first, ans[i].second);
		a[ans[i].second] += a[ans[i].first];
	}
	
	//for (int i = 1; i <= n; i++) std::cerr << a[i] << ' '; std::cerr << std::endl;
	//if (!check() ) std::cerr << "ERROR" << std::endl;
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,a,b;cin>>n>>a>>b;
    vint x(n);
    rep(i,n) cin >> x[i];
    
    int res=0;
    rep(i,n-1){
        res+=min((x[i+1]-x[i])*a,b);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
 
int findSumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  
  int total = 0;
  for(int i = 1; i <= n; i++){
    int sum = findSumOfDigits(i);
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 384
#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.at(i);
  }
  vector<int> sorted = p;
  sort(sorted.begin(), sorted.end());
  bool ans = false;
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      vector<int> v = p;
      swap(v.at(i), v.at(j));
      if (v == sorted) {
        ans = true;
      }
    }
  }
  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  if (n%2 == 0) cout << n << endl;
  else cout << 2*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define _ ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

int main() {_
    long long n;
    int c;
    cin >> n;

    vector<char> str;
    do{
        c = n % 26;
        if(c==0) c=26;
        str.push_back(96+c);
        n-=c;
    }while(n/=26);

    for(int i=str.size()-1; i>=0; i--)
        cout << str[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3640
//
// Created by maze on 2019-07-11.
//
#include <bits/stdc++.h>
using namespace std;

using int64 = int64_t;

#define REP(i, a) for(int64 i = 0; i < (a); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()

int main(void) {
    int N;
    while (cin >> N && N) {
        vector<int64> it(N, 0);
        vector<int64> v(N, 0);
        REP(i, N) {
            int M;
            cin >> M >> v[i];
            REP(_, M) {
                int64 S, E;
                cin >> S >> E;
                FOR(j, S-6, E-6) {
                    it[i] |= 1LL << j;
                }
            }
        }
        vector<int64> dp(1 << 17, 0);
        REP(i, N) {
            for (int64 j = (1 << 17) - 1; j >= 0; j--) {
                if ((it[i] & j) == 0) {
                    dp[j | it[i]] = max(dp[j | it[i]], dp[j] + v[i]);
                }
            }
        }
        cout << *max_element(all(dp)) << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  auto itr=lower_bound(a.begin(),a.end(),(a[n-1]+1)/2);
  int x=*itr;
  if (itr!=a.begin()||x==a[n-1]){
    itr--;
    int y=*itr;
    double z=(double)a[n-1]/2.0;
    if (abs((double)y-z)<abs((double)x-z)||x==a[n-1]){
      x=y;
    }
  }
  cout << a[n-1] << ' ' << x << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > A(N, vector<int>(M));
    REP(i, N){
        REP(j, M){
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    vector<int> score(M, 0);
    vector<int> pointer(N, 0);
    REP(i, N)score[A[i][0]]++;
    int res = 1<<30;
    REP(i, M){
        int idx = -1;
        int tmp = 0;
        REP(j, M){
            if(score[j]==-1)continue;
            if(idx==-1 || tmp<score[j]){
                tmp = score[j];
                idx = j;
            }
        }
        //cerr << tmp << endl;
        res = min(res, tmp);
        score[idx] = -1;
        REP(i, N){
            if(pointer[i]==M)continue;
            if(A[i][pointer[i]]==idx){
                while(pointer[i]<M && score[A[i][pointer[i]]]==-1)pointer[i]++;
                if(pointer[i]==M)continue;
                score[A[i][pointer[i]]]++;
            }
        }
    }
    //REP(i, N)cerr << "!" << pointer[i] << endl;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	d := nextInt()
	clist := make([]int, 26)
	for i := 0; i < 26; i++ {
		clist[i] = nextInt()
	}
	var slist [366][26]int
	for i := 0; i < d; i++ {
		for j := 0; j < 26; j++ {
			tmp := nextInt()
			//fmt.Println(tmp)
			slist[i][j] = tmp
		}
	}

	tlist := make([]int, d) // Answer
	last := map[int]int{}
	vlist := make([]int, d)

	// 貪欲法
	for i := 0; i < d; i++ {
		bestc := 0
		bestm := 0

		// 26タイプ全て実施
		for todaytype := 0; todaytype < 26; todaytype++ {
			lastbak := last[todaytype]
			last[todaytype] = i + 1

			// 基礎満足度増加計算
			basem := 0
			if i == 0 {
				basem = slist[i][todaytype]
			} else {
				basem = vlist[i-1] + slist[i][todaytype]
			}

			// 満足度低下計算
			teika := 0
			for j := 0; j < 26; j++ {
				teika += clist[j] * (i + 1 - last[j])
			}

			// チャンピオン計算
			basem -= teika
			if bestm < basem {
				//fmt.Printf("Camp Changed: %d at type%d\n", basem, todaytype)
				bestm = basem
				bestc = todaytype
			}

			// 初期化
			last[todaytype] = lastbak
		}

		vlist[i] += bestm
		last[bestc] = i + 1

		tlist[i] = bestc
		//fmt.Printf("--- Day End bestm,bestc = %d,%d\n", bestm, bestc)
	}

	// 出力
	for i := 0; i < d; i++ {
		fmt.Printf("%d\n", tlist[i]+1)
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2060
#include <iostream>   
using namespace std;     
int main() {     
    while(1){         
        int a[10000]={0},b[10000]={0},n=0,sum_a=0,sum_b=0;         
        cin>>n;         
        if(!n)break;                 
        for(int i=0;i<n;i++){             
            cin>>a[i]>>b[i];             
            if(a[i]>b[i]){                 
                sum_a+=(a[i]+b[i]);            
            }else if(a[i]<b[i]){                
                sum_b+=(a[i]+b[i]);                 
            }else{                 
                sum_a+=a[i];                 
                sum_b+=b[i];             
            }          
        }         
        cout<<sum_a<<" "<<sum_b<<endl;     
    }             
    return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<cmath>
using namespace std;
int n,K,a[200005],mx=0;
bool Judge(double mid){
	long long cnt=0;
	for(int i=1;i<=n;i++)cnt+=ceil(a[i]/mid)-1;
	return cnt<=K;
}
int main(){
	cin>>n>>K;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),mx=max(mx,a[i]);
	double l=0,r=mx;
	while(r-l>1e-6){
		double mid=(l+r)/2;
		if(Judge(mid))r=mid;
		else l=mid;
	}
	printf("%.0lf\n",ceil((l+r)/2));
    return 0;
}


Measured memory_bytes: 4556
N, K = list(map(int, input().split()))
S = input()

convert_dict = {
    'A': 'a',
    'B': 'b',
    'C': 'c'
}

ans = ''

for i, s in enumerate(S):
    if i != (K - 1):
        ans += s
    else:
        ans += convert_dict[s]

print(ans)


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

int main() {
	string s;
	while (cin >> s) {
		if (s.size() % 2) { puts("NA"); continue; }
		string res;
		int pos = 0;
		while (pos + 1 < s.size()) {
			int d = stoi(to_string(s[pos] - 48) + to_string(s[pos + 1] - 48));
			if (d <= 10 || 65 < d) { puts("NA"); goto p; }
			else if (10 < d&&d <= 15)res += (char)d + 86;
			else if (20 < d&&d <= 25)res += (char)d + 81;
			else if (30 < d&&d <= 35)res += (char)d + 76;
			else if (40 < d&&d <= 45)res += (char)d + 71;
			else if (50 < d&&d <= 55)res += (char)d + 66;
			else if (d == 61)res += 'z';
			else if (d == 62)res += '.';
			else if (d == 63)res += '?';
			else if (d == 64)res += '!';
			else if (d == 65)res += ' ';
			else { puts("NA"); goto p; }
			pos += 2;
		}
		cout << res << endl;
	p:;
	}
}

Measured memory_bytes: 3200
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )
#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = (c).begin(); it != (c).end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define PB( n ) push_back( ( n ) )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define fst first
#define snd second

bool inside( pair<int,int> point )
{
	return 0 <= point.fst && point.fst < 10 && 0 <= point.snd && point.snd < 10;
}

const int jump[][2] = {
	-1,  2,
	 0,  2,
	 1,  2,
	 2,  1,
	 2,  0,
	 2, -1,
	 1, -2,
	 0, -2,
	-1, -2,
	-2, -1,
	-2,  0,
	-2, -1
};

int main()
{
	while ( true )
	{
		int x, y;
		cin >> x >> y;

		if ( x == 0 && y == 0 )
		{
			break;
		}

		int n;
		cin >> n;
		
		vector< pair<int,int> > s;

		REP( i, 0, n )
		{
			int x, y;
			cin >> x >> y;
			s.PB( MP( x, y ) );
		}

		set< pair<int,int> > current;
		current.insert( MP( x, y ) );

		REP( i, 0, n )
		{
			set< pair<int,int> > next;

			IREP( current, it )
			{				
				REP( j, 0, 12 )
				{
					pair<int,int> p = *it;

					p.fst += jump[j][0];
					p.snd += jump[j][1];

					if ( inside( p ) )
					{
						next.insert( p );
					}
				}
			}

			set< pair<int,int> > safety;

			for ( int dx = -1; dx <= 1; dx++ )
			{
				for ( int dy = -1; dy <= 1; dy++ )
				{
					pair<int,int> p = MP( s[i].fst, s[i].snd );

					p.fst += dx;
					p.snd += dy;

					if ( inside( p ) && next.find( p ) != next.end() )
					{
						safety.insert( p );
					}
				}
			}

			current = safety;
		}

		if ( 0 < current.size() )
		{
			cout << "OK";
		}
		else
		{
			cout << "NA";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
N = int(input())
d = {}
for _ in range(N):
    w = input().strip()
    if w in d:
        d[w] += 1
    else:
        d[w] = 1
m = max(d.values())
r = []
for k, v in d.items():
    if v == m:
        r.append(k)
for w in sorted(r):
    print(w)


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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  vector<long long> X(N);
  for (int i = 0; i < N; ++i)
    cin >> X[i];
  long long ans = 0;
  for (int i = 0; i < N - 1; ++i)
    ans += min(A * (X[i + 1] - X[i]), B);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int count=0;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10 && i/1000-10*(i/10000)==(i%100-i%10)/10){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from string import ascii_lowercase as alphabets

def main():
    inf=100
    alphd={x:0 for x in alphabets}
    ansd={x:inf for x in alphabets}
    n=int(input())
    s=[input() for _ in range(n)]
    for st in s:
        for x in st:
            alphd[x]+=1
        for a in alphabets:
            ansd[a]=min(ansd[a],alphd[a])
            alphd[a]=0
    print(''.join([a*ansd[a] for a in alphabets if ansd[a]<inf]))
    

if __name__=='__main__':
    main()


Measured memory_bytes: 9880
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll R) { cout << 2.000 * M_PI * R << endl; }

int main() {
  ll R;
  scanf("%lld", &R);
  solve(R);
  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int n;
  cin>>n;
  cout<<ceil(n/2.0)<<endl;
}
return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, K, Q; cin >> N >> K >> Q;

    set<int> S;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i], S.insert(A[i]);

    int ans = INF;
    for(int mi : S) {
        vector<int> B = A;
        for(int i=0; i<N; i++) B[i] = (B[i] < mi ? -1 : B[i]);
        B.push_back(-1);

        vector<int> whole;
        priority_queue< int, vector<int>, greater<int> > seg;
        for(int i=0; i<=N; i++) {
            // printf("mi = %lld, i = %lld, B[i] = %lld\n", mi, i, B[i]);
            if(B[i] < 0) {
                int M = seg.size();
                // printf("M = %lld, lim = %lld\n", M, M-K+1);
                for(int k=0; k<M-K+1; k++) {
                    whole.push_back(seg.top());
                    seg.pop();
                }
                while(seg.size()) seg.pop();
            }
            else {
                seg.push(B[i]);
            }
        }

        sort(whole.begin(), whole.end());
        if(whole.size() >= Q) chmin(ans, whole[Q-1] - whole[0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n,m,p;
int head[N];
bool vis[N];
vector<int> G[2];
struct Edge {
  int to,last;
  Edge () {}
  Edge (int a,int b) :to(a),last(b) {}
}edge[N<<1];
void ADD(int a,int b) {
  edge[++p]=Edge(b,head[a]); head[a]=p;
  edge[++p]=Edge(a,head[b]); head[b]=p;
}
void DFS(int u,int id) {
  vis[u]=true;
  if(u!=1||id) G[id].push_back(u);
  for(int& i=head[u];i;i=edge[i].last) {
    int v=edge[i].to;
    if(!vis[v]) {
      DFS(v,id);
      break;
    }
  }
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=m;++i) {
    int u,v; read(u,v);
    ADD(u,v);
  }
  DFS(1,0); DFS(1,1);
  printf("%d\n",G[0].size()+G[1].size());
  reverse(G[0].begin(),G[0].end());
  for(auto v: G[0]) printf("%d ",v);
  for(auto v: G[1]) printf("%d ",v);
  return 0;
}


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int p=0;
  int m=0;
  vector<vector<int>> vp;
  vector<vector<int>> vm;
  for(int _=0;_<n;_++){
    string s;
    cin>>s;
    int x=0;
    int v=0;
    for(int i=0;i<(int)s.size();i++){
      x+=(s.at(i)=='('?1:-1);
      v=min(v,x);
    }
    if(x>0){
      if(v==0)
        p+=x;
      else
        vp.push_back({v,x});
    }else{
      if(v==x)
        m+=x;
      else
        vm.push_back({v,x});
    }
  }
  sort(vp.begin(),vp.end(),greater<vector<int>>());
  sort(vm.begin(),vm.end());
  int x=p;
  for(int i=0;i<(int)vp.size();i++){
    if(x+vp.at(i).at(0)<0){
      cout<<"No"<<endl;
      return 0;
    }
    x+=vp.at(i).at(1);
  }
  for(int i=0;i<(int)vm.size();i++){
    if(x+vm.at(i).at(0)<0){
      cout<<"No"<<endl;
      return 0;
    }
    x+=vm.at(i).at(1);
  }
  cout<<(x+m==0?"Yes":"No")<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  
  for (int i = 1; i <= N; i++) {
    if (i<10){
      count++;
    }
    else if (i>99 && i<1000){
      count++;
    }
    else if (i>9999 && i<100000){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3604
using System;

namespace ITP1_9_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a, b;
            a = b = 0;

            for(int i=0;i< n; i++)
            {
                string[] cards = Console.ReadLine().Split(' ');
                int result = cards[0].CompareTo(cards[1]);

                if (result == 0) { a++; b++; }
                else if (result > 0) a += 3;
                else b += 3;
            }
            Console.WriteLine(a + " " + b);
        }
    }
}

Measured memory_bytes: 9996
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;


/* main関数 */
int main(void) {
	int n;
	string s;
	cin >> n;
	rpt(i, n) {
		char c;
		cin >> c;
		s.push_back(c);
	}
	int count = 1;
	char rc = s[0];
	rpt(i, n) {
		if (s[i] != rc) {
			count++;
			rc = s[i];
		}
	}
	cout << count;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;
 class Main {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int t=sc.nextInt();
        int n=sc.nextInt();
        int a[]=new int[t];
        HashMap<Integer,Integer> h=new HashMap<Integer,Integer>();
        int i;
        for(i=0;i<t;i++)
        a[i]=sc.nextInt();
        for(i=0;i<t;i++)
        {
            if(h.containsKey(a[i]))
            {
                int x=h.get(a[i]);
                h.put(a[i],x+1);
            }
            else
            h.put(a[i],1);
            
        }
        int b[]=new int [h.size()];
        i=0;
        for(Integer key:h.keySet())
        {
            int y=h.get(key);
            b[i]=y;
            i++;
        }    
        Arrays.sort(b);
        
        int sum=h.size()-n;
        int sum2=0;
        for(i=0;i<sum;i++)
        {
           sum2+=b[i];
        }
        System .out.println(sum2);
    }
}

     

Measured memory_bytes: 56584
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;
int main(){
  ll x;
  cin >> x;

  ll ans = 0;
  for(int i=0;i<100000;i++){
    ll t;
    t = i*(i+1)/2;
    if(t >= x){
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 2e5+5;
int N;


int main()
{
    cin >> N;
    LL ans = 0;
    LL minb = 1e9 + 7;
    int ok = 0;
    _for(i,0,N){
        LL a,b;
        cin >> a >> b;
        if(a != b) ok = 1;
        ans += a;
        if(a > b) minb = min(b,minb);
    }
    if(!ok){
        cout << 0 << endl;
        return 0;
    }

    cout << ans - minb << endl;
    return 0;
}


Measured memory_bytes: 256
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

dis1 = (A1 - B1) * T1
dis2 = (A2 - B2) * T2

if dis1 > 0:
    dis1 = -dis1
    dis2 = -dis2

if dis1 + dis2 <0:
    print(0)

elif dis1 == -dis2:
    print("infinity")
    
else:
    S = dis1//(dis1+dis2)
    R = dis1%(dis1+dis2) 
    if R == 0:
        ans = S*2 
    else:
        ans = S*2 + 1
    
    print(abs(ans))
 

Measured memory_bytes: 3064
S = list(input())
N = len(S)

if S == S[::-1] and S[:(N-1)//2] == S[:(N-1)//2][::-1] and S[(N+3)//2 - 1:] == S[(N+3)//2 - 1:][::-1]:
    print("Yes")
else:
    print("No")

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << " end.\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


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

    bool ex = 0;
    for(int i = 0; i+2 < n; ++i){
        if(arr[i][0] == arr[i][1] && arr[i+1][0] == arr[i+1][1] && arr[i+2][0] == arr[i+2][1]) ex = 1;
    }

    puts(ex ? "Yes" : "No");
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3652
//AtCoder ABC095 B - Bitter Alchemy
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,X; cin>>N>>X;
    vector<ll> mn(N);
    ll ttl=0;
    ll minm=INT32_MAX;
    for(auto& m:mn){
        cin>>m;
        minm=min(m,minm);
        ttl+=m;
    }
    X-=ttl;
    ll ans=N;
    ans += X/minm;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n)rep(j,n)rep(k,n) ans += gcd(i,gcd(j,k));
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;

  int m = K / 2;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x <= m) {
      sum += x;
    } else {
      sum += K - x;
    }
  }
  cout << sum * 2 << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  dp
  コイン問題
  m種類のコイン，ｎ円にする最小のコインの枚数は？
*/


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> coin(n);
  coin[0] = 0;
  REP2(i,1,m+1) cin >> coin[i];

  int dp[m+1][n+1];
  REP(i,n+1) dp[0][i] = INF;

  // REP(i,n+1) dp[0][i] = 0;
  REP(i,m+1) dp[i][0] = 0;

  //dpテーブル
  REP2(i,1,m+1) {
    REP2(j,1,n+1){
      if(j < coin[i]){
        dp[i][j] = dp[i-1][j];
      }
      else{
        dp[i][j] = min(dp[i-1][j], dp[i][j-coin[i]]+1);
        //追加するのが１なので，dpは一次元配列でもかける
      }

    }
  }

  cout << dp[m][n] << endl;

  return 0;
}



Measured memory_bytes: 7176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 1;
		while(ans * 2 <= N){
			ans *= 2;
		}
		System.out.println(ans);
	}

}



Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int N;
        long D;
        {String[] a = in.readLine().split(" "); N = Integer.parseInt(a[0]); D = Long.parseLong(a[1]);}
        D *= D;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            long x, y; {String[] a = in.readLine().split(" "); x = Long.parseLong(a[0]); y = Long.parseLong(a[1]);}
            long d = x * x + y * y;
            if (d <= D) {
                ans++;
            }
        }
        out.println(ans);
    }
}


Measured memory_bytes: 55096
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<tuple<string,int,int>> a;

    for(int i = 1;i <= N;i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < N;i++){
        cout << get<2>(a[i]) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a = 0;
    int b = 0;
    std::cin >> a >> b;
    if (a>b){
        std::cout << "a > b" <<std::endl;
    }
    else if(a<b){
        std::cout << "a < b" <<std::endl;
    }
    else if(a==b){
        std::cout << "a == b" <<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  
  vector<int> A(N);
  REP(i, N)
    cin >> A[i];
  
  sort(ALL(A));
  REP(i, N - 1)
  {
    if (A[i] == A[i + 1])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
# B
n = int(input())

ans = 0
for i in range(1, n+1):
    if i%3 == 0 and i%5 == 0:
        continue
    elif i%3 == 0:
        continue
    elif i%5 == 0:
        continue
    else:
        ans += i
        
print(ans)

Measured memory_bytes: 9128
from fractions import gcd
n=int(input())
a=list(map(int, input().split()))
List1=[0]*n
List1[0]=a[0]
List2=[0]*n
List2[0]=a[-1]
for i in range(1, n):
    List1[i]=gcd(List1[i-1], a[i])
    List2[i]=gcd(List2[i-1], a[-i-1])
ans=List2[-2]
for i in range(1, n-1):
    ans=max(ans, gcd(List1[i-1], List2[n-i-2]))
ans=max(ans,List1[n-2])
print(ans)

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

void Printf(std::vector<int> & a, int p) {
	for(int i=0;i<=(int)a.size()-1;++i) {
		if (i>0){ 
			cout << " ";
		}
		if (i==p) {
			cout  << "[" << a.at(i) << "]";
		} else {
			cout  << a.at(i);
		}
	}
}
void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
	}
}
void swapint(int &i,int &j) {
	int t=i;
	i = j;
	j = t;
}
int Partition(std::vector<int> & A, int p,int r)
{
	int x = A[r];
	int i = p-1;
	for (int j = p; j <=r-1;++j) {
		if (A[j] <= x) {
			i = i+1;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}


int main(){
	std::vector<int> A;
	::InputSet(A);
	int par = Partition(A, 0, (int)A.size()-1);

	Printf(A,par);
	cout << std::endl;
}

Measured memory_bytes: 1532
# -*- coding: utf-8 -*-
import sys
import math

N,X = list(map(int, input().rstrip().split()))
#-----

## レベルnバーガーの、層の数
def material(n):
    return 2**(n+2)-3

## レベルnバーガーの、Pattyの数
def patty(n):
    return 2**(n+1)-1

cnt=0
while N > 0:
    half = material(N) // 2 + 1
    
    if X == half:
        cnt += patty(N-1) + 1
        break
    elif X == 1:
        break
    elif X > half:
        cnt += patty(N-1) + 1
        N -= 1
        X -= half
    elif 1 < X < half:
        N -= 1
        X -= 1

    ## last    
    if N == 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
import heapq
h, w = map(int, input().split())
cost = []

for i in range(10):
    c = list(map(int, input().split()))
    cost.append(c)
    
dist = [[float('inf') for _ in range(10)] for _ in range(10)]
for i in range(10):
    dist[i][i] = 0
    
for s in range(10):
    next_v = [[0, s]]
    
    while len(next_v):
        v = next_v[0][1]
        for i in range(10):
            if dist[s][i] > dist[s][v] + cost[v][i]:
                dist[s][i] = dist[s][v] + cost[v][i]
                heapq.heappush(next_v, [dist[s][i], i])
        heapq.heappop(next_v)
      
mp = 0
for i in range(h):
    a = list(map(int, input().split()))
    for t in range(w):
        if a[t] != -1 and a[t] != 1:
            mp += dist[a[t]][1]

print(mp)

Measured memory_bytes: 3316
import collections
n = int(input())

lis = []

for k in range(1,101):
    for l in range(1,101):
        for m in range(1,101):
            lis.append(k ** 2 + l ** 2 + m ** 2 + k * l + l * m + m * k)

c = collections.Counter(lis)
for p in range(1, n + 1):
    print(c[p])

Measured memory_bytes: 50532
u = [int(input()) for i in range(4)]
A,B,C,X = u[0],u[1],u[2],u[3]
count=[]
a ,b = 0,0
i = 0
while X-500*a >=0 and a<= A:
    X_1 = X-500*a
    while X_1-100*b>= 0 and b<= B:
        X_2 = X_1-100*b
        if X_2 % 50 == 0 and X_2 / 50 <= C:
            i += 1
        else:
             pass
        b += 1
    b = 0
    count.append(i)
    a += 1
    i=0
print(sum(count))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  vecint a(n);
  for(auto&&e:a)cin>>e;
  REP(i,n-k) {
    if (a[i] < a[i+k]) {
      cout<<"Yes\n";
    } else {
      cout<<"No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3992
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5;
int n;
int pre[2*N+5],cntX[2*N+5],cntY[2*N+5];
int Find(int u){return pre[u]=(pre[u]==u? u:Find(pre[u]));}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=2*N;i++) pre[i]=i;
	for(int i=1;i<=n;i++){
		int x,y;scanf("%d%d",&x,&y);
		int Fx=Find(x),Fy=Find(N+y);
		if(Fx!=Fy) pre[Fx]=Fy;
	}
	for(int i=1;i<=2*N;i++){
		int Fi=Find(i);
		if(i<=N) cntY[Fi]++;
		else cntX[Fi]++;
	}
	ll ans=0;
	for(int i=1;i<=2*N;i++)
		ans+=1ll*cntX[i]*cntY[i];
	printf("%lld\n",ans-n);
	return 0;
}

Measured memory_bytes: 2048
r,g,b,n=list(map(int,input().split()))
ans=0
for gi in range(1,n+2):
  if (gi-1)%r!=0:
    continue
  else:
    for bi in range(gi,n+2):
      if (bi-gi)%g ==0 and (n-bi+1)%b==0 :
        ans+=1
print(ans)
        

Measured memory_bytes: 2940
sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += 'U' * (ty - sy)  # 1
ans += 'R' * (tx - sx)  # 2
ans += 'D' * (ty - sy)  # 3
ans += 'L' * (tx - sx + 1)  # 4
ans += 'U' * (ty - sy + 1)  # 5
ans += 'R' * (tx - sx + 1)  # 6
ans += 'DR'  # 7, 8
ans += 'D' * (ty - sy + 1)  # 9
ans += 'L' * (tx - sx + 1)  # 10
ans += 'U'  # 11
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,a[4],m[4];
	ll w,v,ans=0ll,W,c[4],wsum,vsum;
	vector<ll> g[4];
	cin >> n >> W;
	cin >> c[0] >> v;
	g[0].push_back(v);
	for(i=1; i<n; ++i){
		cin >> w >> v;
		g[w-c[0]].push_back(v);
	}
	for(i=0; i<4; ++i){
		c[i] = c[0]+i;
		m[i] = g[i].l_ength();
		sort(g[i].begin(),g[i].end(),greater<ll>());
		for(j=1; j<m[i]; ++j){
			g[i][j] += g[i][j-1];
		}
		g[i].push_back(0ll);
		for(j=m[i]; j>0; --j){
			g[i][j] = g[i][j-1];
		}
		g[i][0] = 0ll;
	}
	ans = 0ll;
	for(a[0]=0; a[0]<=m[0]; ++a[0]){
		for(a[1]=0; a[1]<=m[1]; ++a[1]){
			for(a[2]=0; a[2]<=m[2]; ++a[2]){
				for(a[3]=0; a[3]<=m[3]; ++a[3]){
					wsum = 0ll;
					for(i=0; i<4; ++i){
						wsum += c[i]*a[i];
					}
					if(wsum>W){
						continue;
					}
					vsum = 0ll;
					for(i=0; i<4; ++i){
						vsum += g[i][a[i]];
					}
					ans = max(ans,vsum);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int x, int y){
    if (y == 0){
        return x;
    }else{
        return gcd(y, x % y);
    }
}

int main()
{

    int a, b, g, l;
    while (cin >> a >> b) {
        g = gcd(a, b);
        l = a / g * b;
        cout << g << ' ' << l << endl;
    }
    return 0;
}

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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	ll n, m, d;
	cin >> n >> m >> d;

	ld ans = d == 0 ? (ld)1.0 / n * (m - 1) : (ld)(2 * (n - d)) / (n * n) * (m - 1);
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
sc=[[0,0] for i in range(m)]
for i in range(m):
    sc[i] = list(map(int,input().split()))

ans = ["a"]*n

f=0
for sc0 in sc:
    if ans[sc0[0]-1] =="a":
        ans[sc0[0]-1] = sc0[1]
    elif ans[sc0[0]-1] !=sc0[1]:
        f=1

if f==1:
    print(-1)
elif ans==[0] or ans == ["a"]:
    print(0)
elif ans[0]==0:
    print(-1)
else:
    if ans[0]=="a":
        ans[0]=1
    answer = [aa if aa!="a" else 0 for aa in ans]
    print( "".join(map(str,answer)) )

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

using namespace std;

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

typedef pair<int, int> pii;

int main() {
	int n;
	bool f = false;
	while (cin >> n, n) {
		if (f) puts("");
		
		string str[10];
		vector<pii> v(n);
		
		REP(i, n) {
			int a, b, c;
			cin >> str[i] >> a >> b >> c;
			int score = 3*a + c;
			v[i] = pii(score, -i);
		}
		sort(v.begin(), v.end(), greater<pii>());
		
		REP(i, n) printf("%s,%d\n", str[-v[i].second].c_str(), v[i].first);
		
		f = true;
	}
	return 0;
}

Measured memory_bytes: 1208
def read():
    A = int(input())
    B = int(input())

    return A, B


def solve(A, B):
    setA = set([1, 2, 3])
    setB = set([A, B])
    ans = str(setA - setB)[1]
    return ans


if __name__ == '__main__':
    A, B = read()
    print("%s" % solve(A,B))





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

using namespace std;

int main(void){
  string S;
  int ans=0;
  cin >> S;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int cs[100000];
std::vector<P> ds;
int even_n, odd_n;

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

    int N;
    std::cin >> N;
    
    for(int i=0;i<N;++i){
        std::cin >> cs[i];
    }

    sort(cs, cs+N);
    
    for(int i=0,j=0;i<N;){
        while(j < N && cs[j] == cs[i]){++j;}
        int n = j - i;
        if(n % 2 == 0){++even_n; n = 2;}
        else{++odd_n; n = 1;}
        ds.emplace_back(n, cs[i]);
        
        i = j;
    }
    
    int M = ds.size();
    if(even_n == 0){
        std::cout << M << std::endl;
        return 0;
    }else if(even_n % 2 == 1){
        std::cout << M - 1 << std::endl;
        return 0;
    }else if(odd_n > 0){
        std::cout << M << std::endl;
        return 0;
    }

    int l = 0, r = 0;
    if(fst(ds[0]) == 2){
        ++l;
    }
    for(int i=2;i<M;++i){
        if(fst(ds[i]) == 2){
            ++r;
        }
    }

    for(int i=1;i+1<M;++i){
        if(fst(ds[i]) == 1){
            if(l > 0 && r > 0){
                std::cout << M << std::endl;
                return 0;
            }
        }

        ++l;
        if(fst(ds[i+1]) == 2){
            --r;
        }
    }

    std::cout << (M - 2) << std::endl;
}


Measured memory_bytes: 1784
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

constexpr int SIZE = 186;

vector<string> board;
int h, w;

int dp[2][SIZE][SIZE][SIZE];

void run() {
	cin >> h >> w;
	board.resize(h);
	each(r, board) cin >> r;

	rep(x1, 0, w) {
		dp[0][h-1][x1][x1+1] = 1;
		rep(x2, x1+2, w+1) {
			if (board[h-1][x2-2] == board[h-1][x2-1]) {
				dp[0][h-1][x1][x2] = dp[0][h-1][x1][x2-1];
			}
		}
	}

	for (int y = h-2; y >= 0; y--) {
		rep(x1, 0, w) {
			rep(x2, x1+1, w+1) {
				if (board[y][x1] != board[y][x2-1]) break;
				dp[0][y][x1][x2] = 1;
				if (board[y][x1] == board[y+1][x1]) {
					dp[0][y][x1][x2] += dp[0][y+1][x1][x2];
				}
			}
		}
	}

	for (int cmpl = 0;; cmpl++) {
		int k = cmpl%2;

		if (dp[k][0][0][w] >= h) {
			cout << cmpl << endl;
			return;
		}

		rep(y, 0, h) rep(x1, 0, w) rep(x2, x1+1, w+1) {
			int p = dp[k][y][x1][x2];
			dp[!k][y][x1][x2] = p + dp[k][y+p][x1][x2];
		}

		rep(y, 0, h) rep(x1, 0, w) rep(x2, x1+2, w+1) {
			int begin = x1+1, end = x2;

			while (begin+1 < end) {
				int mid = (begin+end) / 2 - 1;
				int depth = dp[k][y][x1][mid];
				int depth2 = dp[k][y][mid][x2];

				if (depth2 >= depth) {
					end = mid+1;
				} else {
					begin = mid+1;
				}
			}

			rep(p, -1, 2) {
				int depth = dp[k][y][x1][begin+p];
				int depth2 = dp[k][y][begin+p][x2];
				dp[!k][y][x1][x2] = max(dp[!k][y][x1][x2], min(depth, depth2));
			}
		}
	}
}


Measured memory_bytes: 50432