akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	int a,b;cin>>a>>b;
	cout<<a*b<<endl;
}




Measured memory_bytes: 3600
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 n: usize = input();
    let k: usize = input();
    const MOD: i64 = 1000000007;

    let mut factorial = vec![vec![0i64; 2010]; 2010];
    factorial[0][0] = 1;
    for i in 1..factorial.len() {
        factorial[i][0] = 1;
        factorial[i][i] = 1;
        for j in 1..i {
            factorial[i][j] = (factorial[i - 1][j - 1] + factorial[i - 1][j]) % MOD;
        }
    }

    for i in 1..k + 1 {
        println!(
            "{}",
            factorial[k - 1][i - 1] * factorial[n - k + 1][i] % MOD
        );
    }
}


Measured memory_bytes: 45308
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), bi(M);
    for (int i = 0; i < M; i++) {
        cin >> a.at(i) >> b.at(i);
        int bit = 0;
        for (int j = 0; j < b[i]; j++) {
            int c;
            cin >> c;
            c--;
            bit |= 1 << c;
        }
        bi.at(i) = bit;
    }

    auto dp = make_vec<ll>(1005, 5000);
    for (int i = 0; i < 1005; i++) {
        dp[i][0] = 0;
        for (int j = 1; j < 5000; j++) {
            dp[i][j] = INF;
        }
    }

    for (int i = 0; i < M; i++) {
        for (int j = 0; j < (1 << N); j++) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | bi[i]], dp[i][j] + a[i]);
        }
    }
    if (dp[M][(1 << N) - 1] == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[M][(1 << N) - 1] << endl;
}


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


namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            
           
            int d = a / b;
            int r = a % b;
            double f = (double)a / (double)b;

            Console.WriteLine("{0} {1} {2}", d, r, f.ToString("F5"));
        }
    }
}

Measured memory_bytes: 9228
import std.stdio;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
import std.math;

void main(){

    while(true){
	auto s1 = split(readln()).to!(int[]);
	if(s1[0]==-1&&s1[1]==-1&&s1[2]==-1) break;
	int h,m,s;
	int time = s1[0] * 3600 + s1[1] * 60 + s1[2];
	time = 7200 - time;
	h = time / 3600;
	time %= 3600;
	m = time / 60;
	time %= 60;
	s = time;
	writef("%02d:%02d:%02d\n",h,m,s); 
	time = s1[0] * 3600 + s1[1] * 60 + s1[2];
	time = 7200 - time;
	time *= 3;
	h = time / 3600;
	time %= 3600;
	m = time / 60;
	time %= 60;
	s = time;
	writef("%02d:%02d:%02d\n",h,m,s); 

    }

}

Measured memory_bytes: 2380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s,t,u;
   cin >> s >> t >> u;
   if (s[s.size()-1] == t[0] && t[t.size()-1] ==u[0]) cout << "YES" << endl;
   else cout << "NO" << endl; 
  
  return 0;
}



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

using namespace std;
int main()
{
    int n,i,ans[100000]={0},cnt[2]={0,0},t;
    string s;
    cin >> s;
    n=s.size();
    for(i=0;i<n;i++){
        if(s[i]=='L'){
            t=i;
            while(s[i]=='L'){
                cnt[i%2]++;
                i++;
            }
            ans[t-1]+=cnt[(t-1)%2];
            ans[t]+=cnt[t%2];
            cnt[0]=0;
            cnt[1]=0;
        }
        cnt[i%2]++;
    }
    for(i=0;i<n;i++) cout << ans[i] << ' ';
    return 0;
}

Measured memory_bytes: 4156
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

