akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

int main(){
  int n; cin >> n;
  vl x(n);
  rep(i, n) cin >> x[i];

  COMinit();

  vl s(n-1);
  s[0] = 1;
  rep(i,n-2) {
    s[i+1] = (s[i] + inv[i+2])%MOD;
  }
  
  ll ans = 0;
  rep(i,n-1) {
    ans = (ans + (x[i+1] - x[i])*s[i])%MOD;
  }
  ans = (ans * fac[n-1])%MOD;

  cout << ans << endl;
}

Measured memory_bytes: 13824
#include <stdio.h>

char a,b;
int c,d;

int main(){
	scanf("%c %c",&a,&b);
	if(a=='H'){
		c=1;
	}else{
		c=-1;
	}
	if(b=='H'){
		d=1;
	}else{
		d=-1;
	}
	if(c*d>0){
		printf("H\n");
	}else{
		printf("D\n");
	}
}

Measured memory_bytes: 128
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	sort(a,a+n);
	int ret=0;
	for(int l=0,r=0;l<n;l=r) {
		while(r<n&&a[l]==a[r]) ++r;
		int cnt=r-l,x=a[l];
		if(cnt<x) ret+=cnt; else ret+=cnt-x;
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  string s;
  cin >> s;
  int pos = 0;

  reverse(s.begin(), s.end());
  for (int k = 0; k < 4; k++) reverse(divide[k].begin(), divide[k].end());

  while (pos < (int)s.length()) {
    bool flag = false;
    for (int k = 0; k < 4; k++) {
      string d = divide[k];
      if ((int)s.find(d, pos) == pos) {
        pos += d.length();
        flag = true;
      }
    }
    if (flag != true) break;
  }

  if (pos == (int)s.length()) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

int main() {
	// your code goes here
	int x,i,ans;
	for(i=0;i<5;i++)
	{
		cin>>x;
		if(x==0)
		ans=i;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int d[100005];

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

  sort(d, d + n);
  
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}




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

public class Main {
    static Scanner sc;

    final static int INF = Integer.MAX_VALUE;

    static int M;
    static int P;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        while (true) {
            M = sn();
            int T = sn();
            P = sn();
            int R = sn();
            if ((M | T | P | R) == 0) {
                break;
            }
            Team[] teams = new Team[T];
            for (int i = 0; i < T; i++) {
                teams[i] = new Team(i, P);
            }
            for (int i = 0; i < R; i++) {
                int m = sn();
                int t = sn();
                int p = sn();
                int j = sn();
                teams[t - 1].addScore(p, m, j == 0);
            }

            for (int i = 0; i < T; i++) {
                teams[i].calc();
            }
            Arrays.sort(teams, new Comparator<Team>() {
                @Override
                public int compare(Team o1, Team o2) {
                    if (o1.getSucsessNum() != o2.getSucsessNum()) {
                        return o2.getSucsessNum() - o1.getSucsessNum();
                    }
                    if (o1.time != o2.time) {
                        return o1.time - o2.time ;
                    }
                    return o2.id - o1.id;

                }
            });

            for (int i = 0; i < T; i++) {
                System.out.print(teams[i].id);
                if (i != T - 1) {
                    System.out.print((teams[i + 1].point() == teams[i].point()) ? "=" : ",");
                }
            }
            System.out.println();
        }
    }

    public static void solve(int w, int h) {

    }

    public static int sn() {
        return sc.nextInt();
    }

    static class Team {
        public int[] penarlty;
        public boolean[] sucsess;
        public int time;
        public int id;

        public Team(int id, int n) {
            this.id = id + 1;
            this.time = 0;
            this.penarlty = new int[n];
            this.sucsess = new boolean[n];
            Arrays.fill(this.penarlty, 0);
            Arrays.fill(this.sucsess, false);
        }

        public void addScore(int n, int time, boolean isScusess) {
            this.sucsess[n - 1] |= isScusess;
            if (this.sucsess[n - 1]) {
                this.time += time;
            } else {
                this.penarlty[n - 1]++;
            }
        }

        public void calc() {
            for (int i = 0; i < this.sucsess.length; i++) {
                if (sucsess[i]) {
                    this.time += this.penarlty[i] * 20;
                }
            }
        }

        public int getSucsessNum() {
            int sum = 0;
            for (boolean b : this.sucsess) {
                sum += b ? 1 : 0;
            }
            return sum;
        }

        public int point() {
            return this.getSucsessNum() * M * P + this.time;
        }
    }
}

Measured memory_bytes: 60872
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n),b;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  vector<pair<int,int> > p(m);
  for(int i=0;i<m;i++){
    int bb,c;
    cin>>bb>>c;
    p[i]=make_pair(c,bb);
  }
  sort(all(p));
  per(i,m){
    int co=p[i].fi;
    rep(j,p[i].se){
	 b.pb(co);
	 if(b.size()==n)break;
    }
    if(b.size()==n)break;
  }
  for(int i=0;i<n;i++)b.pb(0);
  int ans=0;
  rep(i,n){
    // cout<<a[i]<<" "<<b[i]<<endl;
    ans+=max(a[i],b[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4724
n = int(input())
a = [ int(i) for i in input().split() ]
start = 0
for i in range(n-1,-1,-1):
    if i % 2 == 0:
        start += a[i]
    else:
        start -= a[i]

ans = [start]
for i in range(0,n-1):
    ans.append( 2 * a[i] - ans[-1] )
for i in ans:
    print(i,end=" ")
print()


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

int factorial(int n) {
  if (n == 0)
    return 1;
  
  return n*factorial(n-1);
}

int calcOrder(int n, std::vector<int>& vec) {
  int numOrder = 1;
  for (int i = 0; i < n; i++) {
	int count = 0;
    for (int j = 0; j < i; j++) {
      if (vec[j] < vec[i])
        count++;
    }
	numOrder += factorial(n-i-1)*(vec[i]-1-count);
  }
  return numOrder;
}

int main() {
  int n;
  std::cin >> n;
  
  std::vector<int> p(n), q(n);
  for (int i = 0; i < n; i++)
    std::cin >> p[i];
  
  for (int i = 0; i < n; i++)
    std::cin >> q[i];

/*  std::cout << "p = {";
  for (int i = 0; i < n; i++) {
    std::cout << p[i] << ", ";
  }
  std::cout << " }" << std::endl;
  std::cout << "order of p = " << calcOrder(n,p) << std::endl;
  
  std::cout << "q = {";
  for (int i = 0; i < n; i++) {
    std::cout << q[i] << ", ";
  }
  std::cout << " }" << std::endl;
  std::cout << "order of q = " << calcOrder(n,q) << std::endl;
*/
  std::cout << std::abs(calcOrder(n,p) - calcOrder(n,q)) << std::endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i;
  int n;
  int ans=0;
  scanf("%d",&n);
  int l[n],r[n];
  for(i=0;i<n;i++){
    scanf("%d%d",&l[i],&r[i]);
  }
  for(i=0;i<n;i++){
    ans+=r[i]-l[i]+1;
  }
  // printf("%d%d\n",l)
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)


int main(){
	int n;
	cin >> n;
	if (n % 1000 == 0) { cout << 0 << endl; }
		else cout << 1000 - (n % 1000) << endl;


	return 0;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }




    public class Test
    {
        public static void Run()
        {
            Input input = new Input(' ');
            input.ReadLine();
            int A = input.Next<int>();
            int B = input.Next<int>();
            int C = input.Next<int>();
            Console.WriteLine(Math.Min(C, B / A));
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}

Measured memory_bytes: 11220
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e,H, W;
long long A[12][20] = {};
long long B[200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;
vector <pl>vpl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

void sai(int kaime) {
	for (int ii = 0; ii < 2; ii++) {
		
		
		for (int j = 0; j <= M; j++) {
			C[kaime][j] = 0;
		}
		

		for (int jj = 0; jj < M; jj++) {
			f = false;
			if (kaime > 0) {
				C[kaime][jj] = C[kaime - 1][jj];
			}

			for (int j = 0; j < A[jj][0]; j++) {
				if (kaime + 1 == A[jj][j+1]) {
					f = true;
				}
			}

			if (ii == 1 && f==true) {
				C[kaime][jj]++;
			}
		}

		if (kaime == N - 1) {
			a = 1;
			for (int j = 0; j < M; j++) {
				if (C[kaime][j] % 2 != B[j]) {
					a = 0;
				}
			}
			if (a == 1) {
				b++;
			}

		}
		else {
			sai(kaime + 1);
		}
	}
}

vector <ST> vst;
double fl, fll;


int main() {

	cin >>N>>M;
	b = 0;
	
	for (int i = 0; i < M; i++) {
		cin >> A[i][0];
		for (int j = 0; j < A[i][0]; j++) {
			cin >> A[i][j + 1];
		}
	}

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

	sai(0);
	
	cout << b << endl;

	return 0;

}


Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(w: i32);
	input!(a: i32);
	input!(b: i32);

	let ans;
	let d = (b-a).abs();
	if d <= w {
		ans = 0;
	}
	else {
		ans = d - w;
	}
	println!("{}", ans);
}



Measured memory_bytes: 2116
s = input()
n = len(s)
if s != s[::-1]:
  print('No')
else:
  s_1 = s[0:(n-1)//2]
  s_2 = s[(n+1)//2:n]
  if s_1 == s_1[::-1] and s_2 == s_2[::-1]:
    print('Yes')
  else:
    print('No')

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

int INF = 1e9 + 5;

int main()
{
    int n;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        if (i % 2 == 0)
        {
            even[num]++;
        }
        else
        {
            odd[num]++;
        }
    }
    int e = -1, e2 = -1, o = -1, o2 = -1;
    for (auto i : even)
    {
        if (i.second >= even[e])
        {
            e2 = e;
            e = i.first;
        }
        else if (i.second >= even[e2])
        {
            e2 = i.first;
        }
    }
    for (auto i : odd)
    {
        if (i.second >= odd[o])
        {
            o2 = o;
            o = i.first;
        }
        else if (i.second >= odd[o2])
        {
            o2 = i.first;
        }
    }
    if (e != o)
    {
        cout << n - even[e] - odd[o] << endl;
    }
    else
    {
        cout << min(n - even[e] - odd[o2], n - even[e2] - odd[o]) << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
(defun main ()
  (let* ((k (read))
	 (a (read))
	 (b (read)))
    (format t "~A~%"
	    (if 
	      (or (>= (+ (- b a k) 1) 0)
		  (> (rem a k) (rem b k))
		  (zerop (rem a k))) "OK" "NG"))))

(main)


Measured memory_bytes: 23488
#import<iostream>
#import<atcoder/all>
int i,N,Q,w,e,r;long a;using namespace std;int main(){cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i<N;i++)cin>>a,b.add(i,a);while(Q--){cin>>w>>e>>r;if(w)cout<<b.sum(e,r)<<'\n';else b.add(e,r);}}

Measured memory_bytes: 8204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  int x = 0;
   cin >> N;

  if (N =="Sunny") {
    cout << "Cloudy" << endl;}
    if (N =="Cloudy") {
    cout << "Rainy" << endl;}
    if (N =="Rainy") {
    cout << "Sunny" << endl;}
  
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm> 

using namespace std;

int main(){


		unsigned long long a[3];

	for(int i=0; i<3; i++)cin >> a[i];
	sort(a,a+3);
	

	if(a[0]*a[1]*a[2]%2 ==  0) cout << 0 << endl;

	else cout << a[0]*a[1]<< endl;

}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	b := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	for i := 0; i < N; i++ {
		b[i] = getInt()
	}
	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = a[i] - b[i]
	}
	sort.Ints(c)

	l := 0
	r := N - 1
	d := 0
	cnt := 0
	for {
		if c[l] >= 0 {
			break
		}
		d += c[l]
		l++
		cnt++
		for d < 0 {
			if c[r] <= 0 {
				out(-1)
				return
			}
			d += c[r]
			r--
			cnt++
		}
	}
	out(cnt)
}


Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int main(){
	int n,S[10000],q,T[500],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(int i=0;i<q;i++)cin>>T[i];
	for(int i=0;i<q;i++){
		for(int i2=0;i2<n;i2++){
			if(S[i2]==T[i]){
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s,t;
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t),greater<char>());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,mas[105][105],a,b,aa;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n >> m;
    cout << "100 100\n";
    n--;
    m--;
    i=0;
    while (i<50)
    {
        j=0;
        while (j<100)
        {
            mas[i][j]=1;
            j++;
        }
        i++;
    }
    i=0;
    while (i<n)
    {
        a=i%50;
        b=i/50;
        mas[b*2+1][a*2+1]=0;
        i++;
    }
    i=0;
    while (i<m)
    {
        a=i%50;
        b=i/50;
        mas[b*2+51][a*2+1]=1;
        i++;
    }
    i=0;
    while (i<100)
    {
        j=0;
        while (j<100)
        {
            if (mas[i][j]==0)
            {
                cout << ".";
            }
            else
            {
                cout << "#";
            }
            j++;
        }
        cout << "\n";
        i++;
    }
    return 0;
}


Measured memory_bytes: 256
i = input().split(' ')
A = int(i[0])
B = int(i[1])

for x in range(1,10000000):
    B_hat = int(x/10)
    if B_hat>100:
        break
    if int(x*2/25)==A and B_hat==B:
        print(x)
        exit()
print(-1)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

double dp[301][301][301];
bool done[301][301][301];

double rec(int N, int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0) { return dp[a][b][c] = 0.0; }
  if (done[a][b][c]) { return dp[a][b][c]; }
  done[a][b][c] = true;
  double X = 1;
  if (a > 0) X += rec(N,a-1,b,c) * a / N;
  if (b > 0) X += rec(N,a+1,b-1,c) * b / N;
  if (c > 0) X += rec(N,a,b+1,c-1) * c / N;
  return dp[a][b][c] = X * N / (a+b+c);
}

int main2() {
  int N = nextInt();
  int count[4] = {};
  REP(i, N) {
    int a = nextInt();
    count[a]++;
  }
  CLR(done, 0);
  double ans = rec(N, count[1], count[2], count[3]);
  printf("%.10f\n", ans);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 239872
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(M);
    vector<int> d(M);
    vector<int> ans(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i) >> b.at(i);
    }
    for(int i = 0; i < M; i++){
        cin >> c.at(i) >> d.at(i);
    }
    for(int i = 0; i < N; i++){
        int m = 999999999;
        int mIndex = -1;
        for(int j = 0; j < M; j++){
            int dist = abs(c.at(j) - a.at(i)) + abs(d.at(j) - b.at(i));
            if(dist < m){
                m = dist;
                mIndex = j;
            }
        }
        ans.at(i) = mIndex+1;
    }
    for(int i = 0; i < N; i++){
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll dp[100000];
ll a[10000];
ll b[10000];

void solve()
{
    IN(h, n);
    vector<pair<ll,ll>> p;
    rep(i, n)
    {
        cin >> a[i] >> b[i];
        p.emplace_back(b[i], a[i]);
    }
    sort(all(p));
    dp[0] = 0;
    reps(i, 1, h+1)
    {
        dp[i] = INF;
    }
    rep(i, h+1)
    {
        ll s = 1;
        rep(j, n)
        {
            reps(k, s, p[j].second+1)
            {
                chmin(dp[i+k], dp[i] + p[j].first);
            }
            s = p[j].second + 1;
        }
    }
    cout << dp[h] << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

bool is_integer(double A){
    if(floor(A) == A){
        return true;
    }
    else{
        return false;
    }
}

//10:35 A 10:37
//10:38 B
int main()
{
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 0; i < s.size(); i++)
    {
        if(i%2 == 0){
            if (!(s[i] == 'R' || s[i] == 'D' || s[i] == 'U'))
            {
                flag = true;
                }
        }
        else{
            if (!(s[i] == 'L' || s[i] == 'D' || s[i] == 'U'))
            {
                flag = true;
            }
        }
    }
    if(flag == false){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N,X;
  cin>>N>>X;
  double ans = 0;
  for(int i = 1;i<=N;i++){
    double tw = 1;
    double p = i;
    while(p<X){
      p *= 2;
      tw *= 2;;
    }
    ans += 1/(N*tw);
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Character> stack = new Stack<Character>();
		String s = sc.next();
		for(int i=0;i<s.length();i++) {
			if (s.charAt(i)=='B') {
				if (stack.isEmpty()==false) {
					stack.pop();
				}
			} else {
				stack.add(s.charAt(i));
			}
		}
		Stack<Character> result = new Stack<Character>();
		while (stack.isEmpty()==false) {
			Character c = stack.pop();
			result.add(c);
		}
		while (result.isEmpty()==false) {
			System.out.print(result.pop());
		}
	}
}

Measured memory_bytes: 21972
n = int(input())
d1 = []
d2 = []
for i in range(n):
    dice1, dice2 = map(int, input().split())
    d1.append(dice1)
    d2.append(dice2)
count = 0
for i in range(n - 1):
    if (d1[i] == d2[i]) and (d1[i + 1] == d2[i + 1]):
        count += 1
    else:
        count = 0
    if count == 2:
        print('Yes')
        break
if count != 2:
    print('No')            


Measured memory_bytes: 9192
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;

int main()
{
	int n,m;
	cin >> n >> m;
	
	int l = 0;
	int r = 1000000;
	for (int i = 0; i < m; i++) {
		int li, ri;
		cin >> li >> ri;

		l = max(l, li);
		r = min(r, ri);
	}

	int ans = r - l + 1;
	ans = max(ans, 0);

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 1)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int ar[3];
	int x, y, z;
	set<int> se;
	cin >> x >> y >> z;
	se.insert (x);
	se.insert (y);
	se.insert (z);
	if (se.size () == 2) { 
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


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

int main() {
  int k;
  cin >> k ;
  
  string s;
  cin >> s;
  
  int size = s.size();
  
  string ans;
  
  if(size<=k)
    ans = s;
  else{
    s.erase(k);
    ans = s+"...";
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

const bool DEBUG=0;
const ll dv[3]={2,3,5};

ll n,cost[3],d;
unordered_map<ll,ll> dist;

void dijkstra(ll src)
{
	pqueue<ii,vii,greater<ii>> q;
	dist[src]=0;
	dist[0]=INF;
	q.push({dist[src],src});
	
	while(!q.empty()){
		ll u=q.top().S; q.pop();
		if(DEBUG) cout<<"u="<<u<<" dist="<<dist[u]<<'\n';
		forn(i,0,3){
			ll v=u/dv[i];
			ll inc=abs(u-v*dv[i])*d+cost[i];
			if(logl(u)+logl(d)<=logl(ll(1e11)) && inc>abs(u-v)*d) inc=abs(u-v)*d;
			if(DEBUG) cout<<"v="<<v<<" dv="<<dv[i]<<" p="<<dv[i]*v<<'\n';
			if(dist.find(v)!=dist.end() && dist[v]<=dist[u]+inc) continue;
			
			dist[v]=dist[u]+inc;
			if(DEBUG) cout<<"dist["<<v<<"]="<<dist[v]<<'\n';
			if(v>0) q.push({dist[v],v});
		}
		
		forn(i,0,3){
			ll v=(u+dv[i]-1)/dv[i];
			ll inc=abs(u-v*dv[i])*d+cost[i];
			if(logl(u)+logl(d)<=logl(ll(1e11)) && inc>abs(u-v)*d) inc=abs(u-v)*d;
			if(DEBUG) cout<<"v="<<v<<" dv="<<dv[i]<<" p="<<dv[i]*v<<'\n';
			if(dist.find(v)!=dist.end() && dist[v]<=dist[u]+inc) continue;
			
			dist[v]=dist[u]+inc;
			if(DEBUG) cout<<"dist["<<v<<"]="<<dist[v]<<'\n';
			if(v>0) q.push({dist[v],v});
		}
	}
}

void solve()
{
	dist.clear();
	cin>>n;
	forn(i,0,3) cin>>cost[i];
	cin>>d;
	dist[n]=0;
	
	dijkstra(n);
	
	cout<<dist[0]<<'\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int t; cin>>t;
	forn(i,0,t) solve();
	
	return 0;
}


Measured memory_bytes: 4216
h, w = map(int, input().split(' '))
a = [list(str(input())) for _ in range(h)]
checker = []
for i in range(len(a)):
    if all(x == '.' for x in a[i]):
        checker.append(i)
    else:
        continue
for i in range(1, len(checker)+1):
    a.pop(checker[-i])
checker = []
for i in range(len(a[0])):
    if all(a[j][i] == '.' for j in range(len(a))):
        checker.append(i)
    else:
        continue
for i in range(1, len(checker)+1):
    for j in range(len(a)):
        a[j].pop(checker[-i])


for i in a:
    print(''.join(i))

Measured memory_bytes: 3188
N,K,C=map(int, input().split())
S=input()

L=[0]*N
R=[0]*N
c=1
last=-C-1
for i in range(N):
    if i-last>C and S[i]!='x' and c<=K:
        L[i]=c
        c+=1
        last=i
c=K
last=N+C
for i in range(N-1,-1,-1):
    if last-i>C and S[i]!='x' and c>=1:
        R[i]=c
        c-=1
        last=i
for i in range(N):
    if 0<L[i]==R[i]: print(i+1)


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

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);
    vector<int> b(n);
    int total=0;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        b.at(i)=(d-1+a.at(i))/a.at(i);
        total+=b.at(i);
    }
    cout << x+total << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> field = new ArrayList<>(Arrays.asList(0,0,0));
		long scoreCount = 0;
		int outCount = 0;
		try {
			int gameNumber = Integer.parseInt(br.readLine());
			while (0 < gameNumber) {
				String line = br.readLine();
				if(line.equals("HIT")) {
					if(field.get(2)==1) {
						scoreCount++;
					}
					field.remove(2);
					field.add(0, 1);
				}else if(line.equals("OUT")) {
					outCount++;
					if (outCount == 3) {
						System.out.println(scoreCount);
						scoreCount = 0;
						outCount = 0;
						field = new ArrayList<>(Arrays.asList(0,0,0));
						gameNumber--;
					}
				}else if(line.equals("HOMERUN")) {
					scoreCount += 1 + field.stream().filter(base -> base==1).count();
					field = new ArrayList<>(Arrays.asList(0,0,0));
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(	(y+r>H)||
		(x-r<0)||
		(y-r<0)||
		(x+r>W)
	){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i];
	sort(all(v));
	ll sum=0;
	for(ll i=0;i<k;i++)
		sum+=v[i];
	cout<<sum<<"\n";
}

Measured memory_bytes: 3624
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s;
    cin >> s;
    rep(i,s.size())
    {
        if(s[i]==',')s[i]=' ';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
from copy import deepcopy
from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

cnt=0
for i in range(m):
  ll=deepcopy(l)
  del ll[i]

  d=[[float('inf')]*n for i in range(n)]
  for i in range(n):
    d[i][i]=0

  for a,b in ll:
    a-=1
    b-=1
    d[a][b]=1
    d[b][a]=1

  s=floyd_warshall(d)
  for i in s:
    if float('inf') in i:
      cnt+=1
      break

print(cnt)

Measured memory_bytes: 15412
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):*a,c=I();R+=[(a,c)];Y+=c,;X+=a
for i in r(m):a,*b=I();H+=[(a,b)];X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)+1
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*(K+1)for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

Measured memory_bytes: 551484
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)
int H,W,N;
bool fie[111][111];

int ix,iy,ox,oy;

struct state{
  int x,y;
};
int memo[111][111];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

bool check(int cx,int cy,int nx,int ny){
  if( nx < 0 || ny < 0 || nx > 2*W || ny > 2*H ) return false;
  if( fie[cx][cy] ) return false;
  if( memo[nx][ny] == -1 ) return true;
  return false;
}

int bfs(){
  memset(memo,-1,sizeof(memo));
  queue<state> q;
  q.push( (state){ix,iy} );
  memo[ix][iy] = 0;
  while( !q.empty() ){
    state p = q.front(); q.pop();
    assert(p.x%2&&p.y%2);
    if( p.x == ox && p.y == oy ) return memo[p.x][p.y];
    for(int i=0;i<4;i++){
      int cx = p.x + dx[i], cy = p.y + dy[i];
      int nx = p.x + dx[i] * 2, ny = p.y + dy[i] * 2;
      if( check(cx,cy,nx,ny) ){
        q.push((state){nx,ny});
        memo[nx][ny] = memo[p.x][p.y] + 1;
      }
    }
  }
  return -1;
}

void view(){
  cout << "view" << endl;
  for(int i=2*H;i>=0;i--){
    for(int j=0;j<=2*W;j++){
      if( j == ix && i == iy ) cout << "s";
      else if( j == ox && i == oy ) cout << "e";
      else cout << fie[j][i];
    }
    cout << endl;
  }
}

int main(){
  cin >> W >> H >> N;
  for(int i=0;i<=2*W;i++){
    fie[i][0] = 1; fie[i][2*H] = 1;
  }
  for(int i=0;i<=2*H;i++){
    fie[0][i] = 1; fie[2*W][i] = 1;
  }

  for(int i=0;i<N;i++){
    int sx,sy,dx,dy;
    cin >> sx >> sy >> dx >> dy;
    if( sx == dx ){
      if( sy > dy )swap(sy,dy);
      sy *= 2; dy *= 2; dx *= 2;
      for(int y=sy;y<=dy;y++)
        fie[dx][y] = 1;      
    } else {
      assert(sy==dy);
      if( sx > dx ) swap(sx,dx);
      sx *= 2; dx *= 2; dy *= 2;
      for(int x=sx;x<=dx;x++)
        fie[x][dy] = 1;
    }
  }

  cin >> ix >> iy >> ox >> oy;
  ix*=2; iy*=2; ox*=2; oy*=2;
  ix++; iy++; ox++; oy++;


  
  int rev = bfs();
  int res = rev;
  
  for(int i=0;i<2*H;i+=2){
    for(int j=0;j<2*W;j+=2){
      if( !fie[j+1][i] ){
        fie[j+1][i] = 1;
        res = max( res, bfs() );
        fie[j+1][i] = 0;    
      }
      if( !fie[j][i+1] ){
        fie[j][i+1] = 1;
        res = max( res, bfs() );
        fie[j][i+1] = 0;
      }
    }
  }
  cout << res - rev << endl;

}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int a = Integer.parseInt(str.substring(0,1));
        int b = Integer.parseInt(str.substring(1,2));
        int c = Integer.parseInt(str.substring(2,3));
        System.out.println(a+b+c);
    }
}


Measured memory_bytes: 23636
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);
	var s = input[1];
	var t = input[2];

	//s=t
	if(N <= s.length && s == t){
		//出力
		console.log(s.length);
		return;
	}
	//s&t	
	var i = 0;
	var count = 0;
	for(;count < s.length || count < t.length;count ++){
		if(s.length + t.length - count == N)break;
		var tmpS = s.substring(s.length - count -1);
		var tmpT = t.substring(0 ,count + 1);
		if(tmpS != tmpT && count >= s.length || tmpS != tmpT && count >= t.length){
			break;
		} else if(tmpS == tmpT) {
			i = tmpT.length;
		}
	}
	if(i > 0){
		console.log(s.length + t.length - i);
		return;
	}

	console.log(s.length + t.length);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20852
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		char[] w = sc.next().toCharArray();

		int[] cnt = new int[26];

		for (char c : w) {
			cnt[c - 'a']++;
		}

		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 != 0) {
				pr.println("No");

				pr.close();
				sc.close();
				return;
			}
		}

		pr.println("Yes");

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int n, k;
vector<vector<int>> adj;

void print(vector<vector<int>> &a) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}

vector<vector<int>> matrix_mult(vector<vector<int>> &a, vector<vector<int>> &b) {
	vector<vector<int>> res(n, vector<int> (n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				res[i][j] += (a[i][k]*b[k][j]) % MOD;
				res[i][j] %= MOD;
			}
		}
	}
	return res;
}

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	cin >> n >> k;
	adj = vector<vector<int>> (n, vector<int> (n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> adj[i][j];
		}
	}
	vector<vector<int>> res(n, vector<int> (n, 0));
	for (int i = 0; i < n; i++) {
		res[i][i] = 1;
	}
	while (k > 0) {
		if (k % 2 == 1) res = matrix_mult(res, adj);
		adj = matrix_mult(adj, adj);
		k /= 2;
	}
	int k_walks = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (res[i][j] != 0) {
				k_walks += res[i][j];
				k_walks %= MOD;
			}
		}
	}

	cout << k_walks << endl;

	return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();


	    System.out.print(Math.max(0, a-2*b));

