akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

ll h[101];

int main(){
	int n;
	
	while (cin >> n, n){
		ll d1, d2, d3, d4, d5, d6, d7, d;
		
		REP(i,n+1){
			scanf("%lld", &h[i]);
		}
		
		d1 = h[1] - h[0];
		d2 = h[2] - h[1];
		d3 = h[2] - h[0];
		d4 = h[3] - h[2];
		d5 = h[3] - h[1];
		d6 = h[4] - h[3];
		d7 = h[4] - h[2];
		
		ll ans = 0;
		int f = 0;
		
		if (d1 == d2 && (d1 == d4 || d1 == d7)){
			f = 1;
			d = d1;
		}
		else if (d2 == d4 && d2 == d6){
			ans = h[0];
		}
		else if (d3 == d4 && (d3 == d7 || d3 == d6)){
			ans = h[1];
		}
		else if (d1 == d5){
			ans = h[2];
		}
		
		if (f){
			int c = h[0];
			
			REP(i,n+1){
				if (c != h[i]){
					ans = h[i];
					break;
				}
				
				c += d;
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

#define N 1000

int main(void) {

	int a=0,ans=0,flag=0;
	//	float p=0,q=0;
	//	char str1[N],str2[N];



	scanf("%d", &a);

	int i=0;
	ans = a;
	if(a!=2){

	while(1){
		for(i=2;i<ans;i++){
			if(ans%i==0){
				break;
			}
			if(ans==i+1){
				flag=1;
			}
		}
		if(flag==1){
			break;
		}
		ans++;
	}
	}



	printf("%d", ans);



	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;
int x[100001];
int y[100000];

vector<int> cp;
int find(int x) {
    return lower_bound(cp.begin(), cp.end(), x) - cp.begin();
}

const int mod = 1e9 + 7;
int seg[100001];
void update(int i, int x) {
    while (i <= cp.size()) {
        seg[i] = (seg[i] + x) % mod;
        i += i & -i;
    }
}

int query(int i) {
    int ret = 0;
    while (i) {
        ret = (ret + seg[i]) % mod;
        i -= i & -i;
    }
    return ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) cin >> x[i];
	for (int i = 0; i < m; ++i) cin >> y[i];
	vector<pii> xs;
	
	for (int i = 1; i <= n; ++i) {
        if (x[i] < y[0]) continue;
        if (y[m - 1] < x[i]) continue;
        int v = lower_bound(y, y + m, x[i]) - y;
        xs.emplace_back(y[v] - x[i], x[i] - y[v - 1]);
        cp.push_back(x[i] - y[v - 1]);
	}
	cp.push_back(0);
	sort(cp.begin(), cp.end());
	cp.erase(unique(cp.begin(), cp.end()), cp.end());
	for (pii &i : xs) i.second = -find(i.second);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	
	update(1, 1);
	for (pii _i : xs) {
        int i = 1 - _i.second;
        update(i, query(i - 1));
	}
	printf("%d\n", query(cp.size()));
	return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <algorithm>
#include <queue>
#define F first
#define S second
using namespace std;

const int N = 50 + 1;
char l[N][N];
char r[N][N];

int r_di[] = { 0,  0, -1, +1};
int r_dj[] = {-1, +1,  0,  0};
int l_di[] = { 0,  0, -1, +1};
int l_dj[] = {+1, -1,  0,  0};

bool vis[N][N][N][N];

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

inline
bool& ref(P p)
{
  pair<int, int> a = p.first;
  pair<int, int> b = p.second;
  return vis[a.first][a.second][b.first][b.second];
}

int main(void)
{
  int h, w;
  while (cin >> w >> h && (h | w)) {
    fill(&vis[0][0][0][0], &vis[N - 1][N - 1][N - 1][N - 1] + 1, false);
    pair<int, int> pr, pl;
    pair<int, int> qr, ql;
    pr = pl = qr = ql = make_pair(-1, -1);
    for (int i = 0; i < h; ++i) {
      string s, t;
      cin >> s >> t;
      for (int j = 0; j < s.size(); ++j) {
	l[i][j] = s[j];
	if (s[j] == 'L') pl = make_pair(i, j);
	if (s[j] == '%') ql = make_pair(i, j);
      }
      for (int j = 0; j < t.size(); ++j) {
	r[i][j] = t[j];
	if (t[j] == 'R') pr = make_pair(i, j);
	if (t[j] == '%') qr = make_pair(i, j);
      }
    }
    queue<P> q;
    P ini = make_pair(pl, pr);
    ref(ini) = true;
    for (q.push(ini); q.size(); q.pop()) {
      P p = q.front();
      pair<int, int> pl = p.first;
      pair<int, int> pr = p.second;
      if(l[pl.F][pl.S] == '%' && r[pr.F][pr.S] != '%')continue;
      if(r[pr.F][pr.S] == '%' && l[pl.F][pl.S] != '%')continue;

      for (int d = 0; d < 4; ++d) {
	int pr_i = pr.first  + r_di[d];
	int pr_j = pr.second + r_dj[d];
	int pl_i = pl.first  + l_di[d];
	int pl_j = pl.second + l_dj[d];
	if (pr_i < 0 || h <= pr_i) pr_i = pr.first, pr_j = pr.second;
	if (pr_j < 0 || w <= pr_j) pr_i = pr.first, pr_j = pr.second;
	if (r[pr_i][pr_j] == '#')  pr_i = pr.first, pr_j = pr.second;
	if (pl_i < 0 || h <= pl_i) pl_i = pl.first, pl_j = pl.second;
	if (pl_j < 0 || w <= pl_j) pl_i = pl.first, pl_j = pl.second;
	if (l[pl_i][pl_j] == '#')  pl_i = pl.first, pl_j = pl.second;
	P next = make_pair(make_pair(pl_i, pl_j), make_pair(pr_i, pr_j));
	if (ref(next)) continue;
	ref(next) = true;
	q.push(next);
      }
    }
    cout << (ref(make_pair(ql, qr)) ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 8752
#include<bits/stdc++.h>
typedef int LL;
const LL maxn=1e4+9,Maxn=1e7+9,inf=0x3f3f3f3f;
const LL dx[]={0,-1,0,1,0},dy[]={0,0,1,0,-1};
inline LL Read(){
    LL 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<<3ll)+(x<<1ll)+c-'0'; c=getchar();
    }return x*f;
}
LL n,m,ans;
LL a[maxn],need[maxn];
int main(){
	n=Read(); m=Read();
	for(LL i=1;i<=m;++i){
		LL val(Read());
		for(LL j=1;j<=val;++j){
			LL bit(Read());
			a[i]|=(1<<bit-1);
		}
//			printf("(%d)\n",a[i]);
	}
	for(LL i=1;i<=m;++i) need[i]=Read();
	LL up(1<<n);
	for(LL bit=0;bit<up;++bit){
//		printf("%d:",bit);
		bool f(true);
		for(LL i=1;i<=m;++i){
			LL tru(bit&a[i]);
//			printf("(%d:",tru);
			LL ret(0);
			while(tru){
				ret+=(tru&1); tru>>=1;
			}
			ret&=1;
//			printf("%d)",ret);
//			if()
			f=(ret==need[i]);
			if(!f) break;
		}
//		puts("");
		if(f) ++ans;
	}
	printf("%d\n",ans);
	return 0;
}/*
2 2
2 1 2
1 2
0 1
*/

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val arg1 = readLine()!!.split(" ")
    val holidayCounts = arg1[0].toInt()
    val homeworkCounts = arg1[1].toInt()
    val homeworkList = readLine()!!.split(" ").asSequence().map { it.toInt() }.toList()

    val homeworkDays = (0 until homeworkCounts).asSequence().map { homeworkList[it] }.sum()

    val enjoyTimes = holidayCounts - homeworkDays
    if (enjoyTimes >= 0)  println(enjoyTimes) else println("-1")
}

Measured memory_bytes: 40980
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

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


const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));




/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int a, b, c, d;
    cin>>a>>b>>c>>d;

    const int N = 3005;

    vector<vector<int>> dp(N, vector<int>(N));

    dp[a][b] = 1;
    for (int i = a; i<=c; i++)
        for (int j = b; j<=d; j++)
        {
            if (i>a) dp[i][j] = add(dp[i][j], mul(dp[i-1][j], j));
            if (j>b) dp[i][j] = add(dp[i][j], mul(dp[i][j-1], i));
            if (i>a && j>b) dp[i][j] = sub(dp[i][j], mul(dp[i-1][j-1], mul(i-1, j-1)));
        }

    /*for (int i = a; i<=c; i++)
        for (int j = b; j<=d; j++) cout<<i<<' '<<j<<": "<<dp[i][j]<<endl;*/

    cout<<dp[c][d];


}



Measured memory_bytes: 38568
#include <stdio.h>

int main(void)
{
    float x[4];
    float y[4];
    float num1, num2;
    int n, i;
    scanf("%d", &n);

    while (n > 0){
        n--;
        for (i = 0; i < 4; i++){
        	scanf("%f %f", &x[i], &y[i]);
        }
        
        num1 = (y[1] - y[0]) / (x[1] - x[0]);
        num2 = (y[3] - y[2]) / (x[3] - x[2]);
        
        if (num1 == num2){
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }

    return 0;
}

Measured memory_bytes: 616
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] magic = new int[n][2];
        for (int i = 0; i < n; i++) {
            magic[i][0] = sc.nextInt();
            magic[i][1] = sc.nextInt();
        }
        int[] dp = new int[h + 1];
        for (int i = 0; i <= h; i++) {
            dp[i] = Integer.MAX_VALUE;
        }
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j < n; j++) {
                if (i - magic[j][0] <= 0) {
                    dp[i] = Math.min(dp[i], magic[j][1]);
                } else {
                    dp[i] = Math.min(dp[i], magic[j][1] + dp[i - magic[j][0]]);
                }
            }
        }
        System.out.println(dp[h]);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
}


