akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, P;
    string S;
    cin >> N;
    vector<pair<string, int>> v1, v2;
    REP(i, N) {
        cin >> S >> P;
        v1.push_back({S, P});
        v2.push_back({S, P});
    }
    sort(ALL(v1), [](const pair<string, int>& x, const pair<string, int>& y) {
        if (x.first == y.first) {
            return x.second > y.second;
        } else {
            return x.first < y.first;
        }
    });

    for (auto p : v1) {
        REP(i, N) {
            if (v2[i] == p) cout << i + 1 << endl;
        }
    }

    return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  n %= 10;

  bool conda = n == 2 || n == 4 || n == 5 || n == 7 || n == 9;
  bool condb = n == 0 || n == 1 || n == 6 || n == 8;
  //bool condc = n == 3;

  string ans;
  if (conda) {
    ans = "hon";
  } else if(condb){
    ans = "pon";
  } else {
    ans = "bon";
  }

  cout << ans << endl;

  return 0;
}


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

int main() {

  int N, L;
  cin >> N >> L;

  int answer = 300;
  int sum = 0;

  for (int i = 1; i <= N; i++) {
    int l = L + i - 1;
    sum += l;
    answer = min(answer, abs(l));
  }

  if (sum < 0) {
    cout << sum + answer << endl;
  } else {
    cout << sum - answer << endl;
  }
}

Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
X=sorted(list(map(int,input().split())))
Y=sorted(list(map(int,input().split())))
if X[-1]<y and X[-1]<Y[0]:
    if x<Y[0]:
        print("No War")
    else:
        print("War")
else:print("War")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int digit = String.valueOf(N).length();

    ArrayList<Integer> combis = new ArrayList<>();
    for (int i = digit; i >= 3; i--) {
      calcCombi("", i, combis);
    }
    ArrayList<Integer> validCombis = new ArrayList<>();
    for (int combi : combis) {
      if (combi <= N) {
        validCombis.add(combi);
      }
    }

    System.out.println(validCombis.size());

  }

  public static void calcCombi(String str, int D, ArrayList<Integer> combis) {
    if (D == 0) {
      boolean exists3 = false;
      boolean exists5 = false;
      boolean exists7 = false;
      for (char digit : str.toCharArray()) {
        switch (digit) {
        case '3':
          exists3 = true;
          break;
        case '5':
          exists5 = true;
          break;
        case '7':
          exists7 = true;
          break;
        }

        if (exists3 && exists5 && exists7) {
          combis.add(Integer.parseInt(str));
          break;
        }
      }
    } else {
      calcCombi(str + '3', D - 1, combis);
      calcCombi(str + '5', D - 1, combis);
      calcCombi(str + '7', D - 1, combis);
    }

  }

}

Measured memory_bytes: 32344
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left, bisect_right

n = int(readline())
a = [int(readline()) for _ in range(n)]
inf = float('inf')
memo = [inf] * n
for aa in a[::-1]:
    memo[bisect_right(memo, aa)] = aa
print(bisect_left(memo, inf))


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

int h, w, mat[2003][2003];
char arr[2002][2002];

int main(){

    scanf("%d %d", &h, &w);
    for(int i = 0; i < h; i++){
        scanf("%s", arr[i]);
    }

    int mx = -1;

    for(int i = 1; i <= h; i++){
        for(int j = 1, act = 0; j <= w; j++){
            if(arr[i - 1][j - 1] == '.'){
                act++;
            }
            if(arr[i - 1][j - 1] == '#' || j == w){
                int k = (arr[i - 1][j - 1] == '#') ? 1 : 0;
                for(k; k < j && arr[i - 1][j - k - 1] == '.'; k++){
                    mat[i][j - k] = act;
                }
                act = 0;
            }
        }
    }

    for(int i = 1; i <= w; i++){
        for(int j = 1, act = 0; j <= h; j++){
            if(arr[j - 1][i - 1] == '.'){
                act++;
            }
            if(arr[j - 1][i - 1] == '#' || j == h){
                int k = (arr[j - 1][i - 1] == '#') ? 1 : 0;
                for(k; k < j && arr[j - k - 1][i - 1] == '.'; k++){
                    mat[j - k][i] += act - 1;
                    mx = max(mx, mat[j - k][i]);
                }
                act = 0;
            }
        }
    }

    /*for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            printf("%d ", mat[i][j]);
        }
        printf("\n");
    }*/

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

    return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const double pi=acos(-1);


//基本的に勝つ手をだす．
//勝つ手がなければ，K回後に勝つ手以外を出す．

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  ll k;

  rep1(i,n){// iの倍数を考える．
    k=n/i;
    ans+=ll(k*(k+1)*i/2);
  }




  cout<<ans<<endl;






}


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