//        if (N%2==0) {
//        	System.out.print(1/2);
//        } else {
//        	System.out.print(((N+1)/2) /N);
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35300
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 6/19/2020

 16:23-16:58 give up
 17:08 read editorial
 19:52-

 https://twitter.com/hanseilimak/status/1274174857194831873

 */

const int MAX_N=1e6+1;
LL C,X[MAX_N],V[MAX_N];
int N;

LL cum[MAX_N];
LL f() {
  REP(i,N+1) cum[i+1]=cum[i]+V[i];
  vector<LL> left(N+1,0);
  for(int i=N-1; i>=0; --i) {
    left[i]=max(left[i+1],cum[N]-cum[i]-(C-X[i]));
  }

  //dumpc(left);
  LL res=0;
  REPE(r,N) {
    LL base=cum[r]-(r==0?0:X[r-1]);
    SMAX(res,base);
    SMAX(res, base-(r==0?0:X[r-1])+left[r]);
  }
  //dump(res);
  return res;
}
void solve() {
  LL res=f();
  reverse(V,V+N);
  vector<LL> ys(N);
  REP(i,N) ys[i]=C-X[N-i-1];
  REP(i,N)X[i]=ys[i];
  SMAX(res,f());
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>C;
  REP(i,N) cin>>X[i]>>V[i];
  solve();

  return 0;
}