Measured memory_bytes: 27580
def oddsolve(x):
    return int((x+1) / 2 % 2)
def solve(x):
    if x % 2 ==0:
        return oddsolve(x+1)^(x+1)
    else:
        return oddsolve(x)

A, B = map(int,input().split())

print(solve(A-1) ^ solve(B))


Measured memory_bytes: 2940
def PointSegmentDistance(point, begin, end):
	point, begin, end = point-begin, 0, end-begin
	point = (point / end) * abs(end)
	end = abs(end)
	if 0 <= point.real <= abs(end):
		return abs(point.imag)
	else:
		return min(abs(point), abs(point - end))

n1 = int(input())
a = [0]
for _ in range(n1):
	x, y = map(int, input().split())
	a.append(complex(x, y))
a.append(1000)
n2 = int(input())
b = [1000j]
for _ in range(n2):
	x, y = map(int, input().split())
	b.append(complex(x, y))
b.append(1000+1000j)
#print(*a, sep="\n")
ans = 10**30
for p in range(n1+2):
	for q in range(n2+1):
		ans = min(ans, PointSegmentDistance(a[p], b[q], b[q+1]))
for q in range(n2+2):
	for p in range(n1+1):
		ans = min(ans, PointSegmentDistance(b[q], a[p], a[p+1]))
