akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
struct P {
	long long cost, pos;
};
bool operator<(P a, P b) {
	return a.cost < b.cost;
}
bool operator>(P a, P b) {
	return a.cost > b.cost;
}
struct B {
	int cost, till;
};
long long a[5001];//?????????????????????????????????
long long g[5001];//?????????????????????????????????????????????
B b[5001];//?????????????????????????????????
vector<long long>e[5001];//???
const long long inf = 8000000000;
int main() {
	int n, k, c, d;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) 
		cin >> b[i].cost >> b[i].till;
	for (int i = 0; i < k; i++) {
		cin >> c >> d;
		e[c].push_back(d);
		e[d].push_back(c);
	}
	fill(a, a + n + 1, inf);
	a[1] = 0;
	priority_queue<P, vector<P>, greater<P>>p;
	p.push(P{ 0,1 });
	while (!p.empty()) {
		P t = p.top(); p.pop();
		priority_queue<P, vector<P>, greater<P>>r;
		fill(g, g + n + 1, inf);
		g[t.pos] = 0;
		r.push(P{ 0,t.pos });
		while (!r.empty()) {
			P y = r.top(); r.pop();
			for (int i = 0; i < (int)e[y.pos].size(); i++) {
				if (g[e[y.pos][i]] > g[y.pos] + 1&&g[y.pos]+1<=b[t.pos].till) {
					g[e[y.pos][i]] = g[y.pos] + 1;
					r.push(P{ g[y.pos] + 1,e[y.pos][i] });
					if (a[e[y.pos][i]] > a[t.pos] + b[t.pos].cost) {
						a[e[y.pos][i]] = a[t.pos] + b[t.pos].cost;
						p.push(P{ a[e[y.pos][i]],e[y.pos][i] });
					}
				}
				else if (g[y.pos] + 1 > b[t.pos].till) break;
			}
		}
	}
	cout << a[n] << endl;
}

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main{
	public static int n;
	public static int []A = new int[50];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		for(int i = 0; i < q; i++) {
			int m = scan.nextInt();
			if(isSolve(0, m)) {
				System.out.println("yes");
			}else {
				System.out.println("no");
			}
		}
		scan.close();
	}
	public static boolean isSolve(int i, int m) {
		if(m == 0) return true;
		if(i >= n) return false;
		boolean res = isSolve(i + 1, m) || isSolve(i + 1, m - A[i]);
		return res;
	}
}


Measured memory_bytes: 26640
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string a,b;
cin>>a>>b;
if(a<=b)
{
for(int i=0;i<stoi(b);i++)
{
cout<<a;
}
}
else
{
for(int i=0;i<stoi(a);i++)
{
cout<<b;
}
}
}

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

