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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	int ans=0;
	rep(i,n) ans+=a.at(i);
	ans-=a.at(n-1)/2;
	cout << ans << endl;
}

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


int main(){
    string p,s;
    bool res = false;
    getline(cin,p);
    getline(cin,s);
    for(int i = 0;i < p.size();i++){
        if(s[0] == p[i]){
            res = true;
            for(int j = 0;j<s.size();j++){
                int k = i+j;
                if(k >= p.size()){
                    k = k - p.size();
                }
                if(s[j] != p[k]){
                    res = false;
                }
                if(j == s.size() - 1){
                    if(res){
                      cout<<"Yes"<<endl;
                      return 0;
                    }
                }
            }
            
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3204
import sys
readline = sys.stdin.readline


def solve():
    N, H = map(int, readline().split())
    a, b = [0] * N, [0] * N
    for i in range(N):
        a[i], b[i] = map(int, readline().split())
    
    max_a = max(a)
    b.sort(reverse=True)
    ans = 0
    for i in range(N):
        if b[i] <= max_a:
            break
        H -= b[i]
        ans += 1
        if H <= 0:
            print(ans)
            exit()
    ans += H // max_a if H % max_a == 0 else H // max_a + 1
    print(ans)


if __name__ == '__main__':
    solve()


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

int a[4];
int b[4];
int hit,blo;

int main(){
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
		cin>>b[0]>>b[1]>>b[2]>>b[3];
		hit=0;
		blo=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				a[i]=-1;
				b[i]=-1;
			}
		}
		sort(a,a+4);
		sort(b,b+4);
		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				blo++;
			}
		}
		blo-=hit;
		cout<<hit<<" "<<blo<<endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <cstdio>

using namespace std;