a = [i**5 for i in range(200)]

for i in range(200):
    for j in range(i+1,200):
        if a[j] - a[i] == X:
            print(j,i)
            break
        if a[j] + a[i] == X:
            print(j,-i)
            break
    else:
        continue
    break


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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int x; cin >> x;
    if(x==5 or x==7 or x==3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010;
const ll Inf=1e18;
int n;
pll a[N],b[N<<1];
#define fi first
#define se second
set<pll>s1,s2;

inline ll calc(){return ((*s1.rbegin()).fi-(*s1.begin()).fi)*((*s2.rbegin()).fi-(*s2.begin()).fi);}

int main()
{
	n=rd();
	fo(i,1,n){
		ll x=rd(),y=rd();
		if(x>y)swap(x,y);
		a[i]=pll(x,y);
		s1.insert(pll(x,i));
		s2.insert(pll(y,i));
	}
	ll mn=calc();
	fo(i,1,n){
		auto x=*s1.begin();
		auto y=pll(a[x.se].se,x.se);
		if(x==y)break;
		s1.erase(x);s2.erase(y);
		s1.insert(y);s2.insert(x);
		mn=min(calc(),mn);
	}
	printf("%lld\n",mn);
	return 0;
}


Measured memory_bytes: 28544
N, M = map(int, input().split())
S = [0]*N

for i in range(M):
    s = list(map(int, input().split()))[1:]
    for s_ in s:
        S[s_-1] ^= 1 << i
P_ = list(map(int, input().split()))
P = 0
for i, p in enumerate(P_):
    P ^= p << i
#print(list(map(bin,S)))
#print(P)
ans = 0
for i in range(1<<N):
    a = P
    for j, s in enumerate(S):
        if i>>j & 1:
            a^=s
    if a==0:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c;
    cin >> a>>b>> c;
 
    if (a+b>=c) cout << "Yes";
    else cout << "No";
    return 0;
}

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

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)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int n;
  cin>>n;
  while(n--){
    string s,t;
    cin>>s>>t;
    for(int i = s.size() - 1; i >= 0; i--){
      if(s[i] == 'C') t = t.substr(1) + t.substr(0, 1);
      if(s[i] == 'J') t = t.substr(t.size()-1) + t.substr(0, t.size()-1);
      if(s[i] == 'E'){
        if(t.size() % 2) t = t.substr(t.size() / 2 + 1) + t.substr(t.size()/2, 1) + t.substr(0, t.size()/2);
        else t = t.substr(t.size()/2) + t.substr(0, t.size()/2);
      }
      if(s[i] == 'A') reverse(t.begin(), t.end());
      if(s[i] == 'M') REP(j, t.size())if(isdigit(t[j])) t[j] = (t[j]-'0' + 1) % 10 + '0';
      if(s[i] == 'P') REP(j, t.size())if(isdigit(t[j])) t[j] = (t[j]-'0' + 9) % 10 + '0';
    }
    cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
#define base 2001
#define Maxn 4050
#define p 1000000007
#define inv2 500000004
inline void read(int& x)
{
	x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
}
int a[maxn],b[maxn],dp[Maxn][Maxn];
int fac[maxn],inv[maxn];
inline int qpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%p;
		x=1ll*x*x%p;
		y>>=1;
	}
	return ans;
}
inline int C(int x,int y)
{
	return 1ll*fac[x]*inv[y]%p*inv[x-y]%p;
}
int main()
{
	int n;read(n);
	fac[0]=inv[0]=1;
	for(int i=1;i<=8000;++i) fac[i]=1ll*fac[i-1]*i%p;
	inv[8000]=qpow(fac[8000],p-2);
	for(int i=7999;i;--i) inv[i]=1ll*inv[i+1]*(i+1)%p;
	for(int i=1;i<=n;++i) read(a[i]),read(b[i]),++dp[base-a[i]][base-b[i]];
	for(int i=1;i<=4002;++i)
		for(int j=1;j<=4002;++j)
			dp[i][j]=(0ll+dp[i][j]+dp[i-1][j]+dp[i][j-1])%p;
	long long ans=0;
	for(int i=1;i<=n;++i)
	{
		ans+=dp[a[i]+base][b[i]+base];
		ans-=C(((a[i]+b[i])<<1),(a[i]<<1));
		ans%=p;
	}
	ans=(ans%p+p)%p;
	ans=ans*inv2%p;
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int now=0;
  int ans=0;
  std::vector<int> a(N+2);
  a[0]=0;
  for(int i=1;i<N+1;i++)cin>>a[i];
  a[N+1]=0;
  for(int i=1;i<N+2;i++){
    ans+=abs(now-a[i]);
    now=a[i];
  }
  for(int i=1;i<N+1;i++){
    cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
  }
}


