akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll i,j,n,k,r,s,p;
      cin>>n>>k;
      cin>>r>>s>>p;
      string t,ss;
      cin>>t;
      ll ans=0;
      for(i=0;i<n;i++)
      {
        if(i>=k)
        {
          if(t[i]=='r')
          {
            if(ss[i-k]=='p') {ss.pb('?');}
            else {ans+=p;ss.pb('p');}
          }
          else if(t[i]=='p')
          {
            if(ss[i-k]=='s') {ss.pb('?');}
            else {ans+=s;ss.pb('s');}
          }
          else
          {
            if(ss[i-k]=='r') ss.pb('?');
            else {ans+=r;ss.pb('r');}
          }
        }
        else
        {
          if(t[i]=='r') {ans+=p;ss.pb('p');}
          else if(t[i]=='p') {ans+=s;ss.pb('s');}
          else {ans+=r;ss.pb('r');}
        }
      }
      cout<<ans;



    }
    return 0;
   }

Measured memory_bytes: 14760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int nn = input[0];
            int yy = input[1];
            int ans = 0;
            
            for(int i =0; i<= nn; i++)
            {
                for(int j =0; j <= nn - i; j++)
                {
                    int k = nn - i - j;
                    if(10000*i + 5000*j + 1000*k == yy){
                        Console.WriteLine("{0} {1} {2}", i, j, k);
                        ans = 1;
                        break;
                    }
                }

                if (ans == 1)
                {
                    break;
                }
            }

            if(ans == 0)
            {
                Console.WriteLine("-1 -1 -1");
            }

        }
    }

 }



Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, r; cin >> n >> r, n;){
        string y;
        rep(i, n) y.pb('0' + n - i);

        while(r--){
            int p, c; cin >> p >> c;

            string str1 = y.substr(p - 1, c);
            string str2 = y.substr(0, p - 1);
            string str3 = y.substr(p + c - 1);
            y = str1 + str2 + str3;
        }

        cout << (int)(y.at(0) - '0') << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
from collections import deque

N, M = map(int, input().split())

nei_L = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while queue:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)

Measured memory_bytes: 34532
#include<iostream>
#include<cstdio>
using namespace std;
inline void swap(int amida[], int a, int b){
	int tmp = amida[a];
	amida[a] = amida[b];
	amida[b] = tmp;
}
int main(){
	int amida[40];
	int w,n,a=0,b=0;
	for(int i=0; i<40; i++)
		amida[i] = i;
	cin >> w >> n;
	for(int i=0; i<n; i++){
		scanf("%d,%d",&a,&b);
		swap(amida,a,b);
	}
	for(int i=1; i<=w; i++)
		cout << amida[i] << endl;
	
	return 0;
	
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n;
	cin >> n;
	long long int ans;
	for(int i = 0; i < n; i++){
        int a;
        scanf("%d",&a);
        ans += a;
	}
	printf("%lld\n",ans/n);
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	double a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);

	adeg=30.0*h+m*0.50;
	
	bdeg=6.0*m;

	deg=fabs(adeg-bdeg);

	rad=deg*PI/180.0;
	
	answer=sqrt(a*a+b*b-2.0*a*b*cos(rad));

	printf("%.10lf",answer);

			return 0;
	}


	







