akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N;

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

    cin >> N;
    vector<pair<int, int> > balls(N);
    rep(i,N) cin >> balls[i].first >> balls[i].second;
    sort(balls.begin(), balls.end());
    int cnt = 0;
    rep(i,N){
        for(int j=i+1; j<N; j++){
            int tmp = 1; //iとjを通る分に関してはここでカウントする。
            int x = balls[j].first-balls[i].first;
            int y = balls[j].second-balls[i].second;
            for(int k=i; k<N; k++){ 
                for(int l=k+1; l<N;l++){
                    if (i == k & j==l) continue; 
                    if (balls[l].second-balls[k].second == y & balls[l].first-balls[k].first == x) tmp+=1;
                }
            }
            cnt = max(cnt, tmp);
        }
    }

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


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;
typedef unsigned long long ULL;

int n;
double v[2999];


// i -> quantidade de moedas já jogadas
// j -> quantidade de moedas que deram 'cara'
double solve()
{
	// double dp[3010][1510] = {0.0L};
	vector<vector<double>> dp(3010, vector<double>(3010, 0.0L));
	dp[0][0] = 1.0;

	queue<pii> Q;
	Q.push(mp(0,0));

	while(!Q.empty())
	{
		pii cur = Q.front();
		Q.pop();

		int i = cur.fi;
		int j = cur.se;

		// cout << i << " " << j << endl;

		double x = dp[i][j] * v[i];
		double y = dp[i][j] * (1.0L-v[i]);

		if(i+1 < n){
			if(dp[i+1][j+1] == 0.0L)
				Q.push(mp(i+1,j+1));
			if(dp[i+1][j] == 0.0L)
				Q.push(mp(i+1,j));
		}

		dp[i+1][j+1] += x;
		dp[i+1][j] += y;

		
	}
	double ans = 0.0L;
	int lim = n/2+1;
	FORI(i,n,lim){
		ans += dp[n][i];
		// cout << dp[n][i] << " " ;
	}
	// cout << endl;
	return ans;
}	



double solve2()
{
	// vector<vector<double>> dp(3010, vector<double>(3010, 0.0L));
	double dp[3010][3010] = {0};
	dp[0][0] = 1.0L;
	FOR(i,0,n){
		FOR(j,0,i+1){
			double x = dp[i][j] * v[i];
			double y = dp[i][j] * (1.0L-v[i]);
			dp[i+1][j+1] += x;
			dp[i+1][j] += y;
		}
	}
	double ans = 0.0L;
	int lim = n/2+1;
	FORI(i,n,lim){
		ans += dp[n][i];
		// cout << dp[n][i] << " " ;
	}
	// cout << endl;
	return ans;
}	

int main(void)
{
	fastIO();
	cin >> n;
	FOR(i,0,n)
		cin >> v[i];

	// cout << fixed << setprecision(10) << solve() << endl;
	cout << fixed << setprecision(10) << solve2() << endl;
	

}

Measured memory_bytes: 71168
N, M = map(int, input().split())
As = list(map(int, input().split()))
As.sort()
BCs = []
for m in range(M):
  B, C = map(int, input().split())
  BCs.append((B, C))
BCs.sort(key=lambda BC: -BC[1])
#print(BCs)

index = 0
for m in range(M):
  B, C = BCs[m]
  for i in range(B):
    if index >= N:
      break
    if As[index] < C:
      As[index] = C
      index += 1
    else:
      break
print(sum(As))


Measured memory_bytes: 25580
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
long long q[101010];
long long st[202020],sn;
long long ans[101010];
vector <pair<long long,long long> > v[202020];
int findp(long long x)
{
	int l=1,r=sn,mid;
	while(l<r)
	{
		mid=(l+r)>>1;
		if(st[mid]>=x)
			r=mid;
		else
			l=mid+1;
	}
	return l;
}
long long cnt=0,nc;
int main()
{
	int n,qn;
	long long mi;
	long long k;
	memset(ans,0,sizeof(ans));
	scanf("%d%d",&n,&qn);
	mi=n;
	for(int i=1;i<=qn;i++)
		scanf("%lld",&q[i]);
	sn=0;
	for(int i=1;i<=n;i++)
		st[++sn]=i;
	for(int i=1;i<=qn;i++)
	{
		while(sn&&st[sn]>=q[i])
			sn--;
		st[++sn]=q[i];
		mi=min(mi,q[i]);
	}
	cnt=1;
	for(int i=sn;i>=1;i--)
	{
		v[i].push_back(make_pair(st[i],cnt));
		cnt=0;
		if(st[i]<=mi)
		{
			for(int j=0;j<v[i].size();j++)
				ans[st[i]]+=v[i][j].second;
		}
		else
		{
			for(int j=0;j<v[i].size();j++)
			{
				k=v[i][j].first%st[i-1];
				if(k)
					v[findp(k)].push_back(make_pair(k,v[i][j].second));
				cnt+=v[i][j].first/st[i-1]*v[i][j].second;
			}
		}
	}
	for(int i=n-1;i>=1;i--)
		ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 25060
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main()
{
    int h, w;
    char s[50][50];
    string line;
    scanf("%d %d\n", &h, &w);
    for (int i = 0; i < h; i++)
    {
        getline(cin, line);
        for (int j = 0; j < w; j++)
        {
            s[i][j] = line[j];
        }
    }
    bool flg = true;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '.')
                continue;
            int minx = max(i - 1, 0);
            int maxx = min(h - 1, i + 1);
            int miny = max(j - 1, 0);
            int maxy = min(w - 1, j + 1);
            bool flg2 = false;
            for (int dx = minx; dx <= maxx; dx++)
            {
                if (dx == i)
                    continue;
                if (s[dx][j] == '#')
                {
                    flg2 = true;
                }
            }
            for (int dy = miny; dy <= maxy; dy++)
            {
                if (dy == j)
                    continue;
                if (s[i][dy] == '#')
                {
                    flg2 = true;
                }
            }

            if (!flg2)
                flg = false;
        }
    }
    printf("%s\n", (flg) ? "Yes" : "No");
    return 0;
}

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