Measured memory_bytes: 1664
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
#define MAX_SIZE 10000000
vector<bool> V(MAX_SIZE,false);
int main(){
      fast
      int D1, D2, M1, M2;
  	cin >> M1 >> D1 >> M2 >> D2;
 
 	if(M1 != M2)cout << 1 << endl;
  	else cout << 0 << endl;
      
      return 0;
}

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

using namespace::std;

int serch_max(vector<double> nums) {

	vector<double>::iterator iter = max_element(nums.begin(), nums.end());
	int index = distance(nums.begin(), iter);
	
	return index;
}


int main()
{

	int N;
	cin >> N;

	vector<double> nums(N);

	for (int i = 0; i < N; i++) {
		cin >> nums[i];
	}

	int max_i = serch_max(nums);

	int sum = 0;

	for (int i = 0; i < N; i++) {
		if (i != max_i)
			sum += nums[i];
	}
	
	//cout << sum << endl;
	
	if (nums[max_i] < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long A, long long B){
	if ((B-A)%2 == 0) {
		cout << (B-A)/2 << endl;
	} else {
		cout << min(A-1+1+(B-A-1)/2, N-B+1+(B-A-1)/2) << endl;
	}
}

int main(){	
	long long B;
	long long A;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(N, A, B);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,tmp;
void dfs(int inp[],int nums[],int pos,int num,int &ans,int &tmp)
{
    if (pos==n)
    {
        ++tmp;
        if (tmp%3==1)
        {
            int i,res=1;
            for (i=0;i<n;i++)
                res*=nums[i];
            if (res%2==0) ans++;
            return ;
        }
        else return ;
    }
    nums[pos]=inp[pos]+num;
    dfs(inp,nums,pos+1,-1,ans,tmp);
    dfs(inp,nums,pos+1,0,ans,tmp);
    dfs(inp,nums,pos+1,1,ans,tmp);
}
void solve()
{
    int i,inp[n],nums[n],ans=0,tmp=0;
    for (i=0;i<n;i++)
        cin>>inp[i];
    dfs(inp,nums,0,-1,ans,tmp);
    dfs(inp,nums,0,0,ans,tmp);
    dfs(inp,nums,0,1,ans,tmp);
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Data.List (sort)

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- VU.fromList . sort . map unsafeSignedDecimal . T.words <$> T.getLine :: IO (VU.Vector Int)
  let
    mins = map f [0..(n - k)]
      where
        f i = (c (pred n - i) (pred k) * (as VU.! i)) `mod` modulus
    maxs = map f [(pred k)..(pred n)]
      where
        f i = (c i (pred k) * (as VU.! i)) `mod` modulus
    step acc x = acc `seq` x `seq` ((acc + x) `mod` modulus)
  print $ (foldl step 0 maxs - foldl step 0 mins) `mod` modulus

modulus :: Int
modulus = 10 ^ 9 + 7

finv :: Int -> Int
finv = (finvs V.!)
  where
    finv' 0 = 1
    finv' n = (finvs V.! (pred n) * inv n) `mod` modulus
    -- finv' n = (finv (pred n) * inv n) `mod` modulus    
    finvs :: V.Vector Int
    finvs = V.generate (10 ^ 5 + 1) finv'

c :: Int -> Int -> Int
c n k | n < 0 || k < 0 || n < k = 0
      |otherwise                = (((fact n * finv k) `mod` modulus) * finv (n - k)) `mod` modulus

inv :: Int -> Int
inv = (invs V.!)
  where
    inv' 1 = 1
    inv' n = (-(invs V.! r) * q) `mod` modulus
    -- inv' n = (-(inv' r) * q) `mod` modulus
      where
        (q, r) = modulus `divMod` n
    invs :: V.Vector Int
    invs = V.generate (10 ^ 5 + 1) inv'

fact :: Int -> Int
fact = (facts V.!)
  where
    fact' 0 = 1
    fact' n = (n * (facts V.! (pred n))) `mod` modulus
    -- fact' n = (n * fact (pred n)) `mod` modulus
    -- fact' n = (n * facts A.! (pred n)) `mod` modulus
    facts :: V.Vector Int
    facts = V.generate (10 ^ 5 + 1) fact'
    -- facts :: A.Array Int Int
    -- facts = A.listArray (0, 10 ^ 5) . map fact $ [0..(10 ^ 5)]

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 37244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long answer = k;
		for(int i =1;i < n;i++) {
			answer *= (k-1);
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21844
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  nums = []
  nums << get_int
  nums << get_int
  n = ([1, 2, 3] - nums)[0]
  puts n
end

if __FILE__ == $0
  main
end

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


typedef long long ll;
#define reg register
#define rep(a,b,c) for(reg int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(reg int a=b,a##end=c;a>=a##end;--a)

char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}


const int N=2e5+10,K=30;

int n,m;



struct Edge{
	int to,nxt,col,len;
}e[N<<1];
int head[N],ecnt;
void AddEdge(int u,int v,int x,int y){
	e[++ecnt]=(Edge){v,head[u],x,y};
	head[u]=ecnt;
}
#define erep(u,i) for(int i=head[u];i;i=e[i].nxt)

int fa[N][21];
ll dis[N];
int ls[N*K],rs[N*K];
struct node{
	ll s;
	ll sum;
}tr[N*K];
int T[N],cnt;

void Add(int p,int pre,int x,int y,int l=1,int r=n){
	tr[p].s=tr[pre].s+1,tr[p].sum=tr[pre].sum+y;
	if(l==r) return;
	int mid=(l+r)>>1;
	if(x<=mid) rs[p]=rs[pre],Add(ls[p]=++cnt,ls[pre],x,y,l,mid);
	else ls[p]=ls[pre],Add(rs[p]=++cnt,rs[pre],x,y,mid+1,r);
}

node Que(int p,int l,int r,int x){
	if(l==r) return tr[p];
	int mid=(l+r)>>1;
	if(x<=mid) return Que(ls[p],l,mid,x);
	else return Que(rs[p],mid+1,r,x);
}

int dep[N];

int LCA(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=0,del=dep[x]-dep[y];(1<<i)<=del;i++) if(del&(1<<i)) x=fa[x][i];
	if(x==y) return x;
	drep(i,20,0) if(dep[x]>=(1<<i)){
		if(fa[x][i]!=fa[y][i]){
			x=fa[x][i],y=fa[y][i];
		}
	}
	return fa[x][0];
}