Measured memory_bytes: 2604
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  string S = readln.chomp;
  switch(S) {
    case "SUN": 7.writeln; break; 
    case "MON": 6.writeln; break;
    case "TUE": 5.writeln; break;
    case "WED": 4.writeln; break; 
    case "THU": 3.writeln; break;
    case "FRI": 2.writeln; break;
    case "SAT": 1.writeln; break;
    default: break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
//cout<<shosu(10)<<3.14159265353238<<endl;                                      

typedef pair<int,int> pii;
int i,j;


int main(void) {
  string s;
  string a="AIDUNYAN";
  sort(all(a));
  cin>>s;
  if(s.size()<8)
    cout<<s<<endl;
  else{
    rep(i,s.size()){
      if(i<s.size()-7){
        string temp=s.substr(i,8);
        sort(all(temp));
        if(temp==a){
          cout<<"AIZUNYAN";
          i+=7;
        }else
          cout<<s[i];
      }else
        cout<<s[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3176
#include<stdio.h>
int main(){
  int n, x, i, ans=0, temp, j, m;
  scanf("%d %d", &n, &x);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    x-=a[i];
  }
  ans+=n;
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(a[j] < a[j-1]){
        temp = a[j];
        a[j] = a[j-1];
        a[j-1] = temp;
      }
    }
  }
  m=x/a[0];
  ans+=m;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val A = map(N)(_ => sc.nextInt())
    var sum = 0L

    def pairSelf(i: Int): Unit = {
      val self = A(i) / 2
      A(i) -= self * 2
      sum += self
    }

    rep(N - 1) { i =>
      pairSelf(i)
      val adj = min(A(i), A(i + 1))
      A(i) -= adj
      A(i + 1) -= adj
      sum += adj
    }

    pairSelf(N - 1)

    out.println(sum)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) { f(i); i += 1 }
  }
  def rep_r(n: Int)(f: Int => Unit): Unit = {
    var i = n - 1
    while(i >= 0) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint n;
    cin >> n;

    vector<llint> a(100005);
    llint atmp, ans=0;
    for(int in=0;in<n;in++) {
        cin >> atmp; atmp--;
        a.at(atmp)++;
        ans += atmp+1;
    }

    llint b, c, q; 
    cin >> q;
    for(int iq=0;iq<q;iq++) {
        cin >> b >> c; b--; c--;
        ans += (c - b) * a.at(b);
        a.at(c) += a.at(b);
        a.at(b) = 0; 
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

char s[100*1000+5];

int main() {
    scanf(" %s", s);
    int n = strlen(s), ans = 0;
    for (int i = 0; i < n; i++) {
        if (i&1) {
            if (s[i] == 'g') ans++;
        } else {
            if (s[i] == 'p') ans--;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
    int n;cin>>n;
    map<int,int> mp;
    for(int i=1;i*i<=n;i++){
        for(int j=1;j*j<=n;j++){
            for(int k=1;k*k<=n;k++){
                int f=i*i+j*j+k*k+i*j+j*k+i*k;
                mp[f]++;
            }
        }
    }
    
    for(int i=1;i<=n;i++){
        cout<<mp[i]<<"\n";
    }
    
}


Measured memory_bytes: 5972
def main():
    N = int(input())
    A = list(map(int,input().split()))
    n_odd = len([A[i] for i in range(N) if A[i]%2 != 0])
    n_even = N - n_odd
    if n_odd%2 != 0:
        print("NO")
    else:
        print("YES")

if __name__ == '__main__':
    main()

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

int N;

int main()
{
    cin >> N;
    int argmax = -1;
    int max = 0;
    for (int i=0; i<N; i++)
    {
        int tmp;
        cin >> tmp;
        if (abs(tmp) > abs(max) || argmax < 0)
        {
            max = tmp;
            argmax = i;
        }
    }
    cout << 2*N << endl;
    if (max >= 0)
    {
        cout << argmax+1 << " " << 1 << endl;
        cout << argmax+1 << " " << 1 << endl;
        for (int i=1; i<N; i++)
        {
            cout << i << " " << i+1 << endl;
            cout << i << " " << i+1 << endl;
        }
        return 0;
    }
    else
    {
        cout << argmax+1 << " " << N << endl;
        cout << argmax+1 << " " << N << endl;
        for (int i=N; i>1; i--)
        {
            cout << i << " " << i-1 << endl;
            cout << i << " " << i-1 << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 380
import sys


def input():
    return sys.stdin.readline().strip()


S = input()
N = len(S)
flag = True
for i in range(N // 2):
    if S[i] == S[N - i - 1]:
        continue
    else:
        flag = False

if flag:
    S1 = S[: (N - 1) // 2]
    N = len(S1)
    for i in range(N // 2):
        if S1[i] == S1[N - i - 1]:
            continue
        else:
            flag = False

if flag:
    S2 = S[(len(S) + 3) // 2 - 1 :]
    N = len(S2)
    for i in range(N // 2):
        if S2[i] == S2[N - i - 1]:
            continue
        else:
            flag = False

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input())
cnt = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (500 * i + 100 * j + 50 * k) == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	b /= 2;
	cout << a + b << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A___Serval_vs_Monster
{
    class Program
    {
        static void Main(string[] args)
        {
            var ue = new List<string[]>();
            int H = 0;
            int A = 0;
            
            int c= 0;
            int amari = 0;
            var up = Console.ReadLine();
            //の行の要素数をカウント
            string[] arrup = up.Split(' ');
            H = int.Parse(arrup[0]);
            A = int.Parse(arrup[1]);

            c = H / A;
            amari = H % A;
            if(amari > 0)
            {
                c = c + 1;
            }
            Console.WriteLine(c);
#if DEBUG
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
bool use[2][100];//グローバル変数のboolは自動的にfalseで初期化される
int main()
{
    
    int h, w;
    cin >> h >> w;
    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
            if(c[i][j] == '#'){
                //一つでも黒のある行、列は使用する可能性があるのでtrueとする
                use[0][i] = true;//行に関するbool
                use[1][j] = true;//列に関するbool
            }
        }
    }
    for(int i = 0; i < h; i++)if(use[0][i]){
        //全部白の行ではfalseなので繰り返し処理が飛ばされる
        //if(use[0][i]) ここにifでもいい
        for(int j = 0; j < w; j++)if(use[1][j]){
            //全部白の列では繰り返し処理が飛ばされる
            cout << c[i][j];
        }
        cout << endl;
        //文字の存在する行だけendlが出力
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/


/****** define variable start ******/
ll n, m;
/******* define variable end *******/

ll solve(){
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9 + 7

H,W = map(int,readline().split())
A = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W]

dp = np.zeros(W,np.int64)
dp[0] = 1

for h in range(H):
    wall = (A[h] == b'#')
    dp[wall] = 0
    np.cumsum(dp,out=dp)
    dp -= np.maximum.accumulate(dp*wall)
    dp %= MOD

answer = dp[-1]
print(answer)

Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define vec vector<ll>
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

void solve(){

    ll x,n;
    cin>>x>>n;

    vec a;
    if(n==0){
        cout<<x; return;
    }
    inpvec(a,n);
    map<ll,ll> m;
    sort(all(a));
    for(ll i=0 ;i<n ;i++ ){
        m[a[i]]++;
    }

    ll temp = x;
    ll lol=1e5;
    ll res1,res2;

    while(lol--){
        if(m.count(temp)==0){
            res1=temp;
            break;
        }
        temp++;
    }
    temp=x;
    lol=1e5;
    while(lol--){
        if(m.count(temp)==0){
            res2=temp;
            break;
        }
        temp--;
    }

    if(abs(res1-x)<abs(res2-x)){
        cout<<res1;
    }
    else{
        cout<<res2;
    }

    return;
} 
 
int main()
{
    IOS;
    solve();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
long long f(long long a, long long b){
    if(b == 0) return -a;
    if(a >= b) return f(b, a%b) + 2*b*(a/b);
    return f(b, a%b);
}
int main(){
    long long n, x;
    scanf("%lld%lld", &n, &x);
    printf("%lld\n", n + f(n-x, x));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn = 200005;

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b);
    
    
    //how much time has elapsed
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    return 0;
    
}


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() {
    int n;
    cin >> n;
    vi p(n), q(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }
    int a = 0;
    int b = 0;
    vi d(n);
    iota(d.begin(), d.end(), 1);
    int idx = 0;
    do {
        idx++;
        int ok = true;
        for (int i = 0; i < n; ++i) {
            if (p[i] != d[i])
                ok = false;
        }
        if (ok) {
            a = idx;
            break;
        }
    } while (next_permutation(d.begin(), d.end()));
    iota(d.begin(), d.end(), 1);
    idx = 0;
    do {
        idx++;
        int ok = true;
        for (int i = 0; i < n; ++i) {
            if (q[i] != d[i])
                ok = false;
        }
        if (ok) {
            b = idx;
            break;
        }
    } while (next_permutation(d.begin(), d.end()));
    cout << abs(a - b) << "\n";
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.split().map(&:to_i)
ans = 0
x = 0
while x == 0
  s.each do |a|
    if a % 2 != 0
      x += 1
    end
  end
  if x == 0
    i = 0
    n.times do
      s[i] = s[i]/2
      i += 1
    end
    ans += 1
  end
end
puts ans

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n-1);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
    a[i] = b[i];
    a[i + 1] = a[i];
  }
  a[0] = b[0];
  for (int i = 1; i < n ; i++) {
    a[i] = min(a[i], b[i - 1]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: usize,
        A1: [usize; N],
        A2: [usize; N],
    }
    println!(
        "{}",
        (0..N)
            .map(|i| match i {
                0 => A1[0] + A2.iter().sum::<usize>(),
                _ => {
                    let (A1l, _) = A1.split_at(i + 1);
                    let (_, A2r) = A2.split_at(i);
                    A1l.iter().sum::<usize>() + A2r.iter().sum::<usize>()
                }
            }).max()
            .unwrap()
    );
}


Measured memory_bytes: 4352
import heapq

n = int(input())
A = [int(x) for x in input().split()]
A_rev = [-x for x in A[::-1]]

def get_sum_list(A):
  h = []
  result = []
  current_sum = 0
  for i,a in enumerate(A[:2*n]):
    heapq.heappush(h,a)
    current_sum += a
    if i >= n:
      m = heapq.heappop(h)
      current_sum -= m
    if i >= n-1:
      result.append(current_sum)
  return result

from_left = get_sum_list(A)
from_right = get_sum_list(A_rev)

ans = -10**18
for i in range(n+1):
  score = from_left[i] + from_right[n-i]
  if ans < score:
    ans = score
    
print(ans)


Measured memory_bytes: 40384
#include <iostream>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

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

void print(int u)
{
    int i, c;

    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }

    cout << "]" << endl;;
}

// 再帰的に深さを求める
void rec(int u, int p)
{
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);      // 右の兄弟にも同じ深さを設定
    if (T[u].l != NIL) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ +1 を設定
}

int main()
{
    int i, j, d, v, c, l, r;

    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

    for (i = 0; i < n; i++)
    {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++)
    {
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

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

    return 0;
}


Measured memory_bytes: 7772
#include <stdio.h>
 
int main(void)
{
    int c,i,j,s,k,out[26];
    for(i=0;i<26;i++) out[i]=0;
    while((c=getchar())!=EOF){
         
        for(j='a',k='A',s=0;j<='z';j++,k++,s++){
            if(j==c || k==c) out[s]+=1;
        }
    }
    for(i='a',j=0;j<26;i++,j++)  printf("%c : %d\n",i,out[j]);
 
 
return 0;
}

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

int main() {
  string s1,s2;
  cin >>s1>>s2;
  int a=0;
  for(int i=0;i < 3;i++){
    if(s1[i]==s2[i]){
      a++;
    }
  }
  
  cout << a << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,a,b,tmp;
  scanf("%d %d %d",&n,&a,&b);
  tmp=b-a;
  if(tmp%2==0){
    printf("Alice\n");
  }else{
    printf("Borys\n");
  }

  return 0;
}


Measured memory_bytes: 128
/**
 *    Creator :  bizarre
 *    Date : 3/2020
 *    Problem Number : 390
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
const int inf = 2e9, mod = 1e9 + 7,N=1e6+5;
long long fact[N], inv[N];

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
                c++;
            }

        }
    }

}
*/

int main()
{

    long long n,ans=0;
    long long c[100][100];
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int b=i%10;string r=to_string(i);
        int a=r[0]-'0';
        if(b==0)continue;// no leading zeros
        c[a][b]++;
    }
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
            ans+=c[i][j]*c[j][i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
input = lambda: stdin.readline().rstrip()

n = int(input())

maxv = 10**9 * -1
min_R = int(input())
for _ in range(n-1):
    r = int(input())
    maxv = max(maxv, r - min_R)
    min_R = min(min_R, r)

print(maxv)



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


int main() {
    long long A,B,N;
    cin >> A >> B >> N;

    if(N == B )cout << (A*(N-1))/B - A*((N-1)/B) << endl;
    else if (N > B){
        N = B-1;
        cout << (A*N)/B - A*(N/B) << endl;
    }
    else cout << (A*N)/B - A*(N/B) << endl;

}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int ans = S.size();
    for (int i = 0; i < 2; i++)
    {
        int cnt = 0;
        for (int j = 0; j < S.size(); j++)
        //{
        //    if (j % 2 == 0 && S[j] != char(i + '0'))
        //        cnt++;
        //    if (j % 2 == 1 && S[j] == char(i + '0'))
        //        cnt++;
        //}
        //　上記は、1個目の条件と2個目の条件が片方満たされるとき、
        //  のみ、cntが++されると見れるので、
        {
            if ((j % 2 == 0) ^ (S[j] == char(i + '0')))
            {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/*** ?¬?????????? ***/

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

int main(){
	int n, p;
	int i;
	int count, size;
	int max, num;
	
	cin >> n >> p;
	while(n!=0 || p!=0){
		vector<int> v;
		for(i=0; i<n; ++i) v.push_back(0);
		count=0;
		size=p;
		
		while(1){
			for(i=size; 0<i; --i){
				++v[count];
				count=(count+1)%n;
			}
			
			max=0;
			num=-1;
			for(i=0; i<n; ++i){
				if(max<v[i]){
					max=v[i];
					num=i;
				}
			}
			if(max==p) break;
			
			while(v[count]==0) count=(count+1)%n;
			size=v[count];
			v[count]=0;
			count=(count+1)%n;
		}
		cout << num << endl;
		
		cin >> n >> p;
	}
	return 0;
}

Measured memory_bytes: 3000
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		BigInteger[] T = new BigInteger[N];
		for(int i = 0; i < N; i++) {
			T[i] = BigInteger.valueOf(scan.nextLong());
		}
		// 最大公約数を求めてそこから最小公倍数を求める
		BigInteger gcd = new BigInteger("1");		// 最大公約数
		BigInteger lcm = T[0];		// 最小公倍数
		
		for(int i = 1; i < N; i++) {
			gcd = lcm.gcd(T[i]);
			lcm = lcm.divide(gcd).multiply(T[i]);
		}
		System.out.println(lcm);
		scan.close();
	}

}


Measured memory_bytes: 25428
n = int(input())
s = [int(i) for i in input().split()]
count = 0
while True:
    tmp = []
    for i in s:
        if i % 2 == 0:
            tmp.append(i/2)
        else:
            print(count)
            exit()
    count += 1
    s = tmp[:]


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

int main()
{
    int H, W;
    
    while (cin >> H >> W, H) {
        char d[H][W];
        int ansW, ansH, ans = 0;
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                cin >> d[i][j];

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (d[i][j] == '.') {
                    ansH = 0;
                    ansW = 9999;
                    while (d[i + ansH][j] == '.' && i + ansH < H) {
                        int m = 0;
                        while (d[i + ansH][j + m] == '.' && j + m < W) m++;
                        ansW = min(ansW, m);
                        ansH++;
                        ans = max(ans, ansW * ansH);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < o.length(); i++) {
		cout << o[i];
		if (i < e.length())cout << e[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdint.h>

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

    int x = 0;
    while (true)
    {
        int y = x + 1;
        if (y * y <= n)
        {
            x = y;
        }
        else
        {
            break;
        }
    }
    std::cout << (x * x) << std::endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

MAX_WEIGHT = 100100


def main(n, w, items):
    dp = np.zeros((n + 1, MAX_WEIGHT), dtype=int)
    for i in range(n):
        weight, value = items[i]
        dp[i + 1][:weight] = dp[i][:weight]
        dp[i + 1][weight:] = np.maximum(dp[i][weight:], dp[i][:MAX_WEIGHT - weight] + value)
    return dp[n][w]


if __name__ == '__main__':
    N, W = map(int, input().split())
    ITEMS = []
    for _ in range(N):
        ITEMS.append(tuple(map(int, input().split())))
    print(main(N, W, ITEMS))


Measured memory_bytes: 92956
/*_BELIEVE_*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
 int n;
 cin>>n;

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

 sort(all(v));

 cout<<v[n/2]-v[n/2-1];

}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cctype>
#include <string.h>
#include <ctime>  
using namespace std;

int a[100005],b[100005];

int main()
{
	int n,s=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for (int i=1;i<=100005;)
	{
		b[i]=1;
		i=a[i];
		s++;
		if (i==2)
		{
			cout<<s<<endl;
			return 0;
		}
		else if (b[i]==1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	
	return 0;
 } 


Measured memory_bytes: 1024
#include <stdio.h>
int main() {
	char a[105];
	for (int i = 0; i < 105; i++)a[i] = '0';
	scanf("%s", a);
	int d;
	for (int i = 0; i < 105; i++) {
		if (a[i] != '0')d = i;
	}
	int k = 0;
	if (a[0] == 'k'&&a[1] == 'e'&&a[2] == 'y'&&a[3] == 'e'&&a[4] == 'n'&&a[5] == 'c'&&a[6] == 'e')k = 1;
	if (a[0] == 'k'&&a[1] == 'e'&&a[2] == 'y'&&a[3] == 'e'&&a[4] == 'n'&&a[5] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[0] == 'k'&&a[1] == 'e'&&a[2] == 'y'&&a[3] == 'e'&&a[4] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[0] == 'k'&&a[1] == 'e'&&a[2] == 'y'&&a[3] == 'e'&&a[d - 3] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[0] == 'k'&&a[1] == 'e'&&a[2] == 'y'&&a[d - 4] == 'e'&&a[d - 3] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[0] == 'k'&&a[1] == 'e'&&a[d - 5] == 'y'&&a[d - 4] == 'e'&&a[d - 3] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[0] == 'k'&&a[d - 6] == 'e'&&a[d - 5] == 'y'&&a[d - 4] == 'e'&&a[d - 3] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (a[d - 7] == 'k'&&a[d - 6] == 'e'&&a[d - 5] == 'y'&&a[d - 4] == 'e'&&a[d - 3] == 'n'&&a[d - 2] == 'c'&&a[d - 1] == 'e')k = 1;
	if (k)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t Int;
const Int MOD = 1e9+7;

int N, K; 
vector<vector<int>> G(100010);
vector<bool> visited(100010, false);
vector<Int> f;


//---------- べき乗 ----------
Int power(Int a, Int n){
    if(a == 0) return 0;
    if(n == 0) return 1;
    
    Int res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD; n /= 2;
    }
    return res;
}

//---------- 逆元 ----------
Int inv(Int a){
    return power(a, MOD-2);
}

//---------- 階乗 ----------
vector<Int> factorial(Int n){
    vector<Int> res(n+1, 1);
    for(int i=1; i<=n; i++) res[i] = i * res[i-1] % MOD;

    return res; // nまでの階乗の配列を返す
}

//--------- 順列 ---------
Int perm(Int n, Int r){
    if(r > n || n < 0) return 0;
    return f[n] * inv(f[n-r]) % MOD;
}


Int dfs(int v){
    visited[v] = true; Int res;
    if(v == 0){
        res = K * perm(K-1,G[v].size()) % MOD; 
    } else {
        res = perm(K-2, G[v].size()-1) % MOD;
    }

    rep(i, G[v].size()){
        if(visited[G[v][i]]) continue;
        res = res * dfs(G[v][i]) % MOD;
    }

    return res;
}

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

    rep(i, N-1){
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    f = factorial(K);
    cout << dfs(0) << endl;
}

Measured memory_bytes: 10368
#include <iostream>

int main() {
    int h, n;
    std::cin >> h >> n;

    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        h -= a;
    }

    if (h <= 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,K = [int(a) for a in input().split()]
P = [int(a) for a in input().split()]
for i in range(len(P)-1):
    for j in reversed(range(i, len(P)-1)):
        if P[j] > P[j+1]:
            P[j], P[j+1] = P[j+1], P[j]
print(sum(P[:K]))

Measured memory_bytes: 9248
#include<stdio.h>
using namespace std;
const int sss=1<<21;
int n;
int a[1000][1000];
int d[1000],p[10000],color[1000];
int prim(){
    int u,minv;
    for(int i=0;i<n;i++){
        d[i]=sss;
        p[i]=-1;
    }
    d[0]=0;
    while(1){
        minv=sss;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=1){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=1;
        for(int v=0;v<n;v++){
            if(color[v]!=1&&a[u][v]!=sss){
                if(d[v]>a[u][v]){
                    d[v]=a[u][v];
                    p[v]=u;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1) {
            sum+=a[p[i]][i];
        }
    }
    return sum;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;scanf("%d",&e);
            a[i][j]=e==-1?sss:e;
        }
    }
    printf("%d\n",prim());
    return 0;
} 


Measured memory_bytes: 2988
n = input()
q = n[0]
w = n[1]
e = n[2]
r = n[3]
a = int(q)
b = int(w)
c = int(e)
d = int(r)

if a + b + c + d == 7:
    print(q+"+"+w+"+"+e+"+"+r+"="+"7")
elif a + b + c - d == 7:
    print(q+"+"+w+"+"+e+"-"+r+"="+"7")
elif a + b - c - d == 7:
    print(q+"+"+w+"-"+e+"-"+r+"="+"7")
elif a - b - c - d == 7:
    print(q+"-"+w+"-"+e+"-"+r+"="+"7")
elif a - b + c - d == 7:
    print(q+"-"+w+"+"+e+"-"+r+"="+"7")
elif a - b - c + d == 7:
    print(q+"-"+w+"-"+e+"+"+r+"="+"7")
elif a + b - c + d == 7:
    print(q+"+"+w+"-"+e+"+"+r+"="+"7")
elif a - b + c + d == 7:
    print(q+"-"+w+"+"+e+"+"+r+"="+"7")


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#define ll long long
using namespace std;
vector<int> ga[100007];
set<pair<int,int> > s,s2;
vector<set<pair<int,int> > > v;
int a[100007];
bool vis[100007];

void dfs(int x){
	for(int i=0;i<ga[x].size();i++){
		int u=ga[x][i];
		if(!vis[u]){
			vis[u]=true;
			s.insert(make_pair(a[u],u));
			dfs(u);
		}
	}
}
int main()
{
	int n,m,i;
	cin>>n>>m;
	
	if(n-m==1)
	{
		cout<<0<<endl;
		return 0;
	}
	if((n-m-1)*2>n)
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x++;y++;
		ga[x].push_back(y);
		ga[y].push_back(x);
	}
	
	for(i=1;i<=n;i++){
		if(!vis[i]){
			vis[i]=true;
			s.insert(make_pair(a[i],i));
			dfs(i);
			v.push_back(s);
			s.clear();
		}
	}
	
	for(i=1;i<=n;i++)
        s2.insert(make_pair(a[i],i));
	ll ans=0;
	for(i=0;i<n-m;i++)
	{
		s=v[i];
		ans+=(*s.begin()).first;
		s2.erase(*s.begin());
	}
	
	for(i=1;i<=2*(n-m-1)-(n-m);i++)
	{
		ans+=(*s2.begin()).first;
		s2.erase(*s2.begin());
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N, K;
  cin >> N  >> K;
  int count = 0;
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    if(h >= K) count++;
  }
  cout << count << endl;
}

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

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

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

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

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

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

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<ll> a(n);
  ll s=0;
  rep(i,n){
    cin>>a[i];
    s+=a[i];
  }
  
  ll t=a[0];
  s-=a[0];
  ll ans=abs(s-t);
  irep(i,1,n-1){
    t+=a[i];
    s-=a[i];
    chmin(ans,abs(s-t));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B = LI()

    ans = 0

    for i in range(A, B + 1):
        if str(i) == str(i)[::-1]:
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10104
#include <stdio.h>

int main(void)
{
	int i;
	int p;
	int total;
	
	total = 0;
	for (i = 0; i < 5; i++){
		scanf("%d", &p);
		if (p < 40){
			p = 40;
		}
		total += p;
	}
	printf("%d\n", total / 5);
	
	return (0);
}

Measured memory_bytes: 1028
<?php
  $five_hundred = trim(fgets(STDIN));
  $one_hundred = trim(fgets(STDIN));
  $fifty = trim(fgets(STDIN));
  $target = trim(fgets(STDIN));

  $cnt = 0;
  for($i = 0; $i <= $five_hundred; $i++){
    for($j = 0; $j <= $one_hundred; $j++){
      $k = $target - ($i * 500 + $j * 100);
      if($k >= 0 && $k / 50 <= $fifty){
        $cnt++;
      }
    }
  }
  echo $cnt;
?>

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int N,M;
    cin >> N >> M;
    
    double ans = pow(2,M) * (1900 * M + 100 * (N - M));
    cout << ans << endl;
    // a1 / (1-r) 

}

Measured memory_bytes: 256
S=input()
N,M,T=S.split("/")
N=int(N)
M=int(M)
T=int(T)
if(N<2019):
    print("Heisei")
elif(N==2019):
    if(M<=4):
        print("Heisei")
    else:
        print("TBD")
else:
    print("TBD")

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

int main() {
    string a, b;
    cin >> a >> b;
    int n = a.length();
    bool ans = true;
    for(int i = 0; i < n; i++) {
        if(a[i] != b[i])
            ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3608