akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, t;
int main()
{
	//run();
	M_Sayed;
	string s;
	deque<char>dq;
	cin >> s;
	for (auto it : s) {
		dq.push_back(it);
	}
	cin >> n;
	ll cnt = 0;
	while (n--) 
	{
		cin >> m;
		if (m == 1)cnt = 1 - cnt;
		else {
			char c;int a;
			cin >> a >> c;
			if (cnt) 
			{
				if (a == 1)
					a = 2;
				else if (a == 2)
					a = 1;
			}
			if (a == 2) {
				dq.push_back(c);
			}
			else {
				dq.push_front(c);
			}
		}
	}
	if(cnt)
		while (sz(dq)) {
			cout << dq.back();
			dq.pop_back();
		}
	else {
		while (sz(dq)) {
			cout << dq.front();
			dq.pop_front();
		}
	}
	
}

Measured memory_bytes: 976
#include <stdio.h>

typedef long long int ll;
int mod = 1000000007;

int dp[1001][1001];
int fact[1001];
int ifact[1001];

int modpow(int n, int k){
  if(k==0) return 1;
  if(k%2) return (ll) n * modpow((ll) n*n %mod, k/2) % mod;
  else return modpow((ll) n*n %mod, k/2);
}

int main(){
  int i, j, k, n, a, b, c, d;

  fact[0]=1;
  for(i=1;i<=1000;i++) fact[i] = (ll) i * fact[i-1] % mod;
  ifact[1000] = modpow(fact[1000], mod-2);
  for(i=999;i>=0;i--) ifact[i] = (ll) (i+1) * ifact[i+1] % mod;
  
  
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

  for(j=0;j<=b-a;j++) dp[0][j] = 1;
  for(i=0;i<=n;i++){
    if((i%a==0) && (i/a>=c) && (i/a<=d)){
      dp[i][0] = (ll) fact[i] * ((ll) modpow(ifact[a], i/a) * ifact[i/a] % mod) % mod;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=b-a;j++){
      int tmp = modpow(ifact[a+j], c);
      dp[i][j] = dp[i][j-1];
      for(k=c; k<=d && k*(a+j)<=i; k++){
        dp[i][j] += (ll) fact[i] * ((ll) tmp * ((ll) ifact[i-k*(a+j)] * ((ll) ifact[k] * dp[i-k*(a+j)][j-1] % mod) % mod) % mod) % mod;
        if(dp[i][j] >= mod) dp[i][j] -= mod;
        tmp = (ll) tmp * ifact[a+j] % mod;
      }
    }
  }

  printf("%d\n", dp[n][b-a]);
  return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main(void){
	int a[110],n=0,i=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>0;i--){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[0]);
	return 0;
}

Measured memory_bytes: 2712
#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> 
#define int long long
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}


signed main() {
	int r;
	cin >> r;
	cout << r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD = 1000000007;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
  
};
     signed main(){
   int n,q;
   cin>>n>>q;
   int c[n];
   for(int i=0;i<n;i++){cin>>c[i];c[i]--;}
   int k[n]={};fill(k,k+n,-1);
   priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>p;
    int l,r,ans[q];
    for(int i=0;i<q;i++){
        cin>>l>>r;l--;
        p.push({r,{l,i}});
    }
    SegmentTree<int,int> rmq(n+3,
			   [](int a,int b){return a+b;},
			   [](int a,int b){return a+b;},
			   0);
    for(int i=0;i<n;i++){
        while(!p.empty()&&(p.top()).first<=i){
            ans[(p.top()).second.second]=rmq.query((p.top()).second.first,(p.top()).first);
           // cerr<<(p.top()).second.second<<' '<<i<<endl;
            p.pop();
        }
        if(k[c[i]]!=-1) rmq.update(k[c[i]],-1);
        rmq.update(i,1);
       k[c[i]]=i;
        ;
    }
       while(!p.empty()&&(p.top()).first<=n){
             ans[(p.top()).second.second]=rmq.query((p.top()).second.first,(p.top()).first);
            p.pop();
        }
    for(int i=0;i<q;i++)cout<<ans[i]<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 35500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long i=0;i<x;i++)