int main(){
	long double a,b,h,m;
	const double pi = 3.141592653589793;
	cin>>a>>b>>h>>m;
	long double s=pi*(m*5.5-h*30.0)/180.0;
	long double ans=sqrt(a*a+b*b-2*a*b*cosl(s));
	cout<<fixed<<setprecision(20)<<ans;
	return 0;
}


Measured memory_bytes: 4124
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
char a[105];
long k[26],n[26];
int main()
{
    fgets(a,105,stdin);
    long l;
    for(long i=0;;i++){if(a[i]>='a'&&a[i]<='z')a[i]-='a';else {a[i]=0;l=i;break;}}
    queue<long> q;
    for(long i=0;i<100;i++)
    {
        memset(k,0,sizeof(k));
        memset(n,0,sizeof(n));
        while(q.size())q.pop();
        long j;
        for(j=0;j<=i;j++){q.push(a[j]);n[a[j]]++;}
        for(long i=0;i<26;i++)if(n[i]==0){k[i]=1;}
        for(;j<l;j++)
        {
            n[a[j]]++;
            q.push(a[j]);
            n[q.front()]--;
            if(n[q.front()]==0)k[q.front()]=1;
            q.pop();
        }
        for(long x=0;x<26;x++)
        {
            if(k[x]==0){cout<<i;return 0;}
        }
    }
    return 0;
}


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

const int mxN = 1e6+5;
const int inf = 1e9+7;
using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int, int>;
#define f first
#define s second
#define mp make_pair

int n;
pi arr[mxN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i].f >> arr[i].s;
    for (int i = 2; i < n; i++) {
        if (arr[i-2].f == arr[i-2].s && arr[i-1].f == arr[i-1].s && arr[i].f == arr[i].s) { cout << "Yes\n"; return 0; }
    }
    cout << "No\n";
    return 0;
}


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

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


int main() {
    int a,b,c; cin >> a >> b >> c;
    if(c>=a && c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
import sys
input=sys.stdin.readline
def main():
    s=tuple(input())
    t=tuple(input())
    n=len(s)
    m=len(t)
    dp=[[0 for i in range(m+1)] for j in range(n+1)]
    for i in range(n):
        for j in range(m):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            else:
                if dp[i+1][j]>dp[i][j+1]:
                    dp[i+1][j+1]=dp[i+1][j]
                else:
                    dp[i+1][j+1]=dp[i][j+1]
    p=dp[n][m]
    ans=['' for _ in range(p)]
    n-=1
    m-=1
    while p>0:
        if s[n]==t[m]:
            ans[p-1]=s[n]
            n-=1
            m-=1
            p-=1
        elif dp[n+1][m+1]==dp[n][m+1]:
            n-=1
        else:
            m-=1
    print(''.join(ans)) 
if __name__=='__main__':
    main()


Measured memory_bytes: 153648
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n,k;
    cin >> n >> k;
    if(k > n-1){
        k = n-1;
    }
    vector<int> h(n);
    for(int i = 0;i < n;i ++){
        cin >> h.at(i);
    }
 
    vector<int> s(n);
    s.at(1) = abs(h.at(1) - h.at(0));
 
    if(n == 2){
        cout << s.at(1) << endl;
        return 0;
    }
 
    for(int i = 2;i < k;i ++){
 
        if(k == 1 || k == 2){
            break;
        }
 
        int m = 1000000000;
 
        for(int j = 0;j < i;j ++){
            m = min(m, s.at(j) + abs(h.at(i) - h.at(j)));
        }
 
        s.at(i) = m;
    }
 
    for(int i = k;i < n;i ++){
        
        int m = 1000000000;
        
        for(int j = i-k;j < i;j ++){
            m = min(m, s.at(j) + abs(h.at(i) - h.at(j)));
        }
 
        s.at(i) = m;
    }
 
    cout << s.at(n-1) << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i < x + k; ++i) {
    if (i != x - k + 1) cout << " ";
    cout << i;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl
#define sz(a) (ll)(a.size())
#define endl "\n"
const ll SZ=55;

ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= mod)
		return res - mod;
	return res;
}