print(ans)


Measured memory_bytes: 5648
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define N_MAX 100
#define K_MAX 3

// [k桁目][N以下確定?]
int DP[N_MAX][2][K_MAX+1];

int min(int a, int b) {
	if (a < b) return a;
	return b;
}

int main(void) {
	char N[N_MAX + 1];
	scanf("%s", &N[0]);
	int K;
	scanf("%d", &K);
	int len = strlen(N);
	{
		int d = N[0] - '0';
		for (int j = 0; j <= d; ++j) {
			bool lt = j < d;
			if (j != 0) {
				DP[0][lt ? 1 : 0][1] += 1;
			}
			else {
				DP[0][lt ? 1 : 0][0] += 1;
			}
		}
	}
	for (int i = 1; i < len; ++i) {
		int d = N[i] - '0';
		for (int lt = 0; lt < 2; ++lt) {
			for (int j = 0; j <= ((lt == 1) ? 9 : d); ++j) {
				bool nlt = (lt == 1) || (j < d);
				if (j != 0) {
					for (int c = 0; c < 3; ++c) {
						DP[i][nlt ? 1 : 0][c+1] += DP[i - 1][lt][c];
					}
				}
				else {
					for (int c = 0; c < 4; ++c) {
						DP[i][nlt ? 1 : 0][c] += DP[i - 1][lt][c];
					}
				}
			}
		}
	}
	printf("%d\n", DP[len-1][0][K]+ DP[len - 1][1][K]);
	return 0;
}
 