void dfs(int u,int f){
	fa[u][0]=f;
	for(int i=1;(1<<i)<=dep[u];i++) fa[u][i]=fa[fa[u][i-1]][i-1];
	erep(u,i){
		int v=e[i].to;
		if(v==f) continue;
		dis[v]=dis[u]+e[i].len;
		Add(T[v]=++cnt,T[u],e[i].col,e[i].len);
		dep[v]=dep[u]+1;
		dfs(v,u);
	}
}




int main(){
	n=rd(),m=rd();
	rep(i,2,n) {
		int u=rd(),v=rd(),c=rd(),d=rd();
		AddEdge(u,v,c,d);AddEdge(v,u,c,d);
	}
	dfs(1,0);
	//cout<<LCA(2,3)<<endl;
	rep(i,1,m){
		int x=rd(),y=rd(),u=rd(),v=rd();
		int lca=LCA(u,v);
		node a=Que(T[u],1,n,x),b=Que(T[v],1,n,x),c=Que(T[lca],1,n,x);
		ll cnt=a.s+b.s-c.s*2;
		ll sum=a.sum+b.sum-2*c.sum;
		ll ans=dis[u]+dis[v]-2*dis[lca];
		ans-=sum;
		ans+=1ll*y*cnt;
		printf("%lld\n",ans);
	}
}















