akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;
    cin>>n;
    string s1,s2;cin>>s1>>s2;
    REP(i,s1.size()){
        cout<<s1[i]<<s2[i];
    }cout<<endl;
}

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



Measured memory_bytes: 256
def main():
    N, K = [int(x) for x in input().split()]
    LR = input()

    count = 0
    for p in range(len(LR)-1):
        if LR[p] == LR[p+1]:
            count += 1
    
    count += K*2
    count = min(count, N-1)

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39408
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    S=list(reversed(list(input())))
    i=0
    f=True
    l=[]
    while True:
        num=0
        for j in range(M):
            if i+(M-j) >= N:
                num=N-i
                break
            else:
                if S[i+(M-j)]=='0':
                    num=M-j
                    break
                else:
                    if j==M-1:
                        f=False
        l.append(str(num))
        i+=num
        if f==False:
            print(-1)
            exit()
        if i >= N:
            break
    print(' '.join(reversed(l)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 54412
N = int(input())
INF = float('inf')
edges = [[] for i in range(N+1)]
for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    edges[a].append((b,c))
    edges[b].append((a,c))

Q,K = list(map(int,input().split()))
checked = [0]*(N+1)
checked[K] = 1
stack = [K]
distances_from_K = [-1]*(N+1)
distances_from_K[K] = 0
while stack:
    s = stack.pop()
    for t in edges[s]:
        if not checked[t[0]]:
            checked[t[0]] = 1
            distances_from_K[t[0]] = distances_from_K[s] + t[1]
            stack.append(t[0])

for i in range(Q):
    x,y = list(map(int,input().split()))
    print(distances_from_K[x]+distances_from_K[y])

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

namespace AOJ
{
    class Factorial
    {
        static void Main(string[] args)
        {
            long result = 1;
            int num = int.Parse(System.Console.ReadLine());
            for(int i=1;i<=num;i++)
            {
                result = result * i;
            }
            System.Console.WriteLine(result);
        }
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    if(c=='a') cout << "b" << endl;
    if(c=='b') cout << "c" << endl;
    if(c=='c') cout << "d" << endl;
    if(c=='d') cout << "e" << endl;
    if(c=='e') cout << "f" << endl;
    if(c=='f') cout << "g" << endl;
    if(c=='g') cout << "h" << endl;
    if(c=='h') cout << "i" << endl;
    if(c=='i') cout << "j" << endl;
    if(c=='j') cout << "k" << endl;
    if(c=='k') cout << "l" << endl;
    if(c=='l') cout << "m" << endl;
    if(c=='m') cout << "n" << endl;
    if(c=='n') cout << "o" << endl;
    if(c=='o') cout << "p" << endl;
    if(c=='p') cout << "q" << endl;
    if(c=='q') cout << "r" << endl;
    if(c=='r') cout << "s" << endl;
    if(c=='s') cout << "t" << endl;
    if(c=='t') cout << "u" << endl;
    if(c=='u') cout << "v" << endl;
    if(c=='v') cout << "w" << endl;
    if(c=='w') cout << "x" << endl;
    if(c=='x') cout << "y" << endl;
    if(c=='y') cout << "z" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  string s;
  cin>>s;
  bool j=true;
  for(int i=1;i<(int)s.size();i+=2){
    j&=(s[i]=='L' || s[i]=='U' || s[i]=='D');
  }
  for(int i=0;i<(int)s.size();i+=2){
    j&=(s[i]=='R' || s[i]=='U' || s[i]=='D');
  }
  cout<<(j?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
int main(void)
{
  ll a,b,v,w,t;
  scanf("%lld %lld %lld %lld %lld",&a,&v,&b,&w,&t);
  if(a==b){
    puts("YES");
    return 0;
  }
  if(a<b){
    if((a+v*t)>=(b+w*t)){
      puts("YES");
    }else{
      puts("NO");
    }
  }else{
    if((a-v*t)<=(b-w*t)){
      puts("YES");
    }else{
      puts("NO");
    }
  }

  return 0;
}


Measured memory_bytes: 1664
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	ll q;
	cin >> q;
	ll n = 0;
	ll left = 0;
	ll right = 0;
	ll sum = 0;
	multiset<ll> m;
	multiset<ll>::iterator it;
	rep(i, q) {
		ll t;
		scanf("%lld", &t);
		if (t == 2) {
			cout << left << " " << sum << endl;
		}
		else {
			ll a, b;
			cin >> a >> b;
			m.insert(a);
			n++;
			if (a >= left && a <= right) {
				sum += b;
			}
			else {
				if (n == 1) {
					sum += b;
				}
				else {
					sum += min(abs(left - a), abs(right - a)) + b;
				}
			}
			if (n == 1) {
				it = m.begin();
				left = *it;
				right = *it;
			}
			else {
				if (n % 2 == 0) {
					if (a < left) {
						it--;
					}
					left = *it;
					it++;
					right = *it;
					it--;
				}
				else {
					if (a >= left) {
						it++;
					}
					right = left = *it;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

int A[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int saidai = 1;
	rep(i, N) {
		A[i] = getint();
		if (A[i] > saidai) saidai = A[i];
	}
	nth_element(A, A + N / 2, A + N);

	ll kotae = 0;
	for (int i = N / 2; i < N; i++) kotae += A[i];

	printf("%lld\n", kotae * 2 - saidai - N % 2 * A[N / 2]);

	Would you please return 0;
}

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


#define	ll_int	long long int


int Binary_Search(ll_int *box, int n, ll_int num)
{
	int mid;
	int left, right;


	left = 0;
	right = n - 1;
	while(left <= right){
		mid = (left + right) / 2;

		if(num == box[mid])
			return 1;
		else if(num < box[mid])
			right = mid - 1;
		else if(box[mid] < num)
			left = mid + 1;
	}

	return 0;
}


int main()
{
	int n, m;
	ll_int *A, *B;
	int i, j;


	scanf("%d", &n);

	A = (ll_int *)malloc(sizeof(ll_int) * n);

	for(i = 0; i < n; i++)
		scanf("%lld", &A[i]);


	scanf("%d", &m);

	B = (ll_int *)malloc(sizeof(ll_int) *m);

	for(i = 0; i < m; i++)
		scanf("%lld", &B[i]);


	for(i = 0; i < m; i++)
		if(Binary_Search(A, n, B[i]) != 1)
			break;

	if(i == m)
		printf("1\n");
	else
		printf("0\n");

	return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

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

	double h, m;
	while (n--){
		scanf("%lf:%lf", &h, &m);
		double hh = 30 * h + 0.5 * m;
		double mm = 6 * m;
		// printf("hour angle %Lf\n", hh);
		// printf("minute angle %Lf\n", mm);
		double diff = abs(hh - mm);
		if (180 < diff) diff = 360 - diff;
		// cout << diff << endl;
		if (0 <= diff && diff < 30){
			cout << "alert" << endl;
		}
		else if (90 <= diff && diff <= 180){
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> upper(N);
  vector<int> lower(N);
  for(int i = 0; i < N; i++){
    cin >> upper.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> lower.at(i);
  }
  
  // down: 下に下がるところ
  long tmpmax = 0;
  for(int down = 0; down < N; down++){
    int cnt = 0;
    for(int i = 0; i <= down; i++){
      cnt += upper[i];
    }
    for(int j = down; j < N; j++){
      cnt += lower[j];
    }
    
    if(cnt > tmpmax){
      tmpmax = cnt;
    }
  }
  cout << tmpmax << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vector<double> dp(1,1);
	
	FOR(i,0,n) {
		double p; cin >> p;
		vector<double> ndp(i+2);
		FOR(j,0,i+1) ndp[j] += p*dp[j];
		FOR(j,0,i+1) ndp[j+1] += (1-p)*dp[j];
		dp = ndp;
	}
	
	double res = 0;
	FOR(i,0,n/2+1) res += dp[i];
	cout << fixed << setprecision(20) << res << endl;
}



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

int main(){
  int N,M;
  cin >> N >> M;
  int count_AC=0;
  int count_pt=0;
  vector<int> count_wa(N,0);
  vector<bool> checked(N,false);
  for(int i=0;i<M;i++){
    int p;
    string s;
    cin >> p >> s;
    if(checked.at(p-1)==false&&s=="AC"){
      count_AC++;
      checked.at(p-1)=true;
      count_pt += count_wa.at(p-1);
    }
    if(checked.at(p-1)==false&&s=="WA"){
      count_wa.at(p-1)++;
    }
  }
  cout << count_AC << " " << count_pt << endl;
}
  

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

const int MAXN = 2e5+5;

int n, a[MAXN];
map<int, int> m;

int p2(int x) {
	int k = 1;
	while (k <= x)
		k *= 2;
	return k;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	for (int i = 0; i < n; ++i)
		m[a[i]]++;
	int ans = 0;

	for (int i = n-1; i >= 0; --i) {
		if (m[a[i]] == 0)
			continue;
		int t = p2(a[i]);
		if (t-a[i] == a[i]) {
			if (m[a[i]] >= 2) {
				m[a[i]] -= 2;
				ans++;
				continue;
			}
		} else {
			if (m[t-a[i]] > 0) {
				m[t-a[i]]--;
				m[a[i]]--;
				ans++;
				continue;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int gcd(int a, int b, int c){
    return __gcd(a, __gcd(b, c));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int sum = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                for(int k = 1; k <= n; k++){
                    sum += gcd(i, j, k);
                }
            }
        }
        cout << sum << '\n';
    }
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 403, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int arr[N], n, Q, sum[N];
int dp[N][N];

int getans(int s, int e)
{     
      if( s >= e ) return 0;
      int &mafia = dp[s][e];
      if( mafia != -1 ) return mafia;

      int ans = INF;
      
      for(int i = s; i < e; i++)
      {
            int a1 = getans(s,i), a2 = getans(i+1, e);
            int sum1 = sum[i] - sum[s-1], sum2 = sum[e] - sum[i];
            int res = a1 + a2 + sum1 + sum2;
            ans = min(ans, res);
      }

      return mafia = ans;
}
void solve()
{
      cin >> n;
      lop(i,1,n+1) cin >> arr[i];
      lop(i,1,n+1) sum[i] += sum[i-1] + arr[i];
      lop(i,0,n+1) lop(j,i,n+1) dp[i][j] = -1;
      cout << getans(1, n) << endl ;
}


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

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //




      

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    int n,l;       
    cin>>n>>l;
    string A[100];
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    for(int i=0;i<n;i++)
    {
        cout<<A[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    int a;
    cin >> a;
    vector<int> z(a);
    for (int i = 0; i < a; i++) {
        cin >> z.at(i);
    }
    sort(z.begin(), z.end());
    cout << z.at(a/2)-z.at(a/2-1) << endl;
}

Measured memory_bytes: 640
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n;
int arr[200007];
void TestingChaluKarEyy(){
	int d;
	cin>>n>>d;
	int cnt=0;
	set<pair<lli,lli> >s;
	fr(i,1,n) {
		lli x,y;
		cin>>x>>y;
		x=abs(x);
		y=abs(y);
		if(sqrt(x*x+y*y) <= d) ++cnt;
		// s.insert(mkp(x,y));
	}
	// for(auto pr:s) {
	// 	lli x=pr.first;
	// 	lli y=pr.second;
	// 	x=abs(x);
	// 	y=abs(y);
	// 	if(sqrt(x*x+y*y) <= d) ++cnt;
	// }
	cout<<cnt<<"\n";
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	jaldiKarNe;
	int TestingKaravvuChhe=1;
	// cin>>TestingKaravvuChhe;
	while(TestingKaravvuChhe--){
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define inf                   LLONG_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

ll f(ll n)
{
    if (n == 0) return 0;
    ll s = 1;
    rep2(i, 2, n + 1)
    {
        s += i;
    }
    return s;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int BUFF_MAX = 1024;
    char buf[BUFF_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll n,p; cin >> n >> p;
        if(n==1){
            cout<<p<<endl;
            return 0;
        }

        ll ans = 1;
        for(int pro = 2; pro<=p; pro++){

            ll product = 1;
            bool isok = true;
            for(ll i = 0; i<n; i++){
                product*=pro;
                if(product>p){
                    isok = false;
                    break;
                }
            }
            if(!isok)break;

            if(p%product==0)ans = pro;
        }

        cout<<ans<<endl;



return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


ll N, U, V;
vector<ll> g[MAX];
ll ud[MAX], vd[MAX];

void dijkstra(ll s, ll* d) {
  ll i, u;
  ll clr[MAX];
  for(i=0; i<N; i++) {
    d[i]=INF;
    clr[i]=0;
  }
  priority_queue<P> q;
  q.push(P(0, s));
  d[s]=0;
  
  while(q.size()) {
    P f=q.top(); q.pop();
    u=f.sc;
    
    clr[u]=1;
    if(d[u]<-f.ft) continue;
    
    for(i=0; i<g[u].size(); i++) {
      ll v=g[u][i];
      if(clr[v]==0 && d[v]>d[u]+1) {
        d[v]=d[u]+1;
        q.push(P(-d[v], v));
      }
    }
  }
}

int main(void) {
  cin >> N >> U >> V;
  U--; V--;
  ll i;
  
  for(i=0; i<N-1; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  dijkstra(U, ud);
  dijkstra(V, vd);
  
  ll ans=0;
  for(i=0; i<N; i++)
    if(vd[i]>ud[i])
      chmax(ans, vd[i]-1);
  
  pt(ans);
}


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

typedef long long ll;
const int N = 100010;
typedef std::pair <int, int> pii;

int a[N], b[N];
pii p[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d%d", &a[i], &b[i]);
        p[i] = {a[i] + b[i], i};
    }
    std::sort(p, p + n, std::greater <pii>());
    ll ans = 0;
    for (int i = 0; i < n; ++ i){
        if (i & 1){
            ans -= b[p[i].second];
        }
        else{
            ans += a[p[i].second];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int main(){
	int n;
	priority_queue<int> pq;
	pq.push(0);
	int ans=0;
	cin>>n;
	rep(i,n){
		int a;
		cin>>a;
		if(pq.top()<a)pq.push(a);
		else if(pq.top()>a){
			while(pq.top()>a){
				pq.pop();
				ans++;
			}
			if(pq.top()!=a)pq.push(a);
		}
	}
	while(!pq.empty()){
		pq.pop();
		ans++;
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 2064
mod = 10**9 + 7
n, k = map(int, input().split())

a = list(map(int, input().split()))

inside = [0] * n
outside = [0] * n

for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            inside[i] += 1

for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            outside[i] += 1

ans = 0
ans += sum(inside) * k
ans %= mod
ans += sum(outside) * k * (k - 1) // 2
ans %= mod
print(ans)


Measured memory_bytes: 3188
#include<cstdio>
int main(){
	char a[220000];
	int i=1,fa,lz;
	bool f=true;
	while(scanf("%c",&a[i])!=EOF){
		if(a[i]=='A'&&f){
			fa=i;
			f=false;
		}
		if(a[i]=='Z')lz=i;
		++i;
	}
	printf("%d\n",lz-fa+1);
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	int a[200000];
	f(i, 200000)a[i] = 0;
	vector<int>b;
	int k;
	int n;
	int x;
	int ans = 0;

	scanf("%d %d", &n,&k);
	f(i, n){
		scanf("%d", &x);
		a[x-1]++;
	}

	f(i, n){
		if (a[i] > 0)b.push_back(a[i]);
	}
	sort(b.begin(), b.end());
	for (int i = 0;i+k< b.size(); i++){

		ans += b[i];

	}

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

	return 0;
}


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

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout)

int main() {
	ioso; //kholo;
	double l; cin >> l;
	l = l/3.000000;
	double k = ((l)*(l)*(l));
	printf("%.7lf\n",k);
}

Measured memory_bytes: 256
#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>

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 popcount __builtin_popcount

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

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, m;
	while (scanf("%d%d", &n, &m), n | m)
	{
		int k[200], x[200][16], d[200][16];
		for (int i = 0; i < n; ++i)
		{
			scanf("%d", k + i);
			for (int j = 0; j < k[i]; ++j)
				scanf("%d%d", &x[i][j], &d[i][j]);
		}

		const int INF = 1 << 29;
		static int dp[200][16][100];	// row, column, jump left
		for (int i = 0; i < 200; ++i)
			for (int j = 0; j < 16; ++j)
				for (int a = 0; a < 100; ++a)
					dp[i][j][a] = INF;
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 16; ++j)
				dp[i][j][m - i] = 0;

		for (int i = 0; i < n - 1; ++i)
		{
			for (int j = 0; j < k[i]; ++j)
			{
				for (int a = 0; a <= m; ++a)
				{
					for (int b = 0; b < k[i + 1]; ++b)
					{
						min_swap(dp[i + 1][b][a]
						, dp[i][j][a] + (d[i][j] + d[i + 1][b]) * abs(x[i][j] - x[i + 1][b]));
					}
					if (i + 2 < n && a > 0)
					{
						for (int b = 0; b < k[i + 2]; ++b)
						{
							min_swap(dp[i + 2][b][a - 1],
								dp[i][j][a] + (d[i][j] + d[i + 2][b]) * abs(x[i][j] - x[i + 2][b]));
						}
					}
				}
			}
		}
		int res = INF;
		for (int i = n - 2; i < n; ++i)
			for (int j = 0; j < k[i]; ++j)
				for (int a = 0; a <= m; ++a)
					if (i == n - 1 || a > 0)
						min_swap(res, dp[i][j][a]);
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N,M,i,j;
    int flag;
    int sumtotalvotes;
    int vote[256];
    std::string str,ans;
    
    cin >> N >> M;
    
    sumtotalvotes = 0;
    
    for (i = 0;i< N; i++){
    
        cin >> vote[i];
        
        sumtotalvotes = sumtotalvotes + vote[i];
        
    }
    
    for(i=0; i< N-1; i++){
        
        for(j = 0; j < N-1; j++){
            
            if (vote[j] < vote[j+1]){
            
                swap(vote[j],vote[j+1]);
            
            }
        }
        
    }
    

    for (i=0; i< M; i ++){
        

        if((double)vote[i]<sumtotalvotes/(4.0*M)){
            
            ans = "No";
            
        }else{
            
            ans = "Yes";
            
        }
        
    }
    
    cout << ans;
    
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> dp(n);
  int INF = 1e9;
  REP(i, n) dp[i] = INF;
  REP(i, n) { *lower_bound(ALL(dp), a[i]) = a[i]; }
  cout << lower_bound(ALL(dp), INF) - dp.begin() << endl;
  return 0;
}


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

int main(){
	int N, i, ans = 1;
	scanf("%d", &N);
	vector<string> S(N);
	for(i = 0; i < N; i++){
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for(i = 1; i < N; i++){
		if(S[i] != S[i - 1]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9608
let main = (input) => {
    let id = parseInt(input)
    let output = ""
    for (let result = id; result != 0; result = Math.floor(result / 26)) {
        let which = result % 26
        if (which == 0) {
            which = 26
            result = result - 26
        }
        output = String.fromCharCode(97 + which - 1) + output
    }

    console.log(output)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

void fast() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
}

const int N = 200005;

int main() {
   fast();
   
   int n, k;
   cin >> n >> k;
   vector <int> h(n);
   for(int i = 0; i < n; i++) {
      cin >> h[i];
   }

   vector <int> dp(n);
   for(int i = 1; i < n; i++) {
      dp[i] = 2e9;
   }


   for(int i = 1; i < n; i++) {
      for(int j = i - 1; j >= max(i - k, 0); j--) {
         dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
      }
   }

   cout << dp[n - 1] << endl;
   return 0;
}


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

int main(){
string a, s;
cin >> a >> s;
string t = a+s;
int n = stoi(t);
int i=1;
bool ans = true;
while(1){
    int che = i*i;
    if(n == che){
        cout <<"Yes"<<endl;
        ans = false;
        break;
    }
    if(che>n){
        break;
    }
    i++;
}
if(ans){
    cout <<"No"<<endl;
}
}

Measured memory_bytes: 256
s = [int(input()) for i in range(4)]
x=0
a=0
b=0
c=0
for i in range(s[0]+1):
    for i in range(s[1]+1):
        for i in range(s[2]+1):
            if 500*a+100*b+50*c == s[3]:
                x=x+1
            c=c+1
        b=b+1
        c=0
    a=a+1
    b=0
    c=0
print(x)

Measured memory_bytes: 8932
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]%=2;
    }
    sort(a.begin(),a.end());
    int p=0;
    for(int i=0;i<n;i++){
        if(a[i]==1){
            p=i;
            break;
        }
    }
    cout << ((n-p)%2==0?"YES":"NO") << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include<cmath>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int count=0;
    int countR=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R')
            countR++;
    }
    for(int i=0;i<countR;i++){
        if(s[i]=='W')
            count++;
    }
    cout<<count<<endl;
    return 0;
}
    



Measured memory_bytes: 3708
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def lcm(m, n):
    return m//gcd(m, n)*n

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for x in a[1:]:
    l = lcm(x, l)
l %= MOD

ans = 0
for x in a:
    ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD
print(ans)


Measured memory_bytes: 4084
#include <cstdio>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while (c>'9'||c<'0') {if (c=='-') f=-1;c=getchar();}
	while ('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int mod(1e9+7),maxn(2e5+5);
int h,w,a,b;
ll fac[maxn],inv[maxn];
ll ans;
ll qpow(ll a,ll b){
	ll sum=1;
	while (b){
		if (b&1) sum=sum*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return sum;
}
void pre(){
	fac[0]=inv[0]=1;
	for (int i(1);i<=maxn;++i) fac[i]=1ll*fac[i-1]*i%mod;
	inv[200000]=qpow(fac[200000],mod-2);
	for (int i(199999);i;--i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
void init(){
	h=read(),w=read(),a=read(),b=read();
}
inline ll cal(int x1,int y1,int x2,int y2){
	int n=x2-x1+y2-y1,m=x2-x1;
	if (n==m||m==0) return 1;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	pre();
	init();
	for (int i(1);i<=h-a;++i)
		ans=(ans+cal(1,1,i,b)*cal(i,b+1,h,w)%mod)%mod;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
#非再帰
import sys
def scc(Edge):
    N = len(Edge)
    Edgeinv = [[] for _ in range(N)]
    for vn in range(N):
        for vf in Edge[vn]:
            Edgeinv[vf].append(vn)
    
    used = [False]*N
    dim = [len(Edge[i]) for i in range(N)]
    order = []
    for st in range(N):
        if not used[st]:
            stack = [st, 0]
            while stack:
                vn, i = stack[-2], stack[-1]   
                if not i and used[vn]:
                    stack.pop()
                    stack.pop()
                else:
                    used[vn] = True
                    if i < dim[vn]:
                        stack[-1] += 1
                        stack.append(Edge[vn][i])
                        stack.append(0)
                    else:
                        stack.pop()
                        order.append(stack.pop())
    res = [None]*N
    used = [False]*N
    cnt = -1
    for st in order[::-1]:
        if not used[st]:
            cnt += 1
            stack = [st]
            res[st] = cnt
            used[st] = True
            while stack:
                vn = stack.pop()
                for vf in Edgeinv[vn]:
                    if not used[vf]:
                        used[vf] = True
                        res[vf] = cnt
                        stack.append(vf)
    M = cnt+1
    components = [[] for _ in range(M)]
    for i in range(N):
        components[res[i]].append(i)
    tEdge = [[] for _ in range(M)]
    teset = set()
    for vn in range(N):
        tn = res[vn]
        for vf in Edge[vn]:
            tf = res[vf]
            if tn*M + tf not in teset:
                teset.add(tn*M + tf)
                tEdge[tn].append(tf)
    return res, components, tEdge
        
V, E = map(int, input().split())
Edge = [[] for _ in range(V)]
for _ in range(E):
    a, b = map(int, sys.stdin.readline().split())
    Edge[a].append(b)
R, com, _ = scc(Edge)
Q = int(input())
for _ in range(Q):
    a, b = map(int, sys.stdin.readline().split())
    if R[a] == R[b]:
        sys.stdout.write('1\n')
    else:
        sys.stdout.write('0\n')



Measured memory_bytes: 9448
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N, std::vector<long long> d) {
  SORT(d);
  int l = d[N/2-1];
  int r = d[N/2];
  cout <<r-l<<endl;
  return;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> d(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &d[i]);
  }
  solve(N, std::move(d));
  return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())
    A = list(map(int,input().split()))
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        count += (i != minj)
        A[i], A[minj] = A[minj], A[i]

    print(" ".join(map(str,A)))
    print(count)


if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Measured memory_bytes: 7776
#include <stdio.h>

int main()
{
	int a,b,c,x,d,T=0;

	scanf("%d %d %d",&a,&b,&c);
	for (x=a;x<=b;x++) {
		if (c%x==0) {
			T++;
		}
	}
	printf("%d\n",T);
	return 0;
}

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

class Program
{
    public Program() { }


    Scanner cin;

    void myon()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
        {
            a[i] = cin.nextInt();
        }
        Array.Sort(a);
        Array.Reverse(a);

        int ans = 0;

        ans += a[0] / 2;
        for (int i = 1; i < n; i++)
        {
            ans += a[i];
        }
        Console.WriteLine(ans);
    }

    static void Main(string[] args)
    {
        new Program().myon();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

public class Main {

	private static Scanner in;
	
	private static int n;
	private static int m;
	private static char[][] g;
	private static long[][] dp;
	private static final int MOD = (int)1e9+7;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		m = in.nextInt();
		g = new char[n][m];
		for(int i=0; i<n; i++) {
			g[i] = in.next().toCharArray();
		}
		
		dp = new long[n][m];
		
		for(int i=0; i<n; i++)
			Arrays.fill(dp[i], -1);
		
		System.out.println(solve(0, 0));
	
	}
	
	private static long solve(int x, int y) {
		if (x==n-1 && y==m-1) return 1;
		
		
		if (dp[x][y]!=-1) return dp[x][y];
		
		int[] dx = {1, 0};
		int[] dy = {0, 1};
		
		long ans = 0;
		
		for(int k=0; k<2; k++) {
			int nx = x+dx[k];
			int ny = y+dy[k];
			if (nx<0 || nx>=n || ny<0 || ny>=m || g[nx][ny]=='#') continue;
			ans = (ans+solve(nx, ny))%MOD;
		}
		
		
		return dp[x][y]=ans;
	}

}


Measured memory_bytes: 69204
import numpy as np
import sys
h, w = [int(x) for x in input().split()]
s = []
for i in range(h):
  s.append([str(r) for r in list(input())])
dot = 0
for i in range(h):
  if(s[i].count('.')==0):
    dot += 1
if(dot == h):
  l = ''
  for j in range(w):
    l += '#'
  for i in range(h):
    print(l)
  sys.exit()
  
count = np.zeros((h+2,w+2))
for i in range(h):
  for j in range(w):
    if(s[i][j]=='#'):
      count[i][j] += 1
      count[i+1][j] += 1
      count[i+2][j] += 1
      count[i][j+1] += 1
      count[i][j+2] += 1
      count[i+2][j+1] += 1
      count[i+1][j+2] += 1
      count[i+2][j+2] += 1

for i in range(h):
  l = ''
  for j in range(w):
    if(s[i][j]=='#'):
      l += '#'
    else:
      l += str(int(count[i+1][j+1]))
  print(l)

Measured memory_bytes: 12516
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	while(true){
		int n;
		scanf("%d",&n);
		if(!n) break;
		bool aknowb[100][100]={};
		rep(i,n){
			int m;
			scanf("%d",&m);
			rep(j,m){
				int p;
				scanf("%d",&p);
				aknowb[i][p-1]=1;
			}
		}
		int k,l[100];
		scanf("%d",&k);
		rep(i,k) scanf("%d",l+i);
		int ans=-1;
		rep(i,n){
			bool ok=true;
			rep(j,k) if(!aknowb[i][l[j]-1]) ok=false;
			if(!ok) continue;
			if(ans!=-1){
				ans=-1;
				break;
			}else{
				ans=i+1;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}


int const maxn = 305;
int par[maxn];

inline int get_par(const int x)
{
    return par[x] == x? x : par[x] = get_par(par[x]);
}

inline void uni(const int x, const int y)
{
    par[get_par(x)] = get_par(y);
}

int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<int> > a(n, vector<int>(n, 0));
    for(auto& vec : a)
    for(int& x : vec)
        cin >> x;

    for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
        if (a[i][k] + a[k][j] < a[i][j])
            FINAL_OUT(-1);

    vector<vector<int> > g(n, vector<int>(n, 1000000009));
    for(int i = 0; i < n; ++i)
        g[i][i] = 0;
    long long ans = 0;


    vector<tuple<int,int,int> > edges;
    for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
        edges.emplace_back(a[i][j], i,j);
    sort(begin(edges), end(edges));

    int cnt = n;
    for(int i = 0; i < n; ++i)
        par[i] = i;

    for(int i = 0;cnt > 1; ++i)
    {
        int w,x,y;
        tie(w,x,y) = edges[i];
        if (get_par(x) != get_par(y))
        {
            g[x][y] = g[y][x] = w;
            uni(x,y);
            --cnt;
            ans += w;
        }
    }

    for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
        if (g[i][k] + g[k][j] < g[i][j])
            g[i][j] = g[i][k] + g[k][j];

    for(const auto& e : edges)
    {
        int w,x,y;
        tie(w,x,y) = e;
        if (g[x][y] != w)
        {
            g[x][y] = g[y][x] = w;
            ans += w;
            vector<int> r = {x,y};
            for(int k : r)
            for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
            if (g[i][k] + g[k][j] < g[i][j])
                g[i][j] = g[i][k] + g[k][j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2680
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
int A,B,cnt1,cnt2,n;
char s[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();A=read();B=read();
	scanf("%s",s);
	range(i,0,n-1){
		bool flag=0;
		if(s[i]=='a'){
			if(cnt1<A+B) cnt1++,flag=1;
		}
		else if(s[i]=='b'){
			if(cnt1<A+B&&cnt2<B) cnt1++,cnt2++,flag=1;
		}
		puts(flag?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 768
n = int(input())
edges = [set() for _ in range(n + 1)]
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    edges[a].add((c, b))
    edges[b].add((c, a))
q, k = map(int, input().split())
stack = [(0, k, None)]
costs = [0] * (n + 1)
while stack:
    c, p, a = stack.pop()
    costs[p] = c
    stack.extend((c + c2, p2, p) for c2, p2 in edges[p] if p2 != a)

print('\n'.join(map(str, (costs[x] + costs[y] for x, y
                          in (map(int, input().split()) for _ in range(q))))))


Measured memory_bytes: 64304
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;

int main() {
	int x, y;
	cin >> x >> y;
	int ans = 1 << 30;
	if (x <= y) {
		ans = min(ans, y - x);
	}
	if (-x <= y) {
		ans = min(ans, y + x + 1);
	}
	if (x <= -y) {
		ans = min(ans, -y - x + 1);
	}
	if (-x <= -y) {
		ans = min(ans, -y + x + 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256