ll mult(ll a, ll b)
{
	long long res = a;
	res *= b;
	if(res >= mod)
		return res % mod;
	return res;
}

struct matrix
{
	ll arr[SZ][SZ];

	void reset()
	{
		memset(arr, 0, sizeof(arr));
	}

	void makeiden()
	{
		reset();
		for(ll i=0;i<SZ;i++)
		{
			arr[i][i] = 1;
		}
	}

	matrix operator + (const matrix &o) const
	{
		matrix res;
		for(ll i=0;i<SZ;i++)
		{
			for(ll j=0;j<SZ;j++)
			{
				res.arr[i][j] = add(arr[i][j], o.arr[i][j]);
			}
		}
		return res;
	}

	matrix operator * (const matrix &o) const
	{
		matrix res;
		for(ll i=0;i<SZ;i++)
		{
			for(ll j=0;j<SZ;j++)
			{
				res.arr[i][j] = 0;
				for(ll k=0;k<SZ;k++)
				{
					res.arr[i][j] = add(res.arr[i][j] , mult(arr[i][k] , o.arr[k][j]));
				}
			}
		}
		return res;
	}
};

matrix power(matrix a, ll b)
{
	matrix res;
	res.makeiden();
	while(b)
	{
		if(b & 1)
		{
			res = res * a;
		}
		a = a * a;
		b >>= 1;
	}
	return res;
}



int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,k;
  cin>>n>>k;
  matrix m;
  forn(i,0,n){
    forn(j,0,n)
      cin>>m.arr[i][j];
  }
  matrix ans=power(m,k);
  ll answer=0;
  forn(i,0,n){
    forn(j,0,n){
      answer=add(answer,ans.arr[i][j]);
    }
  }
  cout<<answer<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int n;
ll a[20000],b[20000];
ll suma,sumb;

int main(){
  cin>>n;

  rep(i,n){
    cin>>a[i];
    suma+=a[i];
  }
  rep(i,n){
    cin>>b[i];
    sumb+=b[i];
  }

  ll sa=0;
  rep(i,n){
    if(a[i]<b[i]){
      sa+=(b[i]-a[i]+((b[i]-a[i])%2))/2;
    }
  }
  ll sumc=sumb-suma;
  if(sumc>=sa)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


  return 0;
}


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

int main(){

    std::string s;
    size_t max = 0, cnt = 0;

    std::cin >> s;

    for(const auto& e : s){
        if(e == 'A' || e == 'C' || e == 'G' || e == 'T'){
            cnt++;
        }else{
            cnt = 0;
        }

        max = std::max(max, cnt);
    }

    std::cout << max << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,M; cin >> N >> M;
    VVI A(N,VI(N)), B(M,VI(M));
    REP(i,N){
        string S; cin >> S;
        REP(j,N){
            if(S[j] == '#') A[i][j] = 1;
        }
    }
    REP(i,M){
        string S; cin >> S;
        REP(j,M){
            if(S[j] == '#') B[i][j] = 1;
        }
    }
    bool exist = false;

    REP(i,N) REP(j,N){
        bool ok = true;
        if(i+M-1 >= N || j+M-1 >= N) continue;

        REP(k,M) REP(l,M){
            if(A[i+k][j+l] != B[k][l]){
                ok = false;
            }
        }
        if(ok) exist = true;
    }
    if(exist){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}


Measured memory_bytes: 256
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])

def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
    return strInput[:a]+strInput[a:b+1][::-1]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()



Measured memory_bytes: 5624
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var A = line[0];
            var B = line[1];
            var T = line[2]+1;
            var total = 0;

            for (var i = A; i < T; i+=A)
            {
                total += B;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-c)<=d)||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

int top;
int S[110];

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top + 1];
}