Measured memory_bytes: 72320
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long X,Y;
    std::cin >> X >> Y;
    if(Y%2==0 && Y/2-X>=0 && 2*X-Y/2>=0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ll dp[N][15];
int n;
string s;

ll solve(int curr, int sofar) {
	ll &res = dp[curr][sofar];
	if(res >= 0) return res;
	res = 0;
	if(curr == n) {
		return res = (sofar == 5);
	}
	if(s[curr] == '?') {
		int tmp;
		FOR(dig, 0, 10) {
			tmp = (sofar * 10 + dig) % 13;
			res += solve(curr+1, tmp);
			res %= MOD;
		}
	} else {
		int dig = s[curr] - '0';
		sofar = (sofar * 10 + dig) % 13;
		res += solve(curr+1, sofar);
		res %= MOD;
	}
	return res % MOD;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>s; n = s.size();
    memset(dp, -1, sizeof(dp));
    cout<<solve(0, 0);
    return 0;
}

Measured memory_bytes: 18512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int n,i,t=0,x=0,y=0;
  scanf("%d",&n);
  int a[n][3];
  for(i=0;i<n;i++)
    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
  for(i=0;i<n;i++){
    if(a[i][0]-t<abs(x-a[i][1])+abs(y-a[i][2])){
      printf("No\n");
      return 0;
    }else if(a[i][0]-t==abs(x-a[i][1])+abs(y-a[i][2])){
      t=a[i][0];
      x=a[i][1];
      y=a[i][2];
      continue;
    }
    else{
      if((a[i][0]-t-abs(x-a[i][1])-abs(y-a[i][2]))%2!=0){
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
   // cin>>TESTS;
    while(TESTS--){
       int a,b;
       cin>>a>>b;
       string A="";
       string B="";
       for(int i=0;i<a;i++){
         A+=char(b+48);
       }
       for(int i=0;i<b;i++){
         B+=char(a+48);
       }
       if(A<B)cout<<A<<endl;
       else cout<<B<<endl;
    }
}











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

int main(){
  int n;
  long long t=0,a=0,ans=0;cin>>n>>t>>a;
  REP(i,n-1){
    long long tn,an,m;cin>>tn>>an;
    m=max((t+tn-1)/tn,(a+an-1)/an);
    t=tn*m;
    a=an*m;
  }
  cout<<t+a<<endl;;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main()
{
    int N = 0;
    string S, T = "";
    cin >> N;
    cin >> S;
    cin >> T;

    string answer = "";
    for (int i = 0; i < N; i++) {
        answer.append(1, S[i]);
        answer.append(1, T[i]);
    }

    cout << answer << endl;
}

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

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

	map<ll, int> m;
	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		m[a]++;
	}

	ll ans = 0;
	vector<ll> x;
	for(auto v : m) {
		if(v.second >= 4){
			ans = max(ans, v.first * v.first);
		}
		if(v.second >= 2) {
			x.push_back(v.first);
		}
	}
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());
	if(x.size() >= 2) {
		ans = max(ans, x[0] * x[1]);
	}

	cout << ans << endl;

}


Measured memory_bytes: 6528
import math
a,b,x = map(int, input().split())

ans = 0
if a * a * b / 2.0 <= x :
    ans = math.atan(2 * (a * a * b - x) / (a * a * a))
else:
    ans = math.pi / 2 - math.atan(2 * x / (a * b * b))


print(math.degrees(ans))


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec[i];
  }

  int maximum = 0, minimum = 0;
  long long sum = 0;

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

  minimum = vec[0];
  maximum = vec[n - 1];

  for(int i = 0; i < n; i++){
    sum += vec[i];
  }

  cout << minimum << " " << maximum << " " << sum << endl;
}