int mday[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string cal[] = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday" ,"Saturday" ,"Sunday"};

int main()
{
  int month, day;
  while (scanf("%d %d ", &month, &day) == 2) {
    if (month == 0 && day == 0) {break;}
    int sumday = 0;
    for (int i = 0; i < month - 1; i++) {
      sumday += mday[i];
    }
    sumday += day;
    cout << cal[(sumday + 2) % 7] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

const int B = 12750;
bitset<B> dp[81][81];
int vs[81][81];

int main(void) {
  int h, w;
  scanf("%d%d", &h, &w);
  REP(i, h) {
    REP(j, w) {
      scanf("%d", &vs[i][j]);
    }
  }
  REP(i, h) {
    REP(j, w) {
      int v;
      scanf("%d", &v);
      vs[i][j] = abs(vs[i][j]-v);
    }
  }
  // cerr << "> " << vs[0][0] << endl;
  dp[0][0].set(vs[0][0]);
  REP(i, h) {
    REP(j, w) {
      if(i == 0 && j == 0) {
        continue;
      }
      int v = vs[i][j];
      auto &s = dp[i][j];
      bitset<B> b;
      if(i-1 >= 0) {
        b = dp[i-1][j];
      }
      if(j-1 >= 0) {
        b |= dp[i][j-1];
      }
      s = b << v;
      s |= b >> v;
      REP(x, v) {
        if(b[x]) {
          s.set(v - x);
        }
      }
      // cerr << s << endl;
    }
  }
  const auto &s = dp[h-1][w-1];
  REP(i, B) {
    if(s[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 11128
var n,i,j,ans,num,maxi:longint;
var a,b:array[0..100020] of longint;
begin
  read(n);for i:=1 to n do begin read(a[i]);inc(b[a[i]]);inc(b[a[i]+1]);
  inc(b[a[i]-1]);end;
ans:=0;
  for i:=0 to 100000 do
 if b[i]>ans then ans:=b[i];
  writeln(ans);{23333333333333333}
end.

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   string s1,s2 ;
   cin>>s1>>s2 ;
   cnt=0 ;
   n=s1.size() ;
   for(i=0;i<n;i++)
   {
       if(s1[i]!=s2[i])
        cnt++ ;
   }
   cout<<cnt ;
   return 0; }


Measured memory_bytes: 3792
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int n, k;
  cin >> n >> k;
  cout << n-k+1 << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]

count = 0

for i in range(n):
    if lis[i]%2 == 0:
        count += lis[i]//2
    else:
        if lis[i+1] > 1:
            count += lis[i]//2+1
            lis[i+1] -= 1
        else:
            count += lis[i]//2
print(count)

Measured memory_bytes: 13836
import java.util.Scanner;

public class Main {
	public void run() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long right = 0, left = 0;
		for (int i = 0; i < n; i++) {
			long x = in.nextLong();
			char c = in.next().charAt(0);
			long a = in.nextLong();
			if (c == '(') left += a;
			else right += a;
			System.out.println((right == left) ? "Yes" : "No");
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 46532
#include <bits/stdc++.h>
#define ll long long int
#define c(a) ll a; cin>>a;
#define cs(a) string a; cin>>a;
#define ci(a) cin>>a;
#define co(a) cout<<a;
#define nl cout<<endl;
#define ca(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n) for(ll i=a;i>=n;i--)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define T ll t=1; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    c(n) c(h) c(w)
    cout<<(n-h+1)*(n-w+1)<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3540
#include<iostream>
#include<vector>

using namespace std;

class Dice{
private:
  int value[6];
  int status[6]; //0:top,1:front,2:right,3:left,4:back,5:bottom
public:
  Dice(int*);
  void rotate(char);
  void show_value();
  void show_status();
  int show_top();
};

int main(int argc, char const *argv[]) {

  int dice_value[6];

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

  char direction[100];

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

  Dice dice(dice_value);

  //dice.show_value();
  //dice.show_status();

  for(int i=0;i<100;i++){
    dice.rotate(direction[i]);
  }

  dice.show_top();

  return 0;
}

Dice::Dice(int* input){
  for(int i=0;i<6;i++){
    value[i]=input[i];
    status[i]=i;
  }
}

void Dice::show_value(){
  for(int i=0;i<6;i++){
    cout << value[i] << " ";
  }
  cout << endl;
}

void Dice::show_status(){
  for(int i=0;i<6;i++){
    cout << status[i] << " ";
  }
  cout << endl;
}

void Dice::rotate(char direct){
  //index of status[i]---0:top,1:front,2:right,3:left,4:back,5:bottom
  int before_status[6];
  for(int i=0;i<6;i++){
    before_status[i]=status[i];
  }

  switch(direct){
    case 'E':
    status[2] = before_status[0];
    status[5] = before_status[2];
    status[0] = before_status[3];
    status[3] = before_status[5];
    break;
    case 'W':
    status[3] = before_status[0];
    status[0] = before_status[2];
    status[5] = before_status[3];
    status[2] = before_status[5];
    break;
    case 'N':
    status[4]=before_status[0];
    status[0]=before_status[1];
    status[5]=before_status[4];
    status[1]=before_status[5];
    break;
    case 'S':
    status[1]=before_status[0];
    status[5]=before_status[1];
    status[0]=before_status[4];
    status[4]=before_status[5];
    break;
    default:
    break;
  }

}

int Dice::show_top(){
  cout << value[status[0]] << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main(){
  int s;
  cin >> s;
  int a = s / 100;//1905 → 19
  int b = s % 100;//1905 → 05
  if ((a > 12 || a == 0 )&&( b > 12 || b == 0))
  {
    cout << "NA" << endl;
  }
  else if (a < 13 && a > 0 && b < 13 && b > 0)
  {
    cout << "AMBIGUOUS" << endl;
  }
  else if (a > 12 || a == 0)
  {
    cout << "YYMM" << endl;
  }
  else
  {
    cout << "MMYY" << endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
  int i, j, n, m;
  cin >> n;
  i=1;
  while(i<=n){
    i*=2;
  }
  cout << i/2;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
  ll n;
  cin >> n;
  ll x,y;
  cin >> x >> y;
  cout << min(x,y) << " ";
  cout << max((ll)0,x+y-n);
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        while(true){
            var line = Console.ReadLine();
            String[] array = line.Split(' ');
            var a = int.Parse(array[0]);
            var ops = array[1];
            var b = int.Parse(array[2]);
            
            if(ops.Equals("?")){
                break;
            }else if(ops.Equals("+")){
                Console.WriteLine(a+b);
            }else if(ops.Equals("-")){
                Console.WriteLine(a-b);
            }else if(ops.Equals("*")){
                Console.WriteLine(a*b);
            }else if(ops.Equals("/")){
                Console.WriteLine(a/b);
            }
            
        }
    }
}



Measured memory_bytes: 15940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
const ll MAX_N = 1e5+10;

int main(int argc, char const *argv[])
{
	ll n, m, p[MAX_N], y[MAX_N];
	cin >> n >> m;
	for (int i = 0; i < m; ++i) cin >> p[i] >> y[i];

	vector<pair<ll, int>> vec[MAX_N];
    for (int i = 0; i < m; ++i) {
    	vec[p[i]].push_back(make_pair(y[i], i));
    }
    for (int i = 0; i <= n; ++i) {
    	sort(vec[i].begin(), vec[i].end());
    }
    vector<pair<int, string>> ans;
    for (int i = 0; i <= n; ++i) {
    	for (int j = 0; j < vec[i].size(); ++j) {
    		string sf(6, '0'), sb(6,'0');
    		string sp = to_string(i), so = to_string(j+1);
    		sf.replace(sf.begin()+(6-sp.size()), sf.end(), sp);
    		sb.replace(sb.begin()+(6-so.size()), sb.end(), so);
    		ans.push_back(make_pair(vec[i][j].second,sf+sb));
    	}
    }
    sort(ans.begin(), ans.end());

    for (int i = 0; i < ans.size(); ++i)
    {
    	cout << ans[i].second << endl;
    }


	return 0;
}

Measured memory_bytes: 14832
while line = gets
  a,b = line.split.map(&:to_i)
  a_times_b = a*b
  gcd = 1
  loop do
    c = a % b
    if c == 0
      gcd = b
      break
    else
      a,b = b,c
      # b = c
    end
  end
  lcm = a_times_b / gcd
  puts "#{gcd} #{lcm}"
end

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;

    if (a.length() == b.length()) {
        if (a > b) {
            cout << "GREATER" << endl;
        } else if (a < b) {
            cout << "LESS" << endl;
        } else if (a == b) {
            cout << "EQUAL" << endl;
        }
    } else if (a.length() > b.length()) {
        cout << "GREATER" << endl;
    } else {
        cout << "LESS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	XYZK := strings.Split(nextLine(), " ")
	X, _ := strconv.Atoi(XYZK[0])
	Y, _ := strconv.Atoi(XYZK[1])
	Z, _ := strconv.Atoi(XYZK[2])
	K, _ := strconv.Atoi(XYZK[3])

	a := strings.Split(nextLine(), " ")
	b := strings.Split(nextLine(), " ")
	c := strings.Split(nextLine(), " ")
	A := make([]int, X)
	B := make([]int, Y)
	C := make([]int, Z)

	for i := 0; i < X; i++ {
		A[i], _ = strconv.Atoi(a[i])
	}
	for i := 0; i < Y; i++ {
		B[i], _ = strconv.Atoi(b[i])
	}
	for i := 0; i < Z; i++ {
		C[i], _ = strconv.Atoi(c[i])
	}

	AB := make([]int, X*Y)
	for i, a := range A {
		for j, b := range B {
			AB[j+Y*i] = a + b
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(AB)))

	AB = AB[:min(K, X*Y)]
	ans := make([]int, K*Z)
	for i, ab := range AB {
		for j, c := range C {
			ans[j+Z*i] = ab + c
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ans)))
	for _, v := range ans[:K] {
		fmt.Println(v)
	}
}


Measured memory_bytes: 35072
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int n, a[10001], cnt = 0;

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        while(((a[i] % 2) == 0) && (a[i] > 0)){
            a[i] = a[i] / 2;
            cnt ++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
  
int main(){
    int S[10001],T[501],U[10001];
    int i,j,lengh1,lengh2,count=0,count2=0,count3=0;
     
    scanf("%d",&lengh1);
    for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);}
      
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
      
    for(i=1;i<=lengh1;i++){
        for(j=1;j<=lengh2;j++){
        	if(S[i]==T[j]){	
        		count++;
        		U[count]=T[j];
        	}
              }}
	
     count2=count;
	
			
			
	for(i=1;i<=count2;i++){
		for(j=i+1;j<=count2;j++){
			if(U[j]==U[i]){
				count--;
				break;}
		}}

    printf("%d\n",count+count3);
	   
      
    return 0;
}

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

ll f(ll b, ll n){
    if(n<b) return n;
    else return f(b,n/b) + n%b;
}

int main(){
    ll n, s;  cin >> n >> s;

    if(s==n){
        cout << n+1 << endl;
        return 0;
    }

    for(ll b=2; b*b<=n; b++){
        if(f(b,n)==s){
            cout << b << endl;
            return 0;
        }
    }

    ll ans = 1e18;
    for(ll p=1; p*p<=n; p++){
        ll q = s - p;
        if((n-q)%p != 0) continue;

        ll b = (n-q)/p;
        if(b > sqrt(n) && 0 <= p && p < b && 0 <= q && q < b){
            ans = min(b, ans);
        }
    }
    if(ans!=1e18) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 1e5 + 17;

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

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n - 1)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		g[u - 1].push_back(v - 1);
		g[v - 1].push_back(u - 1);
	}

	return true;
}

int dfs(int v, int pr)
{
	int gr = 0;
	
	for (auto to : g[v])
		if (to != pr)
			gr ^= dfs(to, v);

	return gr + 1;
}

void solve()
{
	if (dfs(0, -1) == 1)
		printf("Bob\n");
	else
		printf("Alice\n");
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int a[5];
signed main(){
  rep(i,3)cin >> a[i];
  if(a[0] == a[1] and a[1] == a[2])cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}





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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	float x, y;
	cin >> x >> y;
	float crane = ((4*x) - y)/2;
	float turtle = x - crane;
	int c = crane;
	int t = turtle;
	if(crane == c && turtle == t && crane >= 0 && turtle >= 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int h[110], H[110];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> h[i];
	int ans = 0;
	while (true) {
		bool out = true;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (H[i] < h[i]) {
				out = false;
				H[i]++;
				cnt++;
			}
			else {
				if (cnt != 0) break;
			}
		}
		if (out) break;
		else ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys

#fin = open("test.txt", "r")
fin = sys.stdin

while True:
	[n, x] = list(map(int, fin.readline().split()))

	if n == 0 and x == 0:
		break

	counter = 0
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			for k in range(j + 1, n + 1):
				if i + j + k == x:
					counter += 1

	print(counter)

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

int main() {
    int n, y;
    cin >> n >> y;
    int a = -1, b = -1, c = -1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (k >= 0 && i * 10000 + j * 5000 + k * 1000 == y) {
                a = i, b = j, c = k;
                goto ANS;
            }
        }
    }
    ANS:
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1100000000;
 
int main() {
  int n,k,h[110000];
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> h[i];

  vector<long> dp(n, INF);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2; i < n; i++) {
    for(int j = 1; j < k+1; j++) {
      if(i >= j)
        dp[i] = min(dp[i-j] + abs(h[i]-h[i-j]), dp[i]);
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4584
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct edge
{
    int y;
    edge * next;
};
edge * li[100005];
edge * new_edge()
{
    static edge a[200005];
    static int top=0;
    return &a[top++];
}
void inserts(int x,int y)
{
    edge * t=new_edge();
    t->next=li[x];
    t->y=y;
    li[x]=t;
}
void insert_edge(int x,int y)
{
    inserts(x,y);
    inserts(y,x);
}
long long val[100005];
long long tag[100005];
long long sum2[100005];
int deg[100005];
int fa[100005];
void dfs(int x)
{
    edge * t;
    int sum=0;
    for (t=li[x];t!=0;t=t->next)
    {
        if (t->y==fa[x]) continue;
        fa[t->y]=x;
        dfs(t->y);
        if (deg[t->y]>1)
        {
            val[x]-=sum2[t->y]*2;
            sum2[x]+=sum2[t->y];
        }
        sum++;
    }
    if (sum==0)
    {
        tag[x]=val[x];
    }
    if (fa[x]!=-1)
    {
        tag[fa[x]]+=tag[x];
    }
    if (sum!=0)
    {
        val[x]-=tag[x];
    }
    tag[x]=0;
    sum2[x]+=val[x];
}
int res=0;
void dfs2(int x)
{
    edge * t;
    int sum=0;
    long long sum_val=0;
    long long max_val=0;
    for (t=li[x];t!=0;t=t->next)
    {
        if (t->y==fa[x]) continue;
        dfs2(t->y);
        sum++;
        sum_val+=tag[t->y];
        max_val=max(max_val,tag[t->y]);
    }
    if (sum==0)
    {
        tag[x]=val[x];
        return;
    }
    if (val[x]>0)
    {
        res=-1;
    }
    if (val[x]+(sum_val-max_val)<0)
    {
        res=-1;
    }
    if (val[x]+(sum_val/2)<0)
    {
        res=-1;
    }
    sum_val+=val[x]*2;
    tag[x]=sum_val;
    return;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        int t;
        scanf("%d",&t);
        val[i]=t;
    }
    int root=-1;
    for (i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x--;
        y--;
        deg[x]++;
        deg[y]++;
        if (deg[x]>=2) root=x;
        if (deg[y]>=2) root=y;
        insert_edge(x,y);
    }
    if (n==2)
    {
        if (val[0]==val[1])
        {
            puts("YES");
        }
        else
        {
            puts("NO");
        }
        return 0;
    }
    fa[root]=-1;
    dfs(root);
    dfs2(root);
    if (tag[root]!=0) res=-1;
    if (res==-1)
    {
        puts("NO");
    }
    else
    {
        puts("YES");
    }
    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <cmath>
#include <bitset>
#include <random>
#include <ctime>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int a = 0,w = 0,t = 0,r = 0;
    rep(i,n) {
        string s;
        cin >> s;
        if(s == "AC") a++;
        else if(s == "WA") w++;
        else if(s == "TLE") t++;
        else r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<int> c(n + 1, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;
    c[a]++, c[b]--;
  }
  rep(i, n){
    c[i + 1] += c[i];
  }
  rep(i, n){
    if(c[i] == m)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
typedef pair<int,int>P;
int s[100011],ans,n;
main(){
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];
	r(i,n-1){
		if(a[i]==1+i){
			swap(a[i],a[i+1]);
			ans++;
		}
	}
	if(a[n-1]==n)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct Edge{
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
};


ll bfs(Graph &g, ll sn, ll n){
    vi num(n, 0);
    queue<ll> que;
    que.push(sn);
    num[sn] = 1;
    ll maxVertex = -1;

    // その時点での頂点から直接到達可能な頂点に+1の番号を振る
    // 矛盾が生じた時点で-1を返す
    while(que.size()){
        auto node = que.front();
        que.pop();
        for(auto &edge: g.node[node]){
            // 未訪問なら
            if(num[edge.dst] == 0){
                num[edge.dst] = num[node] + 1;
                que.push(edge.dst);
                chmax(maxVertex, num[edge.dst]);
            }
            // 既に追加済みなら
            else{
                // 隣接部分と集合番号が一致したら矛盾
                if(num[edge.dst] == num[node]) return -1;
            }
        }
    }

    return maxVertex;
}   

int main(){
    Init();
    ll n;
    cin >> n;
    Graph g(n);
    vector<string> s(n);
    rep(i, n){
        // 隣接リストの入力
        cin >> s[i];
        // 次数のカウントと辺の追加
        ll cnt = 0;
        rep(j, n){
            if(s[i][j] == '0') continue;
            cnt++;
            if(j <= i) continue;
            g.addEdge(i, j, 1);
        }
    }
    ll ans = -2;
    for(ll i=0; i<n; i++) chmax(ans, bfs(g, i, n));
    cout << ans << endl;
}

Measured memory_bytes: 4960
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
    
public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int D,N;
static int[] T,A,B,C;
static int[][] dp;

public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
D=ir.nextInt();
N=ir.nextInt();
T=ir.toIntArray(D);
A=new int[N];
B=new int[N];
C=new int[N];
for(int i=0;i<N;i++){
A[i]=ir.nextInt();
B[i]=ir.nextInt();
C[i]=ir.nextInt();
}
dp=new int[D][N];
for(int i=0;i<D-1;i++) Arrays.fill(dp[i],Integer.MIN_VALUE);
for(int i=D-2;i>=0;i--){
for(int j=N-1;j>=0;j--){
if(T[i]>=A[j]&&T[i]<=B[j]){
for(int k=0;k<N;k++){
if(T[i+1]>=A[k]&&T[i+1]<=B[k]&&dp[i+1][k]>=0) dp[i][j]=Math.max(dp[i][j],dp[i+1][k]+Math.abs(C[k]-C[j]));
}
}
}
}
int ans=0;
for(int i=0;i<N;i++) ans=Math.max(ans,dp[0][i]);
out.println(ans);
out.flush();
}

static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;

public InputReader(InputStream in) {this.in=in;}
  
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}

public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}

public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
 
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
}

Measured memory_bytes: 20760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[205]={0};

ll cal(ll n){
	if(n==0 || n==1){return 0;}
  if(dp[n]!=0){return dp[n];}
  ll x=n*(n-1)/2;
  dp[n]=x;
  return dp[n];
  	

}
int main(){
ll n,m;
  cin>>n>>m;
  cout<<cal(n)+cal(m);
return 0;
}

Measured memory_bytes: 256
a = list(map(int,list(input())))
ans = 0
b = 0
c = [0 for i in range(2019)]
c[0] = 1
for i in range(len(a)):
  b = (b+pow(10,len(a)-i,2019)*a[i])%2019
  c[b] += 1
c = list(map(lambda x:x*(x-1)//2,c))
ans = sum(c)
print(ans)

  

Measured memory_bytes: 86828
import string
# -*- coding: utf-8 -*-
# 整数の入力
n=int(input())
S=[]
for i in range (0,n):
  S.append(input())

count=0
ans=""
for c in range(97,97+26):
  a=S[0].count(chr(c))
  for i in range(0,n):
    a=min(a,S[i].count(chr(c)))
  for i in range (0,a):
    ans+=chr(c)
print(ans)


Measured memory_bytes: 3768
k,a,b=map(int,input().split())
if a+2>=b or a>=k:
  print(1+k)
  exit()
k-=(a+1)
if k==1:
  print(b+1)
elif k%2==0:
  print(int(b+(b-a)*(k//2)))
else:
  print(int(b+(b-a)*((k-1)//2)+1))

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=3e5+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int cntx[N],cnty[N],x[N],y[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    int mx=0,my=0;
    for(int i=1;i<=k;++i)
    {
        cin>>x[i]>>y[i];
        cntx[x[i]]++;mx=max(mx,cntx[x[i]]);
        cnty[y[i]]++;my=max(my,cnty[y[i]]);
    }
    ll t1=0,t2=0,t=0;
    for(int i=1;i<=n;++i) if(cntx[i]==mx) t1++;
    for(int i=1;i<=m;++i) if(cnty[i]==my) t2++;
    t=t1*t2;
    for(int i=1;i<=k;++i)
    {
        if(cntx[x[i]]==mx&&cnty[y[i]]==my) t--;
    }
    if(t) cout<<mx+my<<endl;
    else cout<<mx+my-1<<endl;
    return 0;
}



Measured memory_bytes: 8308
#include<iostream>

using namespace std;

int main(){
	
	int S=0;
	double q=0;
	char conma;
	int v,n;
	double count=0;
	
	
	while(cin>>v>>conma>>n){
		if(v!=n!=0){
		S+=v*n;
		q+=n;
		count++;
		}
		else
			break;
	}
	if(count!=0){
		int f=q/count+0.5;
	cout<<S<<endl;
	cout<<f<<endl;
	}
	else{
		cout<<S<<endl;
		cout<<q<<endl;
	}
		
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) {
			string t=s;
			if(t.erase(i,j)=="keyence") {
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * author: Behradm
 * Created: 2020.08.29 13:50:28
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << '\n'; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  vector<string> res;
  for (int i = 0; i <= (int) s.size() - (int) t.size(); i++) {
    string ans;
    for (int j = i; j < i + (int) t.size(); j++) {
      ans += s[j];      
    }

    res.emplace_back(ans);
  }


  int ans = (int) t.size();
  for (int i = 0; i < (int) res.size(); i++) {
    int q = 0;
    int go = 0;
    for (int j = 0; j < (int) res[i].size(); j++) {
      if (res[i][j] != t[q]) {
        go += 1;
      }
      q += 1;
    }

    ans = min(ans, go);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	char sChar[N * 2 + 1];
	S.copy(sChar, N * 2);

	int sBW[N * 2];

	// 初期化＆奇数番目を反転
	REP(idx, N * 2) {
		if (sChar[idx] == 'B') {
			// Black
			sBW[idx] = 0;
		} else {
			// White
			sBW[idx] = 1;
		}
		if (idx % 2 != 0) {
			// 奇数番目のマス目は反転する
			sBW[idx] = 1 - sBW[idx];
		}
	}

	// B-W(L-R)の組み合わせ算出
	llong cnt = 1;
	int haveL = 0;
	REP(idx, N * 2) {
		if (sBW[idx] == 0) {
			// L個数足す
			++haveL;
		} else {
			// カウントにLの個数かける
			cnt = cnt * haveL % IMAX;
			// L個数引く
			--haveL;
		}
		if (haveL < 0) {
			// 負になったら解なし
			cout << "0" << endl;
			return 0;
		}

	}

	if (haveL != 0) {
		// B-Wの個数が合ってない時も解なし
		cout << "0" << endl;
		return 0;
	}

	// 最後に N! をかける
	FOR(idx, 1, N) {
		cnt = cnt * idx % IMAX;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1540
#include<iostream>
#include<vector>

int main(){
    int a,over;
    std::cin>>a;
    long double count;
    count=1;
    over=0;
    std::vector<long long int> b(a);
    for(int i=0;i<a;i++){
        std::cin>>b[i];
        if(b[i]==0){
            count=0;
        }
//        std::cout<<count<<std::endl;
    }
//    std::cout<<count<<std::endl;
    if(count==0){
        std::cout<<0<<std::endl;
    }else{
        for(int i=0;i<a;i++){
            if(count/1000000000*b[i]/1000000000>1){
                over=-1;
                break;
            }
            count=count*b[i];
//            std::cout<<count<<std::endl;
        }
//        std::cout<<count<<std::endl;
        long long int c;
        c=count;
        if(over==-1){
            std::cout<<-1<<std::endl;
        }else {
            std::cout<<c<<std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4048
#include <cstdio>
#include <iostream>
#include <algorithm>

int main(){
    int n,m,x,y;
    scanf("%d %d %d %d", &n, &m, &x, &y);
    int pos_x[n];
    int pos_y[m];
    for(int i=0; i<n; i++){ scanf("%d", &pos_x[i]); }
    for(int j=0; j<m; j++){ scanf("%d", &pos_y[j]); }

    int min_pos=x, max_pos=y;
    for(int i=0; i<n; i++){
        if(min_pos < pos_x[i]){
            min_pos = pos_x[i]; 
        }
    }
    for(int i=0; i<m; i++){
        if(pos_y[i] < max_pos){
            max_pos = pos_y[i]; 
        }
    }

    //std::cout << min_pos << "<" << max_pos << std::endl;

    if(min_pos < max_pos){
        std::cout << "No War" << std::endl;
    }else{
        std::cout << "War" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
'use strict'

const Main = (input) => {
  const tmp = input.trim().split(' ')
  const A = parseInt(tmp[0])
  const B = parseInt(tmp[1])
  const C = parseInt(tmp[2])
  let K = parseInt(tmp[3])

  let ans = 0

  if (K - A >= 0) {
    K = K - A
    ans += 1 * A
  } else if (K - A < 0) {
    ans += 1 * K
    K = 0
  }

  if (K != 0 && (K - B) >= 0) {
    K = K - B
  } else if (K != 0 && (K - B) < 0) {
    K = 0
  }

  if (K != 0 && (K - C) >= 0) {
    K = K - C
    ans -= (1 * C)
  } else if (K != 0 && (K - C) < 0) {
    ans -= (1 * K)
  }

  let result = ans

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29792
list1=list(map(int,input().split()))
a=list1[0]
b=list1[1]
c=list1[2]
x=list1[3]
y=list1[4]
if x >= y:
    p = min(a * x + b * y , c * 2 * x , c * 2 * y + a * (x - y))
else:
    p = min(a * x + b * y , c * 2 * y , c * 2 * x + b * (y - x))
print(p)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 998244353;

int main() {
  int N,M;cin >> N >> M;
  bool g[N][N];
  repeat(i,N){
    fill(g[i],g[i]+N,true);
  }
  repeat(i,N){
    g[i][i] = false;
  }
  /*
  repeat(i,N){
    repeat(j,N){
      cerr << g[i][j] << " ";
    }
    cerr << endl;
  }
  */
  repeat(i,M){
    int A,B;cin >> A >> B;A--;B--;
    g[A][B] = g[B][A] = false;
  }
/*
  repeat(i,N){
    repeat(j,N){
      cerr << g[i][j] << " ";
    }
    cerr << endl;
  }
*/
  vint color(N,0);
  vector<Pii> a;
  queue<int> Q;
  bool isok = true;
  repeat(i,N){
    if(color[i] != 0) continue;
    color[i] = i+1;
    int s[2]={0,0};
    Q.push(i);
    while(!Q.empty()){
      int u = Q.front();
      Q.pop();
      s[color[u]>0]++;
      repeat(j,N){
        if(g[u][j]){
          if(color[j]==0){
            color[j] = -color[u];
            Q.push(j);
          }else if(color[j]!=-color[u]){
            isok = false;
          }
        }
      }
    }
    a.push_back({s[0],s[1]});
  }
  //debugArray(color,N);
  if(!isok){
    cout << -1 << endl;
    return 0;
  }
  /*
  for(auto aa:a){
    cerr << aa.first << " " << aa.second << endl;
  }
  */
  bool dp[N+1][N+1];
  repeat(i,N+1){
    fill(dp[i],dp[i]+N+1,false);
  }
  dp[0][0] = true;
  repeat(i,a.size()){
    repeat(j,N+1){
      dp[i+1][j] = (j>=a[i].first&&dp[i][j-a[i].first])
                    ||(j>=a[i].second&&dp[i][j-a[i].second]);
    }
  }
  //debugArray(dp[3],N+1);
  ll ans=INF;
  repeat(i,N+1){
    if(dp[a.size()][i]){
      ans = min(ans,(i*(i-1)+(N-i)*(N-i-1))/2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280