int main() {
  top = 0;
  char c[100];
  int a, b;
  while (true) {
    if (!(cin >> c)) {
      break;
    }
    if (c[0] == '+') {
      b = pop();
      a = pop();
      push(a + b);
    }
    else if (c[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if (c[0] == '*') {
      b = pop();
      a = pop();
      push(a * b);
    }
    else {
      push(stoi(c));
    }
  }
  cout << pop() << endl;
}


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

class Progaram
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);

        if ((a == b || a == c || b == c) && (a != b || a != c || b != c)) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 13140
a, b, k = (int(i) for i in input().split())
s = set()
for i in range(a, a+k):
    if i >= a and i <= b:
        s.add(i)
for i in range(b-k+1, b+1):
    if i > a and i <= b:
        s.add(i)
s = sorted(list(s))
for a in s:
    print(a)

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

int main() {
    long n,m,l;
    cin >> n >> m >> l;
    long a[n][m];
    long b[m][l];
    long c[n][l];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin >> a[i][j];
    for(int i=0;i<m;i++)
        for(int j=0;j<l;j++)
            cin >> b[i][j];
    for(int i=0;i<n;i++)
        for(int j=0;j<l;j++){
            c[i][j]=0;
            for(int k=0;k<m;k++)
                c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
        }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++)
            cout << c[i][j] << (j==l-1?"":" ");
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3292
import numpy as np
import copy
from collections import deque

S = str(input())
Q = int(input())

Que = [0]* Q
for i in range(Q):
    Que[i] = list(map(str, input().split()))

check = 1
L = deque()
R = deque()
for i in range(Q):
    T = Que[i][0]
    if int(T) == 1:
        check *= -1
    else:
        F = Que[i][1]
        if (int(F) == 1 and check == 1) or (int(F) == 2 and check == -1):
#            answer = ''.join([Que[i][2], answer])
            L.appendleft(Que[i][2])
        else:
#            answer = ''.join([answer, Que[i][2]])
            R.append(Que[i][2])
answer = ''.join(L) + S + ''.join(R)
if check == -1:
    answer = ''.join(list(reversed(answer)))
print(answer)

Measured memory_bytes: 52748
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >>c;
    string abc = a.substr(0,1)+b.substr(0,1)+c.substr(0,1);
    transform(abc.begin(),abc.end(),abc.begin(),::toupper);
    cout << abc << endl;
}

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

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  int n,num;
  int i,j;
  char mark;
  int card[4][13]={0};
 
  cin >>n;

  for(i=0;i<n;i++){
    cin >>mark >>num;
    if(mark=='S') card[0][num-1]=1;
    if(mark=='H') card[1][num-1]=1;
    if(mark=='C') card[2][num-1]=1;
    if(mark=='D') card[3][num-1]=1;
  }

  for(i=0;i<4;i++){
    for(j=1;j<=13;j++){
      if(i==0 && card[0][j-1]!=1) cout <<"S" <<" " <<j <<endl;
      if(i==1 && card[1][j-1]!=1) cout <<"H" <<" " <<j <<endl;
      if(i==2 && card[2][j-1]!=1) cout <<"C" <<" " <<j <<endl;
      if(i==3 && card[3][j-1]!=1) cout <<"D" <<" " <<j <<endl;
    }
  }


  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<climits>
#include<queue>
#include<set>
#include<cmath>
#include<map>
#include<bitset>
#include<fstream>
#include<tr1/unordered_map>

typedef long long LL;
using namespace std;
#define pb push_back
#define x first
#define y second

void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

int read()
{
	int x = 0, f = 1; int c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x * 10) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

const int maxn = 510;
const LL INF = 0x3f3f3f3f3f3f3f3f;
LL dp[2][maxn][maxn], A[maxn][maxn], B[maxn][maxn];

inline void ckmin(LL &x, LL y) { x >= y ? x = y : 0; }

int main()
{

	int n = read();
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j) if(i != j)
		{
			int x = read();
			if(i < j) A[j][i] = x;
			else B[i][j] = x;
		}
	}

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= i; ++j)
			A[i][j] += A[i][j - 1], B[i][j] += B[i][j - 1];

	int p = 0, q = 1;
	memset(dp, 0x3f, sizeof(dp));
	dp[p][0][0] = 0;
	for(int i = 2; i <= n; ++i)
	{
		swap(p, q);
		for(int j = 0; j <= i; ++j) for(int k = 0; k <= i; ++k) dp[p][j][k] = INF;

		for(int j = 0; j < i; ++j)
			for(int k = j; k < i; ++k) if(dp[q][j][k] != INF)
			{
				LL tmp = dp[q][j][k];
				//if(tmp == 1) cout << '!' << endl;

				if(j == 0 && k == 0)
				{
					ckmin(dp[p][0][0], tmp + A[i][i]);
					ckmin(dp[p][0][i], tmp);
					continue;
				}

				if(j == 0)
				{
					ckmin(dp[p][0][k], tmp + A[i][i] - A[i][k - 1]);
					ckmin(dp[p][k][i], tmp + B[i][k - 1]);
					continue;
				}

				ckmin(dp[p][j][k], tmp + A[i][i] - A[i][k - 1] + B[i][j - 1]);
				ckmin(dp[p][k][i], tmp + B[i][k - 1]);
			}

		/*
		for(int i = 0; i <= n; ++i)
			for(int j = 0; j <= n; ++j) 
			{
				cout << i << ' ' << j << ' ' << dp[p][i][j] << endl;
			}*/
	}

	LL ans = INF;
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n; ++j) 
		{
			//cout << i << ' ' << j << ' ' << dp[p][i][j] << endl;
			ckmin(ans, dp[p][i][j]);
		}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

class Border {
    public:
        int h;
        int p;
        int q;
};

