akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		a[i] /= 2;
	}
	int pk = -1;
	ll x = 1;
	for (int i = 0; i < n; ++i) {
		int k = 1;
		while (a[i] % (k << 1) == 0) k <<= 1;
		if (pk != -1 && pk != k) {
			printf("0\n");
			return 0;
		}
		pk = k;
		x = x * a[i] / __gcd(x, (ll)a[i]);
		if (x > m) {
			printf("0\n");
			return 0;
		}
	}
	int nums = m / x;
	int ans = (nums + 1) / 2;
	printf("%d\n", ans);
}


Measured memory_bytes: 640
function diff(a,b,c) {
	if (a === b && b === c) {
		return 0
	}

	if (a === b || b === c || c === a) {
		return 1
	}

	return 2
}


function main(arg) {
	var tmp = arg.split("\n")
	var N = Number(tmp[0])
	var A = tmp[1]
	var B = tmp[2]
	var C = tmp[3]

	var sum = 0

	for (var i = 0; i < N;i ++) {
		var tmp = diff(A[i], B[i], C[i])
		sum += tmp
	}

	console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  ll n;
  cin>>n;
  if(n%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll res = 10;
  while(n/res){    
    ans += n/res;
    res *= 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string N = Console.ReadLine();
        int n = Convert.ToInt32(N);

        string A = Console.ReadLine();
        string[] a = A.Split(' ');
        int[] an = new int[n];
        int check1 = 0;
        int check2 = 0;

        for (int i = 0; i < n; i++)
        {
            an[i] = Convert.ToInt32(a[i]);

            if (an[i]%2==0)
            {
                check1++;

                if (an[i] % 3 == 0 || an[i] % 5 == 0)
                {
                    check2++;
                }
            }
        }

        if (check1==check2)
        {
            Console.WriteLine("APPROVED");
        }
        else
            Console.WriteLine("DENIED");
    }
}

Measured memory_bytes: 18004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int t,x; cin>>t>>x;
    cout<<fixed<<setprecision(5);
    cout<<(double)t/x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 30;
ll N, K;

int len(ll x) {
  int res = 0;
  while (x) {
    x /= 10;
    res++;
  }
  return res;
}

ll sumDigitLen(ll x) {
  if (x == 0) return 0;
  ll res = 0;
  for (ll d = 0, pw = 1; ; d++, pw *= 10) {
    if (pw <= x && x < pw * 10) {
      res += (x - pw + 1) * (d + 1);
      break;
    } else {
      res += (pw * 10 - pw) * (d + 1);
    }
  }
  return res;
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> N >> K, N) {
    ll ok = 0, ng = INF;
    while (ng - ok > 1) {
      ll mid = (ok + ng) / 2;
      if (sumDigitLen(mid) < N) ok = mid;
      else ng = mid;
    }

    ll rem = N - 1 - sumDigitLen(ok);
    string s = to_string(ng);
    for (int i = rem; i < s.size(); i++) {
      if (!(i - rem < K)) break;
      cout << s[i];
    }

    ll d;
    K -= s.size() - rem;
    for (d = ng + 1; K - len(d) >= 0; d++) {
      s = to_string(d);
      for (int i = 0; i < s.size(); i++) {
        cout << s[i];
      }
      K -= len(d);
    }

    s = to_string(d);
    for (int i = 0; i < min((ll)s.size(), K); i++) {
      cout << s[i];
    }
    cout << endl;
  }  

  return 0;
}


Measured memory_bytes: 3240
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let r: i64 = input();
    let g: i64 = input();
    println!("{}", 2 * g - r);
}


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

int main(){
    int K,S;
    cin >> K >> S;
    int ans=0;

    for(int x=0; x<=min(K,S); x++){
        for(int y=0; y<=min(K,S); y++){
            if(0<=S-x-y and S-x-y<=K) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
$num_array = explode(" ", trim(fgets(STDIN)));
$limit = array_sum($num_array) / (4*$m);
$count = 0;
foreach ($num_array as $value) {
	if($value>=$limit){
		$count += 1;
	}
}

$ans = $count >= $m ? "Yes" : "No";
echo $ans . "\n";

Measured memory_bytes: 4856
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
ll a[200005], b[200005];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    for (int i = 1,x; i <= n; i++) {
        cin >> x;
        a[i] += a[i-1] + x;
    }
    for (int i = 1, x; i <= m; i++) {
        cin >> x;
        b[i] += b[i-1] + x;
    }
    int j = m;
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) break;
        while (a[i] + b[j] > k && j) j--;
        if (a[i] + b[j] <= k)
        ans = max(i+j, ans);
    }
    cout << ans;
    //system("pause");
}

