akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1000005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

vector<int> g[maxn];
int dp[maxn];

int solve(int v)
{
    if (dp[v] != -1) return dp[v];
    int ret = 0;
    for (auto x : g[v]) {
        ret = max(ret, solve(x) + 1);
    }
    return dp[v] = ret;
}
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, m;
        cin >> n >> m;
        for (int i = 0; i < m; i++) {
            int u, v;
            cin >> u >> v;
            --u;
            --v;
            g[u].push_back(v);
        }

        for (int i = 0; i < n; i++) dp[i] = -1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans = max(ans, solve(i));
            //dbg(ans);
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 31104
#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>

using namespace std;
const int INF = 1<<29;
int dp[16][2048];
int N,K;
vector<int>b[16];
int price[16][2048];

int dfs(int g, int n){
  if(n==K) return 0;
  if(g==10) return -INF;
  int &res = dp[g][n];
  if(res >= 0) return res;
  res = 0;
  for(int i=0;i<=b[g].size();i++){
    if(n+i > K) continue;
    res = max(res, dfs(g+1, n+i)+price[g][i]);
  }
  return res;
}

int main(){
  scanf("%d%d",&N,&K);
  memset(dp, -1, sizeof dp);
  for(int i=0;i<N;i++){
    int c,g; scanf("%d%d", &c,&g); g--;
    b[g].push_back(c);
  }
  for(int i=0;i<16;i++){
    sort(b[i].begin(), b[i].end(), greater<int>());
    for(int j=0;j<b[i].size();j++) price[i][j+1] = price[i][j]+b[i][j];
    for(int j=1;j<2048&&price[i][j];j++){
      price[i][j] += (j-1)*j;
    } 
  }

  printf("%d\n", dfs(0,0));
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<ll> H(N+1);
  for(int i=0;i<N;++i){
    cin>>H[i];
  }
  
  H[N]=10000000000;
  
  ll ans=0;
  ll count=0;
  for(int i=0;i<N;++i){
    if(H[i]<H[i+1]){
      ans=max(ans,count);
      count=0;
      continue;
    }
    else
      ++count;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	cout << fixed << setprecision(10);
	long double a,b; cin>>a>>b;
	a/=100; b*=100;
	long double c=a*b; 
	ll ans=c;
	cout<<ans;
	return 0;
}

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

n, q = map(int, input().split())
events = []
for _ in range(n):
    s, t, x = map(int, input().split())
    events.append((s-x-0.5, 's', x)) # start construction
    events.append((t-x-0.5, 'e', x)) # end construction

for i in range(q):
    d = int(input())
    events.append((d, 'q', i)) # query
    
events = sorted(events)
is_stop = False
stops = set()
min_stop = float('inf')
ans = [-1]*q
for t, e, x in events: # time, event, distance/index
    if e == 's':
        stops.add(x)
        if x < min_stop:
            min_stop = x
            is_stop = True
    elif e == 'e':
        stops.remove(x)
        if min_stop == x:
            is_stop = False
    elif len(stops) > 0:
        if not is_stop:
             min_stop = min(stops)
             is_stop = True
        ans[x] = min_stop
         
for a in ans:
    print(a)

Measured memory_bytes: 96792
def solve():
    n = int(input())
    l = list(map(int,input().split()))
    res = 0
    for i in range(n-1):
        if l[i]==i+1:
            l[i],l[i+1]=l[i+1],l[i]
            res+=1
    if l[n-1]==n:
        res+=1
    print(res)
if __name__=='__main__':
    solve()

Measured memory_bytes: 14008
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
ret = sum([i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 == 0)])
print(ret)

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

int main() {
	long n,k,m;
	cin>>n>>k;
	if(k%2==0){
		m=k/2;
		cout<<((n+m)/(2*m))*((n+m)/(2*m))*((n+m)/(2*m))+(n/k)*(n/k)*(n/k)<<endl;
	}
	
	else {
		cout<<(n/k)*(n/k)*(n/k)<<endl;
	}
	return 0;
}

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