int main(int argc, char const* argv[])
{
    int n,m,a;
    //テァツクツヲテァツキツ堙」ツ?ョテヲツ慊ャテヲツ閉ーテッツシツ古ヲツィツェテァツキツ堙」ツ?ョテヲツ慊ャテヲツ閉ーテッツシツ古ィツェツソテ」ツ?ケテ」ツつ凝ァツクツヲテァツキツ堙」ツ?ョテァツ閉ェテ・ツ渉キ
    int now_h=0;
    while (cin >> n >> m >> a) 
    {
        int ret = a;
        if (n == 0 && m == 0 && a == 0) {break;}
        vector<Border> b(m);

        //テヲツィツェテァツキツ堙」ツ?ョテ・ツ渉姪・ツセツ?
        for (int i = 0; i < m; i++) 
        {
            cin >> b[i].h;
            cin >> b[i].p;
            cin >> b[i].q;
        }
        

        //now_hテ」ツ?ョテ・ツ渉姪・ツセツ?
        for (int i = 0; i <m ; i++) 
        {
            now_h = max(b[i].h, now_h);
        }

            //
            //cout << "now_h" << now_h << endl;
            //cout << "m" << m<< endl;
        //テ、ツクツ?ァツ閉ェテ」ツ?療」ツ?淌」ツ?セテ」ツ?ァテゥツ卍催」ツつ甘」ツつ?
        while (now_h >= 0) 
        {
            //
            //cout << "now_h" << now_h << endl;
            //
            //int test;
            //cin >> test;
            //テゥツ?ゥテ・ツ青暗」ツ?凖」ツつ凝ヲツィツェテヲツ」ツ津」ツつ津ヲツ篠「テ」ツ??
            for (int i = 0; i < m; i++) 
            {
                //テゥツ?ゥテ・ツ青暗」ツ?凖」ツつ凝ヲツィツェテヲツ」ツ津」ツ?古・ツュツ佚・ツ慊ィテ」ツ?療」ツ?淌」ツつ嘉」ツ??ァツァツサテ・ツ仰陛」ツ?療」ツ?ヲテ、ツクツ凝」ツ?ォテゥツ卍催」ツつ甘」ツつ?
                if (b[i].h == now_h ) 
                {
                    if (b[i].p == ret ) 
                    {
                        ret = b[i].q;
                        break;
                    }
                    else if (b[i].q == ret ) 
                    {
                        ret = b[i].p;
                        break;
                    }
                }
                //テゥツ?ゥテ・ツ青暗」ツ?凖」ツつ凝ヲツィツェテヲツ」ツ津」ツ?古・ツュツ佚・ツ慊ィテ」ツ?療」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツつ?テァツァツサテ・ツ仰陛」ツ?崚」ツ?堙」ツ?ォテ、ツクツ凝」ツ?ォテゥツ卍催」ツつ甘」ツつ?
                else 
                {
                    continue;
                }
            }
            now_h--;
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll n, a, b, c;
vector<ll> l(10);

ll dfs(ll n_i, ll l_a, ll l_b, ll l_c){
    if(n_i >= n){
        //無から竹は作れない
        if(l_a*l_b*l_c == 0){
            return INF;
        }
        //合成魔法は使う本数−１*10のコストがかかる
        //合成した後の誤差は延長，短縮魔法を使う
        ll res = abs(a - l_a) + abs(b - l_b) + abs(c - l_c) - 30;
        return res;
    }

    ll res = INF;
    //使わない場合
    res = min(res, dfs(n_i+1, l_a, l_b, l_c));
    //A~Bいずれかに使う場合
    res = min(res, dfs(n_i+1, l_a+l[n_i], l_b, l_c) + 10);
    res = min(res, dfs(n_i+1, l_a, l_b+l[n_i], l_c) + 10);
    res = min(res, dfs(n_i+1, l_a, l_b, l_c+l[n_i]) + 10);

    return res;
}

int main(){
    cin >> n >> a >> b >> c;
    
    rep(i, n)cin >> l[i];

    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 3516
#include <iostream>
#include <cstring> 
#include <algorithm> 
#include <vector> 
#define INF 2000000000 //??¨?????????????????¢????¶??????????????????????????????§????????°???????????¨????????????????????????
             
#define MAX_V 100
     using namespace std;
     int v,u,c,k,vertex;//number of vertices
     int d[MAX_V];
     int ver[100]={};
     int path[100][100]={};
     int path_exist[100][100];
     int min_index;
     bool used[MAX_V];
     int num_used=0,l;
     vector<int> q;
     void dijkstra(int s)
     {
             fill(d,d+v,INF);
             memset(used,false,sizeof(used));//(s,val,end)?????¢?????§s??????end?????§?????¢???????¢???????false??§?????????
             d[s]=0;
             while(q.size()-num_used != 0){
             		while(used[l]==true){
             			l++;
             		}
             		min_index=l;
                     for(int j=0;j<q.size();j++){
                     	if(!used[j]){//???????????¢????????????????¨??????????????????????????????¶
                     		if(d[min_index] > d[j]/*??´??????*/)
                     		min_index=q.at(j);
                     	}
                     }
                        used[min_index]=true;
                        num_used+=1;
                        for(int j=0;j<ver[min_index];j++){//min_index????????°????????????????????????edge????????¨??????????????????????????°
			  d[path_exist[min_index][j]]=min(d[path_exist[min_index][j]], d[min_index] + path[min_index][path_exist[min_index][j]]);/*??´??????*/
                        } 
            }
            return;
    }
    int main(){
        cin>>v;

        for(int i=0; i<v;i++){
        	cin>>u;
        	cin>>k;
        	ver[u]=k;
        	q.push_back(i);
        	for(int j=0;j< k ; j++){
        		cin>>vertex;
        		cin>>c;
        		path[u][vertex]= c;
        		path_exist[u][j]=vertex;

        	}
        }

        dijkstra(0);
        for(int i=0;i<v;i++){
        	cout<<i<<" "<<d[i]<<endl;
        }
        return 0;
    }

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> ans;
  for(int i=1; i<102; i++){
    if(A%i==0 && B%i==0){
      ans.push_back(i);
    }
  }
  sort(ans.begin(),ans.end());
  cout << ans.at(ans.size()-K) << endl;
}


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

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  /*
  It would take a+b-2 steps to get to a point (a,b).
  Thus calculate the minimum of a+b-2 under the condition a*b=N.
  */
  ll temp;
  ll ans;
  for(ll a=1; a<=sqrtl(N); a++){
    if (N%a!=0) continue;
    temp=a+(N/a)-2;
    if (a==1) ans=temp;
    else ans=min(ans,temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;
long long n, m, x, y, z;
const long long template_arry_size = 1000625;
long long a[template_arry_size];
long long b[template_arry_size];
long long c[template_arry_size];
string s, t;
long long ans = 0;

void solve(int tc = 0) {
    cin >> s;
    long long sum = 0;
    for (long long i = 0; i < s.length(); ++i) sum += (s[i] - '0');
    cout << (sum % 9 ? "No": "Yes") << endl;

}

int main(){

    solve();

}



Measured memory_bytes: 3688
n,x,y = map(int,input().split())
a = [0 for _ in range(n-1)]
for i in range(1,n):
  for j in range(i+1,n+1):
    l = min(j-i,abs(x-i)+1+abs(j-y))
    a[l-1] += 1
print("\n".join(map(str,a)))

Measured memory_bytes: 3188
import Text.Printf

main = do
    line <- getLine

    let [a, b] = map (\n -> read n :: Int) $ words line
    let (d, r) = a `divMod` b
    let f = (fromIntegral a :: Double) / (fromIntegral b :: Double)

    printf "%d %d %.5f\n" d r f



Measured memory_bytes: 3888
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int n , a[N] , freq[N];
int main()
{
    abdelrahman010
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        freq[a[i]]++;
    }
    ll ans = 0;
    for(int i = 1;i <= n;i++)
        ans += 1ll * (freq[i] - 1) * freq[i] / 2;
    for(int i = 0;i < n;i++)
    {
        ans -= 1ll * (freq[a[i]] - 1) * freq[a[i]] / 2;
        cout << ans + 1ll * (freq[a[i]] - 2) * (freq[a[i]] - 1) / 2 << '\n';
        ans += 1ll * (freq[a[i]] - 1) * freq[a[i]] / 2;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long LL;
void read(LL& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=1e9+7;
const int maxn =1e6+11;
LL n,m,k;

LL a[maxn],c[maxn],d[maxn];
int tot1=0,tot2=0;
bool cmp2(int a,int b){
    return abs(a)<abs(b);
}
void cal(){
    LL res=1;
    sort(a+1,a+1+n,cmp2);
    fo(i,1,k){
        res *= a[i];
        res%=mod;
    }
    res = (res%mod+mod)%mod;
    printf("%lld\n",res);
}

bool cmp(LL a,LL b){
    return abs(a)>abs(b);
}

LL ksm(LL a,LL b){
    LL res=1;
    while(b){
        if(b&1){
            res =res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}

int main(){
//    op;
    read(n);read(k);
    int num0=0;
    fo(i,1,n) {
        read(a[i]);
        if(a[i]<0)tot1++;
        else if(a[i]>0) tot2++;
        else num0++;
    }

    if(n==k){
        LL res = 1;
        fo(i,1,n) res = res*a[i]%mod;
        res = (res%mod+mod)%mod;
        printf("%lld\n",res);return 0;
    }
    if(num0>n-k) {
        puts("0");return 0;
    }
    if((tot2==0)&&(k&1)){
        cal();return 0;
    }

    LL res=1;
    sort(a+1,a+1+n,cmp);

    LL cnt1=0,mx=-INF,mx2=INF,cnt2=0;

    fo(i,1,k){
        if(a[i]<0) {
            cnt1++;mx = a[i];
        }
        else{
            mx2 =a[i];
        }
        res= res*a[i]%mod;
    }
    if(cnt1&1){
        if(cnt1==k){
            res = res *ksm(a[k],mod-2)%mod;
            fo(i,k+1,n){
                if(a[i]>=0){
                    res = res *a[i]%mod;
                    break;
                }
            }
        }
        else{
            LL t1=mx,t2=mx2;//负正
            int flag1=1,flag2=1;
            res = res*ksm(mx*mx2%mod,mod-2)%mod;

            fo(i,k+1,n){
                if(a[i]>=0&&flag2){
                    flag2=0;
                    t2*=a[i];
                }
                else if(a[i]<0&&flag1){
                    flag1=0;
                    t1*=a[i];
                }
            }
            res = res *(max(t1,t2)%mod)%mod;
        }
    }
    res = (res%mod+mod)%mod;
    printf("%lld\n",res);
    return 0;
}


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

int main(){

  int n;
  cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(p[i]==i+1){
      count++;
    }
  }

  if(count==n){
    cout<<"YES"<<endl;
  }else if(count==n-2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
  	int ans = 0;
  	for(int i = 1; i <= N; i++){
    	int x; cin >> x;
		if((i&x)&1) ans++;
    }
  	cout << ans;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
const long long mod = 1e9+7;
int a[25];
int have[25];
long long dp[1<<17][17];
int pow2[18];
long long f[100005], invf[100005];

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); }

void preWork(int n){
    f[0] = invf[0] = 1;
    for(long long i = 1; i <= n; i++){
        f[i] = f[i-1]*i%mod;
        invf[i] = inv(f[i]);
    }
}

long long comb(int n,int m){
    if(m>n || m<0) return 0;
    else return f[n]*invf[m]%mod*invf[n-m]%mod;
}

long long getWays(int u,int n,int m){
    int queue[25]; int size = 0;
    int mask = u, cnt = 0;
    for(int i = 1; i <= n; i++){
        if(mask%2) cnt += pow2[i-1];
        else queue[++size] = pow2[i-1];
        mask /= 2;
    }
    int total = (1<<n)-1;
    int left = total-cnt;
    long long mul = 1;
    for(int i = 1; i <= size; i++){
        mul = mul*comb(left,queue[i])%mod;
        left -= queue[i];
    }
    long long res = 0;
    for(int i = 0; i <= m; i++){
        res += dp[u][i];
        if(res>=mod) res -= mod;
    }
    res = res*mul%mod;
    return res;
}

int main(){
    preWork(100000);
    pow2[0] = 1;
    for(int i = 1; i <= 17; i++) pow2[i] = pow2[i-1]*2;
    int n,m;
    scanf("%d%d",&n,&m);
    int total = 1<<n;
    for(int i = 1; i <= m; i++) scanf("%d",&a[i]);
    std::sort(a+1,a+1+m,[&](int u,int v){ return u>v; });
    for(int i = 1; i <= m; i++){
        have[i] = total-a[i]+1;
    }
    dp[0][0] = 1;
    for(int i = 1; i < (1<<n); i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = 0;
            int mask = i, select = 0;
            for(int k = 1; k <= n; k++){
                if(mask%2) select += pow2[k-1];
                mask /= 2;
            }
            if(select<=have[j]){
                for(int k = 1; k <= n; k++){
                    int bit = 1<<(k-1);
                    if((bit&i)==0) continue;
                    int cnt = pow2[k-1];
                    int org = have[j]-(select-cnt);
                    long long plan = comb(org-1,cnt-1);
                    int lastMask = i^bit;
                    for(int last = 0; last < j; last++){
                        dp[i][j] += dp[lastMask][last]*plan%mod;
                        if(dp[i][j]>=mod) dp[i][j] -= mod;
                    }
                }
            }
            //printf("dp[%d][%d] = %lld\n",i,j,dp[i][j]);
        }
    }
    //printf("ok\n");
    long long ans = 0, sign = mod-1;
    for(int i = 0; i < (1<<n); i++){
        int mask = i, cnt = 0;
        for(int j = 1; j <= n; j++){
            cnt += mask%2; 
            mask /= 2;
        }
        long long ways = getWays(i,n,m);
        //printf("i = %d: %lld\n",i,ways);
        if(cnt%2) ways = ways*sign%mod;
        ans += ways;
        if(ans>=mod) ans -= mod;
    }
    for(int i = 1; i <= n; i++) ans = ans*f[pow2[i-1]]%mod;
    ans = ans*(long long)(total)%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 11960
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int p,q;
	div_t d;
	vector<int> vRem,vQuot;
	vector<int>::iterator remIte,ite;
	string remStr;
	while(cin >> p >> q)
	{
		vRem.clear();
		vQuot.clear();
		remStr = "";
		for(;;)
		{
			d = div(p*10, q);
			p = d.rem;

			vQuot.push_back(d.quot);
			if(d.rem == 0)	//èØêÜµ½
			{
				break;
			}
			// ÜèªzÂµnßÜµ½
			else if( (remIte=find(vRem.begin(),vRem.end(), d.rem)) != vRem.end() )
			{
				if( *(vQuot.begin()+(remIte-vRem.begin())) == vQuot.back() )
				{
					vQuot.pop_back();
				}
				else
				{
					vRem.push_back(d.rem);
					remIte=find(vRem.begin(),vRem.end(), d.rem)+1;
				}

				//zÂ·éÌoÍ
				for(ite=vRem.begin(); ite < remIte; ++ite)
					remStr += ' ';
				for(; remIte != vRem.end(); ++remIte)
					remStr += '^';
				break;
			}
			vRem.push_back(d.rem);
		}
		for(ite = vQuot.begin(); ite != vQuot.end(); ++ite)
			cout << *ite;
		cout << endl;
		if(!remStr.empty())
			cout << remStr << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int x,n;
int a[110];
bool cnt[1010];
int main()
{
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		cnt[a[i]]=1;
	}
	for(int i=x,j=x;;i--,j++)
	{
		if(cnt[i]==0)
		{
			cout<<i;
			return 0;
		}
		if(cnt[j]==0)
		{
			cout<<j;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  in2(n, k);
  if(n % k == 0)
    out(0);
  else
    out(1);
  memi;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

long long A, B;

int main() {
	scanf("%lld %lld", &A, &B);
	if(A % 2 != 0 && B % 2 != 0) {
		printf("Yes\n");
	}	
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
N,M,X,Y = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

xx = max(x)
yy = min(y)

war = True
if xx < yy:
    z = []
    for i in range(xx+1,yy+1):
        z.append(i)
    for i in range(len(z)):
        if z[i] <= Y and z[i] > X:
            war = False
            break

if war:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
object methods {
  def solver: Unit = {
    val scanner = new java.util.Scanner(System.in)
    val tempList: Seq[Seq[String]] = {
      for(line <- io.Source.stdin.getLines()) yield {
        line.split(' ').toSeq
      }
    }.toSeq

    val X: String = tempList(0)(0)
    val u = X.toCharArray
    val ui: Array[Boolean] = u.map(_.isUpper)

    if(ui(0)) println("A") else println("a")
  }
}

object Main extends App {
  methods.solver
}

Measured memory_bytes: 55604
//https://github.com/mostafa-saad/MyCompetitiveProgramming/blob/master/UVA/UVA_10740.txt
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)

int a,b;
string s;
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
input;
cin>>s;

if(s[0]>'1'||(s[0]=='1'&&s[1]>'2')||(s[0]=='0'&&s[1]=='0'))a=1;
if(s[2]>'1'||(s[2]=='1'&&s[3]>'2')||(s[2]=='0'&&s[3]=='0'))b=1;

if(a&&b)cout<<"NA";
else if(!a&&!b)cout<<"AMBIGUOUS";
else if(a)cout<<"YYMM";
else cout<<"MMYY";

return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int H, W; cin >> H >> W;

  int row = 0, col = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      string s; cin >> s;
      if (s == "snuke") {
        col = i + 1;
        row = j;
      }
    }
  }
  cout << (char)(row + 'A') << col << endl;
  return 0;
}

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

int main(){
  long long h, c = 0; cin >> h;
  long long m = 1;
  while(h) {
    h /= 2;
    c += m;
    m *= 2;
  }
  cout << c << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
import numpy as np
N, C = map(int, input().split())
s = np.empty(N)
t = np.empty(N)
c = np.empty(N)
for i in range(N):
  s[i], t[i], c[i] =  map(int, input().split())
TimeTable = np.zeros((C,100001))
maxTime = 0
for i in range(N):
  channle = int(c[i] - 1)
  for j in range(int(s[i]),int(t[i])+1):
    TimeTable[channle,j] = 1
  if maxTime < t[i]:
    maxTime = t[i]
MaxRecode = 0
for i in range(int(maxTime)):
  Recode = np.sum(TimeTable[:,i])
  if Recode > MaxRecode:
    MaxRecode = Recode
print(int(MaxRecode))

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

int main(){
    while(true){
    int a,b;
    cin >> a >> b;
    if(a==0&&b==0)
    break;
    if(b<a)
    cout << b << ' ' << a << endl;
    else
    cout << a << ' ' << b << endl;
}
    
}


Measured memory_bytes: 3080
#include <iostream>
#include <limits.h>
using namespace std;

int beau = 1000000007;

int main() {
	int n, m;
	long long nn = 1, mm = 1;
	cin >> n >> m;
	if (n - m >= 2 || m - n >= 2) cout << 0;
	else if (n - m == 1 || m - n == 1) {
	    for (int i = n; i > 0; i--) {
	        nn *= i;
	        if (nn > beau) nn %= beau;
	    }
	    for (int i = m; i > 0; i--) {
	        mm *= i;
	        if (mm > beau) mm %= beau;
	    }
	    cout << (nn * mm) % beau;
	}
	else {
	    for (int i = n; i > 0; i--) {
	        nn *= i;
	        if (nn > beau) nn %= beau;
	    }
	    for (int i = m; i > 0; i--) {
	        mm *= i;
	        if (mm > beau) mm %= beau;
	    }
	    cout << (2 * nn * mm) % beau;
	}
	return 0;
}


Measured memory_bytes: 256