Measured memory_bytes: 3188
h,w = map(int,input().split())
c = []
for i in range(10):
  ci = list(map(int,input().split()))
  c.append(ci)
x = [0 for _ in range(10)]
for _ in range(h):
  a = list(map(int,input().split()))
  for ai in a:
    if ai != -1:
      x[ai] += 1
d = [float("inf") for _ in range(10)]
d[1] = 0
done = [False for _ in range(10)]
while sum(done) < 10:
  mni = -1
  mn = float("inf")
  for i in range(10):
    if done[i] == False:
      if mn > d[i]:
        mn = d[i]
        mni = i
  done[mni] = True
  for i in range(10):
    if done[i] == False:
      d[i] = min(d[i],d[mni]+c[i][mni])
ans = 0
for i in range(10):
  ans += x[i]*d[i]
print(ans)

Measured memory_bytes: 73620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define lli long long int
#define pb push_back
using namespace std;
int ab(int x)
{
	if(x>0)
		return x;
	return -1*x;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int l;
	cin>>n>>l;
	int minval = 10000;
	int i;
	int ind=i;
	for(i=1;i<=n;i++)
	{
		int val = l + i - 1;
		val = ab(val);
		if(val < minval)
		{
			minval = val;
			ind = i;
		}
	}
	int ans = 0;
	for(i=1;i<=n;i++)
	{
		if(i!=ind)
		{
			ans = ans + l + i - 1;
		}
	}
	cout<<ans<<endl;


	return 0;
}

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MAX_N = 1e5;
ll N, A, B;
ll X[MAX_N];