Measured memory_bytes: 6288
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int N, minv, maxv;  cin >> N;
    long ans;
    std::vector<int> v(N), u(N);
    for(int i=0; i<N; i++){
        int A, B;   cin >> A >> B;
        v[i] = A;
        u[i] = B;
    }
    std::sort(v.begin(),v.end());
    std::sort(u.begin(),u.end());
    if(N%2 == 1){
        minv = v[int((N-1)/2)];
        maxv = u[int((N-1)/2)];
    }else{
        minv = v[int(N/2) - 1] + v[int(N/2)];
        maxv = u[int(N/2) - 1] + u[int(N/2)];
    }
    ans = maxv - minv + 1;
    cout << ans;
}

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

using namespace std;

#define ll long long

ll MIN(ll num1,ll num2){
    return num1<num2?num1:num2;
}

int main(){

    int N;
    string S,T;

    cin>>N>>S>>T;

    int ans=0;
    for(int i=0;i<N;i++){
        if(S.substr(i,N-i)==T.substr(0,N-i)){
            ans=N-i;
            break;
        }
    }
    cout<<N*2-ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

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

}
 ll lcm(ll a, ll b) {
	 ll g = gcd(a, b);
	 return a / g * b;
 }

 int main() {
	 std::string s;
	 while (std::cin >> s) {
		 if (s == "-") {
			 break;
		 }
		 int n;
		 std::cin >> n;
		 for (int i = 0;i < n;i++) {
			 int a;
			 std::cin >> a;
			 s = s.substr(a) + s.substr(0, a);
		 }
		 std::cout << s << std::endl;
	 }
	return 0;
}


Measured memory_bytes: 3152
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int len = nums.length;
			int[] A = new int[ len ];
			int i, len2 = len-1;

			StringBuilder output = new StringBuilder( 100+1 );									
			for( i=0; i<len; i++ ) {
				A[i] = Integer.parseInt( nums[i] );
				output.append( A[i]  );
				output.append( " "  );
			}
			output.deleteCharAt( output.lastIndexOf( " " ) );
			output.append( "\n"  );

			int key;
			int j, k;
 			for( i=1; i<len; i++ ) {
				key = A[i];
				j = i - 1;
				while( 0 <= j && key < A[j] ) {
					A[ j+1 ] = A[j];
					j--;
				}
				A[ j+1 ] = key;
				for( k=0; k<len; k++ ) {
					output.append( A[k]  );
					output.append( " "  );
				}
				output.deleteCharAt( output.lastIndexOf( " " ) );
				output.append( "\n"  );
			}
			System.out.print( output  );
			
 			kb.close();
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 19880
def main():
    A, B = [int(ele) for ele in input().split()]
    ans = -1
    if 13 <= A:
        ans = B
    elif 6 <= A <= 12:
        ans = int(B/2)
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()


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


namespace std
{
    class Test {
        static void Main(string[] args) {
           int k = 0;
            var n = int.Parse(Console.ReadLine());
            int[] line = new int[n]; 
            
          for (int i = 0; i < n; i++) {
                    line[i] = int.Parse(Console.ReadLine());
                }
        
        shellSort(line, n);
      
      
  
      
        }


     static  int insertionSort(int[] A, int n, int g) {
          int cnt = 0, v, j;
            for (int i = g; i < n; i++) {
                v = A[i];
                j = i - g;
                while (j >= 0 && A[j] > v) {
                    A[j+g] = A[j];
                    j = j - g;
                    cnt++;
                }
            
                A[j+g] = v;
            }
           // shellSort(A, n);
            return cnt;
          
        } 
        
        static void shellSort(int[] A, int n) {
           int cnt = 0;
          int  m = 0;
           List<int> G = new List<int>();
          
          
          	G.Add(1);
		    for(int i = 0; 3 * G[i] + 1 < A.Length; i++) {
			    G.Add(3 * G[i] + 1);
		    }
		    G.Reverse();  
            for (int i = 0; i < G.Count; i++) {
               cnt+= insertionSort(A, n, G[i]);
            }
        
           StringBuilder sb = new StringBuilder();
		    sb.AppendLine(G.Count.ToString());
		    sb.AppendLine(string.Join( " ", G.Select(s => s.ToString()).ToArray() ) );
		    sb.AppendLine(cnt.ToString());
		    foreach(var a in A) {
			    sb.AppendLine(a.ToString());
		    }
		    Console.Write(sb);
	    }
            
   
    }
}
      
      
      
      
      
      
      
      
      
      
      



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

