akhauriyash/Code-Regression huggingface dataset:
// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University
 
#include <bits/stdc++.h>
using namespace std;
 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)
 
#define pb push_back 
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
 
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number
 
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
 
typedef long long ll;
typedef long double lld;
const ll MOD = 1e9+7;
const lld PI = acos(-1.0);
 
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
template<typename T> inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }
 
//inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
//ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
//ll add(ll a,ll b,ll M)  { return mod(( mod(a,M ) + mod(b,M )),M);     }
//ll sub(ll a, ll b,ll M) { return mod((mod(a,M ) + M - mod(b,M )),M);   }
//ll mult(ll a,ll b,ll M) { return  mod(( mod(a,M)*mod(b,M) ),M) ; }
//bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 
 
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
 
ll inv(ll a, ll m) { ll x, y;  extgcd(a, m, x, y);  return (x + m) % m; }
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 1<<30;
const ll LINF = 1ll<<60;
 
/* For counting number of digits, directly do floor(log10(n)+1)*/
               /* -------------------------------Main Code------------------------------- */

int main(){
    FAST
    int a,b;cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9) cout<<a*b<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
  int am[7]={0,0,0,0,0,0,0};
  int i,k;
  while(1) {
    std::cin>>i;
    if(i==0)break;
    for(int j=0;j<i;j++) {
      std::cin>>k;
      if(k>60)k=60;
      am[k/10]++;
    }
    for(i=0;i<7;i++) std::cout<<am[i]<<"\n",am[i]=0;
  }
}

Measured memory_bytes: 864
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	K := nextInt()

	ans := gcd(A, B)

	var res []int
	for i := 1; i <= ans; i++ {
		if ans%i == 0 {
			res = append(res, i)
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(res)))
	fmt.Println(res[K-1])
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using P = std::pair<int, int>;

int N, M;
std::vector<int> vs[100010];
std::priority_queue<int> que;

int main()
{
  scanf( "%d%d", &N, &M );

  rep( i, N )
  {
    int A, B;
    scanf( "%d%d", &A, &B );

    if( M-A >= 0 )
      vs[M-A].emplace_back( B );
  }

  int ans = 0;
  for( int i = M; i >= 0; --i )
  {
    for( auto v : vs[i] )
      que.push( v );

    if( !que.empty() )
    {
      ans += que.top();
      que.pop();
    }
  }

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

  return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>

int main(){ 
  int fib[50];
  int i,num;
  scanf("%d",&num);
  fib[0]=fib[1]=1;
  for(i=2;i<=num;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  printf("%d\n",fib[num]);
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    int n;
    cin>>n;
    vector<pii> v(n);
    vi ans(n);
    rep(i,0,n){
        cin>>v[i].fr;
        v[i].sc =i;
    }
    sort(all(v));
    int hf2 = n/2;
    int hf1 = hf2-1;
    rep(i,0,n){
        if(i<=hf1) ans[v[i].sc]=v[hf2].fr;
        else ans[v[i].sc]=v[hf1].fr;
    }
    for(auto e:ans) cout<<e<<endl;


}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 6912
from functools import reduce
n,m=map(int,input().split())
dic=dict()
p=2
while m>=p*p:
    if m%p==0:
        dic[p]=0
        while m%p==0:
            dic[p]+=1
            m//=p
    p+=1
if m!=1:
    if m not in dic.keys():
        dic[m]=0
    dic[m]+=1
def comb(a,b):
    p=1
    for i in range(a,a-b,-1):
        p*=i
    for i in range(2,b+1):
        p//=i
    return p
l=[comb(i+n-1,i) if 1 not in dic.keys() else 1 for i in dic.values() ]
ans=1
for i in l:
    ans=ans*i%1000000007
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
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); }

int main(){
    ll n;
    cin >> n;
    vector<ll> b(n, 0);
    map<ll, ll> mp;
    for(ll i = 0; i < n; i++){
        ll a = 0;
        cin >> a;
        mp[a]++;
        if(mp[a] == 2) b.push_back(a);
    }
    sort(b.begin(), b.end(), greater<int>());
    if(mp[b[0]] >= 4) cout << b[0]*b[0] << endl;
    else if(mp[b[1]] < 2) cout << 0 << endl;
    else cout << b[0] * b[1] << endl;
    return 0;
}