int main() {
  cin >> N >> A >> B;
  rep(i,N) cin >> X[i];

  ull ans = 0;
  for (int i = 0; i < N-1; ++i) {
    ans += B < A*(X[i+1] - X[i]) ? B : A*(X[i+1] - X[i]);
  }

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




Measured memory_bytes: 1024
//044
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    string s;
    cin >> s;
    set<char>d;
    rep(i,s.size()) d.insert(s[i]);
    for(auto itr=d.begin(); itr !=d.end(); itr++){
        if (count(s.begin(), s.end(), *itr)%2 !=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int to[25][100005];

int main()
{ios_base::sync_with_stdio(false);
int n;
ll a[100005],len,q;

cin>>n;
rep(i,1,n)cin>>a[i];

cin>>len>>q;

rep(i,1,n-1)
{
	int lo=i+1,hi=n,mid;
	while(lo<hi)
	{
		mid=(lo+hi)/2;
		if(a[mid]-a[i]<=len)
		lo=mid+1;
		else
		hi=mid;
	}
	if(a[lo]-a[i]>len)lo--;
	to[0][i]=lo;
}
to[0][n]=n;

rep(i,1,24)
{
	rep(j,1,n)
	to[i][j]=to[i-1][to[i-1][j]];
}

while(q--)
{
	int l,r;
	cin>>l>>r;
	if(l>r)
	swap(l,r);
	int ans=0,ptr=l;
	ren(i,24,0)
	{
		if(to[i][ptr]<r)
		{
			//o2(i,to[i][ptr]);on;
			ans+=(1<<i);
			ptr=to[i][ptr];
		}
	}
	ans++;
	ol(ans);on;
}

return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int M,K;
  while(cin >> M >> K){
    vector<int> ans;
    bool no = false;


    if(K >= (1<<M)){
      no = true;
    }else{
      if(M == 0){
	ans.push_back(0);
	ans.push_back(0);
      }else if(M == 1){
	if(K == 0){
	  ans.push_back(0);
	  ans.push_back(0);
	  ans.push_back(1);
	  ans.push_back(1);
	}else{
	  no = true;
	}
      }else{
	FOR(i,0,1<<M){
	  if(i == K) continue;
	  ans.push_back(i);
	}
	ans.push_back(K);
	REV(i,(1<<M)-1,0){
	  if(i == K) continue;
	  ans.push_back(i);
	}
	ans.push_back(K);
      }
    }

    if(no){
      cout << -1 << endl;
    }else{
      join(cout, ALL(ans));
    }
  }
  
  return 0;
}


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

int main(){
	long double a,b,c,s,l,h;
	cin >> a >> b >> c;
	h = b*sinl(c*3.1415926535/180);
	s = a*h*0.5;
	l = a + b + sqrtl(a*a + b*b - 2*a*b*cosl(c*3.1415926535/180));
	cout << setprecision(18) << s << "\n" << l << "\n" << h << "\n";
	return 0;
}

Measured memory_bytes: 3492
import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x = Integer.parseInt(scan.next());
    boolean bool = x == 1 ? true : false;
    int result = !bool ? 1 : 0;
    PrintWriter out = new PrintWriter(System.out);
    out.println(result);
    out.flush();
  }
}


Measured memory_bytes: 35632
def mask_judge(a, b, i, j):
    flag = 1
    for k in range(m):
        for l in range(m):
            if a[i+k][j+l] != b[k][l]:
                flag = 0
                break
    return flag


def main():
    a = [[0 if i == '.' else 1 for i in input()] for _ in range(n)]
    b = [[0 if i == '.' else 1 for i in input()] for _ in range(m)]

    flag = 0
    for i in range(n-m+1):
        for j in range(n-m+1):
            if mask_judge(a, b, i, j):
                flag = 1
                break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    n, m = map(int, input().split())
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int N=1e5+5,inf=1e9;
using std::max;
int main()
{
	ll a=in(),b=in(),c=in();
	ll ans=b;ans+=std::min(c,a+b+1);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int k,a,b,i;
	cin>>k>>a>>b;
	f(i,a,b+1){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
} 


Measured memory_bytes: 3648
def resolve():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = [0] * n
    for i in range(n):
        l = [min(j - i, abs(x - i) + 1 + abs(y - j)) for j in range(i + 1, n)]
        for j in l:
            ans[j] += 1
    ans.pop(0)
    for i in ans:
        print(i)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,now=1000;
	cin>>n;
	int a[n+1],j=1;
	for(int i=1;i<=n;i++){
		cin>>a[j];
		if(j!=1&&a[j]!=a[j-1]){
			j++;
		}
		if(j==1){
			j++;
		}
	}
	j--;
	for(int i=1;i<j;i++){
		if(a[i+1]>a[i]){
			now=now%a[i]+now/a[i]*a[i+1];
		}
	}
	cout<<now;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
typedef long long ll;
int max = 1e9;

int main(){
    int m,n;
    cin >> m >> n;
    if(m== n){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}
   
   
      
      


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

const int mxN=3e3;
int n;
double ph[mxN], pt[mxN], dp[mxN][mxN];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i=1; i<=n; ++i)
        cin >> ph[i], pt[i]=1-ph[i];
    dp[0][0]=1;
    for (int i=1; i<=n; ++i)
        for (int j=0; j<=i; ++j) {
            dp[i][j]+=dp[i-1][j]*pt[i];
            if (j)
                dp[i][j]+=dp[i-1][j-1]*ph[i];
        }
    double ans=0;
    for (int i=n/2+1; i<=n; ++i)
        ans+=dp[n][i];
    cout << setprecision(12) << ans << '\n';
}


Measured memory_bytes: 49952
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, k; cin >> a >> b >> k;
    int turn = 1;
    while (k--) {
        if (turn == 1) {
            if (a&1) a--;
            b += a/2;
            a /= 2;
        }
        if (turn == -1) {
            if (b&1) b--;
            a += b/2;
            b /= 2;
        }
        turn *= -1;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Pair
{
	public int Color { get; private set; }
	public int Strange { get; private set; }

	public Pair(int color, int strange)
	{
		Color = color;
		Strange = strange;
	}
}


public class D
{
	public static void Main()
	{
		string[] args;

		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int C = Int32.Parse(args[1]);

		int[,] D = new int[C,C];
		for(int i = 0; i < C; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < C; j++)
				D[i,j] = Int32.Parse(args[j]);
		}

		int[,] c = new int[N,N];
		for(int i = 0; i < N; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < N; j++)
				c[i,j] = Int32.Parse(args[j]) - 1;
		}
		
		List<List<Pair>> lists = new List<List<Pair>>(3);
		for(int i = 0; i < 3; i++)
			lists.Add(new List<Pair>(N));

		for(int k = 0; k < C; k++)
		{
			int[] sum = new int[3];
			for(int i = 0; i < N; i++)
				for(int j = 0; j < N; j++)
					sum[(i + j) % 3] += D[c[i,j],k];

			for(int i = 0; i < 3; i++)
				lists[i].Add(new Pair(k, sum[i]));
		}

		for(int i = 0; i < 3; i++)
			lists[i].Sort((x,y) => x.Strange - y.Strange);

		int ans = Int32.MaxValue;
		for(int mask = 0; mask < 27; mask++)
		{
			int tmp = mask;
			int[] rank = new int[3];
			for(int i = 0; i < 3; i++)
			{
				rank[i] = tmp % 3;
				tmp /= 3;
			}

			if(lists[0][rank[0]].Color == lists[1][rank[1]].Color ||
				lists[1][rank[1]].Color == lists[2][rank[2]].Color ||
				lists[2][rank[2]].Color == lists[0][rank[0]].Color )
				continue;

			int sum = 
				lists[0][rank[0]].Strange + 
				lists[1][rank[1]].Strange + 
				lists[2][rank[2]].Strange;
			ans = Math.Min(ans,sum);
		}

		Console.WriteLine(ans);		
	}	
}





