akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main(){
  vector<long long> inputs = {0, 0, 0, 0};
  
  for (int i = 0; i < 4; ++i) {
    cin >> inputs.at(i);
  }
  long long ans = ((inputs[3] % 2 == 0)? inputs[0] - inputs[1] : inputs[1] - inputs[0]);
  if (abs(ans) > (long long)pow((long long)10, (long long)18)) {
    cout << "Unfair" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    string S;
    int K;
    cin >> K >> S;
    int N = S.length();
    if (N <= K){
        cout << S << endl;
    }else{
        REP(j,K){
            cout << S[j];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double sum = 0;
        sc.close();
        for(int i = 1 ; i <= n ; i++){
            int a = i;
            double yono = 1;
            while(k > a){
                yono /= 2.0;
                a *= 2;
            }
            sum += yono;
        }
        System.out.println(sum / n);
    }
}

Measured memory_bytes: 35900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
  	int N,M;
  	cin >>N>>M;
  	vector<vector<int>>A(M+1);//ちょうどi日で終わる仕事の報酬のリスト
  	
  	rep(i,N){
    	int a,b;
    	cin >>a>>b;
      	if(a<=M){A[a].push_back(b);}
    }
  	priority_queue<int>X;//報酬の大きい順に取り出したい
  	int score=0;
	for(int i=1;i<=M;i++){
		for(int j=0;j<A[i].size();j++){
        	X.push(A[i][j]);
        }
      	if(!X.empty()){score+=X.top();X.pop();}
    }
  	cout<<score<<endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k,q;
  cin >> n >> k >> q;
  vl point(n,k-q);
  vl a(q);
  rep(i,q){
    cin >> a[i];
    point[a[i]-1]++;
  }
  rep(i,n){
    if(point[i]>0){
      cout << "Yes" << endl;
    }
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 2176
package main

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

func main() {
	ans := -1
	n := readi()
	s := readSlice()
	t := readSlice()
	for i := 0; i < n; i++ {
		if eq(s[n-i-1:], t[:i+1]) {
			ans = i
		}
	}
	if ans == -1 {
		fmt.Println(2 * n)
	} else {
		fmt.Println(2*n - ans - 1)
	}
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	
	if(a + b < 10)
		cout << a + b << endl;
	else
		cout << "error" << endl;
	
 	return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume0
{
    public class BoxingClass
    {
        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                double weight = double.Parse(input);
                string rank = "";
                if (weight <= 48) { rank = "light fly"; }
                else if (weight <= 51) { rank = "fly"; }
                else if (weight <= 54) { rank = "bantam"; }
                else if (weight <= 57) { rank = "feather"; }
                else if (weight <= 60) { rank = "light"; }
                else if (weight <= 64) { rank = "light welter"; }
                else if (weight <= 69) { rank = "welter"; }
                else if (weight <= 75) { rank = "light middle"; }
                else if (weight <= 81) { rank = "middle"; }
                else if (weight <= 91) { rank = "light heavy"; }
                else { rank = "heavy"; }

                Console.WriteLine(rank);
            }
            return 0;
        }
    }
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int f(int n) {
    int c = 0;
    while (n % 2 == 0) n /= 2, c++;
    return c;
}

void solve(ll N, vector<ll> a) {
    int ans = 0;
    for (auto i : a)
        ans += f(i);
    cout << ans << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    vector<ll> a(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> a[i];
    }
    solve(N, a);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#define mod 998244353
using namespace std;
string s;
int f[1000006][3][2][5];
void upd(int& x, int y){
	x += y;
	if (x >= mod)
		x -= mod;
}
int main(){
	cin >> s;
	int n = s.length();
	int sum = 0;
	if (n <= 3){
		if (n == 1)
			cout << 1 << endl;
		if (n == 2){
			if (s[0] == s[1])
				cout << 1 << endl;
			else
				cout << 2 << endl;
		}
		if (n == 3){
            if (s[0] == s[1] && s[1] == s[2])
				cout << 1 << endl;
			else if (s[0] == s[1] || s[1] == s[2])
				cout << 6 << endl;
			else if (s[0] == s[2])
				cout << 7 << endl;
			else
				cout << 3 << endl;
		}
		return 0;
	}
	bool same = false;
	for (int i = 1; i < n; ++ i)
		if (s[i] != s[i - 1]){
			same = true;
			break;
		}
	if (! same){
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < n; ++ i)
		sum = (sum + s[i] - 'a' + 1) % 3;
	f[0][0][0][3] = 1;
	for (int i = 0; i < n; ++ i)
		for (int j = 0; j <= 2; ++ j)
			for (int have = 0; have <= 1; ++ have)
				for (int last = 0; last <= 3; ++ last){
					if (i)
						upd(f[i + 1][(j + last) % 3][1][last], f[i][j][have][last]);
					for (int k = 0; k <= 2; ++ k)
						if (k != last)
							upd(f[i + 1][(j + k) % 3][have][k], f[i][j][have][last]);
				}
	int ans = 0;
	for (int last = 0; last <= 2; ++ last)
		upd(ans, f[n][sum][1][last]);
	bool flag = false;
	for (int i = 1; i < n; ++ i)
		if (s[i] == s[i - 1]){
			flag = true;
			break;
		}
	upd(ans, ! flag);
	cout << ans << endl;
}


Measured memory_bytes: 25092
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;

static const int N = 1000;

int Lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  REP(i, m + 1) c[i][0] = 0;
  REP(j, n + 1) c[0][j] = 0;

  REP1(i, m + 1) {
    REP1(j, n + 1) {
      if ( X[i] == Y[j] ) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  REP(i, n) {
    cin >> s1 >> s2;
    cout << Lcs(s1, s2) << endl;
  }
  return 0;
}

Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  vector<vector<char>> c(3, vector<char>(3));
  for(int i=0; i<3; ++i) for(int j=0; j<3; ++j) cin >> c[i][j];
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[][] ab = new int[n][2];
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    ab[i][0] = a;
		    ab[i][1] = b;
		}
		Arrays.sort(ab, (s, t) -> Integer.compare(s[0], t[0]));
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    k -= ab[i][1];
		    if(k <= 0){
		        result = ab[i][0];
		        break;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 89220
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string s; 
int main(){
	cin>>s;
	if(s.find('F')==std::string::npos){printf("No");return 0;}
	if(s.find('C')<s.rfind('F')) printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;

int main()
{
    long long l, r;
    int mod = 2019;
    cin >> l >> r;
    if(mod>=l&&mod<=r){puts("0");return 0;}
    if(r-l+1>=mod) {puts("0");return 0;}
    int min = 2020;
    for(long long i =l; i < r; ++i)
    {
        for(long long j = i + 1; j <= r; ++j)
        {
            if(((i%mod)*(j%mod))%mod<min)
            {
                min =((i%mod)*(j%mod))%mod;
            }
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<string>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)

static const int NMAX = 2005;
static const int KMAX = 12;

int dp[KMAX+1][NMAX+1];
int T[KMAX+1][NMAX+1]; // max score of n books of genre k
vector<int> G[KMAX];

main(){
  int N, K;
  cin >> N >> K;
  rep(i, KMAX+1) rep(j, K+1) dp[i][j] = T[i][j] = 0;
  rep(i, N){
    int c, g; cin >> c >> g;
    G[g].push_back(c);
  }
  
  REP(i, 1, 11){
    sort(G[i].begin(), G[i].end(), greater<int>());
    for ( int j = 0; j < G[i].size(); j++ ){
      T[i][j+1] = T[i][j] + G[i][j];
    }
    for ( int j = 0; j < G[i].size(); j++ ){
      T[i][j+1] += j*(j+1);
    }
    }

  REP(k, 1, 11){
    REP(j, 1, K+1){
      for ( int l = 1; T[k][l]; l++ ){
	if ( j - l >= 0 )
	  dp[k][j] = max(dp[k][j], dp[k-1][j-l] + T[k][l]);
      }
    }
    rep(i, K+1) dp[k+1][i] = dp[k][i];
  }
  
  cout << dp[10][K] << endl;

  return 0;
}

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

int main() {
  int A, B, C, K;
  
  cin >> A >> B >> C >> K;
  
  while(K!=0){
    if(A>=B){
      B = B*2;
      K--;;
    }
    else{
      break;
    }
  }
  while(K!=0){
    if(B>=C){
      C = C*2;
      K--;;
    }
    else{
      break;
    }
  }
  if(K>=0 && A<B && B<C) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3628
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=0
import numpy
ll=numpy.cumsum(l)
ans=ll[k-1]
for i in range(0,n-k):
    ans=max(ll[i+k]-ll[i],ans)
ans=ans+k
print(float(ans)/2)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e1+1;
const ll p=1e9+7;
ll mx(ll x,ll y,ll z){return max(max(x,y),z);}
ll mn(ll x,ll y,ll z){return min(min(x,y),z);}
int main()
{
    ll x,y;
    cin>>x>>y;

    ll i,ans=min(x,y);
    if(x%3==0||y%3==0)ans=0;
    else
    {
        for(i=1;i<x;i++)
        ans=min(mx(i*y,(x-i)*(y/2),(x-i)*((y+1)/2))-mn(i*y,(x-i)*(y/2),(x-i)*((y+1)/2)),ans);
        swap(x,y);
        for(i=1;i<x;i++)
        ans=min(mx(i*y,(x-i)*(y/2),(x-i)*((y+1)/2))-mn(i*y,(x-i)*(y/2),(x-i)*((y+1)/2)),ans);
    }
    cout<<ans;
	return 0;
}


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;
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; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    for(int a = 1; a < n; a++) {
       ans += (n-1)/a;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 52;
ll h,w;
char s[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>h>>w;
	FOR(i,0,h){
		FOR(j,0,w){
			cin>>s[i][j];
		}
	}
	bool ok=true;
	FOR(i,0,h){
		FOR(j,0,w){
			bool okok=false;
			if(s[i][j]=='.')continue;
			if(i-1>=0){
				if(s[i-1][j]=='#')okok=true;
			}
			if(i+1<h){
				if(s[i+1][j]=='#')okok=true;
			}
			if(j-1>=0){
				if(s[i][j-1]=='#')okok=true;
			}
			if(j+1<w){
				if(s[i][j+1]=='#')okok=true;
			}
			if(okok==false){
				ok=false;
			}
		}
	}
	if(ok)pri("Yes");
	else pri("No");
	return 0;
}

Measured memory_bytes: 256
import math

r = 200000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

while True:
    n = int(raw_input())
    if not n:
        break
    i, num, sum = 0, 0, 0
    while num < n:
        if p[i] == 1:
            num += 1
            sum += i+1
        i += 1
    print sum

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

int main()
{
	ll n,m;
	cin>>n>>m;
  vector<ll>v(n+1,-1);
  
  for(ll i=0;i<m;i++)
  {
    ll t;
    cin>>t;
    v[t]=0;
  }
  if(v[0]!=0)
  	v[0]=1;
  if(v[1]!=0)
  {
  	v[1]=1;
  }
  for(ll i=2;i<=n;i++)
  {
  	if(v[i]!=0)
  	v[i]=(v[i-1]+v[i-2]) % M;
  }
  cout<<v[n]<<"\n";
 /* for(auto it: v)
cout<<it<<" ";    
*/}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow (int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,ans,f[N][N][N],g[N][N][N];
char ch[N];
void check(int &x,int y){if((x+=y)>=p) x-=p;}
void chkmax(int &x,int y){if (x<y) x=y;}
int main(){
//	freopen("a.in","r",stdin);
	scanf(" %s",ch+1);
	n=strlen(ch+1);
	if (n==1){puts("1");return 0;}
	memset(f,0xC0,sizeof(f));
	f[0][0][0]=0;
	for (int i=0;i<n;i++)
	for (int j=0;j<=i;j++)
	for (int k=0;k<=i;k++){
		chkmax(f[i+1][j][k],f[i][j][k]);
		if (j){
			if (ch[i+1]=='0') chkmax(f[i+1][j-1][k+1],f[i][j][k]);
			else chkmax(f[i+1][j-1][k],f[i][j][k]+1);
		}
		if (i+2<=n){
			if ((ch[i+1]=='0')||(ch[i+2]=='0')) chkmax(f[i+2][j][k+1],f[i][j][k]);
			if ((ch[i+1]=='1')||(ch[i+2]=='1')) chkmax(f[i+2][j][k],f[i][j][k]+1);
			chkmax(f[i+2][j+1][k],f[i][j][k]);
		}
	}
	for (int i=0;i<=n;i++)
	for (int j=0;j<=i;j++)
	for (int k=0;k<=i;k++)
	chkmax(f[i][0][k],f[i][j][k]);
	
	g[n+1][0][0]=1;ans=p-1;
	for (int i=n+1;i;i--)
	for (int j=0;j<i;j++)
	for (int k=0;j+k<i;k++){
		if (f[i-1][0][j]>=k) check(ans,g[i][j][k]);
		if (i==1) continue;
		check(g[i-1][j][k],g[i][j][k]);
		if (ch[i-1]=='0') check(g[i][j][k+1],g[i][j][k]);
		else check(g[i][j+1][k],g[i][j][k]);
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

const string YES = "Yes";
const string NO = "No";

void solve(long long D, long long T, long long S) {
  if (T * S >= D) {
    cout << YES << endl;
  } else
    cout << NO << endl;
}

int main() {
  long long D;
  scanf("%lld", &D);
  long long T;
  scanf("%lld", &T);
  long long S;
  scanf("%lld", &S);
  solve(D, T, S);
  return 0;
}


Measured memory_bytes: 3760
#include <cstdio>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B&&B==C&&A%2==0){
    printf("-1\n");
    return 0;
  }
  for(int i=0;;i++){
    if(A%2==1||B%2==1||C%2==1){
      printf("%d\n",i);
      return 0;
    }
    int A2=(B+C)/2;
    int B2=(A+C)/2;
    int C2=(A+B)/2;
    A=A2,B=B2,C=C2;
  }
  return 0;
}


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

using namespace std;

#define ll long long

const int INF = 1e9+9999;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, arr=0;
    string s;
    cin >> n >> k >> s;
    s.push_back('W');
    for (int i=0; i<n; ++i)
        if (s[i] != s[i+1])
            ++arr;
    int ans = n - arr;
    while (k && arr) {
        if (arr == 2)
            ++ans, ++arr;
        else
            ans+=2;
        --k;
        arr-=2;
    }
    cout << min(ans, n-1);
}


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

namespace AIZU
{
    class Program
    {
        static int cin() { return int.Parse(Console.ReadLine()); }
        static int cin(int D) {
            string s = Console.ReadLine();
            if (string.IsNullOrEmpty(s)) return D;
            return int.Parse(s);
        }
        static int[] cins() {
            string s = Console.ReadLine();
            if (string.IsNullOrEmpty(s)) return new int[] { };
            string[] ss = s.Split(' ');
            int[] Res = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++) Res[i] = int.Parse(ss[i]);
            return Res;
        }
        static void print(object j) { Console.WriteLine(j.ToString()); }
        static void print(string j) { Console.WriteLine(j); }
        static void Main(string[] args)
        {
            int[] G = { 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };
            int[] K = cins();
            print(G[K[0]-1]==G[K[1]-1]?"Yes":"No");
        }
    }
}


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

const int maxn = 1e6+1000;
typedef long long LL;
struct Node
{
    int v;
    LL w;
    Node(int v = 0,LL w = 0):v(v),w(w) {}
};


vector<Node> G[maxn];


int R,C;
int n;


LL A[maxn];
bool vis[maxn];



const LL INF = 0x3f3f3f3f3f3f3f3f;


bool dfs(int u)
{
    for(int i = 0;i < G[u].size();++i)
    {
        int v = G[u][i].v;
        LL w = G[u][i].w;

        if(!vis[v])
        {
            vis[v] = 1;
            A[v] = w-A[u];
            if(!dfs(v)) return false;
        }
        else
        {
            if(A[v] + A[u] != w) return false;

        }
    }
    return true;

}

int x[maxn];

bool bfs()
{

  for (int i = 1; i <= R + C; i++) {
    if (vis[i]) {
      continue;
    }
    int b = 0, e = 1;
    x[0] = i;
    vis[i] = true;
    A[i] = 0;
    while (b < e) {
      for (int j = 0; j < (int) G[x[b]].size(); j++) {
        int u = G[x[b]][j].v;
        int w = G[x[b]][j].w;
        if (vis[u]) {
          if (A[x[b]] + A[u] != w) {
            return false;
            }
          continue;
        }
        x[e] = u;
        A[u] = w - A[x[b]];
        vis[u] = true;
        e++;
      }
      b++;
    }


long long m1 = INF, m2 = INF;
    for (int j = 0; j < e; j++) {
      if (x[j] <= R) {
        m1 = min(m1, A[x[j]]);
      } else {
        m2 = min(m2, A[x[j]]);
      }
    }
    if (m1 + m2 < 0) {
      return false;
    }
}

    return true;


}


bool judge()
{

    memset(vis,0,sizeof(vis));
    for(int i = 1;i <= R;++i)
        if(!vis[i])
        {
            vis[i] = 1;
            A[i] = 0;
            if(!dfs(i)) return false;
        }

    LL Minr = INF;
    LL Minc = INF;
    for(int i = 1;i <= R;++i)
        Minr = min(Minr,A[i]);
    for(int i = R+1;i <= R+C;++i)
        if(vis[i])
        Minc = min(Minc,A[i]);

    if(Minr + Minc < 0) return false;


    return true;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)
    {
        int a,b;
        LL w;
        scanf("%d %d %lld",&a,&b,&w);
        b += R;
        G[a].push_back(Node(b,w));
        G[b].push_back(Node(a,w));
    }
    if(bfs())
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef pair<int, int> ii;

class Node {
public:
    int c;
    bool d;
    map<int, int> tos;
};

const int N_MAX = 100;
int n;
vector<Node> ns;

int dijkstra(int s, int t) {
    for (int i = 0; i < n; i++) {
        ns[i].c = INT_MAX;
        ns[i].d = false;
    }
    ns[s].c = 0;
    priority_queue<ii, vector<ii>, greater<ii> > q;
    q.push(make_pair(0, s));
    while (!q.empty()) {
        ii e = q.top();
        q.pop();
        int i = e.second;
        if (ns[i].d) {
            continue;
        }
        ns[i].d = true;
        for (map<int, int>::iterator it = ns[i].tos.begin(); it != ns[i].tos.end(); it++) {
            int c = ns[i].c + it->second;
            if (ns[it->first].c > c) {
                ns[it->first].c = c;
                q.push(make_pair(ns[it->first].c, it->first));
            }
        }
    }
    return (ns[t].c < INT_MAX) ? ns[t].c : -1;;
}

int main() {
    int k;
    while (cin >> n >> k, n|k) {
        ns.clear();
        ns.resize(n);
        while (k--) {
            int req;
            cin >> req;
            if (req) {
                int c, d, e;
                cin >> c >> d >> e;
                if (ns[c-1].tos.find(d-1) == ns[c-1].tos.end() || ns[c-1].tos[d-1] > e) {
                    ns[c-1].tos[d-1] = ns[d-1].tos[c-1] = e;
                }
            } else {
                int a, b;
                cin >> a >> b;
                cout << dijkstra(a-1, b-1) << endl;
            }
        }
    }
}

Measured memory_bytes: 1296
/*" بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ -In the name of Allah."
   Never stop chasing!-MD.SOURAV.

   ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
   ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
   ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
   [███████████████████].░░░░░░░░░░░░░░
   ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
*/


#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
#define MAX 32000

using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	 ll x,k,d;
	 cin>>x>>k>>d;
	 x=abs(x);
	if(x==d)
	{
		if(k&1)
		{
			cout << 0 << endl;
			return;

		}
		else
		{
			cout << d << endl;
			return;
		}
	}
	ll c=x/d;
	if(c>=k)
	{
		cout << x-(k*d) << endl;
		return;
	}
	ll m=abs(x-(c*d));
	ll n=abs(m-d);
	k=k-c;
	if(m==n)
	{
		cout << m << endl;

	}
	else
	{
		if(k&1)
		{
			cout << n << endl;
		}
		else
		{
			cout << m << endl;
		}
	}





}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3616
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input().strip()


def pon(computer, mine):
    if computer == 'r' and mine == 2: return P
    if computer == 's' and mine == 0: return R
    if computer == 'p' and mine == 1: return S
    return 0


ans = 0
for st in range(K):
    t = T[st::K]

    l = len(t)
    dp = [[0 for _ in range(3)] for _ in range(l+1)]

    for i in range(l):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + pon(t[i], k))
    ans += max(dp[i+1])
print(ans)


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

int main()
{
	string s;
  cin >> s;
 bool f = false; 
for (int i = 1;i < s.length(); i++)
{
  if (s[i-1] == 'A' && s[i] == 'C')
    f = true;
}
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,d=0;
    scanf("%d %d %d",&a,&b,&c);
    while(a<=b){
        if(c % a == 0){
            d++;
        }
        a++;
    }
    printf("%d\n",d);
    return 0;
}    

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
string s;
cin >> s;
map<char, ll> mp;
for (ll i = 0; i < s.size();i++){
    mp[s[i]]++;
}
for(auto i:mp){
    if(i.second%2==1){
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


long[] run;

void main() {
    int K;
    scan(K);
    //K--;

    //long[] run;

    rekkyo(0, true, 0);
    auto rr = run.sort().uniq.array;

    debug {
        writeln(rr[0 .. 100]);
    }

    auto ans = rr[K];
    writeln(ans);
}

enum D = 10;

void rekkyo(int i, bool rz, long val) {
    if (i == D) {
        debug {
            //writeln(val);
        }
        run ~= val;
        return;
    }

    if (rz) {
        rekkyo(i + 1, true, 0);
        foreach (d ; 1 .. 10) {
            rekkyo(i + 1, false, d);
        }
    }
    else {
        int last = val % 10;
        foreach (d ; max(0, last - 1) .. min(9, last + 1) + 1) {
            rekkyo(i + 1, false, val * 10 + d);
        }
    }
}


void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 4220
N = int(input())
A = list(map(int, input().split()))
color = [0] * 8
select = 0
for i in range(N):
    for j in range(8):
        if 400 * j <= A[i] < 400 * (j + 1):
            color[j] += 1
            break
        elif 400 * (j + 1) == 3200:
            select += 1
            break
ans = 0

for k in range(8):
    if color[k] != 0:
        ans += 1
print(max(ans, 1), ans + select)

Measured memory_bytes: 3064
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
vector<string> sort(vector<string> array){
  vector<string> na(array.size());
  //コピー可能
  vector<string> oa=array;
  for(int i=1;i < array.size(); i*=2){
    //for(int aaa=0; aaa < array.size(); aaa++){
    // cout << oa[aaa] << endl;
    //} 
    //a b c d e f g h i -> ab cd ef gh i
    //cout << i << endl;
    for(int k=0; k < (array.size()+2*i-1)/(2*i); k++){
      int right=2*k*i;
      int left=(2*k+1)*i;
      int m=2*k*i;
      //cout << "step:" << i << "-" << k<< endl;
      
      while(m-2*k*i < 2*i){
        //cout << "right:" << right << " left:" << left << endl;
        //末端処理
        if(right-2*k*i >= i){
          for(int L=left;L-(2*k+1)*i < i && L < array.size();L++){
            na[m]=oa[L];
            m++;
          }
          break;
        } else if(left-(2*k+1)*i >= i || left >= array.size() ){
          for(int R=right;R-(2*k)*i < i && R < array.size();R++){
            na[m]=oa[R];
            m++;
          }
          break;
        }
        //cout << "OK" << endl;
        if(oa[right]<=oa[left]){
          na[m]=oa[right];
          right++;
        } else if(oa[right] > oa[left]){
          na[m]=oa[left];
          left++;
        }
        //cout << "right:" << right << " left:" << left << endl;
        m++;
      }
    }
    oa=na;
  }
  return na;
}
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  vector<string> SS(N);
  vector<int> C(N);
  for(int i=0; i < N; i++){
    cin >> S[i];
  }
  SS=sort(S);
  //string now=SS[0];
  int pin=0;
  int nowmax=0;
  int memo=0;
  for(int i=0; i < N; i++){
    if(SS[pin]==SS[i]){
      C[pin]++;
      nowmax=max(C[pin],nowmax);
    } else {
      pin = i;
      C[pin] = 1;
      nowmax = max(C[pin],nowmax);
    }
      
  }
  for(int i=0; i < N; i++){
    if(C[i]==nowmax){
     cout << SS[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 20352
#include <stdio.h>

typedef unsigned long	us;

us max(us a, us b)
{
    if(a > b)
        return a;
    else
        return b;
}

us min(us a, us b)
{
    if(a < b)
        return a;
    else
        return b;
}

int main(void)
{
    us high, wide;
    us s_max = 0;
    us s_min = ~0;
    us ans = ~0;
    us i;
    
    
    scanf("%lu %lu", &high, &wide);
    
    for(i=1; i<high; i++){
        us a, b, c;
        us h = (high-i)/2;
        us w = wide/2;
        
        a = i*wide;
        b = (high-i)*w;
        c = (high-i)*(wide-w);
        s_max = max(a, max(b, c));
        s_min = min(a, min(b, c));
        
        ans = min(ans, s_max-s_min);
        
        b = h*wide;
        c = ((high-i)-h)*wide;
        s_max = max(a, max(b, c));
        s_min = min(a, min(b, c));
        
        ans = min(ans, s_max-s_min);
        
        //printf("high:%d max:%d min:%d\n", i, s_max, s_min);
        //printf("high:%d a:%d b:%d c:%d\n", i, a, b, c);
    }
    for(i=1; i<wide; i++){
        us a, b, c;
        us h = high/2;
        us w = (wide-i)/2;
        
        a = i*high;
        b = (wide-i)*h;
        c = (wide-i)*(high-h);
        s_max = max(a, max(b, c));
        s_min = min(a, min(b, c));
        
        ans = min(ans, s_max-s_min);
        
        b = w*high;
        c = ((wide-i)-w)*high;
        s_max = max(a, max(b, c));
        s_min = min(a, min(b, c));
        
        ans = min(ans, s_max-s_min);
        
        //printf("wide:%d max:%d min:%d\n", i, s_max, s_min);
        //printf("wide:%d a:%d b:%d c:%d\n", i, a, b, c);
    }
    
    printf("%lu\n", ans);
    
    
    return 0;
}

Measured memory_bytes: 128
// AOJ 2064: Make Friendships
// 2017.11.8 bal4u@uu

#include <stdio.h>
#include <string.h>

#define HASHSIZ 2003
typedef struct { int v, id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int lookup(int v)
{
	HASH *p = hash + v % HASHSIZ;
	while (p->v) {
		if (p->v == v) return p->id;
		if (++p == hashend) p = hash;
	}
	return -1;
}

void insert(int v, int id)
{
	HASH *p = hash + v % HASHSIZ;
	while (p->v) {
		if (p->v == v) return;
		if (++p == hashend) p = hash;
	}
	p->v = v, p->id = id;
}

#define MAX 1002
int   m, n;
char  graph[MAX][MAX];
char  seen[MAX];
short matchL[MAX], matchR[MAX];

int bpm(int u)
{
  int v;

  for (v = 0; v < n; v++) if (graph[u][v]) {
    if (seen[v]) continue;
    seen[v] = 1;
    if (matchR[v] < 0 || bpm(matchR[v])) {
      matchL[u] = v;
      matchR[v] = u;
      return 1;
    }
  }
  return 0;
}

char buf[20000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int M, i, j, ans;

	while (fgets(p=buf, 10, stdin) && *buf != '0') {
		n = getint();
		memset(hash, 0, sizeof(hash));
		memset(graph, 0, sizeof(graph));

		fgets(p=buf, sizeof(buf), stdin);
		M = getint(), p++;
		m = 0; while (M--) insert(getint(), m++), p++;

		for (j = 0; j < n; j++) {
			fgets(p=buf, sizeof(buf), stdin);
			M = getint(), p++;
			while (M--) {
				i = getint(), p++;
				if ((i = lookup(i)) >= 0) graph[i][j] = 1;
			}
		}

	    memset(matchL, -1, m*sizeof(matchL[0]));
		memset(matchR, -1, n*sizeof(matchR[0]));

		ans = 0;
		for (i = 0; i < m; i++) {
			memset(seen, 0, n);
			if (bpm(i)) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2712
#include <iostream>

using namespace std;

#define N_MAX 100

int Adj[N_MAX][N_MAX] = {};
int Min_d[N_MAX];

void bfs(int v, int d, int num_node);

int main()
{
    int n, i, u, k, v, j;

    cin >> n;

    for (i = 0; i < n; i++) Min_d[i] = -1;

    //??£??\???????????????
    for (i = 0; i < n; i++) {
        cin >> u >> k;
        while (k-- > 0) {
            cin >> v;
            Adj[u-1][v-1] = 1;
        }
    }
/*
    cout << "show Adjacency matrix" << endl;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n ; j++) {
            if (j == n - 1)
                cout << Adj[i][j] << endl;
            else
                cout << Adj[i][j] << ' ';
        }
    }
*/
    //??¢?´¢??????
    Min_d[0] = 0;
    bfs(1, 1, n);

    //????????????
    for(i = 1; i <= n; i++) {
        cout << i << ' ' << Min_d[i-1] << endl;
    }

    return 0;
}

void bfs(int v, int d, int num_node) {
    int i;
//    cout << "bfs node : " << v << endl;

    for(i = 1; i <= num_node; i++) {
        if (Adj[v-1][i-1] == 1) {
            if (Min_d[i-1] == -1 || Min_d[i-1] > d) {
                Min_d[i-1] = d;
                bfs(i, d+1, num_node);
            }
        }
    }
}

Measured memory_bytes: 3096
#include <iostream>

using namespace std;

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

    if (a > b)
    {
        swap(a, b);
    }

    for (int i = 0; i < b; ++i)
    {
        cout << a;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
s = input()
if s.count("R")==1:
    print(1)
elif s.count("R")==0:
    print(0)
elif s.count("R")==3:
    print(3)
elif s.count("R")==2:
    if s[1]== "R" and s[2] == "R":
        print(2)
    elif s[0]== "R" and s[1] == "R":
        print(2)
    else:
        print(1)

Measured memory_bytes: 9116
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int s[100] = {};
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b >= c ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    num = makeNumList(input())
    ans = 0.0
    
    for i in range(n):
        ans += invNum(num[i])
    
    print(invNum(ans))

def invNum(n):
    return 1 / n

def makeNumList(raw):
    num = []
    raw = raw.split(" ")
    for i in range(len(raw)):
        num.append(int(raw[i]))
    return num

main()

Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
from collections import deque, defaultdict
n , m = map(int, input().split())
# n : 頂点の数 m : 辺の数
#隣接リスト
#G = defaultdict(lambda:[])
li = []
#################################
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    li.append((a, b))
    
#################################

#幅優先探索でトポロジカル順序を求める
#頂点iからの幅優先探索
def bfs(i):
    parent = [-10]*n #parent[i] : 頂点iの親
    order = []
    parent[i] = -1
    stack = deque()
    u = i
    stack.append(u)
    while stack:
        x = stack.popleft()
        order.append(x)
        for v in G[x]:
            if v == parent[x]:
                continue
            if parent[v] != -10:
                continue
            parent[v] = x
            stack.append(v)
    return parent
            
ans = 0
for i in range(m):
    G = [[] for _ in range(n)]
    for j in range(m):
        if i == j:
            continue
        a, b = li[j]
        G[a].append(b)
        G[b].append(a)
    li_p = bfs(0)
    for k in li_p:
        if k == -10:
            ans += 1
            break
print(ans)
    
    

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

template<class T> inline T gcd(T a, T b) {
    if (b == 0) return a;
    return  gcd(b, a % b);
}

int main() {
    cin.tie(0)->sync_with_stdio(false);

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

    cout << 3 * (n - gcd(n, x)) << '\n';
    return 0;
}


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

int main(){
    int X,N,p,q;
    cin >> X >> N;
    vector<int> a(N);
    for(int i = 0; i<N; i++){
    cin >> a[i]; 
    }
    p = 0;
    for(int i = 0; i<=X; i++){
    vector<int>::iterator it;
    it = find (a.begin(), a.end(), X-i);
    if (it != a.end()){
        p = p +1;
    }
    else{
        break;
    }
    }
    
    
    q = 0;
    for(int i = 0; i<=X; i++){
    vector<int>::iterator it;
    it = find (a.begin(), a.end(), X+i);
    if (it != a.end()){
        q = q +1;
    }
    else{
        break;
    }
    }
    if(p<=q){
        cout << X -p;
    }
    else{
        cout << X + q;
    }


}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a, b, c, d;
	a = (n/1000)%10;
	b = (n/100)%10;
	c = (n/10)%10;
	d = n%10;
	if(a+b+c+d==7){
		cout << a << '+' << b << '+' << c << '+' << d << '=' << 7 << endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout << a << '-' << b << '-' << c << '-' << d << '=' << 7 << endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout << a << '+' << b << '+' << c << '-' << d << '=' << 7 << endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout << a << '+' << b << '-' << c << '+' << d << '=' << 7 << endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout << a << '-' << b << '+' << c << '+' << d << '=' << 7 << endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout << a << '-' << b << '-' << c << '+' << d << '=' << 7 << endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout << a << '-' << b << '+' << c << '-' << d << '=' << 7 << endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout << a << '+' << b << '-' << c << '-' << d << '=' << 7 << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    string t;
    cin >> t;
    const li n = t.size();
    for (int i = 0; i < n; ++i) {

        if (t[i] == 'P') {
            cout << 'P';
        }         else {
            cout << 'D';
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3732
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X, x):

    x.reverse()
    sa = [0]
    for a in x:
        sa.append(sa[-1]+a)

    ans = sys.maxsize
    for k in range(1, N+1):
        t = X*N
        for j in range(1, math.ceil(N/k)+1):
            s = (j-1)*k
            e = (j)*k
            if e >= len(sa):
                e = len(sa)-1

            if j == 1:
                t += 5*(sa[e]-sa[s])
            else:
                t += (2*j+1)*(sa[e]-sa[s])

        t += k*X
        ans = min(ans, t)
    return ans


def main():
    N, X = read_int_n()
    x = read_int_n()
    print(slv(N, X, x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 119376
import Control.Applicative
import Control.Monad
import Data.List

comb :: Int -> Int -> Int
comb n r = iterate (scanl1 (+)) [1, 1 ..] !! (n - r) !! r

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = scanl' (+) 0 as
    let cs = filter (>= 2) . fmap length . group . sort $ bs
    print $ foldr (\x a -> comb x 2 + a) 0 cs

Measured memory_bytes: 115196