akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (auto &&i : a) scanf("%lli", &i);
    for (auto &&i : b) scanf("%lli", &i);
    for (auto &&i : c) scanf("%lli", &i);
    sort(a.begin(), a.end(), greater<>());
    sort(b.begin(), b.end(), greater<>());
    sort(c.begin(), c.end(), greater<>());
    vector<ll> ans;
    vector<ll> u;
    for (int i = 0; i < x; ++i) {
        for (int j = 0; j < y; ++j) {
            u.emplace_back(a[i]+b[j]);
        }
    }
    sort(u.begin(), u.end(), greater<>());
    for (int i = 0; i < min((int)u.size(), k); ++i) {
        for (int j = 0; j < z; ++j) {
            ans.emplace_back(u[i]+c[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<>());
    for (int i = 0; i < k; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 43240
S = input()

if (S[0]== "a" or S[1] == "a" or S[2] == "a") and (S[0]== "b" or S[1] == "b" or S[2] == "b") and (S[0] == "c" or S[1] == "c" or S[2] == "c") :
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int a = 0,b = 0,c = 0;

  while(1){
    scanf("%d %d",&a,&b);
    if( a == 0 && b == 0){
      return 0;
    }

    if (a < b){
      printf("%d %d\n",a,b);
    } else {
      printf("%d %d\n",b,a);
    }
  }
  return 0;
}

Measured memory_bytes: 600
// AOJ 1523 Cone Cut
// 2018.3.20 bal4u

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

#define EPS         1e-7
#define EQ(a,b)     (fabs((a)-(b))<EPS)
#define PI          3.1415926535897932384626433832795

// [library]
typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;
typedef struct { double x, y, r; } C;

PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
double dist(PP p1, PP p2) {	return vabs(vsub(p1, p2)); }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }


// 直線同士の交点
PP crossPointLL(LINE ln1, LINE ln2)
{
	PP u = vsub(ln1.e, ln1.s), v = vsub(ln2.e, ln2.s);
	return vadd(ln1.s, vsmul(u, cross(v, vsub(ln2.s, ln1.s))/cross(v, u)));
}

// 円と円の交点２つ、または１つか、ゼロ
int intersectCC(PP *p1, PP *p2, C c1, C c2)
{
	double x1 = c1.x, y1 = c1.y, r1 = c1.r;
	double x2 = c2.x, y2 = c2.y, r2 = c2.r;
	double d = dist(vset(x1, y1), vset(x2, y2));
	double w, n, x, y, p, q;
	double u, v;

	u = r1+r2, v = fabs(r1-r2);

	if ((fabs(d-u) > EPS && d >= u) || fabs(v-d) > EPS && d <= v) return 0;
	w = ((r1*r1 - r2*r2)/d + d) / 2;
	n = sqrt(r1*r1 - w*w);
	x = x1 + (x2-x1)*w / d;
	y = y1 + (y2-y1)*w / d;
	p = (y2-y1)*n / d;
	q = (x2-x1)*n / d;

	p1->x = x+p, p2->x = x-p;
	p1->y = y-q; p2->y = y+q;
	if (fabs(d-u) <= EPS) return 1;
	if (d == r1+r2) return 1;
	return 2;
}

int Sx, Sy, Sz;          // Apex of the cone: S
int Ox, Oy, Oz, R;
int Px, Py, Pz;

double dist3d(int x1, int y1, int z1, int x2, int y2, int z2)
{
	int dx = x1 - x2;
	int dy = y1 - y2;
	int dz = z1 - z2;
	return sqrt(dx*dx + dy*dy + dz*dz);
}

int main()
{
	double SO, SP, PO, V, ans;
	PP     S, O, A, B, P, a, b;		// a = A', b = B'
	double Sa, Sb, ab;           // Sa = |S-A'|, Sb = |S-B'|, ab = |A'-B'|
	LINE   ln1, ln2;

	scanf("%d%d%d", &Sx, &Sy, &Sz);
	scanf("%d%d%d%d", &Ox, &Oy, &Oz, &R);
	scanf("%d%d%d", &Px, &Py, &Pz);

	SO = dist3d(Sx, Sy, Sz, Ox, Oy, Oz);
	SP = dist3d(Sx, Sy, Sz, Px, Py, Pz);
	PO = dist3d(Px, Py, Pz, Ox, Oy, Oz);
	V = R*R*SO* PI/3;

	O = vset( 0, 0);
	S = vset( 0, SO);
	A = vset(-R, 0);
	B = vset( R, 0);

	if (EQ(SP+PO, SO)) {
		P = vset(0, PO);
	} else {
		C c1, c2; PP p;
		c1.x = 0, c1.y = SO, c1.r = SP;
		c2.x = 0, c2.y = 0,  c2.r = PO;
		intersectCC(&P, &p, c1, c2);
		if (P.x > 0) P.x = -P.x;
	}
	ln1.s = P, ln1.e = B, ln2.s = S, ln2.e = A;
	a = crossPointLL(ln1, ln2);

	ln1.s = P, ln1.e = A, ln2.s = S, ln2.e = B;
	b = crossPointLL(ln1, ln2);

	Sa = dist(S, a);
	Sb = dist(S, b);
	ab = dist(a, b);

	ans = (ab+Sa-Sb)*(ab-Sa+Sb)*sqrt((ab+Sa+Sb)*(Sa+Sb-ab)) * PI/24;

	printf("%lf %lf\n", ans, V-ans);
	return 0;
}


Measured memory_bytes: 2092
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = sum(B) - sum(A)
a, b = cnt, cnt
for i in range(N):
    if A[i] < B[i]:
        b -= (B[i]-A[i]+1)//2
    elif A[i] > B[i]:
        a -= A[i]-B[i]
    if a < 0 or b < 0:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 4596
#include <stdio.h>

int type(int s[2])
{
	if ( s[0] == 0 ) {
		if ( s[1] == 0 ) return 0;
		else return 1;
	}
	if ( s[0] == 1 ) {
		if ( s[1] < 3 ) return 1;
		else return 0;
	}
}

int main()
{
	int n = 2;
	int num1[n], num2[n];
	for ( int i = 0; i < n; i++ ) {
		scanf("%1d", &num1[i]);
	}
	for ( int i = 0; i < n; i++ ) {
		scanf("%1d", &num2[i]);
	}
	if ( type(num1) == 1 ) {
		if ( type(num2) == 1 ) printf("AMBIGUOUS");
		else printf("MMYY");
	} else {
		if ( type(num2) == 1 ) printf("YYMM");
		else printf("NA");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N%10==9 || N/10==9){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    vector<int>vec(300);
    for(int i=0;i < 300;i++){
        cin >> vec.at(i);
    }
    int count = 0;
    while(true){
        bool jk = false;
        for(int i = 0;i < 300;i++){
            if(vec.at(i)%2 == 1){
                jk = true;
            }
        }
    if(jk) break;
     for(int i = 0; i < 300; i++){
         vec.at(i)/=2;
     }
    count++;

    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

ld solve(int n, ld d1, ld x) {
	if (n == 1) {
		return d1 + (ld)0.5 * x;
	}
	return (ld)1.0 / (ld)(2 * n) * ((ld)2.0 * (ld)n * d1 + x * (ld)n * (ld)(2 * n - 1)) + solve(n - 1, (ld)1.0 / (ld)(2 * n) * (d1 * (ld)(2 * n + 2) + (ld)5.0 * x), x * (ld)(2 * n + 4) / (ld)(2 * n));
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	int n, d1, x;
	cin >> n >> d1 >> x;
	cout << fixed << setprecision(20) << solve(n, d1, x) << '\n';  
} 

Measured memory_bytes: 15872
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define ll long long
#define ld long double


int main(){

int n,d,x;
cin>>n>>d>>x;

int total=x;
rep(i,n){
    int j=1,a,count=0;
    cin>>a;
    while(j<=d){
        count++;
        j+=a;
    }
    total+=count;
}

cout<<total;
}

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

#ifdef YUCHIKIDEBUG
  #define dump(x)  cerr << #x << " = " << (x) << endl;
  #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#else
  #define dump(x) ;
  #define debug(x) ;
#endif // YUCHIKIDEBUG

#define int long long
#define pb push_back
#define pf push_front

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _repr(i,n) repir(i,n,0)
#define repir(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define repr(...) _overload3(__VA_ARGS__,repir,_repr,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define CINV(x,n) rep(temporary_index,n){int x##temp; cin >> x##temp; x.push_back(x##temp);}
#define REV(x) reverse(all(x))
#define SORT(x) sort(all(x))
#define PUTS(x) cout<<(x)<<endl;

inline int sqr(int x) { return x * x; }
inline int sqrti(int x) { return (int)sqrt(x); }

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

#define put PUTS

signed main(){
    int K; cin >> K;
    vector<int> dist(K, INF);
    dist[1] = 1;
    deque<int> dfs = {1};

    while(!dfs.empty()){
      int node = dfs.front();
      dfs.pop_front();
      int mult_ten = (node * 10) % K;
      int next = (node + 1) % K;
      int d = dist[node];
      if (dist[mult_ten] > d) {
        dist[mult_ten] = d;
        dfs.push_front(mult_ten);
      }
      if (dist[next] > d + 1) {
        dist[next] = d + 1;
        dfs.push_back(next);
      }
    }

    put(dist[0]);
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int MN = 100003;

int n,q,tp;
long long a[MN];

long long times[MN], ans[MN];

void divide(long long len, long long timeS) { // 把给 “ans数组加上第 id 次操作后的序列的长度为 len 的前缀 timeS 次” 分解
    int j = upper_bound(a+1,a+tp+1,len) - a - 1;
    if(!j) ans[1]+=timeS, ans[len+1]-=timeS;
    else {
        times[j] += (len/a[j]) * timeS;
        divide(len%a[j], timeS);
    }
}

int main() {
    scanf("%d%d", &n,&q);
    a[++tp] = (long long)n;
    for(int i=1;i<=q;++i) {
        long long x;
        scanf("%lld",&x);
        while(tp && a[tp]>=x) --tp;
        a[++tp] = x;
    }
    
    times[tp] = 1ll; //题目就是要求把 ans 数组加上一个最终数列
    for(int i=tp;i>1;--i) {
        times[i-1] += (a[i]/a[i-1])*times[i]; //分解前面的整段
        divide(a[i]%a[i-1],times[i]);
    }
    ans[1] += times[1];
    ans[a[1]+1] -= times[1];
    for(int i=2;i<=n;++i) ans[i] += ans[i-1];
    for(int i=1;i<=n;++i) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 6108
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    int ans = 1e9;
    for(int i = 1; i <= 100; i++){
        int temp = 0;
        for(int j = 0; j < N; j++){
            temp += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, temp);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void) {
  int minp = 2000, minj = 2000;
  for (int i = 0; i < 3; i++) {
    int p;
    cin >> p;
    minp = min(minp, p);
  }
  for (int i = 0; i < 2; i++) {
    int j;
    cin >> j;
    minj = min(minj, j);
  }
  cout << minp + minj - 50 << endl;

  return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n,k;
    scanf("%ld%ld", &n, &k);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    vector<long> s(n+1);
    s[0]=0;
    for(i=0; i<n; i++) {
        s[i+1]=s[i]+a[i];
    }

    long ans=0;
    long ll=-1, rr=n;
    while( rr-ll>1 ) {
        long curr = (ll+rr)/2;

        vector<long> vis(k,0);

        vis[0]=1;
        if(0>=k-a[curr]) {
            rr=curr;  // curr is needed
            continue;
        }

        long j;
        for(i=0; i<n; i++) {
            if(i==curr) continue;
            for(j=k-1; j>=0; j--) {
                if(vis[j]==0 && j>=a[i] && vis[j-a[i]]) {
                    vis[j]=1;
                    if(j>=k-a[curr]) {
                        break;
                    }
                }
            }
            if(j>=0) {
                break;
            }
        }

        if(i==n) {
            ll=curr;  // curr is no need
        }
        else {
            rr=curr;  // curr is needed
        }
    }

    printf("%ld\n", ll+1);

    return 0;
}



Measured memory_bytes: 384
import sys

X = int(input())
numbers = [5, 4, 3, 2, 1]

if X <= 99:
    print(0)
    sys.exit()

left = (X // 100)
right = X - left * 100

number = 5
num_goods = 0
while number >= 0:
    goods = right // number
    right -= goods * number
    num_goods += goods
    if right == 0:
        break
    number -= 1

if right != 0:
    print(0)
    sys.exit()

if left < num_goods:
    print(0)
else:
    print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
const int OO = 1e16 , AKA = 1e5 + 5;
int SD(){int x; scanf("%d" , &x); return x;}
lld SLL(){lld x; scanf("%lld" , &x); return x;}
lld mem[101][AKA] , N , C , W[AKA] ,P[AKA];
void init()
{
    for(int i = 0 ; i < 101 ; ++i)
        memset(mem , -1 , sizeof mem);
}
lld knapsack(int i = N - 1 , int rem = C)
{
    if(rem < 0)
        return -OO;
    if(i < 0)
        return 0;
    if(mem[i][rem] != -1)
        return mem[i][rem];
    return mem[i][rem] = max(knapsack(i - 1 , rem - W[i]) + P[i] , knapsack(i - 1 , rem));
}
int main()
{
    init();
    N = SLL() , C = SLL();
    for(int i = 0 ; i < N ; ++i)
        W[i] = SLL() , P[i] = SLL();
    printf("%lld" , knapsack());
}


Measured memory_bytes: 79232
//
// Created by 李青坪 on 2018/11/8.
//
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define INFINITY 1<<21
#define NIL -1
#define MAXN 10000

using namespace std;
struct Node{
    int id;
    int weight;
    friend bool operator < (Node x1, Node x2) {
        return x1.weight < x2.weight;
    }
};

struct cmp{
    bool operator ()(Node &a, Node &b){
        return a.weight > b.weight;
    }
};

vector<Node> graph[MAXN];
priority_queue<Node, vector<Node>, cmp> V_S;
int n;
int d[MAXN];
bool visited[MAXN];

void init(){
    fill(d, d+MAXN, INFINITY);
    d[0] = 0;
    fill(visited, visited+MAXN, false);
    Node node;
    node.id = 0;
    node.weight = 0;
    V_S.push(node);
}

void updateMinWeight(Node u){
    vector<Node>::iterator it;
    for (it = graph[u.id].begin(); it != graph[u.id].end(); ++it){ //遍历与u相连的所有结点，看有没有结点到S的距离减小了
        if (visited[(*it).id]) continue;
        if (d[(*it).id] > d[u.id] + (*it).weight){
            d[(*it).id] = d[u.id] + (*it).weight;
            Node node;
            node.id = (*it).id;
            node.weight = d[(*it).id];
            V_S.push(node);
        }
    }
}

void dijkstra(){
    while (!V_S.empty()){
        Node u = V_S.top();
        V_S.pop();
        visited[u.id] = true;
        updateMinWeight(u);
    }
}

int main(){
    scanf("%d", &n);
    int u, k;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &u, &k);
        int v, w;
        Node node;
        for (int j = 0; j < k; ++j) {
            scanf("%d %d", &v, &w);
            node.id = v;
            node.weight = w;
            graph[u].push_back(node);
        }
    }
    init();
    dijkstra();
    for (int l = 0; l < n; ++l) {
        printf("%d %d\n", l, d[l]);
    }
//    Node l[6];
//    l[0].id = 0; l[0].weight = 3;
//    l[1].id = 1; l[1].weight = 2;
//    l[2].id = 2; l[2].weight = 5;
//    l[3].id = 3; l[3].weight = 3;
//    l[4].id = 4; l[4].weight = 4;
//    l[5].id = 5; l[5].weight = 2;
//    for (int i = 0; i < 6; ++i) {
//        V_S.push(l[i]);
//    }
//    for (int j = 0; j < 6; ++j) {
//        printf("id: %d weight: %d\n", V_S.top().id, V_S.top().weight);
//        V_S.pop();
//    }
}
/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3
 */


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

int main(){
    ll r, d, x; cin >> r >> d >> x; 

    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    set<int> st;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        if (st.find(A) == st.end())
            st.insert(A);
        else
            flag = true;
    }

    cout << (flag ? "NO" : "YES") << endl;

    return 0;
}


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

int main(void){
    int S,h,m,s;
    cin >> S;
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    cout << h;
    cout << ":";    //
    cout << m;  
    cout << ":";
    cout << s;  
    cout << endl;// 改行
    
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,q;
    cin>>n>>k>>q;
    vector<int>p(n,k-q);
    for(int i=0;i<q;i++){
        int a;
        cin>>a;
        a--;
        p[a]++;
    }
    for(int i=0;i<n;i++){
        if(p[i]<=0)puts("No");
        else puts("Yes");
    }
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		int[]B = new int[N];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = int.Parse(str[0]);
			B[i] = int.Parse(str[1]);
		}
		double ans = 0;
		for(var i=0;i<N;i++){
			for(var j=i+1;j<N;j++){
				ans += Math.Pow(Math.Pow(A[j]-A[i],2)+Math.Pow(B[j]-B[i],2),0.5);
			}
		}
		ans = ans * (N-1) / (N*(N-1)/2);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979


int main(){
  ll N,K,C;
  cin>>N>>K>>C;
  string S;
  cin>>S;
  vector<P>A(N+2);
  vector<P>B(N+2);
  rep(i,N+2){A[i]=P(0,0);B[i]=P(0,0);}
  A[0]=P(0,-300000);
  B[N+1]=P(0,500000);
  //前から最適に働く
  for(ll i=0;i<N;i++){
    if(S[i]=='x'){
      A[i+1]=A[i];
    }
    else{
      ll k=i+1;
      //働ける場合
      if(k-A[i].second>C){
      auto t=A[i];  
      t.first+=1;
      t.second=k; 
       
      A[i+1]=P(t.first,t.second);
      }
      if(k-A[i].second<=C){A[i+1]=A[i];}
    }
    
  }
  //後ろから最適に働く
  for(ll i=N-1;i>=0;i--){
    if(S[i]=='x'){
      B[i+1]=B[i+2];continue;
    }
    auto t=B[i+2];
    ll k=i+1;
    //働ける場合
    if(t.second-k>C){
      t.first++;
      t.second=k;
      B[i+1]=t;
    }
    else{B[i+1]=B[i+2];}
  }
  rep(i,N){
    if(S[i]=='x'){continue;}
    auto p=B[i+2];
    auto q=A[i];
    ll sum=p.first+q.first;
    if(p.second-q.second<=C){sum--;}
    if(sum<K){cout<<i+1<<endl;}
  }  
}


Measured memory_bytes: 9740
N=int(input())
dic={}
ans=0
for i in range(N):
    str1=''.join(sorted(input()))
    n=len(str1)
    if n in dic:
        if str1 in dic[n]:
            ans+=dic[n][str1]
            dic[n][str1]+=1
        else:
            dic[n][str1]=1
    else:
        dic[n]={str1:1}
    
print(ans)        

Measured memory_bytes: 17852
import numpy as np
import math

N = int(input())
X = list(map(int, input().split()))

guess1 = math.floor(np.mean(X))
guess2 = math.ceil(np.mean(X))

value1 = 0
value2 = 0
for i in range(N):
    value1 += (X[i] - guess1)**2
    value2 += (X[i] - guess2)**2
if value1 <= value2:
    print(value1)
else:
    print(value2)

Measured memory_bytes: 21476
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]
    
    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)
    
    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)
    
    def bfs(self, s, t):
        self.level = [None]*self.N
        d = deque([s])
        self.level[s] = 0
        while d:
            v = d.popleft()
            lv = self.level[v] + 1
            for w, cap, _ in self.G[v]:
                if cap and self.level[w] is None:
                    self.level[w] = lv
                    d.append(w)
        return self.level[t] is not None
    
    def dfs(self, v, t, f):
        if v == t:
            return f
        for e in self.it[v]:
            w, cap, rev = e
            if cap and self.level[v] < self.level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0
    
    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

N = int(input())
dinic = Dinic(2*(N+1))
for i in range(1, N+1):
  dinic.add_edge(0, i, 1)
  dinic.add_edge(N+i, 2*N+1, 1)

ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(N)]
for i, (a, b) in enumerate(ab, 1):
  for j, (c, d) in enumerate(cd, N+1):
    if a < c and b < d:
      dinic.add_edge(i, j, 1)

print(dinic.flow(0, 2*N+1))

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

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define SZ(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
using namespace std;

typedef long long ll;
typedef pair<int,int> PI;
typedef unsigned long long ull;

#define PR(...) do{cerr << "line : " << __LINE__ << endl; pr(#__VA_ARGS__, __VA_ARGS__);}while(0);
template<class T>
void pr(const string& name, T t){
  cerr << name << ": " << t << endl;
}

template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto comma_pos = names.find(',');
  cerr << names.substr(0, comma_pos) << ": " << t << ", ";
  
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest ...);
}