Measured memory_bytes: 16348
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
ll A,B,C;
cin>>A>>B>>C;

A = B/A;
if(C<A)
cout<<C<<"\n";
else
cout<<A<<"\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
  int N,ans=0;
  cin>>N;
  vector<int> L(N);
  for(int t=0;t<N;t++) scanf("%d",&L[t]);
  sort(L.begin(),L.end());
    for(int a=0;a<N-2;a++){
    for(int b=a+1;b<N-1;b++){
      for(int c=b+1;c<N;c++){
        if(L[c]<L[a]+L[b]) ans++;
        else break;
      }
    }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def S(n):
    return sum(map(int, str(n)))


def snuke(n):
    return n / S(n)


def main():
    K = ii()
    snuke_list = list(range(1, 10))

    for n in range(1, 17):
        c = 1
        while True:
            if snuke(10 ** n * c - 1) < snuke(10 ** n * (c+1) - 1):
                if not 10 ** n * c - 1 in snuke_list:
                    snuke_list.append(10 ** n * c - 1)
                c += 1
            else:
                break

    snuke_list = sorted(snuke_list)
    for i in range(K):
        print(snuke_list[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	int ans = max(0, C - (A - B));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

	int n,m;
	cin>>n>>m;
	long long int a[n],b[m],c[m];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i]>>c[i];

	vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		v.push_back(make_pair(c[i],b[i]));
	}

	sort(a,a+n);
	sort(v.begin(),v.end(),greater<>());

	int j=0,k=0;
	for(int i=0;i<m;i++){
		for(j=k;j<k+v[i].second;j++){
			if(j==n)break;
			if(a[j]<v[i].first)a[j]=v[i].first;
		}
		if(j==n)break;
		k+=v[i].second;
	}

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

	cout<<ans<<endl;

	return 0;
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 1e18;
    ll ah = a / 2, bh = b / 2, ch = c / 2;
    ans = min({ans, abs(b * c * ah - b * c * (a - ah)), abs(b * c * ah - b * c * (a - ah))});
    ans = min({ans, abs(a * c * bh - a * c * (b - bh)), abs(a * c * bh - a * c * (b - bh))});
    ans = min({ans, abs(a * b * ch - a * b * (c - ch)), abs(a * b * ch - a * b * (c - ch))});
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    vector<ll> ac(a);
    vector<ll> bc(b);
    vector<ll> cc(c);
    vector<ll> Q;
    rep(i,a) cin >> ac[i];
    rep(i,b) cin >> bc[i];
    rep(i,c) cin >> cc[i];
    rep(i,a){
        rep(j,b){
            ll num = ac[i] + bc[j];
            Q.push_back(num);
        }
    }
    sort(RALL(cc));
    sort(RALL(Q));

    priority_queue<ll> ans;
    rep(i,min((int)Q.size(),k)){
        rep(j,min(c,k)){
            ll num = Q[i] + cc[j];
            ans.push(num);
        }
    }
    rep(i,k){
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 43368