ll A, B, Q;
ll s[100010], t[100010], x[100010];

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

  s[0] = -1e18; t[0] = -1e18;
  
  cin >> A  >> B >> Q;
  FOR(i,1,A+1) cin >> s[i];
  FOR(i,1,B+1) cin >> t[i];
  REP(i, Q) cin >> x[i];

  s[A+1] = 1e18; t[B+1] = 1e18;
  
  const ll INF = 1e18;
  
  REP(i, Q){
    ll a = upper_bound(s+1, s+A+1, x[i]) - s;
    ll b = upper_bound(t+1, t+B+1, x[i]) - t;
    //cout << a << " " << b << endl;
    ll mini = INF;

    //calc
    FOR(j,a-1,a+1){
      FOR(k,b-1,b+1){	
	mini = min(mini, min(abs(x[i]-s[j])+abs(s[j]-t[k]),abs(x[i]-t[k])+abs(s[j]-t[k])));
      }
    }
    
    cout << mini << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
//Algorithm Visualizer
#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first;
#define S second;
using namespace std;
typedef long long ll;

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n],dp[n];
    memset(dp,1000000,sizeof(dp));
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        for(int j=1; j<=k; j++){
            if(i-j>=0)
                dp[i]=min(abs(a[i-j]-a[i])+dp[i-j],dp[i]);
            else
                break;
        }
    }
    cout<<dp[n-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}




Measured memory_bytes: 4400
import java.util.Scanner;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        int d = a / b;
        int r = a % b;
        double f = 1.0 * a / b;
        
        System.out.println(d + " " + r +" " + String.format("%8f", f));
    }
    
}



Measured memory_bytes: 26448
// Last Change:                   12/09/2018 00:27:04.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

struct Barger {
  ll size;
  ll p;
};

int main() {
  ll N, X;
  Barger barger[50];
  cin >> N >> X;

  barger[0].size = barger[0].p = 1;
  for (int i = 1; i < N; i++) {
    barger[i].size = barger[i - 1].size * 2 + 3;
    barger[i].p = barger[i - 1].p * 2 + 1;
  }

  ll ans = 0, depth = N;
  while (X > 0 && depth > 0) {
    --X;
    --depth;

    if (X > barger[depth].size + 1) {
      X -= barger[depth].size + 1;
      ans += barger[depth].p + 1;
    } else if (X == barger[depth].size + 1) {
      X -= barger[depth].size + 1;
      ans += barger[depth].p + 1;
    }
    if (depth == 0 && X > 0) {
      ans++;
      X = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static void print(int[] A){
		String[] V=new String[A.length];
		for(int i=0;i<A.length;i++){
			V[i]=String.valueOf(A[i]);
		}
		System.out.println(String.join(" ",V));
	}
	
	public static void insertionSort(int[] A,int N){ // N??????????´??????????0-?????????????????????
	   for(int i=0;i<A.length;i++){
		 
	     int v = A[i];
	     int j = i - 1;
	     while(j >= 0 && A[j] > v){
	       A[j+1] = A[j];
	       j--;
	     }
	     A[j+1] = v;
	     print(A);
	   }
	}
	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	int[] A=new int[Integer.parseInt(line)];
            	line=br.readLine();
            	String[] str=line.split(" ");
            	for(int i=0;i<A.length;i++){
            		A[i]=Integer.parseInt(str[i]);
            	}
            	insertionSort(A,A.length);
            	break;
            }
        }
	}
}

Measured memory_bytes: 28444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値

// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
int main(){
ll n;
cin>>n;
ll counter=1;
while(n>0){
if(n*counter%360==0){
break;}
counter++;}
cout<<counter<<endl;}

Measured memory_bytes: 3588
import java.util.Scanner;

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

         while(true){
         int n =sc.nextInt();
         int x =sc.nextInt();
         int m =0;

         if(n==0&&x==0){
         break;
         }

         for(int a=1;a<n+1;a++){
            for(int b=a+1;b<n+1;b++){
               for(int c =b+1;c<n+1;c++){

               if(a+b+c==x){
               m++;
               }

               }
            }
         }

         System.out.println(m);

         }
            

       }
   }