Measured memory_bytes: 7044
let partition (a : int array) p r =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec doit i j =
    if j = r then (swap i r; i)
    else if a.(j) <= a.(r) then (swap i j; doit (i + 1) (j + 1))
    else doit i (j + 1) in
  doit p p

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  print_int a.(0);
  for i = 1 to n - 1 do
    if i = k then (print_string " ["; print_int a.(i); print_string "]")
    else (print_string " "; print_int a.(i))
  done;
  print_newline ()

Measured memory_bytes: 5324
//author : akashksinghal
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
signed main()
{
    fasino
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll x = a*c;
    ll y = a*d;
    ll z = b*c;
    ll o = b*d;
    vector<ll> A={x,y,z,o};
    cout << *max_element(A.begin(),A.end());
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    int s, cnt= 0, a;
    cin>>s;
    if(s == 1 || s == 2)
    {
        cout<<4<<endl;
        return 0;
    }
    else
    {
    while(s != 1)
    {
        if(s%2 == 0) s = s/2;
        else s = 3*s + 1;

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

}



Measured memory_bytes: 3568
class UnionFind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find_root(self, x):
        if self.p[x] != x:
            self.p[x] = self.find_root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def get_size(self, x):
        return self.size[self.find_root(x)]

n = int(input())
xy = [tuple(int(x) for x in input().split()) for _ in range(n)]

sx = set()
sy = set()

for x, y in xy:
    sx.add(x)
    sy.add(y)

dx = dict()
dy = dict()

for i, x in enumerate(sx):
    dx[x] = i

len_x = len(sx)
m = len(sx) + len(sy)

for i, y in enumerate(sy):
    dy[y] = i + len_x


uft = UnionFind(m)

for x, y in xy:
    uft.unite(dx[x], dy[y])

mx = [0] * m
my = [0] * m
for i in range(len_x):
    mx[uft.find_root(i)] += 1
for i in range(len_x, m):
    my[uft.find_root(i)] += 1

ans = 0
for i in range(m):
    ans += mx[i] * my[i]

print(ans - n)

Measured memory_bytes: 35676
"""
AtCoder :: Beginner Contest 176 :: B - Multiple of 9 
https://atcoder.jp/contests/abc176/tasks/abc176_b
"""
import sys


def main():
    """Main program."""
    N = [int(i) for i in sys.stdin.readline().strip()]
    if sum(N) % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10892