int main() {
  int n;
  cin>>n;
  long long a[n+1];
  for (int i=0; i<=n; i++) cin>>a[i];
  if (n == 0) {
    if (a[0] == 1) {
      cout<<1<<endl;
    } else {
      cout<<-1<<endl;
    }
    return 0;
  }
  if (a[0] != 0 || a[n] == 0) {
    cout<<-1<<endl;
    return 0;
  }
  long long left[n+1], right[n+1];
  for (int i=0; i<=n; i++) {
    left[i] = 0;
    right[i] = 0;
  }
  left[0] = 1;
  long long inf = 1e15;
  for (int i=1; i<=n; i++) {
    long long tmp = min((left[i-1] - a[i-1]) * 2, inf);
    left[i] = tmp;
    if (left[i] < 0) {
      cout<<-1<<endl;
      return 0;
    }
  }
  if (left[n] < a[n]) {
    cout<<-1<<endl;
    return 0;
  }
  right[n] = a[n];
  for (int i=n-1; i>=0; i--) {
    long long tmp = right[i+1] + a[i];
    right[i] = tmp;
  }
  long long cnt = 0;
  for (int i=0; i<=n; i++) {
    if (i < n && a[i] >= right[i]) {
      cout<<-1<<endl;
      return 0;
    }
    cnt += min(left[i], right[i]);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 5900
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: Chars,
        b: Chars,
        c: Chars
    };
    println!(
        "{}",
        ["NO", "YES"][((a.last().unwrap() == b.first().unwrap())
            && (b.last().unwrap() == c.first().unwrap())) as usize]
    );
}


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

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

  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
# ABC123
# Five Dishes
#B=A R=B G=C P=D T=E
Ryori = [input() for _ in range(5)]
O = []
t = 0
for i in Ryori:
    if int(i[-1]) == 0:
        x = Ryori.pop(Ryori.index(i))
        O.append(x)
Ryori = sorted(Ryori,key=lambda x: x[-1], reverse=True)

for i in range(len(Ryori)-1):
    for j in range(10):
        if (int(Ryori[i]) + j) % 10 == 0:
            t += int(Ryori[i]) + j
t += int(Ryori[-1])

for i in O:
    t += int(i)
print(t)


Measured memory_bytes: 9104
import java.util.Scanner;

class Main {

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

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(b-a<=0){
      System.out.print("delicious");
    }else if(b-a<=x){
		  System.out.print("safe");
    }else{
      System.out.print("dangerous");
    }

	}

}


Measured memory_bytes: 22228
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        string b;
        cin >> b;
        string S = "ACGT", T = "TGCA";

        for (int i = 0; i < 4; i++)
        {
                if (b[0] == S[i])
                {
                        cout << T[i] << endl;
                }
        }

        return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
dp = [float("inf")] * (N + 1)
dp[0] = 0
for i in range(N):
  dp[i + 1] = min(dp[i + 1], dp[i] + 1)
  for j in range(1, 8):
    if i + pow(6, j) <= N: dp[i + pow(6, j)] = min(dp[i + pow(6, j)], dp[i] + 1)
    if i + pow(9, j) <= N: dp[i + pow(9, j)] = min(dp[i + pow(9, j)], dp[i] + 1)
print(dp[-1])

Measured memory_bytes: 48976
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

typedef pair<int,int> pii;

// 各数字の現在の場所
pii numToPlc[101];
// 各場所にある数字
int plcToNum[10][10];
int res;
map<vector<vector<int> >,int > m;
vector<vector<int> > g;

