akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll a, b;
	cin >> a >> b;
	if (a == 1)a = 100;
	if (a == 0)a = 1;
	if (a == 2)a = 10000;
	if (b == 100)b++;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;

constexpr int INF = 1e9+7;

int main(){
    int N;cin>>N;
    int A[N];
    i64 sum=0;
    REP(i,N){
        cin>>A[i];
        A[i] -= i+1;
        sum += A[i];
    }
    sort(A,A+N);
    int maxi,mini;
    i64 ans = 1e15;
    i64 tmp;
    int ce = ceil(sum/double(N));
    int fl = floor(sum/double(N));
    int b[7] = {A[0],A[N/2-1],A[N/2],A[N/2+1],ce,fl,A[N-1]};
    REP(i,7){
        tmp = 0;
        REP(j,N){
            tmp += abs(A[j] - b[i]);
        }
        ans = min(tmp,ans);
    }
    cout << ans;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 1e5 + 7;

int n, h[N], f[N];

int main() {
	int a, b;
	cin >> a >> b;
	printf("%.10lf\n", 1.0 * a / b); 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,n,a,sum=0;
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
		cin>>a,sum+=a;
	if(sum>=h)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
} 

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep (i, n-2) {
        if (s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <set>

using namespace std;

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

int main( int argc, char **argv )
{
    //
    int N, Q;
    cin >> N >> Q;

    priority_queue<event_t, vector<event_t>, greater<event_t>> que;
    for ( int i = 0; i < N; i++ )
    {
        int S, T, X;
        cin >> S >> T >> X;

        que.push( event_t( S - X, P( 1, X ) ) );
        que.push( event_t( T - X, P( -1, X ) ) );
    }

    set<int> set;

    for ( int i = 0; i < Q; i++ )
    {
        int D;
        cin >> D;

        while ( !que.empty() && que.top().first <= D )
        {
            event_t e = que.top();
            que.pop();

            int type = e.second.first;
            int X = e.second.second;

            if ( type == 1 )
                set.insert( X );
            else
                set.erase( X );
        }

        if ( !set.empty() )
            cout << *set.begin() << endl;
        else
            cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 16620
function Main(input) {
  input = input.split(" ");
  var c = input[2];
  var quot = Math.floor(input[1] / input[0]);
  if(quot > c) {
    console.log(c);
  } else {
    console.log(quot);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
s = input()
l = []
for i in range(4):
    l.append(s[i])
lset = list(set(l))
if len(lset) == 2:
    if l.count(lset[0]) == 2 and l.count(lset[1]) == 2:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define inf 0x3f3f3f3f
#define N 262145
#define M 20
using namespace std;
typedef long long ll;
int n,m,V,a[N],l[N][M],r[N][M],f[N],g[N];
bool ans[N];
int main(){
	cin>>n>>V;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int x=V;;x>>=1){
		for(int i=1;i<=n;i++)
			if(i==1||a[i]-a[i-1]>x)l[i][m]=i;
			else l[i][m]=l[i-1][m];
		for(int i=n;i;i--)
			if(i==n||a[i+1]-a[i]>x)r[i][m]=i;
			else r[i][m]=r[i+1][m];
		if(x)m++;
		else break;
	}
	for(int i=0;i<(1<<m);i++)for(int j=0;j<m;j++)if(!(i>>j&1))
		f[i|(1<<j)]=max(f[i|(1<<j)],f[i]==n?n:r[f[i]+1][j+1]);
	for(int i=0;i<(1<<m);i++)g[i]=inf;
	g[0]=n+1;
	for(int i=0;i<(1<<m);i++)for(int j=0;j<m;j++)if(!(i>>j&1))
		g[i|(1<<j)]=min(g[i|(1<<j)],g[i]==1?1:l[g[i]-1][j+1]);
//	cout<<g[1]<<endl;
	for(int i=0;i<(1<<m);i++){
		int L=f[i],R=g[i^(1<<m)-1];
//		cout<<L<<" "<<R<<endl;
		if(L+1>=R){
			for(int j=1;j<=n;j++)ans[j]=1;
			break;
		}
//		cout<<L+1<<" "<<r[L+1][0]+1<<" "<<R<<endl;
		if(r[L+1][0]+1>=R&&!ans[L+1]){
//			cout<<l[0][L]<<" "<<r[0][L]<<endl;
			for(int j=l[L+1][0];j<=r[L+1][0];j++)ans[j]=1;
		}
	}
	for(int i=1;i<=n;i++)puts(ans[i]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 37760
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 int n;
 cin >> n;
 cout << n*800-200*(n/15) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 123456
#define F first
#define S second
#define M 1000000007

using namespace std;
typedef long long ll;
ll a[maxn],s[maxn],dp[105][105],n,b[maxn],ans,m;
set <ll> f;

ll pow_(ll x,ll y){
    ll rt=1;
    while (y){
        if (y&1) rt=rt*x%M;
        x=x*x%M; y>>=1;
    }
    return rt;
}

int main(){
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=1;i<=n;i++) {
        if (f.find(a[i])==f.end()) f.insert(a[i]),b[++m]=a[i];
    }
    sort(b+1,b+m+1);
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (a[i]==b[j]) s[i]=j;
    dp[0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=1;j<=s[i];j++){
            if (j<=s[i+1]) (dp[i+1][j]+=dp[i][j]*pow_(2ll,max(b[s[i+1]]-b[s[i]],0ll)))%=M;
            else (dp[i+1][0]+=dp[i][j]*2)%=M;
        }
        (dp[i+1][0]+=dp[i][0]*2)%=M;
        if (s[i+1]>s[i]){
            for (int j=s[i]+1;j<=s[i+1];j++) (dp[i+1][j]+=dp[i][0]*(pow_(2ll,b[j]-b[j-1]-(j==1))-1)*2%M*pow_(2ll,b[s[i+1]]-b[j]))%=M;
        }
    }
    for (int i=0;i<=s[n];i++) (ans+=dp[n][i])%=M;
    cout << (ans+M)%M << endl;
}



Measured memory_bytes: 384
import java.util.*;


public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			Arrays.sort(data);
			int sum = 0;
			int count = 0;
			for(int i = n-1; i >= 0; i--){
				if(count % 2 == 0){
					sum += data[i];
				}
				else{
					sum -= data[i];
				}
				count++;
			}
			System.out.println(sum);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23508
#include <stdio.h>
#include <string.h>
int main()
{
  int i,j,u,n,v,k,A[1000][1000];

  for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  A[i][j] = 0;
	}
    }
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      scanf("%d",&u);
      scanf("%d",&k);
      if(k == 0) continue;
	/*{
	  for(l = 0;l < n;l++)
	    {
	      A[u-1][l] = 0;
	      }*/
      for(j = 0;j < k;j++)
	{
	  scanf("%d",&v);
	  A[u-1][v-1] = 1;
	}
    }
  for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  if(j > 0) printf(" ");
	  printf("%d",A[i][j]);
	}
      printf("\n");
    }
  return 0;
}
    
  



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    while(h!=0){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0||i==h-1||j==0||j==w-1){cout<<"#";}
             else{cout<<".";  }
        }cout<<endl;
    }cout<<endl;
    cin>>h>>w;
        }
}



