akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
typedef long long ll;
typedef pair<int,int> pii;
enum{IN=0,OUT,BOMB};
class st{
public:
  int x;
  int id;
  int type;
  bool operator<(const st & a)const{
    return x < a.x;
  }
};

const int N = 100000;
bool isodd[N];

ll solve(vector<st> &in,bool flag){
  ll ret=0;
  ll prev=!flag?0:1000000001;
  int cur=0;
  int cnt[2]={0};
  rep(i,in.size()){
    //cout << prev <<" " << cur << " " << cnt[cur] << endl;
    st &now = in[i];
    if (now.type == IN){
      cnt[cur]++;
      isodd[now.id]=cur;
      ret-=abs(now.x-prev);
    }else if (now.type == OUT){
      if (cur == isodd[now.id])ret+=abs(now.x-prev);
      cnt[isodd[now.id]]--;
    }else if (now.type == BOMB){
      //cout <<"add " <<ret <<" " <<  abs(now.x-prev) <<" " << cnt[cur] << endl;
      ret+=abs(now.x-prev)*cnt[cur];
      prev=now.x;
      cur=1-cur;
    }
  }
  //cout <<"end----------------------" << endl;
  return ret;
}

main(){
  int n,m;
  while(cin>>n>>m){
    vector<pii> tmp(n),a,b;
    vector<int> c(m);
    vector<st> d(m),e;
    rep(i,n)cin>>tmp[i].first>>tmp[i].second;
    rep(i,m){
      cin>>c[i];
      d[i]=(st){c[i],-1,BOMB};
    }
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    e=d;
    reverse(d.begin(),d.end());

    ll ans=0;
    rep(i,n){
      if (lower_bound(c.begin(),c.end(),tmp[i].first) == lower_bound(c.begin(),c.end(),tmp[i].second)){
	ans+=abs(tmp[i].first-tmp[i].second);
      }else if (tmp[i].first < tmp[i].second){
	d.push_back((st){tmp[i].first,i,IN});
	d.push_back((st){tmp[i].second,i,OUT});
      }else if (tmp[i].first > tmp[i].second){
	e.push_back((st){tmp[i].first,i,IN});
	e.push_back((st){tmp[i].second,i,OUT});
      }
    }
    sort(d.begin(),d.end());
    sort(e.begin(),e.end());
    reverse(e.begin(),e.end());
    /*
    cout <<"current ans " << ans << endl;
    cout <<"increase sequence" << endl;
    rep(i,d.size()){
      cout << d[i].x <<" " << d[i].id <<"  " << d[i].type << endl;
    }

    cout <<"decrease sequence " << endl;
    rep(i,e.size()){
      cout << e[i].x <<" " << e[i].id <<"  " << e[i].type << endl;
    }
    */
    ll ans1=solve(d,false),ans2=solve(e,true);
    //cout <<"each answer " << ans <<" " <<  ans1 <<" " << ans2 << endl;
    //cout <<"answer " << ans+ans1+ans2 << endl;
    cout << ans+ans1+ans2 << endl;

#ifdef DEBUG
    cout <<"end"<<endl;
#endif
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int n,a[101];
    
    cin >> n;
    
    for(int i=0; i < n; i++)cin>>a[i];
    for(int i=n-1;i>0; i--)cout << a[i] <<" ";
    cout << a[0] << endl;
    return 0;
}



Measured memory_bytes: 3100
#define DEBUG 0

/**
 * File    : D3.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-28 12:07:16
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
const ll M = 1000000007;

int N;
ll dp[110][4][4][4];

// A: 0, G: 1, C: 2, T: 3;

int main()
{
  cin >> N;
  fill(&dp[0][0][0][0], &dp[0][0][0][0] + 110 * 4 * 4 * 4, 0);
  dp[0][3][3][3] = 1;
  for (auto n = 0; n < N; n++)
  {
    for (auto i = 0; i < 4; i++)
    {
      for (auto j = 0; j < 4; j++)
      {
        for (auto k = 0; k < 4; k++)
        {
          if (dp[n][i][j][k] == 0)
          {
            continue;
          }
          for (auto a = 0; a < 4; a++)
          {
            // jia = 012, 102, 021 は continue;
            if ((j == 0 && i == 1 && a == 2) || (j == 1 && i == 0 && a == 2) || (j == 0 && i == 2 && a == 1))
            {
              continue;
            }
            // kjia = 0x12, 01x2 は continue;
            if ((k == 0 && i == 1 && a == 2) || (k == 0 && j == 1 && a == 2))
            {
              continue;
            }
            dp[n + 1][a][i][j] += dp[n][i][j][k];
            dp[n + 1][a][i][j] %= M;
          }
        }
      }
    }
  }
  ll ans = 0;
  for (auto i = 0; i < 4; i++)
  {
    for (auto j = 0; j < 4; j++)
    {
      for (auto k = 0; k < 4; k++)
      {
        ans += dp[N][i][j][k];
        ans %= M;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


int main() {
	int n, m; cin >> n >> m;
	vector<int> x(m), d(m - 1);
	for (int i = 0; i < m; i++) cin >> x[i];
	sort(x.begin(), x.end());
	for (int i = 0; i < m - 1; i++) d[i] = x[i + 1] - x[i];
	sort(d.begin(), d.end());
	int ans = 0;
	for (int i = 0; i < m - n; i++) ans += d[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<array>
#include<vector>
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int h[n];
  for(int i=0;i<n;i++)scanf("%d",&h[i]);
  int mins[n];
  mins[n-1]=h[n-1];
  for(int i=n-2;0<=i;i--){
    if(mins[i+1]>h[i])mins[i]=h[i];
    else mins[i]=mins[i+1];
  }
  for(int i=0;i<n;i++){
    if(1<h[i]-mins[i]){
      printf("No\n");break;
    }else if(i==n-1)printf("Yes\n");
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long x,a,b,c;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++)
            {
                int k=i*500+j*100+z*50;
                if(k==x) ans++;
                if(k>x) break;
            }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
  cp();
  //w(x)
  {
    de(n);
    cout<<1-n<<endl;
  }
    
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
using namespace std;
double q1,b,c1,c2,q2;

int main(){

  while(cin >> q1 , q1){
    cin >> b >> c1 >> c2 >> q2;
    int ach,bch;
    int mxa = 0,mxb = 0;
    int cost = 0;
    for( ach = 0 ; ach <= q2 ; ++ach ){
      cost = b - c1*ach;
      if(cost < 0)break;
      bch = cost/c2;
      if(mxa < ach && q1 <= ach + bch ){
	mxa = ach;
	mxb = bch;
      }
    }
    if(mxa < 1)cout << "NA" << endl;
    else cout << mxa << ' ' << mxb << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
void read(short &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
short n;
double dp[3003],ans;
int main(){
	read(n);
	dp[0]=1.0;
	for (int i=1;i<=n;i++){
		double x;scanf("%lf",&x);
		for (int j=i;j>=1;j--)
			dp[j]=dp[j]*(1.0-x)+dp[j-1]*x;
		dp[0]=dp[0]*(1.0-x);
	}
	for (int i=n/2+1;i<=n;i++) ans+=dp[i];
	printf("%.10lf",ans);
}

Measured memory_bytes: 256
n=int(input())
a= list(map(int, input().split()))

if n==2:
    print(max(a[0],a[1]))
    exit()
    
dp=[[-float('inf'),-float('inf'),-float('inf')] for i in range(n)]
# dp[i][0]:iまででまだ飛ばしてない
# dp[i][1]:一つ飛ばしてる
# dp[i][2]:２つ飛ばしてる
dp[0][0]=a[0]
dp[1][1]=a[1]
dp[2][2]=a[2]

for i in range(2,n):
    dp[i][0]=dp[i-2][0]+a[i]
    if i>=3:
        dp[i][1]=max(dp[i-2][1]+a[i],dp[i-3][0]+a[i])
    if i>=4:
        dp[i][2]=max(dp[i-2][2]+a[i],dp[i-3][1]+a[i],dp[i-4][0]+a[i])

if n%2==0:
    print(max(dp[-2][0],dp[-1][1]))
else:
    print(max(dp[-3][0],dp[-2][1],dp[-1][2]))

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

vector<pair<int, int>> g[100005], gmst[100005];
vector<pair<int, int>> edges, resedges;
int outdeg[100005];
bool inmst[100005];
int dsu[100005];

int dfind(int x) { return x == dsu[x] ? x : dsu[x] = dfind(dsu[x]); }
void dmerge(int u, int v) {
	u = dfind(u), v = dfind(v);
	if (u == v) return;
	dsu[u] = v;
}

void dfs(int n, int p = -1) {
	//printf("%d -> %d\n", p, n);
	// edge info to parent
	pair<int, int> hint;
	for (auto c : gmst[n]) if (c.first != p) dfs(c.first, n); else hint = c;
	// post-process
	if (p != -1) {
		int eid = hint.second;
		if (outdeg[n] % 2 == 1) {
			// choose up
			resedges[eid] = {n, p};
			outdeg[n]++;
		} else {
			resedges[eid] = {p, n};
			outdeg[p]++;
		}
	}
}

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

	int n, m; read(n, m);

	if (m % 2 == 1)
		die(-1);

	rep(i, 0, 100005) dsu[i] = i;
	edges = vector<pair<int, int>>(m);
	resedges = vector<pair<int, int>>(m);

	for (int i = 0; i < m; i++) {
		read(edges[i].first, edges[i].second);
		g[edges[i].first].push_back({edges[i].second, i});
		g[edges[i].second].push_back({edges[i].first, i});
	}
	
	// calculate mst
	rep(i, 0, m) {
		if (dfind(edges[i].first) != dfind(edges[i].second)) {
			dmerge(edges[i].first, edges[i].second);
			gmst[edges[i].first].push_back({edges[i].second, i});
			gmst[edges[i].second].push_back({edges[i].first, i});
			inmst[i] = true;
		}
	}

	// arbitrary edges 
	rep(i, 0, m) if (!inmst[i]) {
		outdeg[edges[i].first]++;
		resedges[i] = edges[i];
	}

	// other edges
	dfs(1);

	rep(i, 0, m) write(resedges[i].first, resedges[i].second);
}


Measured memory_bytes: 20096
from string import ascii_lowercase as al


def dfs(p, i):
    if len(p) == N:
        print("".join(p))
        return
    for j in range(i+1):
        if j == i:
            dfs(p + list(al[j]), i+1)
        else:
            dfs(p + list(al[j]), i)


N = int(input())
dfs([], 0)


Measured memory_bytes: 60504
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint h,w;std::cin>>h>>w;
    std::vector<lint>ckd(h+w-1);
    for(lint i=0;i<h;i++){
        for(lint j=0;j<w;j++){
            char c;std::cin>>c;
            if(c=='#'){
                if(std::exchange(ckd.at(i+j),true)){
                    std::cout<<"Impossible"<<'\n';
                    return 0;
                }
            }
        }
    }
    std::cout<<"Possible"<<'\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split();
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);

            var A = new int[n, m];
            
            for (var i = 0; i < n; i++)
            {
                line = Console.ReadLine().Split();
                for (var j = 0; j < m; j++)
                {
                    A[i, j] = int.Parse(line[j]);
                }
            }

            for (var i = 0; i < m; i++)
            {
                var b = int.Parse(Console.ReadLine());
                for (var j = 0; j < n; j++)
                {
                    A[j, i] *= b;
                }
            }

            for (var i = 0; i < n; i++)
            {
                var s = 0;
                for (var j = 0; j < m; j++)
                {
                    s += A[i, j];
                }
                Console.WriteLine(s);
            }
        }
    }
}



Measured memory_bytes: 18008
program prob4
    implicit none
    integer(8) :: n
    integer(8), allocatable :: a(:)
    integer(8) :: p(10)
    integer(8) :: s(10)
    integer(8) :: i, j
    integer(8) :: ans
    integer(8) :: cnt
    character(10) :: tmp
    integer(8) :: inttmp

    read(*,*) n
    allocate(a(n))

    p(1) = 1
    do i = 2, 10
        p(i) = p(i-1) * 32
    end do
    do i = 1, n
        read(*,*) tmp
        do j = 1, 10
            s(j) = ichar(tmp(j:j)) - ichar('a')
        end do
        call msort(s)
        a(i) = dot_product(s, p)
    end do

    call msort(a)

    cnt = 1
    inttmp = a(1)
    ans = 0
    do i = 2, n
        if(a(i) == inttmp)then
            cnt = cnt + 1
        else
            ans = ans + cnt * (cnt - 1) / 2
            inttmp = a(i)
            cnt = 1
        end if
    end do
    ans = ans + cnt * (cnt - 1) / 2

    write(*,*) ans



    deallocate(a)

    stop
contains


  !
  ! swap two arguments
  !
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b

    integer(8) :: c

    c = a
    a = b
    b = c

  end subroutine swap

  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)

    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if

    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))

    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x

    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do

    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n

    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program prob4

Measured memory_bytes: 4336
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    x1, y1 = [int(i) for i in input().split()]
    L.append(x1)
    R.append(y1)

high=N
low=0

ans = [True for i in range(N)]
for i in range(M):
    for c,k in enumerate(range(L[i]-2, low-1, -1)):
        if(low < k):
            low=k
        ans[k]=False


    for c,j in enumerate(range(R[i],high)):
        if(high > j):
            high=j
        ans[j]=False


print(ans.count(True))



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

int main(){
  int N;  cin >> N;
  vector<int>C(N);
  vector<int>V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  long long ans = 0;
  for(int i=0;i<N;i++){
    if(V.at(i) - C.at(i) > 0) ans += V.at(i) - C.at(i);
  }
  cout << ans << endl;
}


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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, A;
    cin >> N >> A;

    if(N%500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] tmp = new String[1000];
		int[] point = new int[1000];
		int p = 0;
		while(stdIn.hasNext()) {
			String tmp1 = stdIn.next();
			boolean kk = true;
			for(int i = 0; i < p; i++) {
				if(tmp[i].equals(tmp1)) {
					point[i]++;
					kk = false;
					break;
				}
			}
			if(kk) {
				tmp[p] = tmp1;
				point[p++]++;
			}
		}
		int maxlength = 0;
		int maxlengthid = 0;
		for(int i = 0; i < p; i++) {
			if(maxlength < tmp[i].length()) {
				maxlength = tmp[i].length();
				maxlengthid = i;
			}
		}
		int maxpoint = 0;
		int maxpointid = 0;
		for(int i = 0; i < p; i++) {
			if(maxpoint < point[i]) {
				maxpoint = point[i];
				maxpointid = i;
			}
		}
		System.out.println(tmp[maxpointid] + " " + tmp[maxlengthid]);
		
			
	}
}

Measured memory_bytes: 17168
n, x = map(int, input().split())
ans = n
sum_dounut = 0
min_val = 10 ** 9
for _ in range(n):
  m = int(input())
  sum_dounut += m
  if m < min_val:
    min_val = m
print(ans + ((x - sum_dounut) // min_val))


Measured memory_bytes: 62456
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	//ios_base::sync_with_stdio(0), cin.tie(nullptr);
	long long n;
    cin >> n;
    long long a[n];
    long long sum = 0;
    map<long long, long long> cnt;
    for (long long i = 0; i < n; i++) 
	{
		cin >> a[i];
		sum += a[i];
		cnt[a[i]]++;	
	}	
    long long q;
    cin >> q;
    while (q--) 
	{
        long long b, c;
        cin >> b >> c;
        long long x = cnt[b];
        cnt[b] = 0;
        cnt[c] += x;
        sum += (x * c) - (x * b);
        cout << sum <<endl;
    }
    return 0;
}

Measured memory_bytes: 10224
/*A - Can't Wait for Holiday*/
#include <bits/stdc++.h>

using namespace std;

int main(){

	string cad;

	cin >> cad;

	if(cad == "SUN")
		cout << '7';

	if(cad == "MON")
		cout << '6';

	if(cad == "TUE")
		cout << '5';

	if(cad == "WED")
		cout << '4';

	if(cad == "THU")
		cout << '3';

	if(cad == "FRI")
		cout << '2';

	if(cad == "SAT")
		cout << '1';

	return 0;
}


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

int main() {

long long a,b,c,d,e;
cin >> a>>b>>c;
d=4*a*b;
e=c-a-b;
if(d<e*e&&e>0)
cout <<"Yes";
else
cout << "No";
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,x;
    scanf("%d %d %d",&n,&a,&b);
    x=n*a;
    if(x<b)
    {
        printf("%d\n",x);
    }

    else
    {
        printf("%d\n",b);
    }

    return 0;
}



Measured memory_bytes: 1712
#include<cstdio>
const int N=105;
int n;char s[N],t[N];
inline int ck(int x)
{
	for(int i=1;i<=x;++i)
		if(s[n-x+i]!=t[i])return 0;
	return 1;
}
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	for(int i=n;~i;--i)if(ck(i))
		return printf("%d",2*n-i),0;
	return 0;
}