// 引き数で与えられる数字を移動
// 移動できない場合はfalse
bool moveNum(int a){
  pii cur=numToPlc[a];
  if(a%10==1){
    numToPlc[a].first=(a/10)-1;
    numToPlc[a].second=0;
    plcToNum[(a/10)-1][0]=a;
    // 最初の場所はギャップ化する
    plcToNum[cur.first][cur.second]=-1;
    return true;
  }
  pii nxtPos=numToPlc[a-1];nxtPos.second++;
  // もし移動先がgapでない
  if(plcToNum[nxtPos.first][nxtPos.second]!=-1
     ||nxtPos.second>=8)
    return false;
  // 移動先がgapの場合、移動を行う
  else{
    numToPlc[a]=nxtPos;
    plcToNum[nxtPos.first][nxtPos.second]=a;
    plcToNum[cur.first][cur.second]=-1;
    return true;
  }
}
// 数字aをpの場所へ移動させる(戻す)
void backNum(int a,pii &p){
  pii cur=numToPlc[a];
  plcToNum[cur.first][cur.second]=-1;
  numToPlc[a]=p;
  plcToNum[p.first][p.second]=a;
}

vector<vector<int> > trans(){
  vector<vector<int> > res(4,vector<int>(8,-1));
  for(int i=1;i<=4;i++){
    for(int j=1;j<=7;j++){
      pii &p=numToPlc[i*10+j];
      res[p.first][p.second]=i*10+j;
    }
  }
  return res;
}

void dfs(int hand){
  vector<vector<int> > tmp=trans();
  if(g==tmp){
    res=min(res,hand);
    return;
  }
  else if(m.find(tmp)!=m.end()&&m[tmp]<=hand)return;
  // 最小手数を更新
  m[tmp]=hand;
  // 全数字動かせるか調べる
  for(int i=1;i<=4;i++){
    for(int j=2;j<=7;j++){
      pii cur=numToPlc[i*10+j];
      bool ok=moveNum(i*10+j);
      if(ok){
	dfs(hand+1);
	backNum(i*10+j,cur);
      }
    }
  }
}

int main(){
  const int INF=1000000000;
  // goalの状態を作成
  for(int i=0;i<4;i++)g.push_back(vector<int>(8,-1));
  for(int i=0;i<4;i++)
    for(int j=0;j<7;j++)
      g[i][j]=(i+1)*10+(j+1);
  int t;
  cin>>t;
  while(t--){
    m.clear();
    res=INF;
    memset(plcToNum,-1,sizeof(plcToNum));
    for(int i=0;i<4;i++){
      for(int j=0;j<7;j++){
	int a;
	cin>>a;
	numToPlc[a].first=i;
	numToPlc[a].second=j+1;
	plcToNum[i][j+1]=a;
      }
    }
    // 11,21,31,41を左へ移動
    for(int i=1;i<=4;i++)moveNum(i*10+1);
    // 深さ優先で移動を全通り試す
    dfs(0);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (a == b) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int i;
  int n,sum=1;
  string s;
  cin>>n>>s;
  s+=' ';
  rep(i,0,n-1){
    if(s.at(i)!=s.at(i+1)){
      ++sum;
    }
  }
  cout<<sum<<endl;
}

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

int main() {
  int n, m, x, a;
  int l = 0;
  int r = 0;
  cin >> n >> m >> x;

  for (int i = 0; i < m; i++) {
    cin >> a;
    if (a < x)
      l++;
    else
      r++;
  }
  cout << (l < r ? l : r) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int T,A,B;
  cin>>T>>A>>B;
  cout<<min(T*A,B);
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/20  Problem: ABC 051 D / Link: http://abc051.contest.atcoder.jp/tasks/abc051_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

LL ans = 0LL;

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


	cin >> N >> M;
	VVI d(N, VI(N, INF));
	vector<pair<PII, int>>edge;
	FOR(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		d[a][b] = d[b][a] = c;
		edge.push_back(pair<PII, int>(PII(a, b), c));
	}
	FOR(i, 0, N)d[i][i] = 0;
	FOR(k, 0, N)FOR(i, 0, N)FOR(j, 0, N) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}

	FOR(i, 0, M) {
		int s, t, c;
		auto a = edge[i];
		s = a.first.first;
		t = a.first.second;
		c = a.second;
		int nouse = 1;
		FOR(j, 0, N) {
			FOR(k, 0, N) {
				if (d[j][k] == d[j][s] + c + d[t][k])nouse = 0;
			}
		}
		ans += nouse;

	}

	cout << ans << "\n";

	return 0;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;


struct node {
    int p, l, r;
};
node nodes[100000];


void preorder(int id)
{
    cout << " " << id;
    if (nodes[id].l >= 0)
        preorder(nodes[id].l);
    if (nodes[id].r >= 0)
        preorder(nodes[id].r);
}


void inorder(int id)
{
    if (nodes[id].l >= 0)
        inorder(nodes[id].l);
    cout << " " << id;
    if (nodes[id].r >= 0)
        inorder(nodes[id].r);
}


void postorder(int id)
{
    if (nodes[id].l >= 0)
        postorder(nodes[id].l);
    if (nodes[id].r >= 0)
        postorder(nodes[id].r);
    cout << " " << id;
}


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

    for (int i = 0; i < n; i++)
        nodes[i].p = -1;

    for (int i = 0; i < n; i++) {
        int id;
        int l, r;
        cin >> id;
        cin >> l >> r;
        nodes[id].l = l;
        nodes[id].r = r;

        if (l >= 0)
            nodes[l].p = id;
        if (r >= 0)
            nodes[r].p = id;
    }

    int root;
    for (int i = 0; i < n; i++)
        if (nodes[i].p == -1) {
            root = i;
            break;
        }

    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;
}