template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
template<class T> ostream& operator<< (ostream& o, const set<T> &v){o << "{";for(auto e : v) o << e << ", ";return o << "}";}
template<class T, class U> ostream& operator<< (ostream& o, const map<T,U> &v){o << "{";for(auto e : v) o << e.F << ": " << e.S << ", ";return o << "}";}

//                < v > ^
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
#define endl '\n'


int main(int argc, char *argv[])
{
  int n;
  while(cin >> n && n){
    int ans = 0;
    int st = 0;
    int l = 0, r = 0;
    rep(i, n){
      string s;
      cin >> s;
      if(s[0]=='l') l = !l;
      else r = !r;
      
      if(l == r && l != st){
	st = l;
	++ans;
      }
    }
    cout << ans << endl;
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,D;
vpint G[111111];
vpint T[111111];
int A[111111],B[111111],C[111111];
int dist[111111];

int latte[111111];

void dfs(int v,int p,int d){
    dist[v]=d;
    for(auto &e:G[v])if(e.fi!=p)dfs(e.fi,v,d+e.se);
}

int ans;
void dfs2(int v,int p,int s){
    if(latte[v]<=D){
        chmin(ans,s);
    }
    for(auto &e:T[v]){
        if(e.fi!=p)dfs2(e.fi,v,s+e.se);
    }
}
signed main(){

    cin>>N;
    rep(i,N-1){
        cin>>A[i]>>B[i]>>C[i];
        //A[i]--;B[i]--;
        G[A[i]].pb({B[i],C[i]});
        G[B[i]].pb({A[i],C[i]});
    }
    int v=0;
    rep(t,3){
        dfs(v,-1,0);
        rep(i,N){
            chmax(latte[i],dist[i]);
            if(dist[v]<dist[i])v=i;
        }
    }
    cout<<*max_element(latte,latte+N)<<endl;return 0;
    dfs(0,-1,0);
    int cnt=0;
    rep(i,N-1){
        if(dist[A[i]]>dist[B[i]]){
            T[B[i]].pb({A[i],1});
        }
        else{
            cnt++;
            T[A[i]].pb({B[i],-1});
        }
    }
    ans=INT_MAX;
    dfs2(0,-1,cnt);
    if(ans==INT_MAX)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define cmdMax 10

typedef struct node *link;
struct node{
	int key;
	link left,right;
};

link insert(link head,link z){
	link y=NULL;
	link x=head;
	
	while(x!=NULL){
		y=x;
		if(z->key < x->key)x=x->left;
		else x=x->right;
	}
	
	if(y==NULL)head=z;
	else if(z->key < y->key)y->left=z;
	else y->right=z;
	return head;
}

void preorder(link u){
	if(u==NULL)return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

void inorder(link u){
	if(u==NULL)return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

int main(void){
	int m,i,key;
	char cmd[cmdMax];
	link head=NULL,z;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			z = malloc(sizeof(*z));
			z->key=key;z->left=NULL;z->right=NULL;
			head=insert(head,z);
		}else if(!strcmp(cmd,"print")){
			inorder(head);
			printf("\n");
			preorder(head);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 17340
flg = True
while flg:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        flg = False
        break
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if (i + j + k == x):
                    count += 1
    print(count)



Measured memory_bytes: 5592
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	long long x,y;
	scanf("%lld%lld",&x,&y);
	if(x%y==0) printf("-1\n");
	else{
		for(int i=1;;i++){
			if(x*i%y!=0){
				printf("%lld\n",x*i);
				break;
			}
		}
	}
}

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

int main(){
    int N;
    bool yellow_exist = false;
    string color;
    cin >> N;
    for (int j = 0; j < N; j++) {
        cin >> color;
        if (color == "Y") {
            yellow_exist = true;
        }
    }
    if (yellow_exist) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}


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

int func(int x, int y, int z){
//  cout << x << " " << y << " " << z << endl;
  if (x==y||y==z||z==x) return false;
  if (x+y>z&&y+z>x&&z+x>y){
//    cout << "ok" << endl;
    return true;
  }
  return false;
}

int main(void){
  int n,ans;
  int len[200];
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> len[i];
  ans = 0;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<n; j++){
      for (int k=j+1; k<n; k++){
        ans += func(len[i], len[j], len[k]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h> // {{{
using namespace std;
// clang-format off
#define ARG4(_1,_2,_3,_4,...) _4
#define rep(...) ARG4(__VA_ARGS__,FOR,REP)(__VA_ARGS__)
#define REP(i, a) FOR(i,0,a)
#define FOR(i, a, b) for(int i=(a);i<(int)(b);++i)
#define rrep(...) ARG4(__VA_ARGS__,RFOR,RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i,0,a)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(int)(a);--i)
#define ALL(c) begin(c),end(c)
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template<typename __VA_ARGS__>inline
#define USE2(T, ...) USE1(T,typename __VA_ARGS__)

using ll=long long;
template<typename T>using vec=vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<T>ndvec(T&&v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T&&v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pu(T&&x){cout<<x;}
USE1(T)void pr(T&&x){cout<<x<<'\n';}
USE2(T,...Ts)void pr(T&&x,Ts...xs){cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T)ostream&operator<<(ostream&o,vector<T>const&v){int f=0;for(auto&&x:v){if(f++)o<<' ';o<<x;}return o;}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout.setf(ios::fixed);
  }
} iosetup; //}}}
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  ll N = in();
  map<ll, int> cnt;
  rep(i, N) {
    ll A = in<ll>();
    cnt[-A]++;
  }
  vec<ll> a;
  for (auto kv : cnt) {
    if (kv.se >= 4) {
      a.pb(kv.fi);
      a.pb(kv.fi);
    } else if (kv.se >= 2) {
      a.pb(kv.fi);
    }
  }
  if (a.size() >= 2) {
    pr(a[0] * a[1]);
  } else {
    pr(0);
  }

  return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>

const int MAXN = 100000 + 10;

int fl[MAXN], fr[MAXN];
char s[MAXN];
int ans[MAXN];
int n;

int main() {
	int i;
	
	scanf("%s", s+1);
	n=strlen(s+1);
	
	for(i=1; i<=n; i++) fl[i]=(s[i]=='R')?i:fl[i-1];
	for(i=n; i; i--) fr[i]=(s[i]=='L')?i:fr[i+1];
	for(i=1; i<=n; i++)
		if(s[i]=='L')
			ans[fl[i]+((i-fl[i])&1)]++;
		else
			ans[fr[i]-((fr[i]-i)&1)]++;
	for(i=1; i<=n; i++) printf("%d ", ans[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1664
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      k: usize,
      s: String,
   }

   match s.len() {
      l if l <= k => println!("{}", s),
      _ => {
         print!("{}", s.get(0..k).unwrap());
         println!("...");
      }
   }
}


Measured memory_bytes: 2180
#include <iostream>
#include <cstdio>
#include <algorithm>

typedef long long ll;
using namespace std;

int N;
ll a[200000];

int main() {
    ll sum = 0;
	scanf("%d", &N);
    for (int i = 0; i < N; i ++) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    ll x = 0, y = sum;
    ll diff_min = 1ll<<50;
    for (int i = 0; i < N - 1; i ++) {
        x += a[i];
        y -= a[i];
        ll diff = abs(x - y);
        cerr << diff << endl;
        diff_min = min(diff, diff_min);
    }
    printf("%lld\n", diff_min);
	return 0;
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            sm = 500*a+100*b+50*c
            if sm == X:
                ans += 1
print(ans)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b>>c>>x>>y;
      ans=a*x+b*y;
      if(x>y){
      ans=min(ans,c*2*min(x,y)+(x-y)*a);
      }
      else{
         ans=min(ans,c*2*min(x,y)+(y-x)*b);
      }
      ans=min(ans,c*2*max(x,y));
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
const int maxP = 1e7;
const int maxn = 205;
const int S = 0;
const int T = 204;
using namespace std;
vector <int> p; bool isp[maxP + 5];
void install(){
	isp[1] = 1;
	for (int i = 2; i <= maxP; i++){
		if (!isp[i]) p.push_back(i);
		for (int j = 0; j < p.size() && i * p[j] <= maxP; j++){
			isp[i * p[j]] = 1;
			if (i % p[j] == 0) break;
		}
	}
}
struct E{
	int to, nxt;
}e[maxn * maxn];
int head[maxn], tot = 1;
void addedge(int u, int v){
	e[++tot].to = v, e[tot].nxt = head[u];
	head[u] = tot;
}
int mat[maxn]; bool vis[maxn];
bool dfs(int cur){ 
	for (int i = head[cur]; i; i = e[i].nxt){
		int v = e[i].to;
		if (vis[v]) continue;
		vis[v] = 1;
		if (mat[v] == -1 || dfs(mat[v])){
			mat[v] = cur; mat[cur] = v;
			return true;
		}
	}
	return false;
}
int abs(int x){return x < 0 ? -x : x;}
vector <int> x[2]; int n, c[maxP + 5];
int main(){
	install();
	scanf("%d", &n);
	for (int a, i = 1; i <= n; i++){
		scanf("%d", &a); c[a]++;
	}
	for (int i = 1; i <= maxP + 1; i++)
		if (c[i] != c[i - 1]) x[i & 1].push_back(i);
	for (int i = 0; i < x[0].size(); i++)
		for (int j = 0; j < x[1].size(); j++)
			if (!isp[abs(x[1][j] - x[0][i])]) addedge(i, j + x[0].size());
	int flow = 0;
	memset(mat, -1, sizeof mat);
	for (int i = 0; i < x[0].size() + x[1].size(); i++){
		if (mat[i] == -1){
			memset(vis, 0, sizeof vis);
			flow += dfs(i);
		}
	}
	printf("%d\n", flow + (x[0].size() - flow) / 2 * 2 + (x[1].size() - flow) / 2 * 2 + (x[0].size() - flow) % 2 * 3);
	return 0;
}

Measured memory_bytes: 51564
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) break;
            int i = 0;
            int sum = 0;
            for(i = 0; i < str.length(); i++){
                String st = str.substring(i,i + 1);
                sum =  sum + Integer.parseInt(st);
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26748
#include <iostream>

int a = -1;
int b = -1;
int c = -1;

int check(int n, int y) {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; i + j <= n; ++j) {
      for (int k = 0; i + j + k <= n; ++k) {
        if (n == i + j + k && i * 10000 + j * 5000 + k * 1000 == y) {
          a = i;
          b = j;
          c = k;
          return 1;
        }
      }
    }
  }

  return 0;
}

int main() {
  int n, y;

  std::cin >> n >> y;

  check(n, y);

  std::cout << a << " " << b << " "  << c << " "  << std::endl;

  return 0;
}


Measured memory_bytes: 256
import atexit,io,sys,os,math
from collections import OrderedDict
buffer=io.BytesIO()
sys.stdout=buffer
@atexit.register
def write():
    sys.__stdout__.write(buffer.getvalue())


s=raw_input().strip()
sm=0
for i in s: sm+=int(i)
s=int(s)
print("%s"%{True:"Yes",False:"No"}[(s-(s/sm)*sm)==0])

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

int grid[100][100],x,y,h,w,n;

void fill(int num){
	grid[x][y] = num;
	if(x % 2){
		if(y) y--;
		else x++;
	}
	else {
		if(y < w - 1) y++;
		else x++;
	}
}

int main() {
	cin >> h >> w >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		for(int j = 0;j < a;j++) fill(i + 1);
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) cout << (j ? " " : "") << grid[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];
int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    for (int i = 0; i < m; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int x; cin >> x; x--;
            s[i].push_back(x);
        }
    }
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    ll ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        bool ok = true;
        for (int i = 0; i < m; ++i) {
            int tmp = 0;
            for (int v = 0;v < s[i].size();v++) {
                if(bit & (1<<s[i][v])) tmp++;
            }
            if(tmp %2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,p=MI()
    lis=LI()
    ev=0
    od=0
    for i in range(n):
        if lis[i]%2==0:
            ev+=1
        else:
            od+=1
    ans=0
    for i in range(od+1):
        if i%2==p:
            ans+=factorial(od)//factorial(i)//factorial(od-i)
    ans*=2**ev
    print(ans)

            
        
        







if __name__=="__main__":
    main()


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    string a, s;

    cin >> a >> s;

    if (a < "3200") cout << "red";
    else cout << s;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int s[19]={6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,};
    int n,flag,i,st,fin;

    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&st,&fin);
        if(st < fin){
            for(i = st;i <= fin;i++){
                if(i != st)printf(" ");
                printf("%d",i);
            }
            puts("");
        }else{
            for(i=0,flag=0;i<19;i++){
                if(st==s[i]){
                    flag=1;
                }
                if(flag==1){
                    printf("%d",s[i]);
                    flag++;
                }else if(flag){
                    printf(" %d",s[i]);
                }
                if(flag&&fin==s[i])break;
            }
            puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

ll gcd(ll a, ll b) {
    if (a<b) swap(a, b);
    while(b!=0) {
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

ll lcm(ll a, ll b) { return a/gcd(a, b)*b; }

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

bool dp[82][82][81*160];

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

    int H, W; cin >> H >> W;
    vector<vector<int>> a(H+2, vector<int>(W+2, 0)), b(H+2, vector<int>(W+2, 0));
    rep(i, H) rep(j, W) cin >> a[i+1][j+1];
    rep(i, H) rep(j, W) cin >> b[i+1][j+1];

    rep(i, 82) rep(j, 82) rep(k, 81*160) dp[i][j][k] = false;

    dp[1][1][abs(a[1][1]-b[1][1])] = true;
    repr(i, 1, H+1) repr(j, 1, W+1) rep(k, 80*160+1) {
        if (!dp[i][j][k]) continue;
        if (i+1 <= H) {
            dp[i+1][j][abs(k+a[i+1][j]-b[i+1][j])] = true;
            dp[i+1][j][abs(k-a[i+1][j]+b[i+1][j])] = true;
        }
        if (j+1 <= W) {
            dp[i][j+1][abs(k+a[i][j+1]-b[i][j+1])] = true;
            dp[i][j+1][abs(k-a[i][j+1]+b[i][j+1])] = true;
        }
    }

    rep(k, 89*160+1) if(dp[H][W][k]) {cout << k << endl; return 0;}
    
    return 0;
}


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

int main(){
	double inp1,inp2;
	while(cin >> inp1 >> inp2){
		string opt="NA";
		if(inp1<35.5 && inp2<71.0){
			opt = "AAA";
		}else if(inp1<37.5 && inp2<77.0){
			opt = "AA";
		}else if(inp1<40.0 && inp2<83.0){
			opt = "A";
		}else if(inp1<43.0 && inp2<89.0){
			opt = "B";
		}else if(inp1<50.0 && inp2<105.0){
			opt = "C";
		}else if(inp1<55.0 && inp2<116.0){
			opt = "D";
		}else if(inp1<70.0 && inp2<148.0){
			opt = "E";
		}
		cout << opt << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a*b / 2 << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 1e5 + 123;
int n ,W ,dp[N] , ans;
main(){
	scanf("%lld%lld" , &n , &W);
	
	for(int i = 1 ; i <= n ; i++){
		int w , v;
		scanf("%lld%lld" , &w , &v);
		for(int j = W - w ; j >= 0 ; j--)
			dp[j + w] = max(dp[j + w] , dp[j] + v);
	}
	for(int j = 0 ; j <= W ; j++)
		ans = max(ans,dp[j]);
	printf("%lld" , ans);
}

Measured memory_bytes: 1024
/*
[abc128] E - Roadwork
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;
const int MAX_Q = 2e5;

enum EV {
    EV_T = 0,
    EV_S = 1,
    EV_D = 2,
};

int N, Q;
int S[MAX_N], T[MAX_N], X[MAX_N];
int D[MAX_Q];

void solve() {
    vector<pair<int, pair<EV, int>>> events;
    for (int i = 0; i < N; i++) {
        events.push_back({S[i] - X[i], {EV_S, X[i]}});
        events.push_back({T[i] - X[i], {EV_T, X[i]}});
    }
    for (int i = 0; i < Q; i++) {
        events.push_back({D[i], {EV_D, i}});
    }
    sort(events.begin(), events.end());

    vector<int> ans(Q);
    set<int> cur;
    for (auto& e : events) {
        switch (e.second.first) {
            case EV_T:
                cur.erase(e.second.second);
                break;
            case EV_S:
                cur.insert(e.second.second);
                break;
            default:
                ans[e.second.second] = cur.empty() ? -1 : *cur.begin();
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        cin >> S[i] >> T[i] >> X[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 24040
N = int(input())
A = list(map(int,input().split()))

minuc = 0
for i in range(N):
    if A[i] < 0:
        minuc += 1
ans = 0
if minuc % 2 == 0:
    for i in range(N):
        ans += abs(A[i])

else:
    for i in range(N):
        A[i] = abs(A[i])
    mina = min(A)
    for i in range(N):
        if mina == A[i]:
            ans -= A[i]
        else:
            ans += A[i]
print(ans)


Measured memory_bytes: 64752
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}
set<int>res;
void dfs(string p)
{
  if ((int)p.length() >= 11)
    return;
  int last = p.back() - '0';
  string temp = p;
  temp += (char)(last + '0');
  if (res.find(stoll(temp)) == res.end())
  {
    res.insert(stoll(temp));
    dfs(temp);
  }
  temp = p;
  if (last > 0)
    temp += (char)(last - 1 + '0');
  if (res.find(stoll(temp)) == res.end())
  {
    res.insert(stoll(temp));
    dfs(temp);
  }
  temp = p;
  if (last < 9)
    temp += (char)(last + 1 + '0');
  if (res.find(stoll(temp)) == res.end())
  {
    res.insert(stoll(temp));
    dfs(temp);
  }
  return;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (int i = 1; i <= 9; i++)
    res.insert(i);
  for (int i = 1; i < 10; i++)
  {
    string t;
    t += (char)(i + '0');
    dfs(t);
  }
  int k;
  cin >> k;
  int count = 0;
  for (auto &x : res)
  {
    count++;
    if (count == k)
    {
      cout << x << endl;
      time();
      return 0;
    }
  }
  time();
  return 0;
}

Measured memory_bytes: 27520
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

Measured memory_bytes: 64364