Measured memory_bytes: 1720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                var list = s.Split(',').Select(int.Parse).ToList();
                list.Sort();
                var dict = new Dictionary<int, int>();
                foreach (var v in list)
                {
                    if (dict.ContainsKey(v))
                    {
                        var i = dict[v] + 1;
                        dict.Remove(v); dict.Add(v, i);
                    }
                    else
                    {
                        dict.Add(v, 1);
                    }
                }
                bool isStraight = true;
                for (int i = list[0]; i < list[0] + 5; i++)
                {
                    if (list[i - list[0]] != i) { isStraight = false; break; }
                }
                if (list[0] == 1 && !isStraight)
                {
                    isStraight = true;
                    for (int i = 0; i < 4; i++)
                    {
                        if (list[i+1] != 10+i) { isStraight = false; break; }
                    }
                }

                bool isFour = false;
                bool isThree = false;
                int Pairs = 0;

                var lk = dict.Keys;
                foreach (var v in lk)
                {
                    isFour |= dict[v] == 4;
                    isThree |= dict[v] == 3;
                    Pairs += dict[v] == 2 ? 1 : 0;
                }

                string result = "null";

                if (isFour) result = "four card";
                else if (isThree && Pairs > 0) result = "full house";
                else if (isStraight) result = "straight";
                else if (isThree) result = "three card";
                else if (Pairs == 2) result = "two pair";
                else if (Pairs > 0) result = "one pair";

                Console.WriteLine(result);
            }
        }
    }
}

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