Measured memory_bytes: 3104
// C - Pyramid
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define manhattan(x1,y1,x2,y2) (abs((x1)-(x2))+abs((y1)-(y2)))
#define XMAX 100
#define YMAX 100

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

	VI X(N),Y(N),H(N);

	rp(i, N) cin>>X[i]>>Y[i]>>H[i];

	rp(y0, YMAX+1){
		rp(x0, XMAX+1){

			int x,y,h;

			rp(i, N){
				x = X[i], y = Y[i], h = H[i];
				if(h > 0) break;
			}

			int h0 = h + manhattan(x0,y0, x,y);

			bool exist = true;
			rp(i, N){
				x = X[i], y = Y[i], h = H[i];
				if(h <= 0) continue;
				if(h0 != h + manhattan(x0,y0, x,y)){
					exist = false;
					break;
				}
			}
			if(!exist) continue;

			rp(i, N){
				x = X[i], y = Y[i], h = H[i];
				if(h > 0) continue;
				if(h0 - manhattan(x0,y0, x,y) > 0){
					exist = false;
					break;
				}
			}
			if(exist){
				cout<<x0<<" "<<y0<<" "<<h0<<"\n";
				return 0;
			}

		}
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long a = sc.nextLong();
		String s = sc.next();
		s = s.replace(".", "");
		long bx100 = Integer.parseInt(s);

		long tmp = a * bx100;
		long res = tmp / 100;

		System.out.printf("%d", res);
	}
}