int main()
{
	while (true)
	{
		int num[2];

		for (int i = 0;i < 2;i++)
		{
			cin >> num[i];
		}

		if (num[0] == 0 && num[1] == 0)
		{
			break;
		}

		if (num[0] < num[1])
		{
			cout << num[0] << ' ' << num[1] << '\n';
		}
		else
		{
			cout << num[1] << ' ' << num[0] << '\n';
		}
	}

	// 「numが再定義されています。異なる添字です。」のエラー　未解決

	//while (true)
	//{
	//	int num[2];
	//	
	//	for (int i = 0;i < 2;i++)
	//	{
	//		cin >> num[i];
	//	}
	//	
	//	int x, y = num[0], num[1];

	//	if (x == 0 && y == 0)
	//	{
	//		break;
	//	}
	//	if (x < y)
	//	{
	//		cout << x << ' ' << y << '\n';
	//	}
	//	else
	//	{
	//		cout << y << ' ' << x << '\n';
	//	}
	//}

	//return 0;
}


Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main()
{
    long int X, A;
    A = 100;
    cin >> X;
    int n = 5000;
    for (int i = 0; i < n; i++){
        A *= 1.01;
        if(A >= X){
            cout << i + 1;
            break;
        } 
    }
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(void)
{
	int n,max_count = 0,k=0;
	cin >> n;
	k = 1;
	for(int i = 1;i < n + 1; i++)
	{
		int c = 0,buf = i; 
		while(buf % 2!=1)
		{
			buf /=2;
			c++;
		}
		if(max_count < c){
			max_count = c;
			k = i;
		}
	}
	cout << k <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int main() {

    int n;
    cin>>n;

    int arr[200];
    n--;

    for(int i=0;i<n;i++)cin>>arr[i];

    long ans=arr[n-1]+arr[0];
    for(int i=0;i<n-1;i++){
        //ans+=min(arr[i],arr[i-1]);
        ans+=min(arr[i],arr[i+1]);
    }
    cout<<ans;




	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/




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

int main()
{
    int n,m;
    cin>>n>>m;
    
    int a[50],b[50];
    
    for(int i=0;i<m;i++) cin>>a[i]>>b[i];
    
    int road[50];
    for(int i=0;i<n;i++) road[i]=0;
    
    for(int i=0;i<m;i++){
        road[a[i]-1]+=1;
        road[b[i]-1]+=1;
    }
    for(int i=0;i<n;i++) cout<<road[i]<<endl;
   
}

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

int main(){
  	int N;
	string a;
  	cin >> N >> a;
  	for(int i = 0 ; i < a.length() ; i ++){
    	if(a[i] + N <= 'Z') a[i] += N; else a[i] = 'A' + (a[i] + N - 'Z' - 1);
    }
  	cout << a << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int rows = 1000000000, N = 305;
int n, k, h[N];

map<int, int> dp[N][N];

void upd(int i, int j, int k, int cur) {
    if(dp[i][j].count(k)) {
        dp[i][j][k] = min(dp[i][j][k], cur);
    } else {
        dp[i][j][k] = cur;
    }
}

//[columns][used changes] -> maps[previous val] ans

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;

    for(int i = 0; i < n; ++i) cin >> h[i];

    dp[0][0][0] = 0;

    for(int i = 0; i < n; ++i) {
        int cur = h[i];
        for(int j = 0; j <= k && j <= i; ++j) {
            for(auto p : dp[i][j]) {
                int prev = p.first, cand = p.second;
                upd(i+1, j, cur, cand + max(0LL, cur-prev));
                if(j < k) {
                    upd(i+1, j+1, prev, cand);
                    upd(i+1, j+1, 0, cand);
                }
            }
        }
    }

    int ans = rows*N;
    for(int j = 0; j <= k; ++j) {
        for(auto p : dp[n][j]) {
            ans = min(ans, p.second);
        }
    }

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


Measured memory_bytes: 291456
/* Includes */
#include <stdio.h>

/* Defines */

/* Variables */
int list_dice[6];
char list_direction[100];

/* Prototypes */
int RotDice(char directon, int list_val[6]);

/* Main */
int main()
{
    for (int i = 0; i < 6; i++) {
        scanf("%d", &list_dice[i]);
    }

    scanf("%s", &list_direction);

    for (int i = 0; i < 100; i++) {
        if (list_direction == '\0') {
            break;
        }
        else {
            /* NOP */
        }
        RotDice(list_direction[i], list_dice);
    }


    printf("%d\n", list_dice[0]);
}

/* Sub */
int RotDice(char direction, int list_val[6])
{
    int output_dice[6];
    
    if (direction == 'N') {
        output_dice[0] = list_val[1];
        output_dice[1] = list_val[5];
        output_dice[2] = list_val[2];
        output_dice[3] = list_val[3];
        output_dice[4] = list_val[0];
        output_dice[5] = list_val[4];
    }
    else if (direction == 'E') {
        output_dice[0] = list_val[3];
        output_dice[1] = list_val[1];
        output_dice[2] = list_val[0];
        output_dice[3] = list_val[5];
        output_dice[4] = list_val[4];
        output_dice[5] = list_val[2];
    }
    else if (direction == 'W') {
        output_dice[0] = list_val[2];
        output_dice[1] = list_val[1];
        output_dice[2] = list_val[5];
        output_dice[3] = list_val[0];
        output_dice[4] = list_val[4];
        output_dice[5] = list_val[3];
    }
    else if (direction == 'S') {
        output_dice[0] = list_val[4];
        output_dice[1] = list_val[0];
        output_dice[2] = list_val[2];
        output_dice[3] = list_val[3];
        output_dice[4] = list_val[5];
        output_dice[5] = list_val[1];
    }
    else {
        /* NOP */
    }

    for (int i = 0; i < 6; i++) {
        list_dice[i] = output_dice[i];
    }
}


Measured memory_bytes: 2120
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Indexed<T> {
	int index;
	T obj;

	public Indexed(int index, T obj) {
		this.index = index;
		this.obj = obj;
	}
}

final class Target {
	int y, x;

	public Target(int y, int x) {
		this.y = y;
		this.x = x;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Target target = (Target) o;
		return y == target.y && x == target.x;
	}

	@Override
	public int hashCode() {
		return Objects.hash(y, x);
	}
}

final class Solver {
	void solve(Supplier<String> sc) {
		int H = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());

		var targets = new HashSet<Target>();
		for (int i = 0; i < M; i++) {
			int y = Integer.parseInt(sc.get()) - 1;
			int x = Integer.parseInt(sc.get()) - 1;
			targets.add(new Target(y, x));
		}

		var vertical = new PriorityQueue<>(Comparator.comparingInt((Indexed<HashSet<Target>> i) -> i.obj.size()).reversed());
		var horizontal = new PriorityQueue<>(Comparator.comparingInt((Indexed<HashSet<Target>> i) -> i.obj.size()).reversed());
		{
			var vlist = new ArrayList<HashSet<Target>>();
			var hlist = new ArrayList<HashSet<Target>>();
			for (int i = 0; i < H; i++) {
				vlist.add(new HashSet<>());
			}
			for (int i = 0; i < W; i++) {
				hlist.add(new HashSet<>());
			}

			for (Target target : targets) {
				vlist.get(target.y).add(target);
				hlist.get(target.x).add(target);
			}

			for (int i = 0; i < vlist.size(); i++) {
				vertical.add(new Indexed<>(i, vlist.get(i)));
			}

			for (int i = 0; i < hlist.size(); i++) {
				horizontal.add(new Indexed<>(i, hlist.get(i)));
			}
		}

		var vmax = takeMax(vertical);
		var hmax = takeMax(horizontal);
		for (Indexed<HashSet<Target>> v : vmax) {
			for (Indexed<HashSet<Target>> h : hmax) {
				if (!targets.contains(new Target(v.index, h.index))) {
					System.out.println(v.obj.size() + h.obj.size());
					return;
				}
			}
		}
		System.out.println(vmax.get(0).obj.size() + hmax.get(0).obj.size() - 1);
	}

	private ArrayList<Indexed<HashSet<Target>>> takeMax(PriorityQueue<Indexed<HashSet<Target>>> queue) {
		var vmax = new ArrayList<Indexed<HashSet<Target>>>();
		{
			var max = queue.remove();
			vmax.add(max);
			while (!queue.isEmpty()) {
				var next = queue.remove();
				if (max.obj.size() > next.obj.size()) break;
				vmax.add(next);
			}
		}
		return vmax;
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

using namespace std;
long long mod = 1000000007;
long long n, A, B; 

long long X[100005];
long long Y[100005];

struct seg{
	long long tree[200005];
	void update(int i, long long x){
		i += n;
		tree[i] = x;
		while(i > 1){
			i >>= 1;
			tree[i] = tree[i<<1] + tree[i<<1|1];
			if(tree[i] >= mod) tree[i] -= mod;
		}
	}
	
	long long query(int l, int r){
		long long res = 0;
		for(l += n, r += n;l < r;l >>= 1, r >>= 1){
			if(l&1){
				res += tree[l];
				if(res >= mod) res -= mod;
				l++;
			}
			if(r&1){
				r--;
				res += tree[r];
				if(res >= mod) res -= mod;
			}
		}
		return res % mod;
	}
} xseg, yseg;

int XL = 0, YL = 0;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> A >> B;
	
	vector<long long> arr = {-1500000000000000000LL};
	for(int i = 1;i <= n;i++){
		long long s; cin >> s;
		arr.push_back(s);
				
		if(i == 1){
			X[0] = 1; Y[0] = 1;
			xseg.update(0, 1);
			yseg.update(0, 1);
			continue;
		}
		
		///Update X[i-1], Y[i-1]
		int R = upper_bound(arr.begin(), arr.end(), s - A) - arr.begin();
		X[i-1] = yseg.query(YL, R);
		
		R = upper_bound(arr.begin(), arr.end(), s - B) - arr.begin();
		Y[i-1] = xseg.query(XL, R);
		
		xseg.update(i-1, X[i-1]);
		yseg.update(i-1, Y[i-1]);
		
		///update X[k], Y[k] for k < i - 1
		if(arr[i] - arr[i-1] < A) XL = i-1;
		if(arr[i] - arr[i-1] < B) YL = i-1;	
	}
	
	
	long long ans = xseg.query(XL, n) + yseg.query(YL, n);
	ans %= mod;
	cout << ans;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (ll)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) ll((a).size())
#define mod 1000000007
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool prime[1000001];
void sieve()
{
  memset(prime, true, sizeof(prime));
  prime[1]=false;
  for (int p=2; p*p<=1000000; p++)
  {
    if (prime[p] == true)
    {
        for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
    }
  }
}
void solve()
{

  ll n;
  cin >>n ;
  string s ;
  cin >> s;
  ll k ;
  cin >> k;
  string r="";
  for(int i=0;i<n;i++){
    if(s[i]!=s[k-1]){
        r+="*";
    }
    else{
        r+=s[k-1];
    }
  }
  cout << r << endl ;

 }
int main()
{
  fast();
  /*ll t;
  cin >> t;
  while(t--)*/
  solve();

return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>


int sum[100000],i;

int num(int r,int l)
{
    int x,y,z,w;
    x=sum[l];
    y=r-1;
    for(z=r;z<l;z++)
    {
        if(sum[z]<=x)
        {
            y++;
            w=sum[y];sum[y]=sum[z];sum[z]=w;
        }
    }
    w=sum[y+1];sum[y+1]=sum[l];sum[l]=w;
    return y+1;
}
int main()
{
    int a,b;
    scanf("%d",&i);
    for(a=0;a<i;a++)
    {
        scanf("%d",&sum[a]);
        
    }
    b=num(0,i-1);
    for(a=0;a<i;a++)
    {
        if(a)printf(" ");
        if(a==b)printf("[");
        printf("%d",sum[a]);
        if(a==b)printf("]");
    
    }
    printf("\n");
    return 0;
    
}




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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0 << endl;
	}
	else if (a >= 6 && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int x, y;
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  std::cin >> x >> y;
  std::cout << (a[x] == a[y] ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,valid=0;
int main () {
	cin >> N;
	for(int i=1;i<=9;i++) {
		if((N%i==0) && (N/i<=9))
		valid=1;
	}
	if (valid==1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 256
n, m, x = map(int,input().split())
lst = [[0 for i in range(m + 1)]]
for i in range(n):
    tmp = list(map(int,input().split()))
    for j in range(len(lst)):
        tmp2 = []
        for k in range(len(tmp)):
            y = lst[j][k] + tmp[k]
            tmp2.append(y)
        lst.append(tmp2)
ans = -1
for i in range(len(lst)):
    c = 0
    for j in range(len(lst[i])):
        if (j == 0):
            pass
        else:
            if (lst[i][j] < x):
                c = 1
    if (c == 0):
        if (ans == -1):
            ans = lst[i][0]
        else:
            ans = min(ans, lst[i][0])

print(ans)


Measured memory_bytes: 68404
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		for (int i = 0; i < Math.min(s.length, t.length); i++) {
			if (s[i] == t[t.length-i-1]) {
				continue;
			} else if (s[i] < t[t.length-i-1]) {
				System.out.println("Yes");
				return;
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println(s.length < t.length ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
import Control.Monad
import Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Set as S
main=print.solve.B.lines=<<B.getContents
solve[s,t]=maybe(-1)(uncurry(+)).foldM g(0,0).map f.B.unpack$t where
  n=B.length s
  as=V.accum(flip S.insert)(V.replicate 26 S.empty).(`zip`[1..]).map f.B.unpack$s
  g(k,i)c=case S.lookupGT i$as V.! c of
    Just(j) -> Just(k,j)
    Nothing -> case S.lookupGT 0$as V.! c of
      Just(j) -> Just(k+n,j)
      Nothing -> Nothing
f c=ord c-ord 'a'

Measured memory_bytes: 27568
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


n,k = inpl()
a = inpl()
now = sum(a[:k])
max = now
ans = 0
for i in range(n-k):
    now = now + a[k+i] - a[i]
    if now > max: 
        ans = i+1
        max = now
res = 0
for i in range(ans,ans+k):
    res += (a[i]+1)/2
print(res)

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

using namespace std;

using ll = long long;
const ll M = 998244353LL;
const ll INV2 = 499122177LL;
const int N = 3e3+5;

ll f[N], dp[N][N];

int main() {
    f[0] = 0;
    f[1] = 1;
    for (int i = 2; i < N; i++) {
        f[i] = (f[i-1] * i) % M;
    }
    ll a, b, c, d; cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for (int i = a+1; i <= c; i++) {
        dp[i][b] = dp[i-1][b] * b;
        dp[i][b] %= M;
    }
    for (int i = b+1; i <= d; i++) {
        dp[a][i] = dp[a][i-1] * a;
        dp[a][i] %= M;
    }
    for (int y = a+1; y <= c; y++) {
        for (int x = b+1; x <= d; x++) {
            dp[y][x] = dp[y-1][x] * x + dp[y][x-1] * y;
            dp[y][x] -= (x-1) * (y-1) * dp[y-1][x-1];
            dp[y][x] %= M;
            dp[y][x] += M;
            dp[y][x] %= M;
            // printf("%d %d %lld\n", y, x, dp[y][x]);
        }
    }
    cout << dp[c][d] << endl;
    return 0;
}

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

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

  int l[N];
  for (int i = 0; i < N; i++) cin >> l[i];

  sort(l, l + N, greater<int>());

  int max_length = 0;
  for (int i = 0; i < K; i++) max_length += l[i];

  cout << max_length << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    vector<string> c(2);
    for (int i = 0; i < 2; ++i) {
        cin >> c[i];
    }
    if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
        cout << "YES" << "\n";
    else
        cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Nlist = list(map(int, input().split()))
Nmax = max(Nlist)
Nmin = min(Nlist)
ans = 100**3
for i in range(Nmin, Nmax+1):
    total = 0
    for j in Nlist:
        total += (j-i)**2
    if ans > total:
        ans = total
print(ans)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

struct UnionFind {
    vector<ll> par;
    
    //要素nで初期化
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    //xが属する集合の根を返す
    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    //xとyが同じ集合に属しているかを判定
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    //xが属する集合とyが属する集合をマージ
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // 計算量が減るよ
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    //xが属する集合のサイズ
    ll size(ll x) {
        return -par[root(x)];
    }
};

struct edge { ll u, v, cost; };
bool comp(const edge& e1, const edge& e2) { return e1.cost < e2.cost;}
edge es[500000];
ll E = 0; // 辺数
ll kruskal(ll V) {
	sort(es, es + E, comp); // edge.costが小さい順にソートする 
	UnionFind uf(V); // Union-Findの初期化
	ll res = 0;
	for (ll i = 0; i < E; i++) {
		edge e = es[i];
		if (!uf.issame(e.u, e.v)) {
			uf.merge(e.u, e.v);
			res += e.cost; 
		}
	}
	return res; 
}




int main(){
	ll n;cin>>n;
	vector<P> a(n);
	vector<P> b(n);
	for(ll i = 0; i < n; i++) {
		ll x,y;cin>>x>>y;
		a[i] = mp(x,i);
		b[i] = mp(y,i);
	}
	sort(ALL(a));
	sort(ALL(b));
	for(ll i = 0; i < n - 1; i++) {
		es[E] = {a[i].sc,a[i + 1].sc,abs(a[i].fs - a[i + 1].fs)};
		E++;
		es[E] = {a[i + 1].sc,a[i].sc,abs(a[i].fs - a[i + 1].fs)};
		E++;
		// cost[a[i].sc][a[i + 1].sc] = abs(a[i].fs - a[i + 1].fs);
		// cost[a[i + 1].sc][a[i].sc] = abs(a[i].fs - a[i + 1].fs);
	}
	for(ll i = 0; i < n - 1; i++) {
		es[E] = {b[i].sc,b[i + 1].sc,abs(b[i].fs - b[i + 1].fs)};
		E++;
		es[E] = {b[i + 1].sc,b[i].sc,abs(b[i].fs - b[i + 1].fs)};
		E++;
		// cost[b[i].sc][b[i + 1].sc] = min(cost[b[i].sc][b[i + 1].sc],abs(b[i].fs - b[i + 1].fs));
		// cost[b[i + 1].sc][b[i].sc] = min(cost[b[i + 1].sc][b[i].sc],abs(b[i].fs - b[i + 1].fs));
	}

	cout << kruskal(n) << endl; 

	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int n, k;
long long a[200005], ans;
int main() {
	cin>>n>>k;
	for(int i = 1; i <= n; i++)
	   cin>>a[i];
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n - k; i++)
	   ans += a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
//constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

const int MAX = 4000003;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll cme;

ll modpow(ll b, ll e, ll m){  // bのe乗のmod m を返す
  if (e == 0) return 1;
  cme = modpow(b, e / 2, m);
  cme = (cme * cme) % m;
  if (e % 2 == 1) cme = (cme * b) % m;
  return cme;
}

ll N,M,K;

int main(){
  ll ANS=0;
  COMinit();
  cin >> N >> M >>  K;
  Rep(i,0,K+1){
    ll Z=(M*modpow(M-1,N-i-1,MOD))%MOD;
    Z*=COM(N-1,i);
    Z%=MOD;
    ANS=(ANS+Z)%MOD;
  }
  cout << ANS << endl;
}

Measured memory_bytes: 97388
n = int(input())

a = list(map(int, input().split()))

for i in range(n):
    node = i + 1
    key = a[i]
    out = "node {}: key = {}, ".format(node, key)
    out += "parent key = {}, ".format(a[(i - 1) // 2]) if (i-1)//2 >=0 else ""
    out += "left key = {}, ".format(a[i * 2 + 1]) if i*2 + 1 < n else ""
    out += "right key = {}, ".format(a[i * 2 + 2]) if i*2 + 2 < n else ""
    print(out)


Measured memory_bytes: 5612
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

class D {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        final Segment[] segs = new Segment[M];
        for (int i = 0; i < M; i++)
            segs[i] = new Segment(i, sc.nextInt(), sc.nextInt(), sc.nextInt());
        final TreeSet<Segment> que = new TreeSet<>((Segment o1, Segment o2) -> o1.L == o2.L ? o1.idx - o2.idx : o1.L - o2.L);
        que.addAll(Arrays.asList(segs));
        final long[] dist = new long[N + 1];
        Arrays.fill(dist, Long.MAX_VALUE / 2);
        dist[1] = 0;
        final TreeSet<Segment> set = new TreeSet<>((Segment o1, Segment o2) ->
                o1.dist(dist) == o2.dist(dist) ? o1.idx - o2.idx : Long.compare(o1.dist(dist), o2.dist(dist)));
        for (int i = 1; i <= N; i++) {
            while (!set.isEmpty() && set.first().R < i)
                set.pollFirst();
            if (!set.isEmpty())
                dist[i] = set.first().dist(dist);
            while (!que.isEmpty() && que.first().L == i) {
                set.add(que.pollFirst());
            }
        }
        System.out.println(dist[N] < Long.MAX_VALUE / 2 ? dist[N] : -1);
    }

    static class Segment {
        final int idx, L, R, C;

        public Segment(int i, int l, int r, int c) {
            idx = i;
            L = l;
            R = r;
            C = c;
        }

        public long dist(final long[] dist) {
            return dist[L] + C;
        }
    }
}
public class Main {
    public static void main(String...args) {
        D.main();
    }
}


Measured memory_bytes: 100484
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	min := 1000.0
	total1 := 0
	total2 := 0
	aji := 0
	for i := 1; i <= n; i++ {
		total1 += l + i - 1
	}
	for i := 1; i <= n; i++ {
		total2 = total1 - (l + i - 1)
		if math.Abs(float64(total1-total2)) < min {
			min = math.Abs(float64(total1 - total2))
			aji = total2
		}
	}
	fmt.Println(aji)

}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <strings.h>
#include <cstring>

using namespace std;
 
int main(){
    int nya;
    cin >> nya;
    string po,mi;
    int pos = 0;
    int mis = 0;
    for(int i = 0; i < nya; i++){
        cin >> po >> mi;
        if(po < mi){
            mis += 3;
        }else if(po > mi){
            pos += 3;
        }else if(po == mi){
            pos++;
            mis++;
        }
    }
    cout << pos << " " << mis << endl;
    return 0;
}


Measured memory_bytes: 3196
use std::io;

fn main() {
  let stdin = io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();
  let mut v = buf.trim()
    .split_whitespace()
    .map(|x| x.parse::<i32>().unwrap())
    .collect::<Vec<_>>();
  v.sort();

  println!("{} {} {}", v[0], v[1], v[2]);
}


Measured memory_bytes: 5040
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int K;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> K;
    int a = K / 2;
    int b = K - a;
    cout << a * b << endl;
}

Measured memory_bytes: 256
n = int(input())
pl = list()
for i in range(n):
    pl.append(list(map(int, input().split())))

import math
lsum = 0
for i in range(n):
    for j in range(n):
        if i != j:
            a, b = pl[i]
            c, d = pl[j]
            lsum += math.sqrt((a-c) ** 2 + (b-d) ** 2)
print(lsum /(n))

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> nums = new ArrayList<>();

		for (int i=0; i<3; i++){
			nums.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(nums, Collections.reverseOrder());

		int diff1 = nums.get(0) - nums.get(1);
		int diff2 = nums.get(0) - nums.get(2);

		int ans = 0;
		ans += diff1;

		if ((diff2 - diff1)%2==0){
			ans += (diff2 - diff1)/2;
		}else {
			ans += (diff2 - diff1)/2 + 2;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
N = int(input())
a_list = list(map(int,input().split()))
b = 0
for ai in a_list:
        b += ai
average = int(b/N)

sigma = 0
sigma2 = 0
sigma3 = 0
for ai in a_list:
        sigma += (ai - average) ** 2
        sigma2 += (ai - (average-1)) ** 2
        sigma3 += (ai - (average+1)) ** 2
print(min(sigma,sigma2,sigma3))

Measured memory_bytes: 3064
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

def main():

    for i in range(n-m+1):
        for j in range(n-m+1):
            if match(i, j):
                print("Yes")
                exit()
    
    print("No")

def match(x, y):
    for i in range(m):
        for j in range(m):
            if (a[x+i][y+j] != b[i][j]):
                return False

    return True

if __name__ == "__main__":
    main()

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;


//template< typename T1, typename T2 > struct pair {
  //T1 first;
  //T2 second;
//};
               
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int n; cin >> n;
  vector<int> p(n);
  forn(i , 0 , n) cin >> p[i];
  int maxn = *max_element(all(p));
  sort_all(p);
  int x = maxn / 2;
  forn(i , 0 , n - 1) x += p[i];
  cout << x << endl;

 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

using namespace std;

int main() {

//	string s;
//	cin >> s;

	vector<vector<long>> a(4,vector<long> (4));
	for (int i = 1; i <= 3; i++) {
		cin >> a[i][1] >> a[i][2] >> a[i][3];
	}

	long n;
	cin >> n;

	long b;
	for (int i = 1; i <= n; i++) {
		cin >> b;
		for (int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 3; k++) {
				if (a[j][k] == b) {
					a[j][k] = 0;
					if (a[1][1] + a[1][2] + a[1][3] == 0
						|| a[2][1] + a[2][2] + a[2][3] == 0
						|| a[3][1] + a[3][2] + a[3][3] == 0
						|| a[1][1] + a[2][1] + a[3][1] == 0
						|| a[1][2] + a[2][2] + a[3][2] == 0
						|| a[1][3] + a[2][3] + a[3][3] == 0
						|| a[1][1] + a[2][2] + a[3][3] == 0
						|| a[3][1] + a[2][2] + a[1][3] == 0
						) {
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

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

	return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){

int n, k;
cin >> n >> k;

char s[n];

REP(i, n) cin >> s[i];

k--;
if(s[k] == 'A') s[k] = 'a';
else if(s[k] == 'B') s[k] = 'b';
else s[k] = 'c';

REP(i, n) cout << s[i];
cout << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		String []arr_input = input.split(" ");
		int aux_5 = 0;
		int aux_7 = 0;
		for(int i=0; i<arr_input.length; i++) {
			int value = Integer.parseInt(arr_input[i]);
			if(value==5)aux_5++;
			if(value==7)aux_7++;
		}
		String r = (aux_5==2 && aux_7==1)?"YES":"NO";
		System.out.println(r);
	}
}

Measured memory_bytes: 35604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n ;
	vector<int> d(n);
	rep(i,n) cin >> d[i];
	int ans = 0;
	rep(i,n)rep(j,n){
		if(i<=j) continue;
		ans += d[i]*d[j];
	}
	out(ans);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;
int64_t dp[1000005][2][2];
int main() {
  int N;
  cin>>N;
  dp[0][0][0]=8,dp[0][1][0]=1,dp[0][0][1]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=1;j++){
      for(int k=0;k<=1;k++){
        if(dp[i][j][k]==0){continue;}
        for(int next=0;next<=9;next++){
          if(next==0){
            (dp[i+1][1][k]+=dp[i][j][k])%=mod;
          }
          else if(next==9){
            (dp[i+1][j][1]+=dp[i][j][k])%=mod;
          }
          else{
            (dp[i+1][j][k]+=dp[i][j][k])%=mod;
          }
        }
      }
    }
  }
  //cout<<dp[1][0][1]<<endl;
  cout<<dp[N-1][1][1]<<endl;
  return 0;
}

Measured memory_bytes: 34828
main = do
    c <-  map (map read . words) <$> (sequence $ take 3 $ repeat getLine)
    let test = [c!!0!!0+c!!i!!j == c!!i!!0+c!!0!!j | i<-[1,2],j<-[1,2]]
    putStrLn $ if all id test then "Yes" else "No"


Measured memory_bytes: 508
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    for i in range(K):
        if A < B < C:
            print("Yes")
            exit()

        if A >= B:
            B *= 2
        elif B >= C:
            C *= 2

    if A < B < C:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <stdio.h>
#include <math.h>

int main(void)
{
    int a,b,c,k,s;
    if(!scanf("%d %d %d", &a, &b, &c)){return 0;}
    if(!scanf("%d", &k)){return 0;}
    for(int l=0;l<=k;l++)
    {
        for(int m=0;m<=k;m++){
            for(int n=0;n<=k;n++)
            {
                if(l+m+n!=k) continue;
                s=b*(int)pow(2, (double)m);
                if(a*(int)pow(2, (double)l) < s && s < c*(int)pow(2, (double)n)){
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 2592
#include <iostream>
#include <string>
#include <vector>
#include <map>

#include <algorithm>
#include <queue>
#include <cctype>

using namespace std;

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

int N;
long long a[100003],b[100003],c[100003];
long long dp[100003][6];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i, N - 1) {
                dp[i + 1][1] = max(dp[i + 1][1],dp[i][0] + b[i + 1]);
                dp[i + 1][2] = max(dp[i + 1][2],dp[i][0] + c[i + 1]);

                dp[i + 1][0] = max(dp[i + 1][0],dp[i][1] + a[i + 1]);
                dp[i + 1][2] = max(dp[i + 1][2],dp[i][1] + c[i + 1]);

                dp[i + 1][1] = max(dp[i + 1][1],dp[i][2] + b[i + 1]);
                dp[i + 1][0] = max(dp[i + 1][0],dp[i][2] + a[i + 1]);
    }
    cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << '\n';
}

Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int main() {

  int a,b,c,d=0;
  cin>>a>>b>>c;

  for (int i=1; i<=c; i++) {
    if ((a<=i && i<=b) && (c%i==0)) {
      d++;
    }
  }
    cout<<d<<"\n";

  return 0;
}

Measured memory_bytes: 1168
function main()
  
  (N,T) = map(x -> parse(Int,x), split(readline()))
  
  t = map(x -> parse(Int,x), split(readline()))
  
  ans = T
  
  for i in 2:N
    if t[i] - t[i-1] < T
      ans += t[i] - t[i-1]
    else
      ans += T
    end
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 152176
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long members[]= new long[N];
        long foods[] = new long[N];
        for (int i = 0; i <N ; i++) {
            long n = sc.nextLong();
            members[i] = n;
        }
        for (int i = 0; i < N; i++) {
            long n = sc.nextLong();
            foods[i]= n;
        }
        Arrays.sort(members);
        Arrays.sort(foods);
        long left = 0;
        long right = (long)Math.pow(10, 12);
        while(left < right){
            long mid = (left + right) / 2;
            long shouldTrainingCount = 0;
            for (int i = 0; i < N ; i++) {
                shouldTrainingCount += Math.max(0, members[i] - (mid / foods[N - i -1]));
            }
            if(shouldTrainingCount <= K){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        System.out.println(right);
    }
}


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

BA = []

for i in range(N):

    A,B = map(int,input().split())

    BA.append ([B,A])


BA.sort()


time = 0
flag = True
for i in BA:

    time += i[1]

    if time > i[0]:
        flag = False

if flag:
    print("Yes")

else:
    print ("No")


Measured memory_bytes: 35620
def main():
    input()
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    while len(t) > 1:
        tmp = t.pop(-1)
        tmp2 = t.pop(-1)
        t.append((tmp+tmp2)/2)
    print(t[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060