int main() {
	int n = 0;
	int checknum = 1;
	int sum = 0;

	std::cin >> n;

	std::vector <int> x(n,0);

	for (int i=0; i<n; i++) {
		std::cin >> x.at(i);
	}

	while (checknum != 0) {
		for (int i = 0; i < n; i++) {
			if ((x.at(i) % 2) == 0) {
				x.at(i) = x.at(i) / 2;
			}
			else {
				checknum = 0;
				break;
			}
		}
		sum += 1;
	}

	std::cout << (sum - 1);

	return 0;
}


Measured memory_bytes: 256
def is_palindrome(s):
    return s == s[-1::-1]


S = input()
N = len(S)

if is_palindrome(S) and is_palindrome(S[0:(N-1)//2]) and is_palindrome(S[(N+3)//2-1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int N, A;
int x[51];
int dp[51][51][2501];

int func( int n, int cnt, int sum ) {
  //cout << n << " " << sum << endl;
  if( n == N && cnt != 0 && (double)((double)sum / (double)cnt) == (double)A ) return 1;
  if( n == N ) return 0;
  if( dp[n][cnt][sum] != -1 ) return dp[n][cnt][sum];

  int ret = func( n+1, cnt+1, sum+x[n] ) + func( n+1, cnt, sum );
  return dp[n][cnt][sum] = ret;
}

main()
{
  fill_n( **dp, 51*51*2501, -1);
  cin >> N >> A;
  Rep(i, N) cin >> x[i];

  cout << func( 0, 0, 0 ) << endl;
}


Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int k,x;
signed main(){
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++){
        cout<<i;
        if(i==x+k-1)cout<<endl;
        else cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = []
for i in range(n):
    fla = 0
    for j in reversed(range(n-i)):
        if p[j] == j+1:
            ans.append(p.pop(j))
            fla = 1
            break
    if fla == 0:
        print(-1)
        exit()

for i in reversed(range(n)):
    print(ans[i])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	static int n;
	static int[]a;
	static int []bit;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int q = sc.nextInt();
		bit = new int[n + 1];
		a = new int[n + 1];
		for(int i = 0; i < q; i++) {
			int com = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(com == 0) {
				add(x, y);
			}else {
				System.out.println(sum(y) - sum(x - 1));
			}
		}
		sc.close();
	}
	static void add(int a, int w) {
		for(int x = a; x <= n; x += x & -x) {
			bit[x] += w;
		}
	}
	static int sum(int a) {
		int ret = 0;
		for(int x = a; x > 0; x -= x & -x) {
			ret += bit[x];
		}
		return ret;
	}
}



Measured memory_bytes: 103428
#include <bits/stdc++.h>
//#include "lib/bigint2.h"

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll h;
	cin >>h;
	
	ll w =h, ans =0;
	ll ks =1;
	while(w >0){
		ans +=ks;
		ks *=2;
		w /=2;
	}
	
	//dbg(ans ,ks, ans);
	cout << ans <<"\n";
	return 0;
}


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