Measured memory_bytes: 35836
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FSugoroku {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        string s;
        cin >> s;
        reverse(s.begin(), s.end());

        int cur = 0;
        vector<int> res;
        while (cur < N) {
            int next = min(cur + M, N);
            while (s[next] == '1') {
                next--;
            }
            if (next == cur) {
                cout << -1 << endl;
                return;
            }
            res.push_back(next - cur);
            cur = next;
        }

        reverse(res.begin(), res.end());
        REP(i, res.size()) {
            cout << res[i] << " ";
        }
        cout << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FSugoroku solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1480
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

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

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const double PI = acos(-1);

int main() {
	IOS;
	string s; cin >> s;
	reverse(s.begin(), s.end());
	vector<int> a(s.length());
	llong pow = 1;
	for (int i = 0; i < s.length(); i++) {
		if (i == 0) a[i] = s[i] - '0';
		else a[i] = (a[i-1] + (s[i] - '0') * pow) % 2019;
		pow *= 10;
		pow %= 2019;
	}
	a.push_back(0);
	vector<llong> cnt(2019);
	for (int i = 0; i < s.length()+1; i++) {
		cnt[a[i]] ++;
	}
	llong ans = 0;
	for (int i = 0; i < 2019; i++) {
		ans += cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << ans;
}

Measured memory_bytes: 5160
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn=1e5+5,INF=1e10;
ll n,m,v,p,a[maxn];
bool check(int x) {
	int de=n-p;ll sum=0;
	for(int i=n;i>=1 && de!=0;i--)
	{
		if(i!=x)
		{
			if(a[x]-a[i]>m)
				return false;
			sum+=max(a[x]-a[i],0ll);de--;
		}
	}
	return sum<=1*m*v;
}
int main()
{
	cin>>n>>m>>v>>p;
	v=n-v;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];a[i]=INF-a[i];
	}
	sort(a+1,a+n+1);
	int l=1,r=n,mid;
	while(l<r)
	{
		mid=(l+r+1)/2;
		if(check(mid))
			l=mid;
		else
			r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,k,ans=0;
string s;
int main(){
	int i,j;
	cin>>n>>k;
	cin>>s;
	for(i=1;i<s.size();i++)
	{
		if(s[i]==s[i-1])
		{
			ans++;
		}
	}
	i=1;
	j=n-2;
	while(k>0&&i<=j)
	{
		while(s[i]==s[i-1]&&i<n)
		{
			i++;
		}
		while(s[j]==s[j+1]&&j>=0)
		{
			j--;
		}
		if(i>j)
		{
			break;
		}
		i++;
		j--;
		ans+=2;
		k--;
	}
	if(k!=0)
	{
		if(i==j+1)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

import time, random
import time
start = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [None]*D
for i in range(D):
    s[i] = list(map(int, input().split()))
    
current = [0]*26
ans = [None]*D
def greedy(weight=1.0):
    ans = [None]*D
    for i,ss in enumerate(s):
        vs = [None]*26
        for j in range(26):
            vs[j] = (ss[j] + current[j]*weight, j)
            current[j] += c[j]
        vs.sort()
        v = vs[-1][1]
        ans[i] = v+1
        current[v] = 0
    return ans
def val(ans, c):
    current = [0]*26
    val = 0
    for i,(ss, v) in enumerate(zip(s, ans)):
        for j in range(26):
            current[j] += c[j]
        current[v-1] = 0
        val += ss[v-1] - sum(current)
    return val

ans = greedy()
best = ans
bval = val(ans, c)
num = 2
ren = 0
w = 1.0

for w in range(100, 5000, 10):
    weight = w/100
    tmpans = greedy(weight)
    tmpval = val(tmpans, c)
    if tmpval>bval:
        bval = tmpval
        best = tmpans
        bw = weight
    if time.time() - start >= 1.8:
        break
#         print(bval)
    
write("\n".join(map(str, best)))

Measured memory_bytes: 81720
N,K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(2*K)]


List=[]
for i in range(N):
    for j in range(K):
        check = 0
        for k in range(len(A[1+2*j])):
            if A[1+2*j][k] == i+1:
                check = check + 1
        if check ==0:
            List.append(i+1)


ans = 0
for i in range(1,N+1):
    p = 0
    for j in range(len(List)):
        if List[j] == i:
            p = p+1
    if p == K:
        ans = ans +1
        
        
    
            
print(ans)

Measured memory_bytes: 9228
# coding: utf-8
# Your code here!
N,W=map(int,input().split())
dp=[[-1]*301 for i in range(N+1)]
dp[0][0]=0

for i in range(N):
    w,v=map(int,input().split())
    if i==0:
        base=w
    for i in range(N)[::-1]:
        for j in range(301)[::-1]:
            if dp[i][j]!=-1:
                dp[i+1][j+w-base]=max(dp[i][j]+v,dp[i+1][j+w-base])

ans=0
for index,item in enumerate(dp):
    if W-index*base+1<=0:
        break
    ans=max(max(item[:W-index*base+1]),ans)
    #print(item[:W-index*base+1])

print(ans)


Measured memory_bytes: 42988
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n, m, x; 
    cin >> n >> m >> x;
    vector<int> cs(n, 0); 
    vector<vector<int>> as(n, vector<int>(m, 0));
    rep(i, n) {
        cin >> cs[i];
        rep(j, m) cin >> as[i][j];
    } 
    int tot = 1 << n;
    int ret = numeric_limits<int>::max();
    rep(i, tot) {
        vector<int> ac(m, 0);
        int c = 0;
        rep(j, n) {
            if (i >> j & 1) {
                rep(k, m) ac[k] += as[j][k];
                c += cs[j]; 
            }
        }
        bool check = true;
        rep(k, m) {
            if (ac[k] < x) {
                check = false;
                break;
            } 
        }
        if (check) ret = min(c, ret);
    }
    int ans = ((ret == numeric_limits<int>::max()) ? -1 : ret);  
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,x;cin>>n>>x;
  int m,a=1000,ans=0;
  for (int i = 0; i < n; ++i){
  	cin>>m;
  	a=min(m,a);
  	x-=m;
  	ans++;
  }
  cout<<(x==0 ? ans : x/a+ans)<<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int P = 0, W = 0, G = 0, Y = 0;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;  
  
    if (S == "P") {
      P++;
      continue;
    }
    
    if (S == "W") {
      W++;
      continue;
    }
    
    if (S == "G") {
      G++;
      continue;
    }
    
    if (S == "Y") {
      Y++;
      continue;
    }
  }
  
  if (P > 0 && W > 0 && G > 0 && Y > 0) {
    cout << "Four" <<endl;
  }
  else {
    cout << "Three" <<endl;
  }
}


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

using namespace std;

int main() {
    int n, *s;  cin >> n;
    s = new int[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    
    sort(s, s+n);

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += s[i];

    if (ans % 10) {
        cout << ans << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        if ((ans - s[i]) % 10) {
            cout << ans - s[i] << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll solve(vector<vector<ll>>&dp,ll start,ll end,ll arr[]){
  if(start==end)
    return arr[start];
  if(start>end)
    return 0;
  if(end-start==1)
    return max(arr[start],arr[end]);
  if(dp[start][end]!=-1)
    return dp[start][end];
  dp[start][end]=arr[start]+min(solve(dp,start+2,end,arr),solve(dp,start+1,end-1,arr));
  dp[start][end]=max(dp[start][end],arr[end]+min(solve(dp,start,end-2,arr),solve(dp,start+1,end-1,arr)));
  return dp[start][end];
}
int main(){
  ll n;
  cin>>n;
  ll arr[n];
  ll sum=0;
  for(ll i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
  }
  vector<vector<ll>>dp(n,vector<ll>(n,-1));
  ll start=0;
  ll end=n-1;
  ll ans=solve(dp,start,end,arr);
  cout<<ans-(sum-ans)<<endl;
}

Measured memory_bytes: 73988
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll a, b, c;
	cin >> a >> b >> c;
	
	vector<ll> x = {a, b, c};
	sort(x.begin(), x.end());
	
	if( x[2] % 2 == 0 ) {
		cout << 0 << endl;
	} else {
		cout << (x[0] * x[1]) * ( ( (x[2] + 1) / 2) - (x[2] / 2) ) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n,x,y;
  cin >> n >> x >> y;
  int mx = min(x,y);
  int mn = max(x + y - n,0);
  cout << mx << " " << mn << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

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

using namespace std;

int main(void){
  int N;
  string ans;
  cin >> N;
  if(89< N && N <100 || N==19 or N==29 or N==39 or N==49 or N==59 or N==69 or N==79 or N==89){
    ans = "Yes";
  }
  else{
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N%10==3){
  cout << "bon" << endl;
  }
  else if (N%10==0||N%10==1||N%10==6||N%10==8)
    cout << "pon" << endl;
  else{
  cout << "hon" << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {
    string s, t;
    cin >> s >> t;
    set<int> indeksi[200];
    for(int i = 0; i < s.size(); i++) {
        indeksi[s[i]].insert(i);
    }
    llint t_ind = 0, krugova = 0;
    for(int i = 0; i < t.size(); i++) {
        auto it = indeksi[t[i]].lower_bound(t_ind);
        if(indeksi[t[i]].size() == 0) {
            cout << -1;
            return 0;
        }
        if(it == indeksi[t[i]].end()) {
            krugova++;
            t_ind = *indeksi[t[i]].begin();
        }
        else {
            t_ind = *it;
        }
        t_ind++;
        if(t_ind == s.size()) {
            krugova++;
            t_ind = 0;
        }
    }
    cout << krugova * s.size() + t_ind;
}

Measured memory_bytes: 5120
#include <stdio.h>
int main(void)
{
int i,j;
int H,W;

while(1){
 scanf("%d %d",&H,&W);
 if ( H == 0 && W == 0 )
  break ;

 for(i=0;i<H;i++){
  for(j=0;j<W;j++){
   if((i+j)%2==0)
    printf("#");
   else if((i+j)%2==1)
    printf(".");
   }
   printf("\n");
 }
 printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <stdio.h>

int main(){
  int n ,num ,i ,j;
  char seg[] = "0000000";
  char L[][8] = {"0111111", "0000110", "1011011", "1001111", "1100110",
                        "1101101", "1111101", "0100111", "1111111", "1101111"};
  while(1){
    scanf("%d",&n);
    if(n==-1)break;
    for(i=0;i<n;i++){
      scanf("%d",&num);

      for(j=0;j<7;j++){
        if(L[num][j]=='1')seg[j]++;
        if(seg[j]=='2')seg[j]='0';
      }
      printf("%s\n", seg);
      for(j=0;j<7;j++){
        seg[j]=L[num][j];
      }
    }
    for(i=0;i<7;i++){
      seg[i]='0';
    }
  }

  return 0;
}

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		int c = max(a,b);
		int d = min(a,b);
			for(int i=1;i<=c;i++) cout << d;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int MatrixChainOrder(int n,int p[]){
  int i,l,j,k,q;
  int m[103][103];

  for(i = 1 ; i <= n ; i++){//
    m[i][i] = 0;
  }
  for(l = 2 ; l <= n ; l++){//
    
    for(i = 1 ; i <= n-l+1 ; i++){//
      j = i+l-1;
      m[i][j] = 1000000000;
  
      for(k = i ; k <= j-1 ; k++){//
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	
	if(q < m[i][j]){
	  m[i][j] = q;
	}
	
      }
      
    }
    
  }

  return m[1][n];
}

int main(void){
  int r[101],c[101],p[101];
  int cost,n,i;

  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  
  for(i = 0 ; i < n ; i++){
    p[i] = r[i];
  }
  p[n] = c[n-1];
  
  cost = MatrixChainOrder(n,p);

  printf("%d\n",cost);
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int N, M;
int main() {
	cin >> N >> M;
	if (N > M) swap(N, M);
	cout << (N == 1 ? (M == 1 ? 1 : M - 2) : 1LL * (N - 2) * (M - 2)) << endl;
	return 0;
}

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

char a[105];
long long k;
long long f,e,s;
long long ans;

int main()
{
    scanf("%s",a+1);
    int n=strlen(a+1);
    scanf("%lld",&k);

    bool ok=0;
    s=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])
            s++;
        else
        {
            if(!ok)f=s;
            else ans+=(s/2);
            ok=1;
            s=1;
        }
    }
    ans=ans*k;
    e=s;

    if(!ok)
        ans=e*k/2;
    else if(a[n]==a[1])
        ans=ans+(e+f)/2*(k-1)+e/2+f/2;
    else ans=ans+e/2*k+f/2*k;

    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
def prim(n):
    min_cost = [1 << 31] * n
    used = [False] * n
    min_cost[0] = 0
    ret = 0
    while 1:
        v = -1
        for u in range(n):
            if not used[u] and (v == -1 or min_cost[u] < min_cost[v]):
                v = u
        if v == -1:
            break
        used[v] = True
        ret += min_cost[v] - 100

        for u in range(n):
            min_cost[u] = min(min_cost[u], edges[v][u])
    return ret

if __name__ == '__main__':
    while 1:
        n = input()
        if n == 0:
            break
        m = input()

        edges = [[1 << 30] * n for _ in xrange(n)]
        for i in xrange(m):
            a, b, cost = map(int, raw_input().split(','))
            edges[a][b] = cost
            edges[b][a] = cost
        print (prim(n) + 100) / 100

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string S, T;
	cin >> S >> T;
	int res = 0;
	for (int i = 0; i != 3; ++i) res += S[i] == T[i];
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 200000
pair<int,int> X[N],Y[N];
pair<int,pair<int,int> > all[N];

int dsu[N];

int f(int x) {
  if(x==dsu[x]) {
    return x;
  }
  return dsu[x] = f(dsu[x]);
}
bool merge(int x,int y) {
  x = f(x),y=f(y);
  if(x==y) {
    return false;
  } else {
    dsu[x] = y;
    return true;
  }
}
void solve() {
  int n;scanf("%d ", &n);
  for(int i=0;i<n;++i) {
    scanf("%d %d ", &X[i].first,&Y[i].first);
    X[i].second = Y[i].second = i;
    dsu[i] = i;
  }
  sort(X,X+n);
  sort(Y,Y+n);
  int pos = 0;
  for(int i=0;i<n-1;++i) {
    all[pos++] = make_pair(X[i+1].first-X[i].first,make_pair(X[i].second,X[i+1].second));
    all[pos++] = make_pair(Y[i+1].first-Y[i].first,make_pair(Y[i].second,Y[i+1].second));
  }
  sort(all,all+pos);
  long long ret = 0;
  for(int i=0;i<pos;++i) {
    int w = all[i].first;
    int a = all[i].second.first,b = all[i].second.second;
    if(merge(a,b)) {
      ret += w;
    }
  }
  printf("%lld\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;

    for (int i = 0; i <= 100; i++) {
        int num = d * i;
        if (l <= num && num <= r) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632