long n,q,k,a,b,c,cost[100005],x,y;
vector<pair<long,long>>edge[100005];
void dfs(long now,long prev,long c){
	cost[now]=c;
	for(auto e:edge[now]){
		if(e.first==prev)continue;
		dfs(e.first,now,c+e.second);
	}
}
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		edge[a].push_back(make_pair(b,c));
		edge[b].push_back(make_pair(a,c));
	}
	cin>>q>>k;
	dfs(k,-1,0L);
	while(q--){
		cin>>x>>y;
		cout<<(cost[x]+cost[y])<<endl;
	}
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int len=S.size();
  long long ans = 0;
  for(int i=0;i<pow(2,len-1);i++){
    long long temp = 0;
    for(int k=0;k<len-1;k++){
      temp = temp * 10 + (S[k]-'0');
      if(i & (1<<k)){
        ans=ans+temp;
        temp=0;
      }
    }
    temp=temp*10+(S[len-1]-'0');
    ans=ans+temp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
set<int> result; 
void add_edge(int u, int v, vector<int> graph[]) 
{ 
    graph[u].push_back(v); 
    graph[v].push_back(u); 
} 
void depthFirst(int v, vector<int> graph[], 
                vector<bool>& visited, int& ans) 
{ 
    visited[v] = true; 

    ans++; 
  
    for (auto i : graph[v]) { 
        if (visited[i] == false) { 
            // Recursive call to the DFS algorithm 
            depthFirst(i, graph, visited, ans); 
        } 
    } 
} 
  
// Function to initialize the graph 
// and display the result 
void UniqueConnectedComponent(int n, 
                              vector<int> graph[]) 
{ 
  
    vector<bool> visited(n + 1, false); 
  
    for (int i = 1; i <= n; i++) { 
        if (visited[i] == false) { 
            // ans variable stores the 
            // individual counts 
            int ans = 0; 
  
            // DFS algorithm 
            depthFirst(i, graph, visited, ans); 
            result.insert(ans);
        } 
    } 
} 

int main() 
{ 
    ll n;cin>>n;
    ll m;cin>>m;
    vector<int> graph[n + 1]; 
  	fr(i,0,m)
  	{
  		ll x,y;cin>>x>>y;
  		add_edge(x,y,graph);
  	}
  	UniqueConnectedComponent(n, graph); 
  	auto it=result.end();
  	it--;
  	if(m==0) cout<<1;
  	else cout<<*it;
  
    return 0; 
} 

Measured memory_bytes: 27004
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int r,d;
	cin>>r>>d;
	LL a;
	cin>>a;
	FOR(i,0,10){
		a=a*r-d;
		cout<<a<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int m,d;
    cin >> m >> d;
    int res = 0;
    rep(i,m){
        int k = i+1;
        rep(j,d){
            int p = j+1;
            if((p/10)>=2&&(p%10)>=2&&(p/10)*(p%10)==k){
                res++;
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 888
import sys
texts=sys.stdin.read()
texts=texts.lower()
cnt=[0]*26

letters=list('abcdefghijklmnopqrstuvwxyz')
for x in texts:
    i=0
    for y in letters:
        if x==y:
            cnt[i]+=1
        i+=1
for i in range(26):
    print(letters[i]+" : "+str(cnt[i]))



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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  map<char, int> m;
  string S;
  cin >> S;
  for(char c: S){
    if(m.count(c) != 0){
      cout << "no" << endl;
      return 0;
    } else {
      m[c]++;
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE MultiWayIf #-}
import Control.Monad.ST
import Data.Array.MArray
import Data.Array.ST
import Debug.Trace (trace)

f :: [(Char,Char)] -> STUArray s Char Char -> ST s Bool
f [] _ = return True
f ((s,t):xs) arr = do
  c <- readArray arr t
  if | c=='-' -> do
          writeArray arr t s
          f xs arr
     | c==s -> f xs arr
     | otherwise -> return False

check xs ys = runST $ do
  arr <- newArray ('a','z') '-'
  f (zip xs ys) arr

solv ss ts = check ss ts && check ts ss

yesno True = "Yes"
yesno False = "No"

main = do
  ss <- getLine
  ts <- getLine
  putStrLn . yesno $ solv ss ts

Measured memory_bytes: 27516
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

ll xor0toN(ll N){
	if(N%2==1){
		if(((N+1)/2)%2==1)return 1;
		else return 0;
	}else{
		if((N/2)%2==1)return N^1;
		else return N;
	}
}


int main(){
	ll a,b;
	cin>>a>>b;
	ll ans;
	if(a==0?ans=xor0toN(b):ans=xor0toN(a-1)^xor0toN(b));
	print(ans);
}


Measured memory_bytes: 256
let rec input n =
		if n = 0
		then []
		else match List.map(fun x -> int_of_string x)(Str.split (Str.regexp " ") (read_line ())) with
		| x::y::xs -> (x,y) :: input (n-1)
		| _ -> raise  (Failure "Format Error")

let solve lst =
	let rec solve_loop before lst = match lst with
		| [] -> let(a,b) = before in a + b
		| first :: xs ->
			let (x,y) = first in
			let (a,b) = before in
			let ratio = max ((a-1)/x+1) ((b-1)/y+1) in
				solve_loop (x*ratio,y*ratio) xs
	in
		solve_loop (1,1) lst
	
let () =
	print_string (string_of_int (solve (input (int_of_string (read_line ())))))


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
int main()
{
	string a;
	int flag=0;
	cin>>a;
	for (int i=0;i<3;i++)
	{
		if (a[i]=='7')
			flag=1;
	}
	if (flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    string S; cin >> S;
    string T; cin >> T;
    int N = S.size();
    REP(i,N){
        bool ok = true;
        REP(j,N){
            if(S[(j+i)%N] != T[j]) ok = false;
        } 
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
def bisect_search(L, x):
    idx = 0
    start = 0
    end = len(L)
    while(True):
        if x <= L[start]:
            y = start
            break
        elif x > L[end - 1]:
            y = end
            break

        center = start + (end - start) // 2
        if x <= L[center]:
            end = center
        else:
            start = center
    return y


a, b, q = map(int, input().split())
INF = 10 ** 11
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]

ans = []
for xi in x:
    s_idx = bisect_search(s, xi)
    t_idx = bisect_search(t, xi)
    yi = []
    for j in range(2):
        sj = s[s_idx - j]
        for k in range(2):
            tk = t[t_idx - k]
            d = min(abs(xi - sj), abs(xi - tk)) + abs(sj - tk)
            yi.append(d)
    ans.append(min(yi))
for ansi in ans:
    print(ansi)


Measured memory_bytes: 21576
#include <iostream>
#include <vector>
#include <string>
#include <set>
#define ll long long int
using namespace std;



int main()
{
   int v , e ;
   cin>>v>>e ;
   int arr[v+1];
   fill (arr,arr+v+1,0);
   int src,des;
   bool ans = true ;
for(int i = 0 ; i < e  ;++i)
{
    cin>>src>>des;
    arr[src]++;
    arr[des]++;
}
for(int i = 0 ; i<= v ; ++i)
{
    if(arr[i] % 2 != 0)
    {
        ans = false;
        break;
    }
}
if(ans)
    cout<<"YES\n";
else
    cout<<"NO\n";
    return 0;
}


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

int main()
{
	long long n,a,b,x;
	cin>>n>>a>>b;
    x=abs(a-b);
    if(x%2==0)
    	cout<<x/2<<endl;
    else
    {
       long long y=min(a-1,n-b);
       cout<<y+1+((b-a-1)/2)<<endl;
    }
}

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

#define int long long
#define INT int
#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(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<set<int>> g(n);
    set<int> cand;
    rep(i, m)
    {
        g[a[i]].insert(b[i]);
        g[b[i]].insert(a[i]);
        cand.insert(a[i]);
        cand.insert(b[i]);
    }

    vector<int> indx(n);
    rep(i, n)
    {
        indx[i] = 0;
    }

    int ans = 1;
    for (auto x : cand)
    {
        if (indx[x] != 0)
        {
            continue;
        }
        int temp = 1;
        indx[x] = 1;

        deque<int> q;
        q.push_back(x);

        while (!q.empty())
        {
            int t = q.front();
            q.pop_front();

            for (auto y : g[t])
            {
                if (indx[y])
                {
                    continue;
                }
                else
                {
                    q.push_back(y);
                    temp++;
                    indx[y] = 1;
                }
            }
        }
        ans = max(ans, temp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 45944
heights = []
for i in range(10):
    heights.append(int(input()))

for i in range(10):
    for j in range(i,10):
        if (heights[j] > heights[i]):
            w = heights[i]
            heights[i] = heights[j]
            heights[j] = w

print(heights[0])
print(heights[1])
print(heights[2])

Measured memory_bytes: 7628
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

pii S, T;

int X[] = {0, 0, -1, 1};
int Y[] = {-1, 1, 0, 0};

int v[2202][2202];

bool vis[2202][2202];

string s = "UDRL";

void tap(pii ww, pii www)
{
	queue <pii> Q;
	
	Q.push(ww);
	
	FOR (i, 0, 2200)
		FOR (h, 0, 2200)
			v[i][h] = inf;
	
	v[ww.ff][ww.ss] = 0;
	
	vis[S.ff][S.ss] = vis[T.ff][T.ss] = 0;
	
	while (!Q.empty()) {
		int x = Q.front().ff;
		int y = Q.front().ss;
		
		Q.pop();
		
		if (x == www.ff && y == www.ss)
			break;
		
		for (int i = 0; i < 4; i++) {
			int a = x+X[i];
			int b = y+Y[i];
			
			if (a>=0 && b>=0 && a<=2200 && b<=2200 && !vis[a][b] && v[a][b] == inf)
				Q.push({a, b}), v[a][b] = v[x][y]+1;
		}
	}
}

void show(pii x)
{
	string q;
	while (1) {
		if (v[x.ff][x.ss] == 0)
			break;
//		cout << x.ff-1000 << " " << x.ss-1000 << "\n";
//		getchar();
		for (int i = 0; i < 4; i++) {
			int a = x.ff+X[i];
			int b = x.ss+Y[i];
			
			if (a>=0 && b>=0 && a<=2200 && b<=2200 && !vis[a][b] && v[a][b] == v[x.ff][x.ss]-1) {
				x = {a, b};
				vis[a][b] = 1;
				q+=s[i];
				break;
			}
		}
	}
	reverse(all(q));

	FOR (i, 0, q.length()-1)
		printf("%c", q[i]);
}

int main()
{
//	cin >> S.ff >> S.ss;
//	cin >> T.ff >> T.ss;
	
	scanf("%d%d", &S.ff, &S.ss);
	scanf("%d%d", &T.ff, &T.ss);
	
	S.ff+=1100, S.ss+=1100;
	T.ff+=1100, T.ss+=1100;

	tap(S, T), show(T), tap(T, S), show(S);
	tap(S, T), show(T), tap(T, S), show(S);
}


Measured memory_bytes: 23552
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  long long int n, x;
  cin >> n >> x;

  vector< long long int > v;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;

    v.push_back( in );

  }

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

  long long int cnt = 0;
  long long int ans = 0;

  for ( long long int i = 0; i < n; i++ ) {

    cnt += v[i];
    ans = i;
    if ( cnt == x ) {
      ans = i + 1;
      break;
    } else if ( cnt < x ) {
      continue;
    } else {
      break;
    }

  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A = lr()
X = np.array(lr())
X.sort()
X -= A
pos = X[X>0]
zero = X[X==0]
neg = X[X<0]
limit = max(pos.sum(), neg.sum()) + 10
dp_pos = [0] * limit
dp_neg = [0] * limit
dp_pos[0] = 1
dp_neg[0] = 1
dp_pos = np.array(dp_pos)
dp_neg = np.array(dp_neg)

for p in pos:
    dp_pos[p:] = dp_pos[p:] + dp_pos[:-p]
for n in neg:
    dp_neg[-n:] = dp_neg[-n:] + dp_neg[:n]

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

  
dp_pos = np.array(dp_pos)
dp_neg = np.array(dp_neg)
Y = dp_pos * dp_neg
if len(zero) + Y.sum() == 0:
    print(0)
    exit()
answer = 2 ** len(zero)
if Y.sum() > 0:
    answer *= np.sum(Y)
print(answer - 1)
#54

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

int bin(vector<int> &a, int target){
    int l = 0, r = sz(a)-1;

    while (r >= l){
        int m = (l+r)/2;
        if (a[m] == target) return m;
        if (a[m] > target) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    int a, b;
    cin >> a >> b;
    int c = b*10;
    for (int i = 0; i < 10; i++){
        c = b*10+i;
        if (c*2/25 == a){
            cout << c << '\n';
            return;
        }
    }
    cout << -1 << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

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

int main(){
	long int ggd[200],num1,num2,lcm[200];
	int a,b;
	int i=0;
	
	while(cin >> a >> b){
		num1 = a;
		num2 = b;
	
		if( a<b ){
			num2 = a;
			num1 = b;
		}
		
		while( (ggd[i]=num1%num2) != 0){
			num1 = num2;
			num2 = ggd[i];
		}
		ggd[i] = num2;
		lcm[i] = a / ggd[i] * b;
		i++;
	}
	
	for(int j=0; j<i; j++)
		cout << ggd[j] <<" "<< lcm[j] << "\n";
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[1<<18];

int calc(int l,int r){
    if(l+1==r)return A[l];
    int a=calc(l,(l+r)/2);
    int b=calc((l+r)/2,r);
    if(a!=b)return max(a,b)-min(a,b);
    return a;
}

signed main(){
    cin>>N;
    rep(i,1<<N)cin>>A[i];

    cout<<calc(0,1<<N)<<endl;
    return 0;
}


Measured memory_bytes: 2304
#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 rSort(v) sort(v.rbegin(), v.rend())
#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;

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

  ll n, a;
  cin >> n >> a;

  vll xs(n);
  rep(i, n) cin >> xs[i];

  ll vmax = 2505;
  vector<vvll> dp(n+1, vvll(n+1, vll(vmax, 0)));
  rep(i, n+1) dp[i][0][0] = 1;

  repLRE(i, 1, n) { 
    repLRE(j, 1, i) {
      rep(k, vmax){
        dp[i][j][k] = dp[i-1][j][k];
        if(k - xs[i-1] >= 0) dp[i][j][k] += dp[i-1][j-1][k - xs[i-1]];
      }
    }
  }

  ll ans = 0;
  repLRE(j, 1, n) {
    ans += dp[n][j][a*j];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll a[35] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    ll n;
    cin>>n;
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, w, v;
	cin >> n >> w;
	v = n * 1000;
	vector<ll> weight(n);
	vector<ll> value(n);
	for (int i = 0; i < n; i++)
	{
		cin >> weight[i] >> value[i];
	}

	vector<vector<ll>> dp(n, vector<ll>(v + 1, INT_MAX));
	dp[0][0] = 0;
	for (int i = 1; i <= v; i++)
	{
		if (i <= value[0])
		{
			dp[0][i] = weight[0];
		}
	}

	for (int i = 1; i < n; i++)
	{
		for (ll j = 0; j <= v; j++)
		{
			if (j < value[i])
			{
				dp[i][j] = dp[i - 1][j];
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - value[i]] + weight[i]);
			}
		}
	}

	ll ans = 0;
	for (ll i = 0; i <= v; i++)
	{
		if (dp[n - 1][i] <= w)
		{
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int n, a, b;//1<=N<=20 1<=A<=50 1<=B<=50
	cin >> n >> a >> b;

	//densha
	int densha = n*a;
	int taxi = b;

	if (densha > taxi){
		cout << taxi << endl;
	}
	else{
		cout << densha << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
abc = []
for i in range(m):
    a, b = map(int, input().split())
    c_ = list(map(int, input().split()))
    c = 0
    for v in c_:
        c += 2**(v-1)
    abc.append([a, b, c])

INF = 10**9
dp = [[INF for _ in range(1 << n)]for _ in range((m+1))]

for i in range(m):
    dp[i][0] = 0

for i in range(m):
    for j in range(1 << n):
        s = j | abc[i][2]
        dp[i+1][s] = min(dp[i+1][s], dp[i][j] + abc[i][0])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1])


Measured memory_bytes: 80856
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "1" << endl;
    else cout << "0" << endl;
}
int main(){
    intl a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << double(double(a * b) / 2) << endl;
    fp((2 * c == a)&&(2 * d == b));
    return 0;
}

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

int main() {
	int sum,i;
	std::string number;

	for (;;) {
		std::cin >> number;

		if (number=="0") break;

		sum = 0;
		
		for (i = 0; i < number.size(); i++) {
//			std::cout << i<<" " <<(number[i]-'0') << " "<<sum<<std::endl;
			sum += number[i]-'0';
		}
		std::cout << sum << std::endl;

	}

	}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ran(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N, W;
    vector<int> w(110);
    vector<int> v(110);
    static int dp[110][100010];
    int i, j, k;
    ll ans = 0;
    ll sum = 0;

    cin >> N >> W;

    ran(i, 1, N)
    {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    ran(j, 1, sum)
    {
        dp[0][j] = MOD;
    }

    dp[0][0] = 0;

    ran(i, 1, N)
    {
        dp[i][0] = 0;
        ran(j, 1, 100005)
        {
            if (j - v[i] >= 0)
            {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    for (i = 1; i <= sum; i++)
    {
        if (dp[N][i] <= W)
        {
            ans = max(ans, (ll)i);
        }
    }

    cout << ans << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = array[0];
            var K = (int)array[1];

            checked
            {
                var hp = Console.ReadLine().Split().Select(long.Parse).
                    OrderByDescending(_ => _).Skip(K).Sum();

                Console.WriteLine(hp.ToString());
            }
        }
    }
}


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

int n,q;
int A[21];
bool dp[21][2000];

bool solve(int i,int k){
    if(dp[i][k]==true) return true;
    if(k==0)
        dp[i][k]=true;
    else if(i>=n){
        dp[i][k]=false;
    }else if(solve(i+1,k)){
        dp[i][k]=true;
    }else if(solve(i+1,k-A[i])){
        dp[i][k]=true;
    }else{
        dp[i][k]=false;
    }

    return dp[i][k];

}
void deal(int k){
    for(int i=0;i<n;i++) {
        for(int j=1;j<2000;j++)
            dp[i][j]=false;
    }
    if(solve(0,k)){
        cout<<"yes"<<endl;
    }else{
        cout<<"no"<<endl;
    }
}

int main(){
    int k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
        dp[i][0]=true;
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>k;
        deal(k);
    }
    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, k;
	cin >> n >> k;
	vi cou(n, 0);
	rep(i, 0, n) {
		int a;
		cin >> a;
		cou[a - 1]++;
	}
	sort(all(cou));
	reverse(all(cou));
	int x = 0;
	rep(i, 0, k) {
		x += cou[i];
	}
	cout << n - x << endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	c, _ := strconv.Atoi(a + b)
	for i := 1; i < c; i++ {
		x := i * i
		if c == x {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

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

int cnt[2333];
void solve(ll N, ll X, ll Y)
{
    for(ll i=1;i<=N;++i)
    {
        for(ll j=i+1;j<=N;++j)
        {
            ll dis = j-i;
            dis = min(dis,abs(i-X)+1+abs(j-Y));
            cnt[dis]++;
        }
    }
    for(int i=1;i<N;++i)
    {
        cout<<cnt[i]<<endl;
    }
}


int main()
{
    ll N;
    cin >> N;
    ll X;
    cin >> X;
    ll Y;
    cin >> Y;
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <utility>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
const int INF = 1000000000;
typedef pair<int, int> P;
char S[50][50];
int d[50][50];
int H, W;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
typedef pair<int, int> P;

int bfs(){
  queue<P> que;
  for (int i=0; i<H;i++)
    for(int j=0; j<W; j++) d[i][j] = INF;
  
  que.push(P(0, 0));
  d[0][0] = 0;
  
  while(que.size()){
  P p = que.front();que.pop();
    if (p.first == H-1 && p.second == W-1) break;
    for (int i=0; i< 4; i++){
      int nh=p.first + dy[i], nw = p.second + dx[i];
      if (nh>=0 && nh<H && nw>=0 && nw<W && S[nh][nw] != '#' && d[nh][nw] == INF){
		que.push(P(nh, nw));
        d[nh][nw] = d[p.first][p.second] + 1;
      }  
    }
  }
  
  return d[H-1][W-1];
}
 
 
int main(){
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> H >> W;
  int b_cnt = 0;
  for (int i=0; i<H;i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
      if (S[i][j] == '#') b_cnt++;
    }
  }
  
  int res = bfs();
  
  int ans = (res!=INF)?H*W - b_cnt - 1 - res:-1; 
  cout << ans << endl; 
  
}

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

long long  N;
long long  A[2*100000+1];
const long long mod=1000000000+7;
int main(){
  long long sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    sum +=A[i];
  }
  sum %=mod;
  sum= (sum*sum)%mod;
  for(int i=0;i<N;i++){
    sum -=(A[i]*A[i])%mod;
  }
  if(sum%2 !=0) sum +=mod;
  sum /=2;
  sum %=mod;
  if(sum<0) sum +=mod;
  cout<<sum<<endl;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int heap[500000];
int h;

void max_heapify(int i){
    int l = 2 * (i + 1) - 1;
    int r = l + 1;
    int largest;
    if(l < h && heap[l] > heap[i])
        largest = l;
    else
        largest = i;
    if(r < h && heap[r] > heap[largest])
        largest = r;
    if(largest != i){
        swap(heap[i], heap[largest]);
        max_heapify(largest);
    }
    return;
}

void build_max_heap(){
    for(int i = (h-1)/2 ; i >= 0; i--) {
        max_heapify(i);
    }
}

int main() {
    cin >> h;
    REP(i, h) cin >> heap[i];
    build_max_heap();
    REP(i, h) cout << " " << heap[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#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 ull unsigned 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 pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll StringToNumber(string s)
{
    stringstream geek(s);
    ll x=0;
    geek>>x;
    return x;
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,l,temp=0;
    ll n,k;
    cin>>n>>k;
    ull ans = k*modPow(k-1,n-1,mod);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    ans=0
    for i in 2:n
        if a[i]<a[i-1]
            ans+=a[i-1]-a[i]
            a[i]=a[i-1]
        end
    end
    println(ans)
end
main()

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

using namespace std;

int main(){
  int N, T, i, dis=0, cnt = 0;
  int mini = 1000000000;
  cin >> N >> T;

  int A[N];
  for(i=0; i<N; i++){
      cin >> A[i];
      mini = min(A[i], mini);
      if(dis < A[i]-mini){
        dis = A[i]-mini;
        cnt = 0;
      }
      if(dis == A[i]-mini && (A[i]-mini)>0) cnt++;

  }

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


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

int A, B;

int main(void){
    
    scanf("%d %d", &A, &B);
    printf("%d\n", max({A + B, A - B, A * B}));
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)x=-x,putchar('-');
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
int n,a,b;
int main(){
	n=read(),a=read(),b=read();
	puts((b-a)&1?"Borys":"Alice");
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

char SmallToLarge(char x){
	return x-'a'+'A';
}

char LargeToSmall(char x){
	return x-'A'+'a';	
}

int main(){
	string s;
	char c;
	while(cin >> s >> c){
		if(c=='X') break;
		
		string t=s;
		//UpperCmaelCase??????
		if('a'<=s[0] && s[0]<='z'){
			bool underscore=false;
			for(int i=0; i<s.size(); ++i){
				if(s[i]=='_'){
					underscore=true;
					break;	
				}	
			}	
			
			stringstream ss;
			ss << SmallToLarge(s[0]);
			
			if(underscore){
				for(int i=1; i<s.size(); ++i){
					if(s[i]=='_') continue;
					
					if(s[i-1]=='_') ss << SmallToLarge(s[i]);
					else ss << s[i];
				}
			}
			else for(int i=1; i<s.size(); ++i) ss << s[i];	
			
			t=ss.str();
		}
		
		//cout << t <<endl;
		
		if(c=='L') t[0]=t[0]-'A'+'a';
		else if(c=='D'){
			stringstream tt;
			tt<<LargeToSmall(t[0]);
			for(int i=1; i<t.size(); ++i){
				if('A'<=t[i] && t[i]<='Z'){
					tt<<'_';
					tt<<LargeToSmall(t[i]);	
				}
				else tt<<t[i];	
			}
			
			t=tt.str();
		}
		
		cout << t <<endl;		
		
	}
}

Measured memory_bytes: 1208
using System;
using System.Linq;

namespace A___Sharing_Cookies
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B[0], B = A_B[1];

            Console.WriteLine(((A + B) % 3  == 0| A % 3 == 0| B % 3 == 0) ? "Possible" : "Impossible");
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main(void){
    int a, b, d, r;
    double f;
    
    scanf("%d %d" ,&a, &b);
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %.6f\n", d, r, f);
    return 0;
}


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

using namespace std;

#define For(i,a,b) for(ll i=a;i<b;i++)
#define Ford(i,a,b) for(ll i=a;i>=b;i--)
#define RET(x) { cout << x; exit(0); }
#define smin(a,b) a=min(a,b)
#define SZ(x) ((ll)((x).size()))
#define PB push_back
#define ER(x) cout << #x << ' ' << x << '\n';

typedef long long int LL;
typedef LL ll;
typedef vector<ll> vll;

const ll M=2000+5,mod=924844033;
ll pw(ll x,ll y){ if (y==0) return 1; return pw(x*x%mod,y/2)*(y&1?x:1)%mod; }

#define MOK(x) if (x>=mod) x-=mod;

ll dp1[M][M];
ll n,k;
ll mac[M];
vll mast;
ll dp[2][M];
ll fac[M];
ll faci[M];

ll CM(ll n,ll r){
  //ER(n);ER(r);ER((fac[n]*faci[r]%mod)*faci[n-r]%mod);
  return (fac[n]*faci[r]%mod)*faci[n-r]%mod;
}

int main(){
  ios::sync_with_stdio(0);
  cin >> n >> k;
  dp1[1][1]=1;
  dp1[1][0]=1;
  dp1[0][0]=1;
  For(i,2,n){
    dp1[i][0]=1;
    For(j,1,i){
      dp1[i][j]=dp1[i-1][j]+dp1[i-2][j-1];
      MOK(dp1[i][j]);
    }
  }
  For(i,0,n){
    if (i<k){
      mac[i]=0;
    }
    else{
      mac[i]=mac[i-k]+1;
    }
  }
  For(i,n-k,n){
    mast.PB(mac[i]);
    mast.PB(mac[i]);
  }
  ll alt=1;
  dp[1][0]=1;
  for(ll x:mast){
    //ER(x);
    ll al=alt;
    alt^=1;
    For(k,0,n+1) dp[alt][k]=0;
    For(t,0,x+1){
      For(k,t,n+1){
	dp[alt][k]+=(dp[al][k-t]*dp1[x][t])%mod;
	MOK(dp[alt][k]);
	//ER(dp[al][k-t]);
	//ER(x);ER(t);ER(dp1[x][t]);
      }
    }
  }
  faci[0]=fac[0]=1;
  For(i,1,n+5){
    fac[i]=(fac[i-1]*i)%mod;
    faci[i]=pw(fac[i],mod-2);
  }
  For(i,0,n+1){
    dp[alt][i]*=fac[n-i];
    dp[alt][i]%=mod;
    //ER(i);ER(dp[alt][i]);
  }
  Ford(i,n,0){
    For(j,i+1,n+1){
      dp[alt][i]+=mod-(dp[alt][j]*CM(j,i))%mod;
      MOK(dp[alt][i]);
    }
    //ER(dp[alt][i]);
  }
  RET(dp[alt][0]);
}


Measured memory_bytes: 30336
import numpy as np

A=np.zeros((3,3),dtype=int)
B=np.zeros((3,3),dtype=int)

#Aのビンゴカード生成
for i in range(3):
    A[i][0],A[i][1],A[i][2]=map(int,input().split())

N=int(input())

#Bで穴の空いた場所を1とする
for i in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                B[i][j]=1

#ビンゴ判定
ans=False

#横方向
for i in range(3):
    cnt=0
    for j in range(3):
        cnt+=B[i][j]
    if cnt==3:
        ans=True

#縦方向
for i in range(3):
    cnt=0
    for j in range(3):
        cnt+=B[j][i]
    if cnt==3:
        ans=True

#斜め右下がり
cnt=0
for i in range(3):
    cnt+=B[i][i]
if cnt==3:
    ans=True

#斜め右上がり
cnt=0
for i in range(3):
    cnt+=B[i][2-i]
if cnt==3:
    ans=True

if ans==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//ワーシャルフロイド法、全点対最短路
//実装例
const int INFTY=numeric_limits<int>::max();
vector<vector<int>>d;//d[u][v]は辺uvのコスト、ただし存在しないときINFTY,d[i][i]=0

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j)//目的地の頂点
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}



int main(){
    int h,w;
    cin>>h>>w;
    int ans=0;
    d=vector<vector<int>>(10,vector<int>(10,INFTY/3));
    rep(i,10)d[i][i]=0;
    rep(i,10)rep(j,10)cin>>d[i][j];
    warshall_floyd(10);
    int a;
    rep(i,h)rep(j,w){
        cin>>a;
        if(a!=-1)ans+=d[a][1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256