bool irekae(string s){
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main(){
  string s;
  std::cin >> s;
  bool ans = true;
  if(!irekae(s)) ans = false;
  if(!irekae(s.substr(0, s.size()/2))) ans = false;
  if (ans) {
    std::cout << "Yes" << '\n';
  }
  else{
    std::cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=2001;
int p=1e9+7;
int main()
{
  int n,m,i,j;
  int s[N_MAX],t[N_MAX],u[N_MAX][N_MAX];
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> s[i];
    u[i+1][0]=1;
  }
  fill(u[0],u[0]+m+1,1);
  for(j=0;j<m;j++)
    cin >> t[j];
  for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
      if(s[i-1]==t[j-1]){
        u[i][j]=(u[i-1][j]+u[i][j-1])%p;
      }else{
        u[i][j]=(u[i-1][j]+u[i][j-1]-u[i-1][j-1])%p;
        if(u[i][j]<0)
          u[i][j]+=p;
      }
  cout << u[n][m] << endl;
  return 0;
}


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

int main(void)
{
  int n;
  cin >> n;
  char c[8];
  int i = 0;
  int out = 0;
  int array[3] = {};
  int score = 0;

  while(i != n){
    cin >> c;
    if(c[0] == 'H' && c[1] == 'I' && c[2] == 'T'){
      if(array[2] == 1){
	score++;
      }
      array[2] = array[1];
      array[1] = array[0];
      array[0] = 1;
    }
    if(c[0] == 'H' && c[1] == 'O' && c[2] == 'M' && c[3] == 'E' && c[4] == 'R' && c[5] == 'U' && c[6] == 'N'){
      score = score + array[0] + array[1] + array[2] + 1;
      array[0] = 0;
      array[1] = 0;
      array[2] = 0;
    }
    
    if(c[0] == 'O' && c[1] == 'U' && c[2] == 'T'){
      out++;
    }
    if(out == 3){
      cout << score << endl;
      array[0] = 0;
      array[1] = 0;
      array[2] = 0;
      score = 0;
      out = 0;
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 3016
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int a, b;
  cin>>a>>b;
  
  cout<<a*b<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}

Measured memory_bytes: 3652
#include <cstdio>

using namespace std;

int main() {
    double a, b, c, d, e, f;
    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != -1) {
        double x = (c*e - b*f) / (a*e - b*d);
        double y = (c*d - a*f) / (b*d - a*e);
        if (x == -0) x = 0;
        if (y == -0) y = 0;
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b-1; i >= a; i--)
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

signed main(){
    ll N; cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    ll cnt = 0, t = 1;
    rep(i, 0, N){
        if(a[i] == t){
            t++;
        }else{
            cnt++;
        }
    }
    if(cnt == N) cout << -1 << endl;
    else cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int main() {
  vector<string> s(3);
  vector<int> s_pos(3, 0);
  for (int i = 0; i < 3; ++i) cin >> s[i];
  int turn = 0;  // a
  while (s_pos[turn] != s[turn].size()) {
    turn = s[turn][s_pos[turn]++] - 'a';
  }
  cout << (char)(turn + 'A') << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		while (true) {
			int r = sc.nextInt(), c = sc.nextInt();
			if (r == 0) break;
			int[][] senb = new int[r][c];
			for (int i = 0; i < r; i++) {
				for (int j = 0; j < c; j++) {
					senb[i][j] = sc.nextInt();
				}
			}
			
			int ans = 0;
			int count;
			for (int i = 0; i < 1<<r; i++) {
				count = 0;
				for (int j = 0; j < c; j++) {
					int m = 0;
					for (int k = 0; k < r; k++) {
						if ((i>>k & 1) == 1) {
							m += (1-senb[k][j]);
						} else {
							m += senb[k][j];
						}
					}
					count += Math.max(m, r-m);
				}
				ans = Math.max(ans, count);
			}
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int m, a[30];
int max(int i, int n){
	if(n == 0) return 1;
	if(i >= m) return 0;
	int res = max(i+1, n) || max(i+1, n-a[i]);
	return res;
}

int main(void){
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}
	int q, b;
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> b;
		if(max(0, b)){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main(){
  long long int x;
  cin >> x;
  int y;
  if(x % 11 == 0){
    cout << (x / 11) * 2 << endl;
  }else if(x % 11 <= 6){
    cout << (x / 11) * 2 + 1 << endl;
  }else{
    cout << (x / 11) * 2 + 2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string.h>
#include<stdlib.h>
using namespace std;

struct Node{
  int num;

  vector<int> edge_to;
  vector<int> edge_cost;

  bool done;
  int cost;
};

vector<string> splitAll(string s, string t) {
  vector<string> v;
  for (int p = 0; (p = s.find(t)) != s.npos; ) {
    v.push_back(s.substr(0, p));
    s = s.substr(p + t.size());
  }
  v.push_back(s);
  return v;
}


int main(){
  int n,m;
  cin>>n;

  vector<Node> graph;
  graph.reserve(n+1);
  graph.resize(n+1);

  for(int i=1; i<=n; i++){
    graph[i].num=(i+1);
    graph[i].cost=-1;
    graph[i].done=false;
  }

  string s;

  cin>>m;
  getline(cin,s);

  int a,b,c,d;
  vector<string> vv;
  vv.reserve(4);
  vv.resize(4);

  while(m--){
    getline(cin,s);
    vv = splitAll(s,",");

    a = atoi( vv[0].c_str() );
    b = atoi( vv[1].c_str() );
    c = atoi( vv[2].c_str() );
    d = atoi( vv[3].c_str() );

    //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

    graph[a].edge_to.push_back(b);
    graph[a].edge_cost.push_back(c);
    graph[b].edge_to.push_back(a);
    graph[b].edge_cost.push_back(d);

  }

  int x1,x2,y1,y2;
  getline(cin,s);
  vv = splitAll(s,",");

  x1 = atoi( vv[0].c_str() );
  x2 = atoi( vv[1].c_str() );
  y1 = atoi( vv[2].c_str() );
  y2 = atoi( vv[3].c_str() );

  d=-1;

  vector<Node> n1;
  n1.reserve(n+1);
  n1.assign(graph.begin(),graph.end());

  n1[x1].cost=0;

  while(1){
    d=-1;

    for(int i=1;i<=n;i++){
      if( n1[i].done || n1[i].cost < 0 ) continue;
      if( d==-1 || n1[i].cost < n1[d].cost ) d=i;
    }

    if(d==-1) break;
    n1[d].done=true;

    for(int i=0; i< n1[d].edge_to.size(); i++){
      int to = n1[d].edge_to[i];
      int cost = n1[d].cost + n1[d].edge_cost[i];
      if(n1[to].cost < 0 || cost < n1[to].cost)
	n1[to].cost = cost;
    }
  }

  graph[x2].cost=0;

  while(1){
    d=-1;

    for(int i=1;i<=n;i++){
      if( graph[i].done || graph[i].cost < 0 ) continue;
      if( d==-1 || graph[i].cost < graph[d].cost ) d=i;
    }

    if(d==-1) break;
    graph[d].done=true;

    for(int i=0; i< graph[d].edge_to.size(); i++){
      int to = graph[d].edge_to[i];
      int cost = graph[d].cost + graph[d].edge_cost[i];
      if(graph[to].cost < 0 || cost < graph[to].cost)
	graph[to].cost = cost;
    }
  }

  cout<<y1-y2-graph[x1].cost-n1[x2].cost<<endl;

}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

class UFT {
private:
  vi data, rnk;

public:
  UFT(const int &size)
    : data(size), rnk(size) {
    iota(all(data), 0);
  }

  int root(const int &x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  bool same(const int &a, const int &b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rnk[a] < rnk[b]) swap(a, b);
    data[b] = a;
    if (rnk[a] == rnk[b]) rnk[a]++;
  }
};

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<tuple<int, int, int>> v;
    while (m--) {
      int t, s, d;
      cin >> t >> s >> d;
      v.emplace_back(t, --s, --d);
    }
    sort(all(v));
    UFT uf(n);
    rep(i, v.size()) {
      int s, d;
      tie(ignore, s, d) = v[i];
      if (uf.same(0, s)) uf.unite(0, d);
    }
    int c = 0;
    rep(i, n) c += uf.same(0, i);
    cout << c << endl;
  }
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;


int main() {
    ll x; cin >> x;
    ll a = 100;
    ll ans = 0;
    while(a < x){
        ans++;
        a = a*1.01;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
S = input()
if len(S)%2 == 0:
  c = 2
else:
  c = 1
flag = False
T = S[0:(len(S)-c)//2]
U = S[(len(S)-c)//2:(len(S)-c)]
while flag == False:
  if T == U:
    flag = True
    break
  else:
    c += 2
    T = S[0:(len(S)-c)//2]
    U = S[(len(S)-c)//2:(len(S)-c)]
print(len(S)-c)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.EducationalDP
{
    class L
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            long[,] dp = new long[n, n];
            for (int i = n - 1; i >= 0; i--)
            {
                for (int j = i; j < n; j++)
                {
                    bool first = (n - (i - j)) % 2 == 1;
                    long right = i == n - 1 ? 0 : dp[i + 1, j];
                    long left = j == 0 ? 0 : dp[i, j - 1];
                    if (first)
                    {
                        dp[i, j] = Math.Max(right + array[i],
                            left + array[j]);
                    }
                    else
                    {
                        dp[i, j] = Math.Min(right - array[i],
                            left - array[j]);
                    }
                }
            }
            Console.WriteLine(dp[0, n - 1]);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 81504
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
	ll N, M; cin >> N >> M;
	vector<ll> A(N), D;
	vector<pair<ll, ll> > CB(M);

	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < M; ++i){
		cin >> CB[i].second >> CB[i].first;
	}
	sort(CB.begin(), CB.end(), greater<pair<ll, ll> >());

	for(int i = 0; i < M; ++i){
		for(ll j = 0; j < CB[i].second; ++j){
			D.push_back(CB[i].first);
			if(D.size() > N) break;
		}
		if(D.size() > N) break;
	}

	sort(A.begin(), A.end());

	for(int i = 0; i < D.size() && i < A.size(); ++i){
		if(A[i] < D[i]) A[i] = D[i];
		else break;
	}

	ll cnt = 0;
	for(int i = 0; i < N; ++i){
		cnt += A[i];
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3704
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 998244353;

        public static void Main()
        {

            Console.WriteLine(Console.Read() < 94 ? "A" : "a");

        }

    }

}

Measured memory_bytes: 25872
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Integer[] l = new Integer[n];
		for ( int i = 0; i < n; i++ ) {
			l[i] = in.nextInt();
		}
		Arrays.sort(l, Comparator.reverseOrder());

		int cnt = 0;
		for ( int p = 0; p < n; p++ ) {
			for ( int c = p + 1; c < n; c++ ) {
				int d = l[p] - l[c];
				for ( int i = c + 1; i < n; i++ ) {
					if ( l[i] > d ) cnt++;
					else break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 26164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 1000

int n, ans;

int main()
{
    cin >> n;
    int a = n;
    while(n){
        ans += n % 10;
        n /= 10;
    }
    if(a % ans == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int man = max(a,b);
  int count=0;
  int ans=0;
  for(int i=man;i>0;i--){
    if(a%i==0 && b%i==0){
        count++;
    }
    if(count==k){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import random
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
i = 0
for y in range(h):
    row = []
    for _ in range(w):
        row += [ i + 1 ]
        a[i] -= 1
        if a[i] == 0:
            i += 1
    if y % 2 == 1:
        row = reversed(row)
    print(*row)


Measured memory_bytes: 4084
x = list(map(int, input().split()))

if (x[0]==1 and x[1]==1):
    print(1)    
    quit()
elif(x[0]==1):
    print(x[1]-2)    
    quit()
elif(x[1]==1):
    print(x[0]-2)    
    quit()

print((x[0]-2)*(x[1]-2)) 

quit()

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if(a == b){
        ans = c;
    }else if(b == c){
        ans = a;
    }else{
        ans = b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

#define RATE 380000.0

int main()
{
  int n;
  cin >> n;
  ld x;
  string u;
  ld ans = 0.0;
  REP(i,n){
    cin >> x >> u;
    if(u=="JPY") ans += x;
    else ans += x*RATE;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string s,S,P;cin>>s;
    S=s;
    vl count(26);
    rep(i,S.size())count[S[i]-'a']++;
    ll ans=inf;
    rep(i,26){
        S=s;
        char c='a'+i;
        if(count[i]==0)continue;
        ll now=0;
        while(true){
            string T;
            rep(j,S.size())T+=c;
            if(T==S)break;
            string nS;
            rep(i,S.size()-1){
                if(S[i]==c or S[i+1]==c){
                    nS+=c;
                }
                else nS+=S[i];
            }
            S=nS;
            now++;
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
    int n;
    scanf("%d", &n);

    int length = n + 2;

    int *points;
    points = malloc(sizeof(int) * length + 1);
    points[0] = 0;
    points[length -1] = 0;
    for (int i = 1; i < length - 1; i++) scanf("%d", &points[i]);

    int allCost = 0, c = 0;
    int *costs;
    costs = malloc(sizeof(int) * length + 1);
    costs[0] = 0;
    for (int i = 0; i < length; i++) {
        if (!i) {
            c = points[i];
            costs[i] = c;
            allCost += c;
        } else {
            c = abs(points[i] - points[i - 1]);
            costs[i] = c;
            allCost += c;
        }
    }

    for (int i = 1; i < length - 1; i++) {
        c = abs(points[i + 1] - points[i - 1]);
        printf("%d\n", allCost - costs[i] - costs[i + 1] + c);
    }

    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int x;
    int next_idx;
} E;

int main(void)
{
    char line[19];
    fgets(line, 19, stdin);
    int n = atoi(line);

    E table[500000];
    int start[1000]; /* start index */
    int end[1000]; /* end index */
    int is_empty[1000];
    int i;
    for (i = 0; i < n; i++) is_empty[i] = 1;

    char *a;
    a = line;
    while (*a >= '0') a++;
    int q;
    q = atoi(a + 1);

    int op, s, t, x, j;
    i = 0;
    while (q--) {
        fgets(line, 19, stdin);
        op = atoi(line);
        a = line + 2;
        if (op == 2) {
            s = atoi(a);
            while (*a >= '0') a++;
            t = atoi(a + 1);
            if (is_empty[t]) {
                start[t] = start[s];
                is_empty[t] = 0;
            }
            else table[end[t]].next_idx = start[s];
            end[t] = end[s];
            is_empty[s] = 1;

        }
        else {
            t = atoi(a);
            if (op == 0) {
                while (*a >= '0') a++;
                x = atoi(a + 1);
                table[i].x = x;
                if (is_empty[t]) {
                    start[t] = i;
                    end[t] = i;
                    is_empty[t] = 0;
                }
                table[end[t]].next_idx = i;
                end[t] = i++;
            }
            else {
                if (is_empty[t]) printf("\n");
                else {
                    j = start[t];
                    while (j != end[t]) {
                        printf("%d ", table[j].x);
                        j = table[j].next_idx;
                    }
                    printf("%d\n", table[j].x);
                }
            }
        }
    }

    return 0;
}


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

int main(){
  int k, s; cin >> k >> s;
  int ans = 0;
  
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if (z >= 0 && z <= k) ans++;
    }
  }
  
  cout << ans << endl;
  
}

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

ll calc(string s){
  int N = s.size();
  ll ret = stoll(s);
  
  //recursive step
  for(int i=1;i<N;i++){
    string sl = s.substr(0,i);
    string sr = s.substr(i,N-i);
    ret += stoll(sl)*pow(2,sr.size()-1);
    ret += calc(sr);
  }
  
  return ret;
}

int main(){
  string s;
  cin >> s;
  cout << calc(s) << endl;
  
}

Measured memory_bytes: 3968
def do_transform(txt, *args):
    op = args[0]
    a = int(args[1])
    b = int(args[2])
    if op == 'print':
        print(txt[a:b+1])
        return txt
    elif op == 'reverse':
        first_part = txt[:a]
        second_part = txt[a:b+1]
        third_part = txt[b+1:]
        return first_part + second_part[::-1] + third_part
    elif op == 'replace':
        p = args[3]
        first_part = txt[:a]
        third_part = txt[b+1:]
        return first_part + p + third_part


if __name__ == '__main__':
    # ??????????????\???
    text = input()
    op_count = int(input())
    transformations = []
    for i in range(op_count):
        data = [x for x in input().split(' ')]
        transformations.append(data)

    # ???????????????
    for d in transformations:
        text = do_transform(text, *d)
        # print('debug: {0}'.format(text))

    # ???????????????

Measured memory_bytes: 7756
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func isEvenString(s string) bool {
	if len(s)%2 == 1 {
		return false
	}

	l, r := s[:len(s)/2], s[len(s)/2:]
	return l == r
}

func main() {
	s := next()

	for i := 2; i < len(s); i += 2 {
		ss := s[:len(s)-i]
		if isEvenString(ss) {
			fmt.Println(len(ss))
			return
		}
	}
}


Measured memory_bytes: 1804
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int n;
  cin >> n;
  vector<int> n1, n2;
  rep(i, n){
      int num; cin >> num;
      if(i % 2 == 0) n1.push_back(num);
      else n2.push_back(num);
  }
  if(n % 2 == 0){
      reverse(all(n2));
      rep(i, n2.size()) cout << n2[i] << " ";
      rep(i, n1.size()){
          cout << n1[i];
          if(i != n1.size() - 1) cout << " ";
          }
  } else{
      reverse(all(n1));
      rep(i, n1.size()) cout << n1[i] << " ";
      rep(i, n2.size()){
        cout << n2[i];
        if(i != n1.size() - 1) cout << " ";
      }
  } cout << ln;
}

Measured memory_bytes: 3188
while True:
	a,b,c = [i for i in input().split()]
	a = int(a)
	c = int(c)
	if b == "+":
		print(a + c)
	elif b == "-":
		print(a - c)
	elif b == "*":
		print(a * c)
	elif b == "/":
		print(a // c)
	else:
		break


Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	bool b[101][101];
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			b[i][j]=true;
		}
	}
	int w,h,n,x,y,a;
	cin>>h>>w>>n;
	for(int z=0;z<n;z++){
		cin>>x>>y>>a;
		if(a==1){
			for(int i=1;i<=x;i++){
				for(int j=1;j<=w;j++)
				b[i][j]=false;
			}
		}
		if(a==2){
			for(int i=x+1;i<=h;i++){
				for(int j=0;j<=w;j++){
					b[i][j]=false;
				}
			}
		}
		if(a==3){
			for(int i=0;i<=h;i++){
				for(int j=1;j<=y;j++){
					b[i][j]=false;
				}
			}
		}
		if(a==4){
			for(int i=0;i<=h;i++){
				for(int j=y+1;j<=w;j++)
				b[i][j]=false;
			}
		}
	}
	int sum=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(b[i][j]) sum++;
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e3 + 5;
const double eps = 1e-9;
int dp[N][N], C[N][N], fac[N], ifac[N], inv[N];
int n, a, b, c, d, cnt[N]; 
vi cur;
int ans = 0, cnt2[N][N];

int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int mul(int x, int y) { return x * 1ll * y % mod; }

int pw(int x, int y) {
  int r = 1;
  while (y > 0) {
    if (y & 1)
      r = mul(r, x), y--;
    else
      x = mul(x, x), y /= 2;
  }
  return r;
}

int main() {
  for (int i = 0; i < N; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++)
      C[i][j] = add(C[i-1][j], C[i-1][j-1]);
  }
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = mul(i, fac[i-1]);
    inv[i] = i == 1 ? 1 : (mod - mul(mod/i, inv[mod%i])) % mod;
    ifac[i] = mul(inv[i], ifac[i-1]);
  }
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  for (int i = a-1; i < b; i++)
    dp[0][i] = 1;
  for (int i = c*a; i <= n; i++) {
    for (int j = a; j <= b; j++) {
      dp[i][j] = dp[i][j-1];
      for (int k = c; k <= d && i-k*j >= 0; k++) {
        int nx = mul(fac[i], ifac[i-k*j]);
        nx = mul(nx, ifac[k]);
        nx = mul(nx, pw(ifac[j], k));
        dp[i][j] = add(dp[i][j], mul(nx, dp[i-k*j][j-1]));
      }
    }
  }
  printf("%d\n", dp[n][b]);
  return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = sc.nextLong();
    long ans = 1;

    while (true) {
      if ((x * (long) Math.pow(2, ans - 1)) > (y / 2)) {
        System.out.println(ans);
        return;
      }
      ans++;
    }

  }
}

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

#define rep(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    bool res = false;
    rep(i, 10) rep(j, 10) if(i * j == N) res = true;

    if(res == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main() {
  int a, b, c, d;
  cin >>a >> b >>c >>d;
  if ((a+b) > (c+d)) {
    cout << "Left" << endl;
  }
  else if ((a+b) < (c+d)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int vis[N];
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    LL res=(1900*m+100*(n-m))*(1<<m);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    s = input()
    a= int(s[len(s)-1])

    list1 =[2,4,5,7,9,]
    list2= [0,1,6,8]

    if a in list1:
        print("hon")
    elif a in list2:
        print("pon")
    else:
        print("bon")

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

int main() {
  int A,B;
  cin >> A >> B;
  int ans=0;
  for (int i=0; i<=20; i++){
    if (B>(1+(A-1)*i)) ans++;
    else break;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
//#define int long long
#define ll long long
#define PI acos(-1.0)
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int, int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define EPS 1e-9
#define mod 1000000007
#define N 
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

main()
{	
	#ifndef ONLINE_JUDGE
//		freopen("C:\\Users\\HP\\Desktop\\in.in", "r", stdin);
//		freopen("C:\\Users\\HP\\Desktop\\out.out", "w", stdout);
		//freopen("C:\\Users\\HP\\Desktop\\err.out", "w", stderr);
	#endif
	
	cerr << "I will return...\n";
	
	int n;
	string s;
	cin >> n >> s;
	
	int lw[n], re[n];
	
	lw[0] = 0;
	rep(i, 1, n) {
		lw[i] = lw[i - 1] + (s[i - 1] == 'W');
	}
	
//	for(int i : lw) {
//		cout << i << ' ';
//	}
	
	re[n - 1] = 0;
	repi(j, n - 2, -1) {
		re[j] = re[j + 1] + (s[j + 1] == 'E');
	}
	
//	for(int i : re) {
//		cout << i << ' ';
//	}
	
	int mn = INT_MAX;
	
	rep(i, 0, n) {
		mn = min(mn, re[i] + lw[i]);
	}
	
	cout << mn << '\n';
	
	cerr << "...don't you ever hang your head.";
}








Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed main() 
{
int n,k;
cin>>n>>k;
int count0=0,count=0;
for(int i=1;i<=n;i++)
{
          if(i%k==0) count0++;
          
          if(k%2==0 && i%k==(k/2)) count++;
}
int ans=count0*count0*count0;
ans+=count*count*count;
cout<<ans<<"\n";
}


Measured memory_bytes: 3568
n=int(input())
ans=[0]*n

s=[]
for i in range(3):
    s.append(list(input()))

for i in range(n):
    if s[0][i]==s[1][i] and s[1][i]==s[2][i]:
        ans[i]=0
    elif s[0][i]==s[1][i] or s[0][i]==s[2][i] or s[1][i]==s[2][i]:
        ans[i]=1
    else:
        ans[i]=2

print(sum(ans))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
a=[[]for i in range(n+m)]
for i in range(n):
    s=list(map(int,input().split()))
    for j in s[1:]:
        a[i].append(j+n-1)
        a[n+j-1].append(i)
t=[False]*(n+m)
def g(x):
    t[x]=True
    for i in a[x]:
            if not t[i]:
                g(i)
g(0)
if all(t[:n]):
    print("YES")
else:
    print("NO")


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

long long n, q;

const long long N = 200010;
vector<long long> G[N];
vector<long long> Count(N, 0);
vector<bool> seen(N);

void dfs(long long now, long long cnt){
    seen[now] = true;
    for(long long i = 0; i < G[now].size(); i++){
        long long to = G[now][i];
        if(seen[to]) continue;
        dfs(to, cnt + Count[now]);
    }
    Count[now] += cnt;
    return;
}

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

    cin >> n >> q;
    for(long long i = 0; i < n - 1; i++){
        long long a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    while(q--){
        long long p, x;
        cin >> p >> x;
        p--;
        Count[p] += x;
    }

    dfs(0, 0);

    for(long long i = 0; i < n; i++){
        cout << Count[i] << ' ';
    }
    cout << endl;

    return 0;
}


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

int main() {
  int N; string S; int K;
  cin >> N >> S >> K;
  char A = S.at(K-1);
  for( int i = 0; i < N; i++ ) {
    if( S.at(i) != A )
      S.at(i) = '*';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
def dfs2(i):
    global ans
    for j in range(num[i-1], m):
        num[i] = j
        if i == n:
            now = 0
            for k in range(q):
                if num[b[k]] - num[a[k]] == c[k]:
                    now += d[k]
            ans = max(ans, now)
        else:
            dfs2(i+1)


n, m, q = map(int, input().split())
a, b, c, d = [], [], [], []
ans = 0

for i in range(q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

num = [0] * (n+1)

# dfs([1])
dfs2(1)
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{	
    ll n;
    cin >> n;
    ll ans = 1000 - (n % 1000);
    ans %= 1000;
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{ set<long long int >s;
	ll n,c=0;
	cin>>n;
	for(ll i=0;i<n;i++)
	{  ll temp;
		cin>>temp;
		s.insert(temp);
		if(*s.begin()==temp)
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define fi first
#define sf scanf
#define se second
#define pf printf
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset((x),(y),sizeof(x))
#define fup(i,x,y) for(int i=(x);i<=(y);++i)
#define fdn(i,x,y) for(int i=(x);i>=(y);--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
using namespace std;

int main()
{
    int k,a,b;sf("%d%d%d",&k,&a,&b);
    if(b<=a+2)return !pf("%d\n",k+1);
    if(k<a+1)return !pf("%d\n",k+1);
    k-=a+1;
    ll ans=b;
    if(k&1)pf("%lld\n",b+1ll*k/2*(b-a)+1ll);
    else pf("%lld\n",b+1ll*k/2*(b-a));
//    ans+=1ll*k/(a+2)*b+(k%(a+2));
//    pf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();
    if(e-a>k){
      System.out.println(":(");
      return;
    }
    System.out.println("Yay!");
  }
  

  
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

template <class T>
struct Bit{
	std::vector<T> v;
	int n;
	Bit(int n_): n(n_){ v.assign(n_, 0); }
	// i must be 0 <= i < n
	T sum(int i){
		T s=0;
		while(i>0){ s += v[i]; i -= i & -i; }
		return s;
	}
	// i must be 1 <= i < n
	void add(int i, T x){
		while(i < n){ v[i] += x; i += i & -i; }
	}
};

// v: permutation of (1, ... , n)
int crossing(std::vector<int> &v){
	Bit<int> bit(v.size()+1);
	int count = 0;
	for(int i=0; i<v.size(); i++){
		count += i - bit.sum(v[i]);
		bit.add(v[i], 1);
	}
	return count;
}

int _main(){
	using namespace std;
	Bit<int> bit(10);
	bit.add(1,10);
	bit.add(5,20);
	assert(bit.sum(0)==0);
	assert(bit.sum(2)==10);
	assert(bit.sum(5)==30);
	assert(bit.sum(8)==30);

	vector<int> v = {3, 5, 1, 2, 4};
	assert(crossing(v)==5);
	return 0;
}

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

	int ans = 1e9;
	for(int k=0; k<(1<<N); k++){

		vector<pair<int, int>> xs;
		vector<pair<int, int>> ys;
		for(int i=0; i<N; i++){
			if((k>>i)&1){
				if(i%2) xs.push_back({B[i] ,i});
				else ys.push_back({B[i], i});
			} else {
				if(i%2) ys.push_back({A[i], i});
				else xs.push_back({A[i], i});
			}
		}
		if(xs.size()!=(N+1)/2) continue;

		sort(xs.begin(), xs.end());
		sort(ys.begin(), ys.end());
		debug(k, (int)xs.size(), (int)ys.size());

		vector<pair<int, int>> zs(N);
		for(int i=0; i<N; i++) zs[i] = i%2?ys[i/2]:xs[(i+1)/2];

		bool sorted = true;
		for(int i=0; i<N-1; i++){
			if(zs[i].first>zs[i+1].first) sorted=false;
		}
		if(!sorted) continue;

		vector<int> ix(N);
		for(int i=0; i<N; i++) ix[i] = zs[i].second+1;

		ans = min(ans, crossing(ix));
	}

	cout << (ans==1e9?-1:ans) << endl;

	return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        k: u16,
        mut p: [u16; n],
    }

    p.sort();
    let mut ans: u32 = 0;
    for i in 0..k {
        ans += p[i as usize] as u32;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c=0;cin>>a;
  rep(g,a){
    c=0;
  for(ll i=1;i*i<a;i++){
    for(ll o=i;o<100;o++){
      for(ll j=o;j<100;j++){
        b=i*i+o*o+j*j+i*o+j*i+o*j;
        if(b==g+1){
          if(i==o&&o==j)c++;
          else if(i==o||o==j||j==i)c+=3;
          else c+=6;
        }
        if(b>a)break;
      }
    }
  }
    cout<<c<<endl;
  }
}



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

#define INF (1<<30)

int main(){
	int n;	cin>>n;
	vector<double> a(n);	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(), a.end());

	//{{{
	double used[2];
	double m=INF;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[j]-a[i]<m){
				m=a[j]-a[i];
				used[0]=a[i];	used[1]=a[j];
			}
		}
	}

	double ans1=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			bool flag=true;
			for(int k=0;k<2;k++){
				if(a[i]==used[k] || a[j]==used[k]){
					flag=false;
					break;
				}
			}
			if(flag==false)continue;

			double tmp=(a[i]+a[j])/m;
			ans1=max(ans1,tmp);
		}
	}
	//}}}
	double ans2=0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-2;j++){
			double tmp=(a[n-2]+a[n-1])/(a[j]-a[i]);
			ans2=max(ans2,tmp);
		}
	}

	double ans=max(ans1,ans2);

	printf("%.6lf\n",ans);

	return 0;

}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int k, a, b; cin >> k >> a >> b;
  if (b - a <= 1) {
    cout << 1 + k << endl;
  } else {
    int ans = 1;
    ans += min(k, a - 1);
    k -= min(k, a - 1);
    ans += (k / 2) * (b - a);
    ans += k % 2;
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
L = list(map(int, input().split()))

L.sort()
sum = 0

for i in range(0, N - 1):
	sum += L[i]
	
sum -= L[N - 1]
if sum > 0:
	print('Yes')
else:
	print('No')
	

Measured memory_bytes: 38384
import math
import calendar
import fractions
import itertools

n = int(input())
a = sorted(map(int, input().split()), reverse=True)
h = 0
w = 0
index = -1
for i in range(n - 3):
    if a[i] == a[i + 1]:
        h = a[i]
        index = i + 2
        break

for i in range(index, n - 1):
    if a[i] == a[i + 1]:
        w = a[i]
        break

print(h * w)



Measured memory_bytes: 96492