int main() {
	long long N , Z , W;
	cin >> N >> Z >> W;
	vector<long long>A(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i];
	}
	if (1!=N) {
		cout << max(abs(W - A[N - 1]), abs(A[N - 1] - A[N - 2])) << endl;
	}
	else {
		cout << abs(W - A[N - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
# Your code here!

N, T = map(int, input().split())
a1 = [list(map(int, input().split())) for i in range(N)]
a2 = list(filter(lambda i: i[1] <= T, a1))
if a2 == []:
    print("TLE")
else:
    print(a2[(a2.index(min(a2)))][0])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}
	
	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
	
	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		
		char num[20]; int len = 0;
		while (x > 9) { num[++len] = char(x % 10 + '0'); x /= 10; }
		
		num[++len] = char(x + '0');
		
		while (len) putchar(num[len--]);
	}
	template <typename T> inline void writeln(T x) { write(x); puts(""); }
}
using namespace IO;
int n, a, b;
int main(){
	read(n); read(a); read(b);
	if (abs(a - b) % 2 == 1) puts("Borys");
	else puts("Alice");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
   public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] dists = new int[n];
        for (int i = 0; i < n; i++) {
            dists[i] = sc.nextInt();
        }
        int[] costs = new int[m];
        for (int i = 0; i < m; i++) {
            costs[i] = sc.nextInt();
        }
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
            for (int j = i; j <= m; j++) {
                dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + dists[i - 1] * costs[j - 1]);
                for (int k = j + 1; k <= m; k++) {
                    dp[i][k] = dp[i][j];
                }
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= m; i++) {
            min = Math.min(min, dp[n][i]);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 37220
card = []
check = [False for i in range(9)]
for i in range(3):
  card += list(map(int, input().split()))
N = int(input())
for i in range(N):
  a = int(input())
  if a in card:
    check[card.index(a)] = True
ans = "No"
for i in range(3):
  if check[i] and check[3+i] and check[6+i]:
    ans = "Yes"
  if check[i*3] and check[i*3+1] and check[i*3+2]:
    ans = "Yes"
if check[4] and ((check[0] and check[8])or(check[2] and check[6])):
  ans = "Yes"
  
print(ans)

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007

using namespace std;

using ll = long long;

template <class T, T M>
class modulo {
public:
    T data;

    modulo(T data = 0) : data(data % M) {
    }

    modulo operator+(const modulo &x) const {
        return modulo(data + x.data);
    }

    modulo operator-(const modulo &x) const {
        return modulo(data + (M - x.data));
    }

    modulo operator*(const modulo &x) const {
        return modulo(data * x.data);
    }

    modulo operator/(const modulo &x) const {
        return modulo(data * x.inv().data);
    }

    modulo operator+=(const modulo &x) {
        data = (data + x.data) % M;
    }

    modulo operator-=(const modulo &x) {
        data = (data + (M - x.data)) % M;
    }

    modulo operator*=(const modulo &x) {
        data = (data * x.data) % M;
    }

    modulo operator/=(const modulo &x) {
        data = (data * x.inv().data) % M;
    }

    modulo inv() const {
        return _pow(M - 2);
    }

    template <class Integer>
    modulo operator^(Integer n) const {
        if (n >= 0) {
            return _pow(n);
        } else {
            return _pow(M - 1 - (-n) % (M - 1));
        }
    }

    friend std::ostream& operator<<(std::ostream &os, const modulo &x) {
        os << x.data;
        return os;
    }

private:
    template <class NonNegativeInteger>
    modulo _pow(NonNegativeInteger n) const {
        modulo result(1);
        modulo x(*this);
        while (n) {
            if (n & 1) {
                result *= x;
            }
            x *= x;
            n >>= 1;
        }
        return result;
    }
};

using mod = modulo<ll, MOD>;

int main() {
    int N;
    cin >> N;
    vector<ll> C(N);
    REP(i, N) cin >> C[i];
    sort(rall(C));

    mod result = 0;
    REP(i, N) {
        result += mod(i + 2) * C[i];
    }
    result *= mod(2) ^ (2 * (N - 1));
    cout << result << endl;

    return 0;
}

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
  	if((abs(a-b)<=d&&abs(c-b)<=d)||abs(c-a)<=d)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct SEG{
	ll seg[1<<19];
	void ini(void){for(int i=0;i<1<<19;i++)seg[i]=INF;}
	void up(int a,int b,int l,int r,int k,ll x){
		if(r<a||b<l)return;
		if(a<=l&&r<=b){
			seg[k]=min(seg[k],x);
			return;
		}
		up(a,b,l,(l+r-1)/2,k*2+1,x);
		up(a,b,(l+r+1)/2,r,k*2+2,x);
	}
	ll que(int a){
		a+=(1<<18)-1;
		ll res=seg[a];
		while(a>0){
			a=(a-1)/2;
			res=min(seg[a],res);
		}
		return res;
	}
};
ll n,q,s[200005],t[200005],w[200005];
vector<ll>cm;
SEG seg;
int main(void){
    cin>>n>>q;
    seg.ini();
    for(int i=0;i<n;i++){
		ll a,b,x;
		cin>>a>>b>>x;
		s[i]=a-x;
		t[i]=b-x;
		w[i]=x;
	}
	for(int i=0;i<q;i++){
		ll x;
		cin>>x;
		cm.PB(x);
	}
	for(int i=0;i<n;i++){
		int l=lower_bound(cm.begin(),cm.end(),s[i])-cm.begin();
		int r=lower_bound(cm.begin(),cm.end(),t[i])-cm.begin()-1;
		if(l<=r)seg.up(l,r,0,(1<<18)-1,0,w[i]);
	}
	for(int i=0;i<q;i++){
		ll ans=seg.que(i);
		if(ans==INF)ans=-1;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 12400
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a%3==0) printf("Possible\n");
    else if(b%3==0) printf("Possible\n");
    else if((a+b)%3==0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll a,b,c,x,y,ans=0; cin>>a>>b>>c>>x>>y;
 ll t=min(x,y);
  ans+=t*min(c*2,a+b);
  if(x-t>0)ans+=(x-t)*min(a,2*c);
  if(y-t>0)ans+=(y-t)*min(b,c*2);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Rep(i,n,m) for(int i = (int)(n);i < (int)(m);i++)
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl 

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    int max = 0;
    Rep(i,0,N)
        cin >> list.at(i);
    Rep(i,0,N)
    {
        Rep(j,i,N)
        {
            if(max < abs(list[i] - list[j]))
                max = abs(list[i] - list[j]);
        }
    }
    cout << max << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

string s;
int dp[N][13];

int f(int pos, int rem) {
	if (pos + 1 == s.size()) {
		return rem == 5;
	}

	if (dp[pos][rem] != -1) {
		return dp[pos][rem];
	}

	int res = 0;
	if (s[pos + 1] == '?') {
		for (int dig = 0; dig < 10; dig++) {
			int nrem = (rem * 10 + dig) % 13;
			res = (res + f(pos + 1, nrem)) % MOD;
		}
	} else {
		int nrem = (rem * 10 + (s[pos + 1] - '0')) % 13;
		res = (res + f(pos + 1, nrem)) % MOD;
	}

	return dp[pos][rem] = res;
}

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

	cin >> s;

	int cnt = 0, r = 0;
	for (int i = 0; i < s.size(); i++) {
		r = (r * 10 + (s[i] - '0')) % 13;
		if (s[i] == '?') {
			cnt++;
		}
	}

	if (cnt == 0) {
		cout << (r == 5) << "\n";
		return 0;
	}

	for (int i = 0; i <= s.size(); i++) {
		for (int rem = 0; rem < 13; rem++) {
			dp[i][rem] = -1;
		}
	}

	int ans = 0, rem = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '?') {
			for (int dig = 0; dig < 10; dig++) {
				ans = (ans + f(i, (rem * 10 + dig) % 13)) % MOD;
			}
			break;
		} else {
			rem = (rem * 10 + (s[i] - '0')) % 13;
		}
	}

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

Measured memory_bytes: 16876
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll y, m, d;
string g;

int main(){
	while(cin >> g && g != "#"){
		cin >> y >> m >> d;
		ll ymd =  10000 * y + 100 * m + d;
		if(ymd >= 310501){
			g = "?";
			y -= 30;
		}
		cout << g << " " << y << " " << m << " "<< d << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
/*
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int int64_t
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;*/
using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;

    for(int i=0; i<s.size(); i++){
        if(s == t){
            cout<<"Yes"<<'\n';
            return 0;
        }
        s = s.back() + s.substr(0,s.size()-1);
    }

    cout<<"No"<<'\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc170/tasks/abc170_c>
 問題文============================================================
 https://atcoder.jp/contests/abc170/tasks/abc170_c
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int X,N; cin >> X >> N;
    vector<int> p(N); for(auto& in:p) cin >> in;
    
    
    for(int x = 0; x <= 101; x++){
        bool ok = true;
        for(int i = 0; i < N;i++) if(p[i] == x) ok = false;
        if(ok){
            if(abs(res-X) > abs(x-X)){
                res = x;
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	//buf := make([]byte, 0)
	//sc.Buffer(buf, mod)
	//sc.Split(bufio.ScanWords)
	var n int
	fmt.Scan(&n)
	smin := q(0)
	if smin == "Vacant" {
		os.Exit(0)
	}
	smax := q(n - 1)
	if smax == "Vacant" {
		os.Exit(0)
	}
	min, max := 0, n-1
	for max-min > 1 {
		mid := (max + min) / 2
		sm := q(mid)
		if sm == "Vacant" {
			os.Exit(0)
		}
		if ((mid-min)%2 == 0 && sm == smin) || ((mid-min)%2 == 1 && sm != smin) {
			min = mid
			smin = sm
		} else {
			max = mid
			smax = sm
		}
	}
}

var w = bufio.NewWriter(os.Stdout)

func q(i int) string {
	var s string
	fmt.Fprintln(w, i)
	_ = w.Flush()
	fmt.Scan(&s)
	return s
}


Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long
#define MOD (1000000007)
using namespace std;
int main(void){
    string S;
    cin >> S;
    vector<ll> dp(13);
    dp[0] = 1;
    for(int i = 0; i < S.length(); i++){
        vector<ll> nx(13, 0);
        for(int j = 0; j < 13; j++){
            if(S[i] == '?'){
                for(int k = 0; k < 10; k++){
                    nx[(10 * j + k) % 13] += dp[j];
                }
            }else{
                nx[(10 * j + S[i] - '0') % 13] += dp[j];
            }
        }
        dp = nx;
        for(ll &d : dp) d %= MOD;
        // for(int j = 0; j < 13; j++) cout << dp[j] << endl;
        // cout << endl;
    }
    cout << dp[5] << endl;
    return 0;
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll n, m, x;
ll arr[100][100];
ll ans = LONG_LONG_MAX;

int main() {
    FAST
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            cin >> arr[i][j];
        }
    }

    for (int i = 0; i < (1 << n); i++) {
        ll sum = 0;
        vector<ll> v(m, 0);

        for (int j = 0; j < n; j++) {
            if (i & 1 << j) {
                sum += arr[j][0];
                for (int k = 1; k <= m; k++) {
                    v[k - 1] += arr[j][k];
                }
            }
        }
        ll c = 0;
        for (int j = 0; j < v.size(); j++) {
            if (v[j] >= x)
                c++;
        }
        if (c == m)
            ans = min(ans, sum);
    }
    if (ans == LONG_LONG_MAX)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		char[] s = n().toCharArray();

		int count = 1;

		for (int i = 1; i < n; i++) {
			if (s[i] != s[i - 1]) {
				count++;
			}
		}
		out(count);

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 39468
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, k, s; cin >> n >> k >> s;

  vector<int> ans(n);
  if(s == 1e9){
    for(int i = 0; i < k; i++){
      ans[i] = s;
    }
    for(int i = 0; i < n-k; i++){
      ans[k + i] = 1;
    }
  }else{
    for(int i = 0; i < k; i++){
      ans[i] = s;
    }
    for(int i = 0; i < n-k; i++){
      ans[k + i] = 1e9;
    }
  }

  for(int i = 0; i < n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=2100,mod=1e9+7;
int K,n,f[N],ans;
int qpow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=(LL)res*x%mod;
		x=(LL)x*x%mod, y>>=1;
	}
	return res;
}
int main() {
	scanf("%d%d",&n,&K);
	if(K == 1) {
		if(n == 1) puts("1");
		else printf("%d\n",qpow(2,n-2));
		return 0;
	}
	f[n+1]=1;
	for(int i=1,sum;i<K;++i) {
		sum=f[n-i+2], f[n-i+2]=0;
		for(int j=n-i+1;j>=2;--j)
			sum=(sum+f[j])%mod, f[j]=sum;
	}
	for(int i=2;i<=n;++i)
		ans=(ans+f[i])%mod;
	if(n-K-1>=0) ans=(LL)ans*qpow(2,n-K-1)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
	return 0;
}


Measured memory_bytes: 3632