Measured memory_bytes: 7280
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n;
	while (cin >> n, n)
	{
		int t[32][32];
		rep (i, n)
		{
			cin >> t[i][n];
			rep (j, n)
				cin >> t[i][j];
		}

		static int dp[1 << 16][16];
		const int INF = 1 << 29;
		for (int s = 0; s < 1 << n; ++s)
			for (int i = 0; i < n; ++i)
				dp[s][i] = INF;
		for (int i = 0; i < n; ++i)
			dp[1 << i][i] = t[i][n];

		for (int s = 0; s < 1 << n; ++s)
		{
			for (int i = 0; i < n; ++i)
			{
				if (s >> i & 1)
				{
					for (int j = 0; j < n; ++j)
					{
						if (i != j && s >> j & 1)
						{
							int equip = s ^ 1 << i;
							int e = t[i][n];
							for (int k = 0; k < n; ++k)
								if (equip >> k & 1)
									min_swap(e, t[i][k]);

							min_swap(dp[s][i], dp[s ^ 1 << i][j] + e);
						}
					}
				}
			}
		}

		int res = INF;
		for (int i = 0; i < n; ++i)
			min_swap(res, dp[(1 << n) - 1][i]);
		cout << res << endl;
	}
}

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

int main(){
  long N,cnt=0,ans=0;
  cin >> N;
  vector<long> vec(N);
  bool zero=0;
  for(int i=0;i<N;i++){
    cin >> vec[i];
    if(vec[i]==0)
      zero=1;
    if(vec[i]<0)
      cnt++;
  }
  if(zero||cnt%2==0){
    for(int j=0;j<N;j++){
      if(vec[j]<0)
        ans-=vec[j];
      else
        ans+=vec[j];
    }
  }
  else{
    for(int k=0;k<N;k++){
      if(vec[k]<0)
        vec[k]*=-1;
    }
    sort(vec.begin(),vec.end());
    ans-=vec[0];
    for(int l=1;l<N;l++)
      ans+=vec[l];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

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

        int[] juwelValue = new int[juwelNum];
        for(int i = 0; i < juwelNum; i++){
            juwelValue[i] = sc.nextInt();
        }
        int[] juwelCost = new int[juwelNum];
        for(int i = 0; i < juwelNum; i++){
            juwelCost[i] = sc.nextInt();
        }

        int ans = 0;
        for(int i = 0; i < juwelNum; i++){
            if(juwelValue[i] > juwelCost[i]){
                ans += juwelValue[i] - juwelCost[i];
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int hyou[8] = {1, 2, 1, 2, 1, 4, 1, 4};
	int a[8];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7]) {
		int kari;
		int sum = 0;
		for (int i = 0; i < 8; i++) {
			sum += a[i];
		}
		int MIN = sum;
		long long int p;
		for (int i = 0; i < 8; i++) {
			int k = sum;
			for (int j = 0; j < 8; j++) {
				if (hyou[j] >= a[j]) {
					k -= a[j];
				} else {
					k -= hyou[j];
				}
			}
			if (MIN > k){
				MIN = k;
				p = 0;
				for (int j = 0; j < 8; j++) {
					p *= 10;
					p += hyou[j];
				}
			} else if (MIN == k) {
				long long int karikari = 0;
				for (int j = 0; j < 8; j++) {
					karikari *= 10;
					karikari += hyou[j];
				}
				p = min(karikari, p);
			}
			kari = hyou[0];
			for (int j = 0; j < 7; j++) {
				hyou[j] = hyou[j+1];
			}
			hyou[7] = kari;
		}
		for (int i = 7; i >= 0; i--) {
			a[i] = p % 10;
			p /= 10;
		}
		cout << a[0];
		for (int i = 1; i < 8; i++) {
			cout << ' ' << a[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 100000000000L

using namespace std;

int main() {
    int a, b, q;
    long x;
    long v;

    cin >> a >> b >> q;
    vector<long> s = { -INF };
    vector<long> t = { -INF };
    for (int i = 0; i < a; ++i) {
        cin >> v;
        s.push_back(v);
    }
    s.push_back(INF);
    for (int i = 0; i < b; ++i) {
        cin >> v;
        t.push_back(v);
    }
    t.push_back(INF);
    for (int i = 0; i < q; ++i) {
        cin >> x;
        long result = INF;
        long s1, s2, t1, t2;
        vector<long>::iterator it;
        it = lower_bound(s.begin(), s.end(), x);
        s1 = *(it - 1);
        s2 = *it;
        it = lower_bound(t.begin(), t.end(), x);
        t1 = *(it - 1);
        t2 = *it;
        result = min(result, abs(s1 - t1) + abs(t1 - x));
        result = min(result, abs(s1 - t1) + abs(s1 - x));
        result = min(result, abs(s2 - t2) + abs(t2 - x));
        result = min(result, abs(s2 - t2) + abs(s2 - x));
        result = min(result, abs(t2 - s1) + abs(t2 - x));
        result = min(result, abs(t2 - s1) + abs(s1 - x));
        result = min(result, abs(t1 - s2) + abs(s2 - x));
        result = min(result, abs(t1 - s2) + abs(t1 - x));
        cout << result << endl;
    }
}

Measured memory_bytes: 3060
require 'prime'
primes = Prime.each(10_000_000).to_a
quad = []
primes.each_cons(4) do |x, _, _, y|
    quad << y if y - x == 8
end
loop do
    n = gets.to_i
    break if n == 0
    i = (0..quad.size-1).bsearch {|i| quad[i] > n}
    puts i ? quad[i - 1] : quad[-1]
end


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

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

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


int main(){
	string s;
	cin >>s;
	int n=s.length();
	long long tmp=0,ans=0;
	REP(bit,1<<(n-1)){
		REP(i,n){
			tmp*=10;
			tmp+=s[i]-'0';
			if((bit&(1<<i))||i==n-1){
				ans+=tmp;
				tmp=0;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,N;
vvd in,dp;
double dfs(int a,int b){
	if(dp[a][b]+1)return dp[a][b];
	double out=0;
	rep(i,n)if((a&1<<i)==0){
		double sum=0;
		double p=1;
		loop(j,b,m){
			sum+=p*(1-in[i][j])*dfs(a|1<<i,j);
			p*=in[i][j];
		}
		out=max(out,sum+p);
	}
	
	return dp[a][b]=out;
}
int main(){
	cin>>n>>m;
	in=vvd(n,vd(m));
	rep(i,n)rep(j,m)cin>>in[i][j];
	N=1<<n;
	dp=vvd(N,vd(m,-1));
	cout<<shosu(11)<<dfs(0,0)<<endl;
}










Measured memory_bytes: 13812
#include <stdio.h>

int main(void)
{
	int a1, a2, a3, aSum;

	scanf("%d %d %d", &a1, &a2, &a3);

	aSum = a1 + a2 + a3;

	if (aSum >= 22)
	{
		printf("bust\n");
	}
	else
	{
		printf("win\n");
	}

	return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
h = [0]*n
for i in range(n):
	h[i] = int(input())
h.sort()
min = pow(10,9)
for i in range(n+1-k):
	m = h[i+k-1]-h[i]
	if m < min:
		min = m
print(min)

Measured memory_bytes: 13224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{

  int n;
  cin>>n;
int  n1=n%10;
int n2=n/10;
  if(n1==9||n2==9) printf("Yes");
  else printf("No");





  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
int G[10][10];
int A[201][201];
int N = 10;
void WarshallFloyd(){
    REP(i, N) REP(j,N) REP(k, N) G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
}


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

    int H, W;
    cin >> H >> W;
    REP(i, 10){
        REP(j, 10){
            cin >> G[i][j];
        }
    }
    WarshallFloyd();

    int ans = 0;
    REP(i, H*W){
        int x;
        cin >> x;
        if(x == -1) continue;
        ans += G[x][1];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    #define nos 1000000007;
    void solve()
    {
        in2(n,m);
        char a[n][m];f(i,0,n){f(j,0,m)cin>>a[i][j];}
        ll dp[n][m];f(i,0,n){f(j,0,m)dp[i][j]=0;}dp[0][0]=1;
        f(i,1,n)
        {
            if(a[i][0]=='#')continue;
            if(a[i-1][0]!='#')dp[i][0]+=(dp[i-1][0])%nos;
        }
        f(j,1,m)
        {
            if(a[0][j]=='#')continue;
            if(a[0][j-1]!='#')dp[0][j]+=(dp[0][j-1])%nos;
        }
        f(i,1,n)
        {
            f(j,1,m)
            {
                if(a[i][j]=='#')continue;
                if(a[i-1][j]!='#')dp[i][j]+=(dp[i-1][j])%nos;
                if(a[i][j-1]!='#')dp[i][j]+=(dp[i][j-1])%nos;
            }
        }

        cout<<dp[n-1][m-1]%nos;
    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 12320
#include<stdio.h>

int main (void)
{
    int x, y;

    while(scanf("%d%d",&x,&y) != EOF){
        int z = 1;

        char added[100][100];
        int length[100];

        int i, j;
        int a = 0;
        int b;


        x += y;

        for(;;){
            x /= 10;
            z++;
            if(x < 10){
                break;
            }
        }
        printf("%d\n",z);

    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define forn(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define TC(n) while(n--)
#define forb(i,n) for(int i=n-1;i>=0;--i)
#define repb(i,n) for(int i=n;i>=1;--i)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;
int x,y;
bool cek = false;
int main(){
	scanf("%d%d",&x,&y);
	if(!(x%y)){
		printf("-1\n");
	}else{
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
using vertex = struct vertex {ll to,cost;vertex(ll to,ll cost):to(to),cost(cost){}};
using AdjList = vector<vector<vertex>>;
void chmax(ll& a,const ll& b){if(a<b)a=b;}
AdjList adj;
vector<ll> dp;
ll n,m;

ll solve(ll now){
  if(dp[now]!=-1)return dp[now];
  ll res=0;
  for(auto next:adj[now]){
    chmax(res,solve(next.to)+1);
  }
  return dp[now]=res;
}

main(){
  cin>>n>>m;
  adj.resize(n);
  for(int i=0;i<m;++i){
    ll x,y;cin>>x>>y;
    x--;y--;
    adj[x].emplace_back(y,1);
  }

  dp.resize(n,-1);
  ll ans=0;
  for(ll i=0;i<n;++i)chmax(ans,solve(i));
  cout<<ans<<endl;
}

Measured memory_bytes: 8576
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string s;
    char x;
    vector<int> count(26,0);
    while(cin>>x){
        if('a'<=x&&x<='z') count[x-'a']++;
        else if('A'<=x&&x<='Z') count[x-'A']++;
    }    
    rep(i,26){
        cout<<(char)(i+'a')<<" : "<<count[i]<<endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=1000000007;

int n;
int a[17][17];
ll dp[1<<17];
ll sum[1<<17];
int main(){
    cin>>n;
    rep(i,n)rep(j,n) cin>>a[i][j];
    rep(i,1<<n){
        if(sum[i]==0){
            rep(k1,n)rep(k2,n)if((i>>k1&1)&&(i>>k2&1)){
                sum[i]+=a[k1][k2];
            }
            sum[i]/=2;
        }
        for(int j=i;j>0;j=(j-1)&i){
            ll nx=dp[i&(~j)]+sum[j];
            dp[i]=max(dp[i],nx);
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(void) {
	int n, i, suma = 0;
	int b[100000], a[100000];

	scanf("%d", &n);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &b[i]);

	a[0] = b[0];
	for (i = 0; i < n - 1; i++) {
		if (b[i] <= b[i + 1])
			a[i + 1] = b[i];
		else
			a[i + 1] = b[i + 1];
	}
	a[n - 1] = b[n - 2];

	for (i = 0; i < n; i++)
		suma += a[i];

	printf("%d", suma);

	return 0;
}

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

using namespace std;
vector<int> s;

void fact(long long v){
    long double limt = sqrt(v);

    for (int i = 2 ; i <= limt ; i++){
        if (v % i == 0){
            s.push_back(i);
            fact(v/i);
            return;
        }
    }
    if (v==1)return;
    s.push_back(v);
    return;

}




int main()
{
    long long a;
    cin >> a;

    fact(a);

    sort(s.begin(), s.end());

    map<int,int> occ;

    vector<int> sums;

    for (int i = 1 ; i <= 20 ; i++){
        long long push = (i + 1) * (i /2.0);
        sums.push_back(push);
    }

    for (int i = 0 ; i < s.size() ; i++){
        occ[s[i]]++;
    }

    int ans = 0;

    for (auto p : occ){
        int prim = p.first;
        int occc = p.second;
        int idx = lower_bound(sums.begin() , sums.end() , occc) - sums.begin();
        if (sums[idx] != occc){
            idx--;
        }
        ans+= (idx + 1);
    }

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


Measured memory_bytes: 3728
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>

#define	min3(a,b,c)	min((a),min((b),(c)))

using namespace std;

int main()
{
	int n;	cin>>n;
	while(n--){
		int h,m;	scanf("%d:%d",&h,&m);
		double degh=30*h+0.5*m,degm=6*m;
		double deg=min3(abs(degh-degm),abs(degh-degm-360),abs(degh-degm+360));
		if     (deg<30)	cout<<"alert"<<endl;
		else if(deg<90)	cout<<"warning"<<endl;
		else			cout<<"safe"<<endl;
	}
	return 0;
}

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

using namespace std;

class Dice{
private:
  void roll(int a,int b,int c,int d){
    swap(x[a],x[b]);
    swap(x[b],x[d]);
    swap(x[c],x[d]);
  }
public:
  int x[6];
  void roll_N(){ roll(0,1,4,5); }
  void roll_E(){ roll(0,3,2,5); }
  void roll_S(){ roll(0,4,1,5); }
  void roll_W(){ roll(0,2,3,5); }
  void rotation(){ roll(1,2,3,4); }
  void roll(int top,int front){
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        roll_N();
        if(top == x[0]){ goto next; }
      }
      roll_E();
    }
     next:
    for(int i = 0 ; i < 4 ; i++){
      rotation();
      if(front == x[1]){ break; }
    }
  }
};

int main(){
  Dice die;
  for(int i = 0 ; i < 6 ; i++){
    cin >> die.x[i];
  }
  int q,t,f;
  cin >> q;
  while(q--){
    cin >> t >> f;
    die.roll(t,f);
    cout << die.x[2] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
// https://atcoder.jp/contests/abc115/tasks/abc115_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  cin >> n;

  int m = 0, sum = 0;
  REP(i, n)
  {
    int p;
    cin >> p;
    sum += p;
    m = max(m, p);
  }

  sum -= (m / 2);

  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h, w, n;
    cin >> h >> w >> n;

    map<pii, int> mp;

    auto addok = [&](int y, int x){
        return (y > 1 && x > 1 && y < h && x < w);
    };

    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(addok(a, b)) ++mp[{a,b}];
        rep(j,8){
            int y = a + dy[j];
            int x = b + dx[j];
            if(addok(y, x)){
                ++mp[{y,x}];
            }
        }
    }

    vector<int> res(10);

    for(auto e : mp){
        res[e.second]++;
    }

    res[0] = (h-2) * (w-2) - mp.size();

    for(auto e : res){
        cout << e << '\n';
    }

    return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
#define INF (1ll<<60)
typedef pair<li, li> PI;

li dp[3030][3030];
li footprint[3030][3030];

int main(void)
{
	string s;
	string t;
	cin >> s >> t;

	rep(j, t.size()) {
		dp[0][j] = 0;
		footprint[0][j] = -1;
	}

	rep(i, s.size()) {
		dp[i + 1][0] = 0;
		footprint[i + 1][0] = 1;
		rep(j, t.size()) {
			dp[i + 1][j + 1] = dp[i + 1][j];
			footprint[i + 1][j + 1] = -1;
			if (dp[i + 1][j + 1] < dp[i][j + 1]) {
				dp[i + 1][j + 1] = dp[i][j + 1];
				footprint[i + 1][j + 1] = 1;
			}
			if (s[i] == t[j] &&
			        dp[i + 1][j + 1] < dp[i][j] + 1) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				footprint[i + 1][j + 1] = 0;
			}
		}
	}

	string res = "";

	PI pos = {s.size(), t.size()};
	while (max(pos.first, pos.second) > 0) {
		if (footprint[pos.first][pos.second] == 0) {
			res = s[pos.first - 1] + res;
			pos.first--;
			pos.second--;
		} else if (footprint[pos.first][pos.second] == 1) {
			pos.first--;
		} else {
			pos.second--;
		}
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 143616
n,p = map(int,input().split())
if n == 1:
    print(p)
    exit()
if n >=40:
    print(1)
    exit()
i =2
ans =1
while i**n <= p:
    if p%(i**n)==0:
        ans *= i
        p =p//(i**n)

    else:
        i += 1
print(ans)

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

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	int count=0;

    for(int i=0;i<s.length(); i++){ 
        if(s[i]==t[i]) count++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main(){
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++){
        if(s[i]=='C'){
            for(int j=i+1;j<l;j++){
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

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

int main(){

    int64_t X;
    cin >> X;

    int64_t A, B;
    int64_t ans_A, ans_B;
    int64_t diff;

    for (A=-1000; A<1001; A++){
        for (B=-1000; B<1001; B++){
            ans_A = A*A*A*A*A;
            ans_B = B*B*B*B*B;
            diff = ans_A - ans_B;

            if (diff == X){
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut v = read_vec::<i64>();

    let mut ans = 0;
    for ti in 1..k + 1 {
        if ti > n {
            break;
        }
        let mut temp_get = v.iter().cloned().take(ti).collect::<VecDeque<_>>();
        for tj in 0..ti + 1 {
            let mut temp_get_clone = temp_get.iter().cloned().collect::<Vec<_>>();
            temp_get_clone.sort();
            for ki in 0..k - ti {
                if ki >= temp_get_clone.len() {
                    break;
                }
                if temp_get_clone[ki] < 0 {
                    temp_get_clone[ki] = 0;
                }
            }
            ans = max(ans, temp_get_clone.iter().sum::<i64>());

            temp_get.pop_back();
            if tj <= n - 1 {
                temp_get.push_front(v[n - 1 - tj]);
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2192
n, a, b = gets.strip.split.map(&:to_i)

ans = 0

def sum_digit(digit)
  res = 0
  while digit > 0 do
    res += digit%10
    digit /= 10
  end
  res
end

n.times do |i|
  sd = sum_digit(i+1)
  if sd >= a and sd <= b
    ans += i+1
  end
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int A[200010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 0;
	int num = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] != num) ans++;
		else num++;
	}
	if (ans == N) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 4396
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


void double_helix()
{
  char b;
  cin >> b;

  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";

}


void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;

  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";

}

void buttons()
{
  int a, b;
  cin >> a >> b;

  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}


void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;

  cout << t / a * b << "\n";
}


void changing_a_character()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] += 32;
  cout << s <<"\n";
}


void ferris_wheel()
{
  int a, b;
  cin >> a >> b;

  if (a >= 13) cout << b << "\n";
  else if(a >= 6) cout << b / 2 << "\n";
  else cout << 0 << "\n";
}


void apple_pie()
{
  int a, p;
  cin >> a >> p;

  p += 3 * a;

  cout << p / 2 << "\n";
}


void airplane()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a[0] + a[1] << "\n";
}


void rounding()
{
  int x, a;
  cin >> x >> a;

  if (x < a) cout << 0 << "\n";
  else cout << 10 << "\n";
}


int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  //biscuit_generator();
  //changing_a_character();
  //ferris_wheel();
  //apple_pie();
  //airplane();
  rounding();
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
e = list(map(int, input().split()))
f = list(map(int, input().split()))
e.sort()
f.sort()
for i in range(e[len(e)-1] + 1, f[0] + 1):
    if c < i <= d:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int



#if 1
const int MOD = (int) 1e9 + 7;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;




int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    vector <int> x(n + 1);
    for(i = 1; i <= n; i++) {
        cin >> x[i];
    }

    vector <int> sum(n + 1);
    for(i = 1; i <= n; i++) {
        sum[i] = sum[i - 1];
        add(sum[i], inv(i));
    }

    int ans = 0;
    for(i = 1; i < n; i++) {
        ans = (ans + 1LL * sum[i] * (x[i + 1] - x[i])) % MOD;
    }

    for(i = 1; i < n; i++) {
        mul(ans, i);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
	int n, a, b, i, max = 0, num;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d", &a, &b);
		if(max <= b){
			if(max < b){
				num = a;
				max = b;
			}else if(num > a) num = a; 
		}
	}
	printf("%d %d\n", num, max);
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int a,b;
	int n;
	int i,j;
	long long int** count;
	while(scanf("%d %d",&a,&b),a)
	{
		count = (long long int**)malloc(sizeof(long long int*)*a);
		for(i = 0;i < a;i++)
		{
			count[i] = (long long int*)malloc(sizeof(long long int)*b);
			for(j = 0;j < b;j++)
			{
				count[i][j] = 0;
			}	
		}
		scanf("%d",&n);
		for(i = 0;i < n;i++)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			count[x-1][y-1] = -1;
		}
		count[0][0] = 1;
		for(i = 1;i < b;i++)
		{
			if(count[0][i] != -1)
				count[0][i] = count[0][i-1];
			else
				count[0][i] = 0;
		}
		for(i = 1;i < a;i++)
		{
			if(count[i][0] != -1)
				count[i][0] = count[i-1][0];
			else
				count[i][0] = 0;
			for(j = 1;j < b;j++)
			{
				if(count[i][j] != -1)
					count[i][j] = count[i-1][j]+count[i][j-1];
				else
					count[i][j] = 0;
			}
		}
		printf("%lld\n",count[a-1][b-1]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
// #define int long long
// #define CHAL_BC_APNE_BAAP_KO_MAT_SIKHA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fr first
#define se second
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(b,n*a);
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    cnt = 0
    for i in range(1, n):
        if i + 1 <= n - i <= n:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    int ans = 0;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vector<ll> a_r(n + 1);
    a_r[0] = 0;
    vector<ll> b_r(m + 1);
    b_r[0] = 0;
    for (int i = 1; i <= n; i++) a_r[i] += a_r[i - 1] + a[i - 1];
    for (int i = 1; i <= m; i++) b_r[i] += b_r[i - 1] + b[i - 1];

    rep(i, n + 1) {
        int num = k - a_r[i];
        if (num < 0) break;
        int ok = 0, ng = m + 1;
        while (ng - ok > 1) {
            int mid = (ng + ok) / 2;
            if (num - b_r[mid] >= 0) {
                ok = mid;
            }
            else {
                ng = mid;
            }
        }

        ans = max(ans, i + ok);
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 8048
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
bool ok(vector<int> v){
  do{
    bool ok = true;
    for(int i = 0; i < v.size(); i+=3){
      bool eq = true;
      bool sc = true;
      REP(j,2){
        if(v[i+j+1]-v[i+j]!=1)sc = false;
        if(v[i+j+1]-v[i+j]!=0)eq = false;
      }
      if(!eq&&!sc) ok = false;
    }
    if(ok) return true;
  }while(next_permutation(v.begin(), v.end()));
  return false;
}

int main(){
  int n; cin>>n;
  while(n--){
    vector<int> v(9);
    vector<int> r;
    vector<int> b;
    vector<int> g;
    REP(i,9)cin>>v[i];
    REP(i,9){
      char c; cin>>c;
      if(c=='R')r.push_back(v[i]);
      else if(c=='G')g.push_back(v[i]);
      else if(c=='B')b.push_back(v[i]);
    }
    if(r.size() % 3 || b.size() % 3 || g.size() % 3){
      cout<<0<<endl;
      continue;
    }
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(b.begin(),b.end());
    cout<<(int)(ok(r)&&ok(g)&&ok(b))<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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 Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    string N; cin >> N;
    int K; cin >> K;
    int n = N.size();

    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(2, vector<ll>(6,0)));
    dp[0][0][0] = 1;

    rep(i,n){
        rep(j,5){
            rep(k,10){
                if (k != 0){
                    dp[i+1][1][j+1] += dp[i][1][j];
                }
                else{
                    dp[i+1][1][j] += dp[i][1][j];
                }
            }

            int num = N[i]-'0';

            rep(k,num){
                if (k != 0){
                    dp[i+1][1][j+1] += dp[i][0][j];
                }
                else{
                    dp[i+1][1][j] += dp[i][0][j];
                }
            }
            if (num != 0) dp[i+1][0][j+1] += dp[i][0][j];
            else dp[i+1][0][j] += dp[i][0][j];
        }
    }
    ll ans = 0;
    ans += dp[n][0][K];
    ans += dp[n][1][K];

    cout << ans << endl;

}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;
struct UF{
    int par[100000];
    int rank[100000];
    int g[100000];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            g[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }

    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x!=y){
            if(rank[x]<rank[y]){
                par[x]=y;
                g[y]+=g[x];
                g[x]=0;
            }else{
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
                g[x]+=g[y];
                g[y]=0;
            }
        }
    }

    bool same(int x, int y){
        return find(x)==find(y);
    }
};


int main(void){
    int n,m,a[100000],b[100000];
    ll c[100000];
    UF u;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    u.init(n);
    c[m-1]=(ll)n*(n-1)/2;
    for(int i=m-1;i>=0;i--){
        c[i-1]=c[i];
        if(i>=1&&!u.same(a[i], b[i])){
            ll s=u.g[u.find(a[i])],t=u.g[u.find(b[i])];
            c[i-1]-=s*t;
        }
        u.unite(a[i], b[i]);
    }
    for(int i=0;i<m;i++){
        cout<<c[i]<<endl;
    }

}


Measured memory_bytes: 4096