Measured memory_bytes: 26380
INF = 10 ** 15
MOD = 10 ** 9 + 7 
def main():
    N,L = map(int,input().split())
    A = list(map(int,input().split()))
    point = -1
    for i in range(N - 1):
        if A[i] + A[i + 1] >= L:
            point = i + 1
            break
    if point == - 1:
        print('Impossible')
        return
    ans = []
    for i in range(point - 1):
        ans.append(i + 1)
    for i in range(N - 2,point - 1,-1):
        ans.append(i + 1)
    ans.append(point)
    print('Possible')
    print('\n'.join(map(str,ans)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 18120
"""
abc141-b
"""

S = input()

ans="Yes"

for i in range(int(len(S))):
    if (i % 2 == 0):
        if (S[i] == "L"):
            ans="No"
            break
    else:
        if (S[i] == "R"):
            ans="No"
            break
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll n,k,x,y,i,j,q;
   vector<ll>v,u;
   ll sum=0;
   cin>>n>>k;
  ll ans=k;
  for(i=0;i<n-1;i++)
  {
      ans*=(k-1);
  }
  cout<<ans<<endl;
    return 0;
}


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

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for ( int i = 0; flag; i++ ) {
        flag = 0;
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j] < A[j - 1] ) {
                swap(A[j],A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    
    sw = bubbleSort(A, N);
    
    for ( int i = 0; i < N; i++ ) {
        if (i) cout << " "; //最初以外
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3136
n,m = map(int,input().split())
ac = 0
wa = 0
acbox = [0]*(n+1) #配列作って初期化
wabox = [0]*(n+1)
for i in range(m):
  p,q = input().split()
  p = int(p)
  if q == "WA":
    if acbox[p] == 0:
      wabox[p] += 1
  else:
    if acbox[p] == 0:
      ac += 1
      wa += wabox[p]
      acbox[p] =+ 1
print(ac,wa)



Measured memory_bytes: 4596
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる
#define _abs(x) ((x)<0 ? -(x) : (x))
#define _MAX 200000
#pragma endregion

// ABC095 B - Bitter Alchemy

int main(void) {
	int i,n,x,m[101],min=_MAX,mp;

	scanf("%d %d ", &n,&x);

	for (i = 0; i < n; i++) {
		scanf("%d", &m[i]);
		if (m[i] < min) {
			min = m[i];
			mp = i;
		}
		x -= m[i];
	}

	printf("%d\n",n+x/m[mp]);
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define ll long long
#define L long
#define endl "\n"
#define mset(x, val) memset(x, val, sizeof(x))
#define For(i, init, n) for (ll int i = init; i < n; i++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const double PI = acos(-1.0), E = exp(1.0), EPS = DBL_EPSILON;
const ll int MOD = (ll int)1e9 + 7, N = (ll int)1e5;

int main()
{   
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    int n;
    cin >> n;
    int x;
    set<int> st;
    while (n--)
    {
        cin >> x;
        if (st.find(x) == st.end())
            st.insert(x);
        else
        {
            cout<< "NO";
            return 0;
        }
    }
    cout<< "YES";
    
    return 0;
}

Measured memory_bytes: 12972
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12)

p,q = map(int,list(f(raw_input())))
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)]


Measured memory_bytes: 28012
/* 拡張ダイクストラ */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int n, m, q;
ll ans = 0;
ll a[50], b[50], c[50], d[50];

typedef struct {
    ll app[10];
} gr;

void dfs(gr tmp, int kosu) {
    if(kosu == n) {
        ll tmp2 = 0;
        REP(i, q) {
            if(tmp.app[b[i]] - tmp.app[a[i]] == c[i]) tmp2 += d[i];
        }
        ans = max(tmp2, ans);
    } else {
        REPN(i, tmp.app[kosu-1], m+1) {
            tmp.app[kosu] = i;
            dfs(tmp, kosu+1);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    REP(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    REPN(i, 1, m+1) {
        gr tmp;
        tmp.app[0] = i; 
        dfs(tmp, 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{


    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();//n??????????????????
		int m = scan.nextInt();//m?????????????¨????
		
		int retu[][] = new int[n][m];//??????
		int beku_b[] = new int[m];//???????????????B
		int beku_c[] = new int[n];//???????????????C
		
		//?????????????????????????´?
		for (int cnt_n = 0; cnt_n < n; cnt_n++){
			for (int cnt_m = 0; cnt_m < m; cnt_m++) {
				retu[cnt_n][cnt_m] = scan.nextInt();
			}
		}
		//???????????????B???????????????????´?
		for (int cnt_m = 0; cnt_m < m; cnt_m++) {
			beku_b[cnt_m] = scan.nextInt();
		}
		
		//???????????????C????¨??????¨????´?
		for (int cnt_n = 0; cnt_n < n; cnt_n++){
			for (int cnt_m = 0; cnt_m < m; cnt_m++) {
				beku_c[cnt_n] += retu[cnt_n][cnt_m] * beku_b[cnt_m];
			}
		}

		//????????????
		for (int cnt_c = 0; cnt_c < n; cnt_c++){
					System.out.println(beku_c[cnt_c]);
			}
		scan.close();
	}
}

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

int main(){

    int i,j,n,k;
    cin>>n>>k;

    double p = (double) (1.0/n);
    double sum=0;

    for(i=1;i<=n;i++){
        double num=i,c=0;
        while(1){
            num*=2;
            c++;
            if(num>=k) break;
        }

        if(i>=k) c--;
        double m = pow(0.5,c);
        sum+= m;
    }

        printf("%.10f\n",sum*p);

    return 0;
}


Measured memory_bytes: 256
while True:
	a, op, b = input().split()
	a = int(a)
	b = int(b)
	if op == "+":
		print(a + b)
	elif op == "-":
		print(a - b)
	elif op == "*":
		print(a * b)
	elif op == "/":
		print(a // b)
	elif op == "?":
		break

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

int n,m,q;
vector<int> a,b,c,d;
int ans=-1;

void dfs(vector<int> A){
  if(A.size() > n){
    int pt = 0;
    for(int i=0;i<q;i++){
      if(A[b[i]] - A[a[i]] == c[i]) pt+=d[i]; 
    }
    ans = max(pt, ans);
    return ;
  }
  
  A.push_back(A.back());
  while(A.back() <= m){
    dfs(A);
    A.back()++;
  }
}

int main(void){
    // Your code here!
    cin>>n>>m>>q;
    a=b=c=d=vector<int> (q);
    for(int i=0;i<q;i++){
      cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int> A(1,1);
    dfs(A);
    cout<<ans<<endl;
}


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

int main() {
  int H, W;
  scanf("%d%d", &H, &W);

  string pixel;
  for (int i = 0; i < H; i++) {
      cin >> pixel;
      cout << pixel << endl;
      cout << pixel << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll K, A, B, num=1, i;

    cin >> K >> A >> B;

    i = 1;
    while(i<=K){
        if(num>=A && i<=K-1 && B-A>=3){
            num += (B-A);
            i += 2;
        }
        else{
            num++;
            i++;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

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

	int N,x,X[200000],X2[200000];
	cin>>N;
	REP(i,N){
		cin>>x;
		X[i]=X2[i]=x;
	}
	SORT(X2,N);
	int tem=X2[(N+1)/2-1],tem2=X2[(N+1)/2];

	REP(i,N){
		if(X[i]<=tem) print(tem2);
		else print(tem);
	}
	return 0;
}


Measured memory_bytes: 3712
import java.lang.reflect.Array;
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 ans = n * (n - 1) / 2 + m * (m - 1) / 2;

        System.out.println(ans);
    }

}


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

ans = 0

for i in range(n):
    if a[i] - b[i] >= 0:
        ans += b[i]
    elif a[i] < b[i] <= a[i] + a[i+1]:
        ans += b[i]
        a[i+1] -= b[i] - a[i]
    elif a[i] + a[i+1] < b[i]:
        ans += a[i] + a[i+1]
        a[i+1] = 0

print(ans)


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

vector<ll> width = {1LL};

ll solve(ll s1, ll s2, ll l1, ll l2, int level){
    if (level == 0) return abs(l1-l2);
    ll w = width[level-1];
    if (s1/w != s2/w) {
        return abs(s1-s2) + abs(l1-l2);
    } else if (s1/w == 1 && abs(l1/w - l2/w) >= 2) {
        return min(s1%w + s2%w + 2, w*2 - s1%w - s2%w) + abs(l1-l2);
    } else {
        return solve(s1%w, s2%w, l1, l2, level-1);
    }
}

int main(void){
    rep(i,30){
        width.push_back(width.back() * 3LL);
    }
    int Q;
    cin >> Q;
    rep(q,Q){
        ll x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--,y1--,x2--,y2--;
        if (abs(x1-x2) > abs(y1-y2)) {
            swap(x1,y1), swap(x2,y2);
        }
        cout << solve(x1,x2,y1,y2,30) << endl;
    }
    return 0;
}


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

using M = Mint<1'000'000'007>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto k = load<int>();
    auto bounds = loadMany<int>(n);
    auto dyn = vector<vector<M>>(n+1, vector<M>(k+1, 0));
    auto pre = vector<vector<M>>(n+1, vector<M>(k+1, 0));
    dyn[0][0] = 1;
    for (auto j=0; j<=k; ++j)
        pre[0][j] = 1;
    for (auto i=0; i<n; ++i) {
        for (auto j=0; j<=k; ++j) {
            dyn[i+1][j] = pre[i][j];
            if (j-bounds[i]-1 >= 0)
                dyn[i+1][j] -= pre[i][j-bounds[i]-1];
            pre[i+1][j] = dyn[i+1][j];
            if (j > 0)
                pre[i+1][j] += pre[i+1][j-1];
        }
    }
    cout << dyn[n][k] << '\n';
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  constexpr auto K = 'z' - 'a' + 1L;

  array<int64_t, K> a{};
  for (auto i : irange(0L, n)) {
    string s;
    cin >> s;

    array<int64_t, K> t{};
    for (auto c : s) {
      ++t[c - 'a'];
    }
    for (auto j : irange(0L, K)) {
      if (i == 0 || t[j] < a[j]) {
        a[j] = t[j];
      }
    }
  }

  for (auto i : irange(0L, K)) {
    for (auto j : irange(0L, a[i])) {
      cout << char('a' + i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 100005
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n; cin>>n;
    while(n){
        ll x=n%10;
        if(x==7){
            cout<<"Yes";
            return 0;
        }
        n/=10;
        if(n==1)
            break;
    }
    cout<<"No";

    
    return 0;
}


Measured memory_bytes: 3592
class Hand
  def initialize(cards)
    @cards = cards.sort
  end

  def what_hand
    case
    when is_four_card?
      'four card'
    when is_full_house?
      'full house'
    when is_straight?
      'straight'
    when is_three_card?
      'three card'
    when is_two_pair?
      'two pair'
    when is_one_pair?
      'one pair'
    else
      'null'
    end
  end

  private

  def is_one_pair?
    is_n_card?(2)
  end

  def is_two_pair?
    ( is_n_card?(2, @cards[0,2]) and is_n_card?(2, @cards[2,2]) ) or
    ( is_n_card?(2, @cards[0,2]) and is_n_card?(2, @cards[3,2]) ) or
    ( is_n_card?(2, @cards[1,2]) and is_n_card?(2, @cards[3,2]) )
  end

  def is_three_card?
    is_n_card?(3)
  end

  def is_straight?
    return true if @cards.inject do |x,y|
                     break if x + 1 != y
                     y
                   end
    return true if @cards[1] == 10 and @cards[2] == 11 and @cards[3] == 12 and
                   @cards[4] == 13 and @cards[0] == 1
    false
  end

  def is_full_house?
    ( is_n_card?(3, @cards[0..2]) and is_n_card?(2, @cards[3..4]) ) or
    ( is_n_card?(2, @cards[0..1]) and is_n_card?(3, @cards[2..4]) )
  end

  def is_four_card?
    is_n_card?(4)
  end

  def is_n_card?(n, cards = @cards)
    cards.each_cons(n){|a|return true if a.all?{|x|x == a[0]}}
    false
  end
end

while gets do
  hand = Hand.new($_.split(?,).map(&:to_i))
  puts hand.what_hand
end

Measured memory_bytes: 6128
#include <iostream>
using namespace std;
int main() {
	long long int n, m, k;cin >> n >> m >> k;
	if (n < k) {
		long long int a = k - n;
		if (a >= m) cout << 0 << " " << 0 << endl;
		else cout << 0 << " " << m - a << endl;
	}
	else cout << n - k << " " << m << endl;
}

Measured memory_bytes: 3572
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	al := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		al[i] = a
	}

	bcm := make(map[int]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		c, _ := strconv.Atoi(sc.Text())
		bcm[c] += b
	}

	cl := make([]int, m)
	for c := range bcm {
		cl = append(cl, c)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cl)))

	last := 0
	sort.Ints(al)
	for _, c := range cl {
		end := min(len(al), last+bcm[c])
		for i := last; i < end && al[i] < c; i++ {
			al[i] = c
		}
		if last = end; last >= len(al) {
			break
		}
	}

	fmt.Println(sum(al))
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func sum(l []int) int {
	t := 0
	for _, v := range l {
		t += v
	}
	return t
}


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

int main() {
    int a, b,c;
    cin >> a >> b >> c;
    if(2*b == c+a){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    string s;
    cin >> s;
    for (char c : s)
    {
        if (c == '1')
        {
            cout << 9;
        }
        else
        {
            cout << 1;
        }
    }
}

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

using namespace std;

int main(){
    string n;
    cin >> n;
    n = "0" + n;
    int m = n.size();
    vector<int64_t> A(m);
    for (int i = 0; i < m; i++)
        A[i] = n[m - i - 1] - '0';  

    const int64_t INF = 1e15;
    vector<vector<int64_t>> DP(m + 1, vector<int64_t>(2, INF));
    DP[0][0] = 0;
    for (int i = 0; i < m; i++){
        for (int j = 0; j < 10; j++){
            if (j >= A[i])
                DP[i + 1][0] = min(DP[i + 1][0], DP[i][0] + 2 * j - A[i]);
            else
                DP[i + 1][1] = min(DP[i + 1][1], DP[i][0] + 2 * j - A[i] + 10);
            if (j - 1 >= A[i])
                DP[i + 1][0] = min(DP[i + 1][0], DP[i][1] + 2 * j - 1 - A[i]);
            else
                DP[i + 1][1] =  min(DP[i + 1][1], DP[i][1] + 2 * j - 1 - A[i] + 10);
        }
    }
    
    cout << DP[m][0] << endl;
}

Measured memory_bytes: 63792
X = int(input())

if(X >= 400 and X <= 599):
  print(8)
elif(X >= 600 and X <= 799):
  print(7) 
elif(X >= 800 and X <= 999):
  print(6)
elif(X >= 1000 and X <= 1199):
  print(5)
elif(X >= 1200 and X <= 1399):
  print(4)
elif(X >= 1400 and X <= 1599):
  print(3)
elif(X >= 1600 and X <= 1799):
  print(2)
elif(X >= 1800 and X <= 1999):
  print(1)

Measured memory_bytes: 9200
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        str = br.readLine();
        ArrayList<Integer> A = new ArrayList<>();
        for (String s:str.split(" ")){
            A.add(Integer.parseInt(s));
        }
        ArrayList<Integer> l = new ArrayList<>();
        l.add(0);
        for (int i=0;i<N;i++){
            l.add(GCD(l.get(i),A.get(i)));
        }
        ArrayList<Integer> r = new ArrayList<>();
        r.add(0);
        for (int i=N-1;i>=0;i--){
            r.add(GCD(r.get(r.size()-1),A.get(i)));
        }
        Collections.reverse(r);
        ArrayList<Integer> gcd = new ArrayList<>();
        for (int i=0;i<N;i++){
            gcd.add(GCD(l.get(i),r.get(i+1)));
        }
        int max = 0;
        for (int i:gcd){
            if (i > max){
                max = i;
            }
        }
        System.out.println(max);
    }

    public static int GCD(int a,int b){
        if (b==0){
            return a;
        }
        if (a%b==0){
            return b;
        } else {
            return GCD(b,a%b);
        }
    }
}

Measured memory_bytes: 49368
n = int(input())
A = list(map(int, input().split()))
INF = (10 ** 9) * 2
count = 0


def merge(left, mid, right):
    n1 = mid - left
    n2 = right - mid

    L = [0] * (n1 + 1)
    R = [0] * (n2 + 1)

    for i in range(n1):
        L[i] = A[left + i]

    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = INF
    R[n2] = INF

    i = 0
    j = 0

    count = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return count


def mergesort(left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        count = 0
        count += mergesort(left, mid)
        count += mergesort(mid, right)
        return count + merge(left, mid, right)
    return 0


count = mergesort(0, len(A))

print(*A)
print(count)



Measured memory_bytes: 61652
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << endl;
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define mp(n, o) map<n, o>
#define so(n) sort(n.begin(), n.end())
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int A, P, a = 0;
  ci(A, P);
  a = (A * 3 + P) / 2;
  co(a);
} 


Measured memory_bytes: 256
#![allow(non_snake_case)]
 
use std::collections::*;
use std::io::prelude::*;

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}
 
macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}
 
macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}
 
pub fn main() {
	let (n, m) = read!(usize, u64);
	let a = read!([u64]);
	let sum: u64 = a.iter().sum();

	let elect: usize = a.iter().filter(|&e| (*e) * 4 * m >= sum).count();

	if elect >= (m as usize) { println!("Yes"); }
	else { println!("No"); }
}
 

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, k;
string s;

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res = res * i;
	for (int i = 1; i <= b; i ++ ) res = res / i;
	return res;
}

int main()
{
	cin >> s >> k;
	n = s.size();
	
	vector<int> num;
	for (int i = 0; i < n; i ++ ) num.PB(s[i] - '0');
	
	int res = 0, last = 0;
	for (int i = 0; i < n; i ++ )
	{
		int x = num[i];
		
		if (x)
		{
			res += C(n - i - 1, k - last) * qp(9, k - last);
			res += (x - 1) * C(n - i - 1, k - last - 1) * qp(9, k - last - 1);
			last ++ ;
		}

		if (last == k)
		{
			res ++ ;
			break;
		}
	}
	
	cout << res << endl;
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int maxL, minR;
    maxL = -1e9;
    minR = 1e9;
    rep(i, m)
    {
        int l, r;
        cin >> l >> r;
        minR = min(minR, r);
        maxL = max(maxL, l);
        // printf("%d %d\n", minR, maxL);
    }
    cout << max(0, minR - maxL + 1) << endl;
    return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
  int i, j, k , B, A,ans = 0;
  scanf("%d", &A);
  scanf("%d", &B);

  while (B > 1 + ans * (A - 1)) {
    ans++;
  }
  printf("%d", ans);
  return 0;
  }

Measured memory_bytes: 128
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int D = 8e3 + 10;

bool dp[D][D], seen[D][D];

bool solve(vector <int> &a, int i, int j);

int main() {
	string s; int x, y;
	cin >> s >> x >> y;
	int n = s.length(), st = 0;
	while (st < n and s[st] == 'F') {
		--x;
		++st;
	}

	int cur = 0;
	vector <int> moves[2];
	moves[1].push_back(0);
	for (int i = st; i < n; ++i) {
		if (s[i] == 'T') {
			moves[cur].push_back(0);
			cur = 1 - cur;
		}  else {
			++moves[cur].back();
		}
	}

	bool ans = solve(moves[0], moves[0].size() - 1, abs(x));
	memset(seen, 0, sizeof(seen));
	ans = ans and solve(moves[1], moves[1].size() - 1, abs(y));
	if (ans) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

bool solve(vector <int> &a, int i, int d) {
	if (i < 0) {
		return (d == 0);
	} else if (d >= D) {
		return false;
	} else if (seen[i][d]) {
		return dp[i][d];
	}

	seen[i][d] = true;
	dp[i][d]   = solve(a, i - 1, abs(d + a[i])) or solve(a, i - 1, abs(d - a[i]));
	return dp[i][d];
}

Measured memory_bytes: 94720
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Point {
    int x;
    int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int distanceTo(Point other) {
        return Math.abs(x - other.x) + Math.abs(y - other.y);
    }

    public String toString() {
        return String.format("(%d, %d)", x, y);
    }
}

class Solver {

    private boolean reachable(int difft, int d) {
        int diff = difft - d;
        if (diff < 0)  return false;
        if ((diff % 2) == 0) return true;
        return false;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] t = new int[N];
        Point[] p = new Point[N];


        int sum = 0;
        for (int i = 0; i < N; i++) {
            t[i] = sc.nextInt();
            p[i] = new Point(sc.nextInt(), sc.nextInt());
        }

        int curt = 0;
        Point curp = new Point(0, 0);
        for (int i = 0; i < N; i++) {
            int nxtt = t[i];
            Point dst = p[i];
            int d = curp.distanceTo(dst);
            if (!reachable(nxtt - curt, d)) {
                System.out.println("No");
                return;
            }
            curt = nxtt;
            curp = dst;
        }

        System.out.println("Yes");
        return;
    }

}

Measured memory_bytes: 96648
def main(A,B):
    if A >= -100 and B <= 100:
        mul = A*B
        plus = A+B
        minus = A-B
        num = [mul,plus,minus]
    return max(num)

if __name__ == '__main__':
    s = list(map(int, input().split()))
    huga = main(s[0], s[1])
    print(huga)

Measured memory_bytes: 3060
# coding: utf-8
from collections import defaultdict, deque

import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    P = list(map(int, args[1].split()))
    X = list(map(int, args[2].split()))

    T = defaultdict(set)
    for i, p in enumerate(P):
        T[p-1].add(i+1)

    stack = []
    Q = deque()
    Q.append(0)
    while Q:
        i = Q.popleft()
        stack.append(i)
        for c in T[i]:
            Q.append(c)

    ret = 'POSSIBLE'
    inf = 2**32-1
    Y = [0]*n
    for i in stack[::-1]:
        prev = np.full(X[i]+1, inf, np.int64)
        prev[0] = 0
        x_acc, y_acc = 0, 0
        for c in T[i]:
            cur = np.full(X[i]+1, inf, np.int64)
            x, y = X[c], Y[c]
            x_acc += x
            y_acc += y
            cur[x:] = np.minimum(cur[x:], y+prev[:-x if 0 < x else len(prev)])
            cur[y:] = np.minimum(cur[y:], x+prev[:-y if 0 < y else len(prev)])
            prev = np.copy(cur)

        y = np.min(prev)
        if y < inf:
            Y[i] = y
        else:
            ret = 'IMPOSSIBLE'
            break

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 13840
using System;
using System.Collections.Generic;
using System.Linq;

namespace arc073_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long minw = 0;
			List<int> k1 = new List<int>(); List<int> k2 = new List<int>();
			List<int> k3 = new List<int>(); List<int> k4 = new List<int>();
			for (int i = 0; i < x[0]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				if (i == 0)
				{
					minw = a[0]; k1.Add(a[1]);
					continue;
				}
				switch (a[0] - minw)
				{
					case 0: { k1.Add(a[1]); break; }
					case 1: { k2.Add(a[1]); break; }
					case 2: { k3.Add(a[1]); break; }
					case 3: { k4.Add(a[1]); break; }
				}
			}
			int[] a1 = k1.ToArray(); Array.Sort(a1); Array.Reverse(a1);
			int[] a2 = k2.ToArray(); Array.Sort(a2); Array.Reverse(a2);
			int[] a3 = k3.ToArray(); Array.Sort(a3); Array.Reverse(a3);
			int[] a4 = k4.ToArray(); Array.Sort(a4); Array.Reverse(a4);
			long[] s1 = new long[a1.Length + 1];
			for (int i = 0; i < a1.Length; i++) s1[i + 1] = s1[i] + a1[i];
			long[] s2 = new long[a2.Length + 1];
			for (int i = 0; i < a2.Length; i++) s2[i + 1] = s2[i] + a2[i];
			long[] s3 = new long[a3.Length + 1];
			for (int i = 0; i < a3.Length; i++) s3[i + 1] = s3[i] + a3[i];
			long[] s4 = new long[a4.Length + 1];
			for (int i = 0; i < a4.Length; i++) s4[i + 1] = s4[i] + a4[i];
			long ret = 0;
			for (int i = 0; i < s1.Length; i++)
			{
				for (int j = 0; j < s2.Length; j++)
				{
					for (int k = 0; k < s3.Length; k++)
					{
						for (int l = 0; l < s4.Length; l++)
						{
							if (minw * i + (minw + 1) * j + (minw + 2) * k + (minw + 3) * l <= x[1])
							{
								ret = Math.Max(ret, s1[i] + s2[j] + s3[k] + s4[l]);
							}
						}
					}
				}
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		if (a != c) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else if (b == c) {
		if (a != b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else if (c == a) {
		if (a != b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d;
  int flag=0;
  int w=0,l=0;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  while(1){
    c=c-b;
    if(c<=0){
      printf("Yes");
      return 0;
    }
    a=a-d;
    if(a<=0){
      printf("No");
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1692
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
    double a,b,x,angle;
    cin >> a >> b >> x;
    if(x>=a*a*b/2){
        angle = 180*atan(2*(a*a*b-x)/(a*a*a))/M_PI;
    }
    else
    {
        angle = 180*atan(a*b*b/(2*x))/M_PI;
    }
    cout << setprecision(8)<<angle << endl;    

}

Measured memory_bytes: 256