Measured memory_bytes: 128
#include <iostream>
#include <string.h>

using namespace std;
string s, t;
int F[3001][3001];

int main()
{
    cin>>s>>t;
    int a, b;
    a=s.length();
    b=t.length();
    for(int i=1; i<=a; i++)
    {
        for(int j=1; j<=b; j++)
        {
            if(s[i-1]==t[j-1]) F[i][j]=F[i-1][j-1]+1;
            else F[i][j]=max(F[i-1][j], F[i][j-1]);
        }
    }
    string tmp;
    while(a*b!=0)
    {
        if(s[a-1]==t[b-1])
        {
            tmp+=t[b-1];
            a--;
            b--;
        }
        else
        {
            if(F[a-1][b]>F[a][b-1]) a--; else b--;
        }
    }
    for(int i=tmp.length(); i>=1; i--)
    {
        cout<<tmp[i-1];
    }
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

    cout<<min(n%k,k-(n%k))<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> P; // Bi, Ai
int n;
P p[1010];
int max_fa=0;

void dfs(int t, int fa, int st_index){
  max_fa = max(max_fa, fa);

  for( int i=st_index;i<n;i++ ){
    int ta = t + p[i].second;
    if( ta <= p[i].first )
      dfs( ta, fa+1, i+1);
  }
}

int main(){

  cin >> n;
  for( int i=0;i<n;i++ )
    cin >> p[i].second >> p[i].first;
  sort(p, p+n );

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

  return 0;
}

Measured memory_bytes: 1172
N = int(input())
A = [int(x) for x in input().split()]
i = 1
ans = 0
for j in range(len(A)):
    A[j] = A[j] - i
    i += 1

A.sort()
#print(A)
if len(A) % 2 == 1:
    b = A[((len(A) + 1) // 2) - 1]
#    print(b)
    for j in range(len(A)):
        ans = ans + abs(A[j] - b)
    print(ans)

else:
    b = (A[(len(A) // 2) - 1] + A[(len(A) // 2)]) // 2
#    print(b)
    for j in range(len(A)):
        ans = ans + abs(A[j] - b)
    print(ans)




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

int main(){
    int n,cnt = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0;i < n;i ++){
        cin >> p[i];
        if(p[i]!=i+1) cnt ++;
    }
    if(cnt==2||cnt==0)  cout << "YES" << endl;
    else                cout << "NO"  << endl;
    return 0;
}

Measured memory_bytes: 256
// 2019/07/13
// AtCoder Beginner Contest 055 - A

import java.util.*;
public class Main {
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
        // Input
        int n = sc.nextInt();
        int ans = 0;
        
        // Calc
        ans = n * 800 - (int)(n / 15) * 200;

        // Output
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;
vector<vector<ll>>adj(2001);
vector<ll>used(2001,0);
vector<ll>ans(2001,0);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,y,r,k,d,m,t,a,b,n,x;
	cin>>x;
	 map<ll,ll>mp;
	 for(i=-1000;i<=1000;i++)
	 {
	     mp[pow(i,5)]=1;
	 }
	 for(auto u:mp)
	 {
	     if(mp[u.fi-x]==1)
	     {
	         y=u.fi;
	     break;
	     }
	 }
	  a=pow(abs(y),0.2);
	 if(y<0)
	 a=-1*a;
	 
	  b=pow(abs(y-x),0.2);
	 if(y-x<0)
	 b=-1*b;
	cout<<a<<" "<<b;
	return 0;
	
	
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5+7;
const int Inf = 0x3f3f3f3f;
int pre1[MAXN],pre2[MAXN];
int finds(int x,int *pre)
{
    return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre);
}
void join(int x,int y,int *pre)
{
    int px = finds(x,pre);
    int py = finds(y,pre);
    if( px!=py)
    {
        pre[px] = py;
    }
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    for(int i = 1;i<=n;i++)
        pre1[i] = i,pre2[i] = i;
    for(int i = 1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre1);
    }
    for(int i = 1;i<=l;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre2);
    }
    for(int i = 1;i<=n;i++)
    {
        finds(i,pre1);
        finds(i,pre2);
    }
    map<pair<int,int>,int> mp;
    for(int i = 1;i<=n;i++)
    {
        mp[make_pair(pre1[i],pre2[i])] ++;
    }
    for(int i = 1;i<=n;i++)
    {
        cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (1) {
    C -= B;
    A -= D;

    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    else if (A <= 0) {
    cout << "No" << endl;
    break;
    }
  }
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main(){
  ll n;cin >>n;
  ll k;cin >>k;
  mint ans=1;
  vector<ll>a;
  vector<ll>ap;
  vector<ll>an;
  
  for(ll i=0;i<n;i++){
    ll tmp;cin>>tmp;
    a.push_back(tmp);
    if(tmp<0)an.push_back(tmp);
    else ap.push_back(tmp);
  }
  
  if(n==k){
    for(auto aa:a){
      ans*=aa;
    }
    cout <<ans<<endl;
    return 0;
  }
  
  ll apsize=ap.size();
  if(apsize==0&&k%2==0){
    sort(an.begin(),an.end());
    for(ll i=0;i<k;i++){
      ans*=an.at(i);
    }
    cout <<ans<<endl;
    return 0;
  }
  else if (apsize==0&&k%2==1){
    sort(an.begin(),an.end());
    reverse(an.begin(),an.end());
    for(ll i=0;i<k;i++){
      ans*=an.at(i);
    }
    cout <<ans<<endl;
    return 0;
  }
  
  sort(an.begin(),an.end());
  sort(ap.begin(),ap.end());
  ll apmax;
  if(k%2==1){
    apmax=ap.back();
    ap.pop_back();
  }
  reverse(ap.begin(),ap.end());
  
  ll ansize2=an.size();
  ll apsize2=ap.size();
  
  if(ansize2<=1&&k%2==0){
    for(ll i=0;i<k;i++){
      ans*=ap.at(i);
    }
    cout <<ans<<endl;
    return 0;
  }
  else if(ansize2<=1&&k%2==1){
    for(ll i=0;i<k-1;i++){
      ans*=ap.at(i);
    }
    ans*=apmax;
    cout <<ans<<endl;
    return 0;
  }
  
  vector<ll>aabs;
  for(ll i=0;i+1<ansize2;i+=2){
    aabs.push_back(an.at(i)*an.at(i+1));
  }
  for(ll i=0;i+1<apsize2;i+=2){
    aabs.push_back(ap.at(i)*ap.at(i+1));
  }
  sort(aabs.rbegin(),aabs.rend());
  for(ll i=0;i<k/2;i++){
    ans*=aabs.at(i);
  }
  if(k%2==1)ans*=apmax;
  cout <<ans<<endl;
}

Measured memory_bytes: 8348
n,m,k=map(int,input().split())
mod=10**9+7
import math
def f(x):
  return math.factorial(x)
def c(x,y):
  return f(x)//(f(x-y)*f(y))

ans=(n**2*(m-1)*m*(m+1)//6)%mod
ans=(ans+m**2*(n-1)*n*(n+1)//6)%mod
ans=(ans*c(m*n-2,k-2))%mod
print(ans)


Measured memory_bytes: 74588
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while (true){
int H = sc.nextInt();
int W = sc.nextInt();
if(H == 0 && W == 0){
break;
}
for(int i = 1;i <= H;i++){
for(int j = 1;j <= W;j++){
System.out.printf("#");
}
System.out.printf("\n");
}
System.out.printf("\n");
}
sc.close();
}
}


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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int count = 0;
    rep(i,3){
        if(s[i] == t[i]){
            count++;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		sc.close();

		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (s.charAt(i) == t.charAt(i)) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int sum = a + b + c;
        
        if(sum == c*2){System.out.println("Yes");}
        else if(sum == b*2){System.out.println("Yes");}
        else if(sum == a*2){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if ((i*a) % b == c) {
            cout << "YES" << '\n';
            return 0;
        }
    }
    cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll gcl(ll a, ll b){
    return a / gcd(a, b) * b;
}

using namespace std;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ca = (a-1) / c;
    ll cb = b / c;
    ll da = (a-1) / d;
    ll db = b / d;
    ll e = gcl(c, d);
    ll ea = (a-1) / e;
    ll eb = b / e;
    ll p = cb - ca;
    ll q = db - da;
    ll r = eb - ea;
    ll s = p + q - r;
    ll ans = b - a - s + 1;

    cout << ans;



}

Measured memory_bytes: 256
class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time

    def __str__(self):
        return str(self.time)


n, q = map(int, input().split(' '))

queue = []
for i in range(n):
    name, time = input().split(' ')
    queue.append(Process(name, int(time)))

idx = 0
total = 0
while len(queue) > idx:
    time = queue[idx].time
    if time > q:
        total += q
        queue[idx].time -= q
        queue.append(queue[idx])
    else:
        total += time
        print(queue[idx].name + ' ' + str(total))

    idx += 1



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

using namespace std;

typedef long long ll;

ll max_self(ll& a, ll b) {
    a = max(a, b);
    return a;
}

int main() {
    ll N, W, w, v, ans = 0;

    scanf("%lld %lld", &N, &W);

    vector<ll> dp(W + 1);
    for (ll i = 1; i <= N; i++) {
        scanf("%lld %lld", &w, &v);
        for (int wt = W - w; wt >= 0; wt--) {
            ll tmp = max_self(dp[wt + w], dp[wt] + v);
            max_self(ans, tmp);
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int t;
  int n,m,k,ans=0;
  cin>>n>>m>>k;
  string s[6];
  bool v[6][6]={0};
  rep(i,n) cin>>s[i];
  int t_c=0;
  rep(k,n)rep(l,m) if(s[k][l]=='#') t_c++;
  rep(i,1<<n){
    rep(j,1<<m){
      rep(k,n)rep(l,m) v[k][l]=false;
      int count=0;
      rep(k,n){
        if(i & (1<<k)){
          rep(l,m) if(s[k][l]=='#') count++,v[k][l]=true;
        }
      }
      rep(k,m){
        if(j & (1<<k)){
          rep(l,n) if(s[l][k]=='#' && v[l][k]==false) count++,v[l][k]=true;
        }
      }
      if(t_c-count==k) ans++;
     }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
n = int(input())
v = list(map(int, input().split()))
sort_v = sorted(v, reverse=False)
sum_tmp = 0
for i in range(2, n):
  sum_tmp += sort_v[i]*(2**(i-1))
sum_all = sort_v[0] + sort_v[1] + sum_tmp
div = 2 ** (n-1)
ans = sum_all / div
print(ans)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int t=n-i;
		for(int i=1;i*i<=t;i++)
		    if(t%i==0&&i*i!=t)ans+=2;
		    else if(i*i==t)ans++;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 3632
#include <stdio.h>

int sq_cmp(int h, int w, int h2, int w2)
{
	int d1 = h * h + w * w , d2 = h2 * h2 + w2 * w2;
	if (d1 > d2) return(1);
	else if (d1 < d2) return (-1);
	else {
		if (h > h2) return (1);
		else if (h < h2) return (-1);
		else return(0);
	}
}

int main(void)
{
	int h, w, h2, w2, i, j;
	
	while(1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) break;
		
		h2 = 150;
		w2 = 150;

		for (i = 1; i <= 150; i++){
			for (j = i + 1; j <= 150; j++){
				if (sq_cmp(h, w, i, j) == -1 && sq_cmp(h2, w2, i, j)== 1){
					h2 = i;
					w2 = j;
				}
			}
		}
		printf("%d %d\n", h2, w2);
	}

	return(0);
}

Measured memory_bytes: 600
n = int(input())
dp = [False] * (n+5)
dp[0] = True

for i in range(len(dp)):
    if i < 4:
        continue
    elif dp[i-4] == True:
        dp[i] = True

    if i < 7:
        continue
    elif dp[i-7] == True:
        dp[i] = True

#print(dp)
if dp[n]:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	int n, p;
	cin >> n >> p;
	bool ans = 0;
	for (int i = 0; i< n; i++){
		int a;
		cin >> a;
		if (a % 2 == 1)
			ans = 1;
	}
	if (!ans){
		if (p == 0)
			cout << (long long)pow(2, n) << endl;
		else
			cout << 0 << endl;
		return 0;
	}
	cout << (long long)pow(2, n-1) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
}

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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    double x;
    cin >> n;
    x = ceil((double)n / 1.08);
    if((n+1)<=x*1.08) cout << ":(" << endl;
    else cout << (int)x << endl;
    return 0; 
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Println(logic(a, b))
}

func logic(a, b int) int {
	var x int
	for i := 0; i < 2; i++ {
		if a > b {
			x += a
			a--
		} else {
			x += b
			b--
		}
	}
	return x
}


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

int main()
{
    int b,n,m=100000;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		m*=1.05;
		b=m%1000;
		if(b>=1){
			m+=1000;
			m-=b;
		}
	}
	cout << m << endl;
	return 0;
}

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

void check(int* a) {
	if(a[0] != 0 && a[0] == a[1] && a[1] == a[2]) {
		switch(a[0]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[3] != 0 && a[3] == a[4] && a[4] == a[5]) {
		switch(a[3]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[6] != 0 && a[6] == a[7] && a[7] == a[8]) {
		switch(a[6]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[0] != 0 && a[0] == a[3] && a[3] == a[6]) {
		switch(a[0]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[1] != 0 && a[1] == a[4] && a[4] == a[7]) {
		switch(a[1]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[2] != 0 && a[2] == a[5] && a[5] == a[8]) {
		switch(a[2]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[0] != 0 && a[0] == a[4] && a[4] == a[8]) {
		switch(a[0]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else if(a[2] != 0 && a[2] == a[4] && a[4] == a[6]) {
		switch(a[2]) {
			case 1  : cout << 'o' << endl;   break;
			case -1 : cout << 'x' << endl;   break;
		}
	} else {
		cout << 'd' << endl;
	}
}

int main(void) {
	string str;
	int board[9] = {};
	
	while(cin >> str) {
		for(int i = 0; i < 9; ++i) {
			switch(str[i]) {
				case 'o' : board[i] = 1;   break;
				case 'x' : board[i] = -1;   break;
				case 's' : board[i] = 0;;   break;
			}
		}
		
		check(board);
	}
	
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main() {
    int h,w;
    cin>>h>>w;
    vector<string>grid(h);
    for(int i=0; i<h;i++){
        cin>>grid[i];
    }
    vector<vector<int>>dist(h,vector<int>(w,-1));
    vector<pair<int, int>> que;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]=='#'){
                que.emplace_back(i,j);
                dist[i][j]=0;
            }
        }
    }
    for(int b=0;b<(int) que.size();b++){
        for(int dx=-1;dx<=1;dx++){
            for(int dy=-1;dy<=1;dy++){
                if(dx*dx+dy*dy==1){
                    int xk=que[b].first+dx;
                    int yk=que[b].second+dy;
                    if(xk>=0 && yk>=0 && xk<h &&yk<w && dist[xk][yk]==-1){
                        que.emplace_back(xk,yk);
                        dist[xk][yk]=dist[que[b].first][que[b].second]+1;
                    }
                }
            }
        }
    }
    cout<<dist[que.back().first][que.back().second]<<'\n';


    return 0;
}

Measured memory_bytes: 15092
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      ss: chars,
    }

    let mut black = 0u64;
    let mut ans = 0u64;
    for i in 0..ss.len() {
        if ss[i] == 'B' {
            black += 1;
        } else {
            ans += black;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n;
string t;
set<string>s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	while(n--){
		cin>>t;
		s.insert(t);
	}
	cout<<s.size();
	return 0;
}


Measured memory_bytes: 19164
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<double>   vd;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define mii map<int,int>
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define log2(x) (31 - __builtin_clz(x))
#define lcm(x,y) (x*y) / __gcd(x,y)

int inf = (1e9) + 7;
int main(){



	ll a, b;
	cin >> a >> b;


	int ans = 0;
	while(a <= b)
	{
		a *= 2;
		ans++;
	}

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


}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int main()
{
	int x, n, a;
	cin >> x >> n;
	rep(i, n) cin >> a, x -= a;
	cout << max(x, -1) << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n>>m;
    for(int x=0; x<=n;x++){
        for(int y=0; y<=n;y++){
            int z = n - x- y;
            if(x*10000 + y*5000 + z*1000 == m && z>=0){
                printf("%d %d %d\n",x,y,z);
                return 0;
            }
        }   
    }
    printf("-1 -1 -1\n");
    return 0;
}

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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  
  if (b >= c) cout << "delicious" << endl;
  else if (b >= c-a) cout << "safe" << endl;
  else cout << "dangerous" << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No";
    else cout << "Yes";
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else:  #opが"?"以外の時
        # ここ処理を書いてください
        # else のなかです。この通りのインデントを付けてください。
        if op== "+":
            print(a+b)
        elif op== "-":
            print(a-b) 
        elif op== "*":
            print(a*b)        
        elif op== "/":
            print(a//b)
        else:
            print()


Measured memory_bytes: 5592
import java.util.*;
import java.util.Arrays;
class Main
{
  public static void main(String args[])
  {
    Scanner sc= new Scanner(System.in);
    int n=sc.nextInt();
    int p=sc.nextInt();
    int ar[]=new int[n];
    for(int i=0;i<n;i++)
    {
      ar[i]=sc.nextInt();
    }
    Arrays.sort(ar);
    int sum=0;
    for(int i=0;i<p;i++)
    {
      sum+=ar[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 30148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin >> s >> t;

    char schar[s.size()], tchar[t.size()];
    rep(i,s.size()) schar[i] = s[i];
    rep(i,t.size()) tchar[i] = t[i];


    sort(schar, schar+sizeof(schar)/sizeof(*schar));
    sort(tchar, tchar+sizeof(tchar)/ sizeof(*tchar), greater<char>());

    string ssort(schar, s.size());
    string tsort(tchar, t.size());

    if (ssort < tsort)
    {
	    cout << "Yes" << endl;
    }
    else
    {
	    cout << "No" << endl;
    }



}


Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m;
ll k;
string s;

int ans = 0;

bool solve(){
	omajinai;
	cin >> s;
	string t = "AKIHABARA";
	int c=0, j=0;
	bool flag = 1;
	REP(k, t.size()){
		if(c < s.size() && s[c]==t[k]){
			c++;
		}else if(t[k]!='A'){
			return 0;
		}
	}
	return c==s.size();
}

int main() {
	cout << (solve() ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int n, m;
double a[16][16];
double dp[1 << 16][16];

double f(int s, int k) {
    double &ret = dp[s][k];
    if (ret != -1) return ret;
    ret = 0;
    rep(i, n) {
        if (s >> i & 1) continue;
        double sm = 0;
        double t = 1;
        rep2(j, k, m) {
            sm += f(s | 1 << i, j) * t * (1 - a[i][j]);
            t *= a[i][j];
        }
        sm += t;
        chmax(ret, sm);
    }
    return ret;
}

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

    cin >> n >> m;
    rep(i, n) rep(j, m) cin >> a[i][j];
    rep(i, 1 << n) rep(j, m) dp[i][j] = -1;
    cout << fixed << setprecision(10) << f(0, 0) << endl;
}

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B.at(i);
    }

    vector<vector<int>> A(N,vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = C;
        for (int j = 0; j < M; j++) {
            sum += A.at(i).at(j) * B.at(j);
        }
        if (sum > 0) ans++;
    } 

    cout << ans << endl;
    
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.buffer.readline

W, H = map(int, input().split())
ps = sorted(int(input()) for _ in range(W))
qs = sorted(int(input()) for _ in range(H))

# Add [0] to satisfy "q_cumsum[index] = sum(q[:index])".
q_cumsum = np.cumsum([0] + qs)

ans = sum(ps) + q_cumsum[-1]

index = 0
for p in ps:
    while index < H and qs[index] <= p:
        index += 1
    ans += q_cumsum[index] + p * (H - index)
    
print(ans)

Measured memory_bytes: 23116
// https : //onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/2/ITP2_2_C

#include <iostream>
#include <vector>
#include <queue>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::priority_queue<int>> qu(n);

    int m, t, x;
    for (int i = 0; i < q; i++)
    {
        std::cin >> m >> t;
        if (m == 0)
        {
            std::cin >> x;
            qu[t].push(x);
        }
        else if (m == 1)
        {
            if (qu[t].size() > 0)
            {
                //デフォルトで大きい順に並んでいる
                std::cout << qu[t].top() << std::endl;
            }
        }
        else if (m == 2)
        {
            if (qu[t].size() > 0)
            {
                qu[t].pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4128