Measured memory_bytes: 3100
#include <stdio.h>

int main(){
 int i;
 char str[12];
 for(i=0; i<12; i++){
   scanf("%c", &str[i]);
 }
 for(i=0; i<4; i++){
   printf("%c", str[i]);
 }
 printf(" ");
 for(i=4; i<12; i++){
   printf("%c", str[i]);
 }
 printf("\n");
 return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    double N;
    scanf("%lf", &N);
    if((int)N%2==1) printf("%.7f\n", ((int)N/2+1) / N);
    else puts("0.5");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using  namespace std;
int a[100000];
int search(int n,int m, int k) {
	int all = 0;
	int i = 0;
	for (int t = 0; t < m; t++) {
		all = 0;
		while (all + a[i] <= k)
		{
			all += a[i];
			i++;
			if (i >= n) return 1;
		}
		if (all == 0) return 0;
	}
	return 0;
}
int solve(int n,int m) {
	int min = 1;
	int max = 1000000000;
	while (min<max)
	{
		int midle = (min + max) / 2;
		if (search(n, m, midle)) max = midle;
		else min = midle+1;
	}
	return max;
}
int main(void) {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << solve(n, k)<<endl;

}


Measured memory_bytes: 3484
class UnionFind:
    def __init__(self, n: int) -> None:
        self.forest = [-1] * n

    def union(self, x: int, y: int) -> None:
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.forest[x] > self.forest[y]:
            x, y = y, x
        self.forest[x] += self.forest[y]
        self.forest[y] = x
        return

    def findRoot(self, x: int) -> int:
        if self.forest[x] < 0:
            return x
        else:
            self.forest[x] = self.findRoot(self.forest[x])
            return self.forest[x]

    def issame(self, x: int, y: int) -> bool:
        return self.findRoot(x) == self.findRoot(y)

    def size(self, x: int) -> int:
        return -self.forest[self.findRoot(x)]


n, m, k = map(int, input().split())
u = UnionFind(n)
dire = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    dire[a - 1].append(b - 1)
    dire[b - 1].append(a - 1)
    u.union(a - 1, b - 1)
for i in range(k):
    c, d = map(int, input().split())
    if u.issame(c-1,d-1):
        dire[c - 1].append(d - 1)
        dire[d - 1].append(c - 1)

print(*[u.size(i) - len(dire[i]) - 1 for i in range(n)])


Measured memory_bytes: 41804
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
h = LIST()
h.insert(0, 0)
 
ans = 0
for i in range(1, max(h)+1):
	for j in range(1, len(h)):
		if h[j-1] < i and i <= h[j]:
			ans += 1
 
print(ans)

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;

typedef string::const_iterator State;
class ParseError{};

int factor(State &begin);

int number(State &begin){
    int ret=0;

    while(isdigit(*begin)){
        ret*=10;
        ret+=*begin -'0';
        begin++;
    }
    return ret;
}

int term(State &begin){
    int ret=factor(begin);

    while(true){
        if(*begin=='*')ret*=factor(++begin);
        else if(*begin=='/')ret/=factor(++begin);
        else break;
    }
    return ret;
}

int expression(State &begin){
    int ret=term(begin);
    while(true){
        if(*begin=='+')ret+=term(++begin);
        else if(*begin=='-')ret-=term(++begin);
        else break;
    }
    return ret;
}

int factor(State &begin){
    int ret;
    if(*begin=='('){
        ret=expression(++begin);
        begin++;
    }else{
        ret =number(begin);
    }
    return ret;
}

int main(){

    int N;
    cin>>N;
    cin.ignore();
    string s[N];
    REP(i,N)getline(cin,s[i]);
    REP(i,N){
        s[i]=s[i].substr(0,s[i].size()-1);
        State begin=s[i].begin();
        int ret=expression(begin);
        cout<<ret<<endl;
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  for (char c = 'a'; c <= 'z'; c++) {
    bool b = false;
    rep(i,s.size()) {
      if (s[i] == c) b = true;
    }
    if (b == false) {
      cout << c << endl;
      ans = false;
      break;
    }
  }
  if(ans) cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

#ifdef INPUT
stringstream input(R"(
4 972439611840
)");
#define cin input
#endif

std::map<long long, int> primeFactors(long long n)
{
    std::map<long long, int> m;
    
	for (long long i = 2; i * i <= n; ++i)
    {
		while (n % i == 0)
		{
			++m[i];
			n /= i;
		}
	}
    
	if (n > 1)
        ++m[n];
    
    return m;
} 

int main()
{
    ll n, p, a;
    ll ans = 1;
    cin >> n >> p;

    if (n==1)
        ans = p;
    else if (p == 1)
        ans = 1;
    else
    {
        const auto m = primeFactors(p);
        for (const auto& i:m)
        {
            for (int j=0; j<i.second/n; j++)
            {
                ans *= i.first;
            }
        }
    }

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

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

int main() {
    int n,m,p;
    while(cin>>n>>m>>p,n||m||p){
        int ch[100],mm=0,ans;
        for(int i=1;i<=n;i++){
            cin >> ch[i];
            mm+=ch[i];
        }
        mm*=100;
        if(ch[m]==0) cout << ch[m] << endl;
        else{
            mm=mm*(100-p)/100;
            ans=mm/ch[m];
            cout << ans << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	vector <int> ar(3);
	for (int i = 0; i < 3; ++i) {
		cin >> ar[i];
	}
	sort(ar.begin(), ar.end());
	int ans = 0;
	for (int i = 0; i < 2; ++i) {
		while (ar[i] + 2 <= ar[2]) {
			ans++;
			ar[i] += 2;
		}
	}
	int cnt = 0;
	for (int i = 0; i < 3; ++i) {
		cnt += ar[i] == ar[2];
	}
	ans += cnt % 3;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 29;
	static int nmax = 40;
	static int abmax = 10;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int ma = in.nextInt();
			int mb = in.nextInt();
			int[] a = new int[nmax];
			int[] b = new int[nmax];
			int[] c = new int[nmax];

			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
				c[i] = in.nextInt();
			}

			int[][][] dp = new int[nmax+1][nmax*abmax+1][nmax*abmax+1];
			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= nmax*abmax; j++) {
					for (int k = 0; k <= nmax*abmax; k++) {
						dp[i][j][k] = INF;
					}
				}
			}
			dp[0][0][0] = 0;

			for (int i = 0; i < n; i++) {
				for (int ca = 0; ca <= nmax*abmax; ca++) {
					for (int cb = 0; cb <= nmax*abmax; cb++) {
						if (dp[i][ca][cb] == INF) continue;
						dp[i+1][ca][cb] = Math.min(dp[i+1][ca][cb], dp[i][ca][cb]);
						dp[i+1][ca+a[i]][cb+b[i]] = Math.min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
					}
				}
			}

			int ans = INF;
			for (int ca = 1; ca <= nmax*abmax; ca++) {
				for (int cb = 1; cb <= nmax*abmax; cb++) {
					if (ca*mb == cb*ma) {
						ans = Math.min(ans, dp[n][ca][cb]);
					}
				}
			}

			if (ans == INF) {
				ans = -1;
			}

			out.println(ans);

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 56148
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i = 1;i < N+1;i++){
			if(i < 10){
				ans++;
			}else if(i > 99 && i < 1000){
				ans++;
			}else if(i > 9999 && i < 100000){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#[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 ! 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 ! 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 ) * } } ; }

pub trait Permutation {
    fn next_permutation(&mut self) -> bool;
}
impl<T: Ord> Permutation for [T] {
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }
}

fn rank(p: &Vec<i32>) -> i32 {

    let mut arr: Vec<i32> = vec![];
    for i in 0..p.len() {
        arr.push(i as i32 + 1);
    }
    let mut ret = 0i32;
    loop {
        if arr == *p {
            break;
        }
        ret += 1;
        if !arr.next_permutation() {
            break;
        }
    }
    ret
}

fn main() {
    input! {
        n: usize,
        p: [i32; n],
        q: [i32; n],
    }
    let ret = (rank(&p) - rank(&q)).abs();
    println!("{}", ret);
}


Measured memory_bytes: 2144
/*input

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define pb push_back
#define print(a) cout<<a<<endl
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define all(x) x.begin(), x.end()
#define loop(i,n) for(int i = 0; i < n; i++)
#define getName(x) #x
#define debug(x) cerr<< getName(x) << ":" << x << endl;
//#define int long long int
 
const int MOD = 1e9 + 7;

int fastexpo(int x, int y) 
{ 
    int res = 1;
    x = x % MOD;
    while (y) 
    { 
        if (y & 1) res = (res*x) % MOD; 
        y = y>>1;
        x = (x*x) % MOD;   
    } 
    return res; 
}

int mod(int x, int y){
    return (x%y + y)%y;
}

void solve();

signed main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

const int MAXN = 1e5 + 10;

int dp[MAXN];
bool dont[MAXN];

int n, m;

int solve(int idx){
    if(dont[idx])
        return 0;
    if(idx < 0)
        return 0;
    if(idx == 0)
        return 1;
    if(dp[idx] != -1)
        return dp[idx];
    return dp[idx] = (solve(idx - 1)%MOD + solve(idx - 2)%MOD)%MOD;
}

void solve(){
    mem(dp, -1);
    mem(dont, 0);
    cin>> n >> m;
    for(int i = 0; i < m; i++){
        int x;
        cin>> x;
        dont[x] = 1;
    }
    print(solve(n));
}

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

int main()
{
    int n;
    vector<int> a(300000);
    cin >> n;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.begin() + n);
    rep(i, n - 1)
    {
        if (a[i] == a[i + 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4580
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9 + 7

N,K = map(int,readline().split())
AB = map(int,read().split())

if N == 1:
    print(K)
    exit()
if K == 1:
    print(0)
    exit()

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

fact,fact_inv = make_fact(K+10,MOD)

graph = [[] for _ in range(N+1)]
for a,b in zip(AB,AB):
    graph[a].append(b)
    graph[b].append(a)

# 次数1の頂点を根とする
deg = [len(x) for x in graph]
for i,x in enumerate(deg):
    if x == 1:
        break
root = i

parent = [0] * (N+1)
ts = [root]
stack = [root]
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        ts.append(y)

perm = np.zeros(N+K+10,np.int64)
perm[:K-1] = fact[K-2] * fact_inv[K-2::-1] % MOD
perm = perm.tolist()

dp = [1] * (N+1)
for v in ts[::-1]:
    if v == root:
        break
    d = deg[v]
    dp[v] *= perm[d-1]; dp[v] %= MOD
    p = parent[v]
    dp[p] *= dp[v]; dp[p] %= MOD

x = dp[root]
x *= K*(K-1)%MOD
x %= MOD
print(x)

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

int n;
int a[500000];
int b[500000];
int cnt = 0;

void merge(int l, int r)
{
    if (r - l == 1)
        return;
    int mid = (l + r) / 2;

    merge(l, mid);
    merge(mid, r);

    int lp = l, rp = mid;

    for (int i = l; i < r; i++)
    {

        if (lp == mid)
        {
            b[i] = a[rp];
            rp++;
        }

        else if (rp == r)
        {
            b[i] = a[lp];
            lp++;
        }

        else if (a[lp] < a[rp])
        {
            b[i] = a[lp];
            lp++;
        }

        else
        {
            b[i] = a[rp];
            rp++;
        }
        cnt++;
    }
    for(int i = l; i < r; i++){
        a[i] = b[i];
    }
}
int main()
{
    cin >> n;
    for (int i; i < n; i++)
    {
        cin >> a[i];
    }
    merge(0,n);
    for (int i = 0; i < n; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 6960
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int i, j, k, l, m, n, len;
	int A, B, C, N;
	char S[3];
	ll sum = 0;

	scanf("%d", &N);

	for (i = 1; i <= N; i++){
		if (i % 3 != 0 && i % 5 != 0){
			sum += i;
		}

	}
	printf("%lld\n", sum);
	return 0;

}
    


Measured memory_bytes: 3776
/*
[arc103] E - Tr/ee
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#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;

int N;
string s;

bool solve(vector<pii>& ans) {
    if (s[0] == '0' || s[N - 1] == '1') {
        return false;
    }
    ans.resize(N - 1);
    s[N - 1] = '1';

    int par = 0;
    for (int i = 0; i < N - 1; i++) {
        if (s[i] != s[N - i - 2]) {
            return false;
        }
        while (!(i < par && s[par] == '1')) {
            par++;
        }
        ans[i] = pii(i, par);
    }

    return true;
}

int main() {
    cin >> s;
    N = s.length();

    vector<pii> ans;
    if (!solve(ans)) {
        cout << -1 << endl;
        return 0;
    }
    for (auto& p : ans) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int r = sc.nextInt();
			if (r == 0) {
				sc.close();
				break;
			}

			int n = sc.nextInt();

			int[] xl = new int[n];
			int[] xr = new int[n];
			int[] h = new int[n];
			for (int i = 0; i < n; i++) {
				xl[i] = sc.nextInt();
				xr[i] = sc.nextInt();
				h[i] = sc.nextInt();
			}

			int[] cover = new int[2 * r];
			for (int i = 0; i < n; i++) {
				int ll = Math.max(0, xl[i] + r);
				int rr = Math.min(r * 2, Math.max(0, xr[i] + r));

				for (int j = ll; j < rr; j++) {
					cover[j] = Math.max(cover[j], h[i]);
				}
			}

			double ans = 100000.0;
			for (int i = 0; i < cover.length; i++) {
				int x = Math.abs(r - i);// 円の中心のx座標とビルの角のx座標の距離
				int xx = Math.abs(r - i - 1);// 円の中心のx座標とビルの角の右隣のx座標の距離
				double o1 = cover[i] - Math.sqrt(r * r - x * x);
				double o2 = cover[i] - Math.sqrt(r * r - xx * xx);
				ans = Math.min(ans, Math.min(o1 + r, o2 + r));
			}

			System.out.println(String.format("%.4f", ans));
		}
	}
}

Measured memory_bytes: 26248
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int len = s.size();
    if(s[0] != 'A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int c = 0;
    int upper = 0;
    for(int i = 1; i < len; i++){
        if(isupper(s[i]))upper++;
    }
    for(int i = 2; i < len - 1; i++){
        if(s[i] == 'C')c++;
    }
    if(c == 1 && upper == 1){
        cout<<"AC"<<endl;
    }else{
        cout<<"WA"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int q;
	std::list<long> list;
	std::list<long>::iterator it = list.end();
	

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	q = std::stoi(buf);

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		if(buf[0] == '0'){
			std::istringstream stream(buf);
			int tmp, x;

			stream >> tmp >> x;
			it = list.insert(it, x);
		}
		else if(buf[0] == '1'){
			std::istringstream stream(buf);
			int tmp, d;

			stream >> tmp >> d;

			if(d > 0){
				for(int i = 0; i < d; i++){
					it++;
				}
			}
			else{
				for(int i = 0; i < -d; i++){
					it--;
				}
			}
		}
		else{
			it = list.erase(it);
		}
	}
	for(it = list.begin(); it != list.end(); it++){
		std::cout << *it << std::endl;
	}
	return 0;
}


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

diff = []
for i in range(len(A)):
    if i < N-1:
        diff.append(A[i+1] - A[i])

diff = diff + [K-A[-1]+A[0]]
longest_interval = diff.index(max(diff))
diff.pop(longest_interval)
ans = sum(diff)

print(ans)

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    int N, K;
    cin >> N >> K;

    cout << N - K + 1 << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define INF (int)(1e9 + 7)
#define int long long

signed main()
{
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = K; i <= N + 1; i++)
    {
        int m = i * (i - 1) / 2;
        int M = (2 * N - i + 1) * i / 2;
        ans += M - m + 1;
        ans %= INF;
    }
    cout << ans << endl;
}

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

int t[16];
int ans[31];

void make_table(){
  int a=1;
  t[1]=1;
  for(int i=2;i<16;i++){
    a*=3;t[i]=t[i-1]+a;
  }

  ans[1]=1;
  for(int i=2;i<31;i++){
    ans[i]=t[i/2]+t[i-i/2];
  }
}
int main(){
  make_table();
  int n;
  while(cin>>n)cout<<ans[n]<<endl;
  return 0;
}

Measured memory_bytes: 1160
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
#from operator import itemgetter
from copy import deepcopy
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)]
inf = 10**17
mod = 10**9 + 7

n,a,b=MI()
print(min(a*n,b))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int imx=0;
  int MAX=*max_element(a.begin(),a.end());
  int imin=0;
  int MIN=*min_element(a.begin(),a.end());
  bool g=true;
  if(abs(MIN)>abs(MAX)){g=false;}

  for(int i=0;i<N;i++){
    if(a[i]==MAX){imx=i;}
    if(a[i]==MIN){imin=i;}
  }
  
  vector<pair<int,int>>ans;
  if(g){
    for(int i=0;i<N;i++){
      if(i==imx){continue;}
      a[i]+=MAX;
      ans.push_back(make_pair(imx,i));
    }
    for(int i=0;i<N-1;i++){
      a[i+1]+=a[i];
      ans.push_back(make_pair(i,i+1));
    }
  }
  else{
    for(int i=N-1;i>=0;i--){
      if(i==imin){continue;}
      a[i]+=MIN;
      ans.push_back(make_pair(imin,i));
    }
    for(int i=N-1;i>=1;i--){
      a[i-1]+=a[i];
      ans.push_back(make_pair(i,i-1));
    }
  }
  
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }
  return 0;                       
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

ll gcd(ll a, ll b)
{
    ll r = a % b;
    if (r == 0)
        return b;
    return gcd(b, r);
}

vector<ll> dv;
void divisor(ll n)
{
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            dv.push_back(i);
            if (i * i != n)
                dv.push_back(n / i);
        }
    }
    sort(ALL(dv));
}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    divisor(gcd(a, b));

    OP(dv[dv.size() - k]);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int i;
    int cnt(0);
    rep(i, s.size()) {
        cnt += s[i] != t[i];
    }
    cout << cnt << endl;
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll MOD = 998244353;

constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}


struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val > MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

ll N, A, B, K;
vector<Fp> fact;
vector<Fp> invFact;

Fp combi(ll n, ll r) {
  Fp c = fact.at(n) * invFact.at(r) * invFact.at(n-r);
  DLOG("combi(%lld, %lld) = %lld\n", (ll)n, (ll)r, (ll)c);
  return c;
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> A >> B >> K;
  ll p = 0;
  ll q = 0;
  ll g = eGCD(A, B, p, q);
  if (K % g != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll c = K / g;
  if (p <= 0) {
    swap(A, B);
    swap(p, q);
  }

  fact.resize(N+1);
  fact.at(0) = 1;
  for (int i = 1; i <= N; i++) {
    fact.at(i) = fact.at(i-1) * Fp(i);
  }
  invFact.resize(N+1);
  invFact.at(N) = fact.at(N).inv();
  for (int i = N; i >= 1; i--) {
    invFact.at(i-1) = invFact.at(i) * Fp(i);
  }
  // Apc + Bqc = K, p > 0, q <= 0
  // A(pc-Bt) + B(qc+At) = K, t \in [ (A - 1 - qc) / A, pc / B ]
  Fp cnt = 0;
  ll uA = A / g;
  ll uB = B / g;
  for (ll t = (uA-1 - q*c) / uA; t <= p*c / uB; t++) {
    ll nA = p*c - uB*t;
    ll nB = q*c + uA*t;
    DLOG("nA, nB = %lld, %lld\n", nA, nB);
    if (nA > N || nB > N) continue;
    cnt += combi(N, nA) * combi(N, nB);
  }
  cout << cnt << endl;


  return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>

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

using namespace std;

int n;
int c[100001];

int main(){
  cin >> n;
  rep(i, n){
    int a;
    cin >> a;
    ++c[a];
  }
  int ans = 0;
  int p = 0;
  rep(i, 100001){
    if(c[i] > 0){
      ++ans;
      p += !(c[i] % 2);
    }
  }
  ans -= p % 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s;
	cin >> s;

	int ans = 0;
	if (s=="SUN"){
		ans = 7;
	}
	if (s=="MON"){
		ans = 6;
	}
	if (s=="TUE"){
		ans = 5;
	}
	if (s=="WED"){
		ans = 4;
	}
	if (s=="THU"){
		ans = 3;
	}
	if (s=="FRI"){
		ans = 2;
	}
	if (s=="SAT"){
		ans = 1;
	}



	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
import sys


def solve(N: int, v: "List[int]"):
    v.sort()
    ans = (v[0] + v[1]) / 2
    for i in range(2, N):
        ans = (ans + v[i]) / 2
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61864
n = int(input())
a = list(map(int,input().split()))
b1 = 0
b2 = 0
b4 = 0
for i in range(n):
    c = 0
    while a[i] % 2 == 0:
        c += 1
        a[i] /= 2
    if c == 0:
        b1 += 1
    elif c == 1:
        b2 += 1
    else:
        b4 += 1
if b2 == 0:
    if b1 <= b4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if b1 <= b4:
        print('Yes')
    else:
        print('No')

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

int main() {
  ll N,M;
  cin >> N >> M;
  ll t;
  if((M-2*N)>=0) {
    t=(M-2*N)/4;
    cout << N+t << endl;
  }else {
    cout << M/2 << endl;
  }
}

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

int main(void){
    ll a,b,k;
    cin  >> a >> b >> k;
    
    if(a>=k){a -= k; k = 0;}
    else{k -= a; a = 0;}

    if(b>=k){b -= k; k = 0;}
    else{b = 0;}


    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n;
	int ans=0;
	cin >>n;
	ll c;
	// find; 4abc==Nab+Nbc+Nac;
	// c(4ab-N(b+a))==Nab
	for (int a = 1; a <= 3500;a++){
		for (int b = 1; b <= 3500;b++){
			if ((ll)4 * a * b - n * (a + b) == 0) continue;
			if ((n * a * b) % ((ll)4 * a * b - n * (a + b)) == 0 and
			    (n * a * b) >0 and ((ll)4 * a * b - n * (a + b))>0) {
				c = (n * a * b) / ((ll)4 * a * b - n * (a + b));
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		} 
		}
	//cout << ans << endl;
}

Measured memory_bytes: 3632