akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 300005;

int h, w, m, hi, wi, c[MAXN], r[MAXN];

int main(){
	scanf("%d %d %d", &h, &w, &m);
	
	set < pair <int, int> > s;
	
	for(int i = 0; i < m; i++){
		scanf("%d %d", &hi, &wi);
		hi--, wi--;
		
		r[hi]++;
		c[wi]++;
		
		s.insert(make_pair(hi, wi));
	}
	
	int rmx = *max_element(r, r + h);
	int cmx = *max_element(c, c + w);
	
	vector <int> vr, vc;
	for(int i = 0; i < h; i++)
		if(r[i] == rmx)vr.push_back(i);
	for(int i = 0; i < w; i++)
		if(c[i] == cmx)vc.push_back(i);
	
	bool found = false;
	for(int x : vr){
		for(int y : vc){
			if(!s.count(make_pair(x, y))){
				found = true;
				break;
			}
		}
		if(found)break;
	}
	
	if(found)printf("%d\n", rmx + cmx);
	else printf("%d\n", rmx + cmx - 1);
	
	return 0;
}


Measured memory_bytes: 23836
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());

//        String str1 = scan.next();
//        int int3 = Integer.parseInt(scan.next());
//        String str1 = scan.next();

        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";

        ans_int = (int2 - int1) + int2;

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 23252
n=int(input())
b=[]
a=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
def f(x):
	b=[]
	y=x
	for i in range(len(a)):
		x=y
		cnt=0
		while cnt>=0:
			if x%a[i]==0:
				cnt+=1
				x=x//a[i]
			else:
				break
		b.append(cnt)
	ans=1
	for i in range(len(b)):
		ans*=b[i]+1
	return ans
ans=0
for j in range(1,n+1,2):
	if f(j)==8:
		ans+=1
print(ans)




Measured memory_bytes: 3064
from fractions import gcd
A,B,C,D=map(int,input().split())
#CとDのどちらかで割り切れる
#=(Cで割り切れる)+(Dで割り切れる)-(lcm(C,D)で割り切れる)
L=(C*D)//gcd(C,D)
#(i-1)<A/C<=i
#i*C<=B<(i+1)C
i=(B//C)-(-((-A)//C))+1
j=(B//D)-(-((-A)//D))+1
k=(B//L)-(-((-A)//L))+1
print(B-A+1-(i+j-k))


Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }
int main(){
  string S;
  cin>>S;
  if(S=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N){
        rep(i,N)par[i]=i;
    }

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

    void unite(int x, int y){
        if(root(x)==root(y))return;
        par[root(x)]=root(y);
    }

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

int main(){
    int N,M;
    cin>>N>>M;
    int p[N];
    rep(i,N)cin>>p[i];
    UnionFind tree(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        tree.unite(a-1,b-1);
    }
    int ans=0;
    rep(i,N){
        if(tree.same(i,p[i]-1))ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3996
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;



public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	   	int n = sc.nextInt();
	   	int m = sc.nextInt();
	   	int sum = 0;
	   	for(int i = 0; i < m; i++) {
	   		int a = sc.nextInt();
	   		sum+=a;
	   	}
	   	sum = n-sum;
	   	if(sum < 0) {
	   		System.out.println(-1);
	   	}
	   	else {
	   		System.out.println(sum);
	   	}
	}
}

Measured memory_bytes: 46304
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

class UnionFind {
public:
  vector<int> par, rank;
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
  inline bool isroot(int x) const { return par[x] < 0; }
};

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> vv(h);
  rep(i,h) cin>>vv[i];
  vector<vector<bool>> v(h,vector<bool>(w));
  rep(i,h) rep(j,w) v[i][j] = vv[i][j] == '#';
  vector<vector<int>> num(h,vector<int>(w));
  rep(i,h) rep(j,w) num[i][j] = i*w + j;

  UnionFind uf(h*w);
  rep(i,h) rep(j,w){
    if(i<h-1 && v[i][j] != v[i+1][j]) uf.unite(num[i][j], num[i+1][j]);
    if(j<w-1 && v[i][j] != v[i][j+1]) uf.unite(num[i][j], num[i][j+1]);
  }

  vector<long> a(h*w,0), b(h*w,0);
  rep(i,h) rep(j,w){
    if(v[i][j]) a[uf.find(num[i][j])]++;
    else b[uf.find(num[i][j])]++;
  }

  long ans = 0;
  rep(i,h*w) ans += a[i]*b[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4864
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
struct Info {
    int low, high, cnt;
};

int N;
string S;
vector<vector<int>> g;

vector<Info> info;

void dfs (int x, int p) {
    info[x] = Info {(1<<30), 0, 0};

    info[x].cnt = (S[x] == '1');

    vector<pair<int, int>> upd;

    for (auto v : g[x]) {
        if (v != p) {
            dfs (v, x);

            info[x].cnt += info[v].cnt;
            info[x].high += info[v].high + info[v].cnt;

            upd.emplace_back(info[v].low + info[v].cnt, info[v].high + info[v].cnt);
        }
    }

    if (!upd.size()) {
        info[x].low = info[x].high;
        return;
    }

    int mx = -1;
    int idx = -1;

    for (int i = 0; i < upd.size(); i++) {
        if (upd[i].second > mx) {
            mx = upd[i].second;
            idx = i;
        }
    }

    int other = 0;
    for (int i = 0; i < upd.size(); i++) {
        if (i != idx) {
            other += upd[i].second;
        }
    }

    info[x].low = max (info[x].high % 2, upd[idx].first - other);
}

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

    cin >> N;
    cin >> S;

    g.resize(N);

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    bool ok = false;
    int bst = (1<<30);

    for (int i = 0; i < N; i++) {
        info.resize(N);

        dfs (i, i);

        if (!info[i].low) {
            // debug() << "works: " << i;

            // for (int j = 0; j < N; j++) {
            //     debug() << j << " " << info[j].low << " " << info[j].high << " " << info[j].cnt;
            // }

            ok = true;
            bst = min(bst, info[i].high / 2);
        }
    }

    if (ok) {
        cout << bst << "\n";
    } else {
        cout << -1 << "\n";
    }

    return 0;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    for (int i=1; i<=9; i++) {
        if (n%i == 0) {
            if (n/i >= 1 && n/i <= 9) {
                cout << "Yes" << endl;
                break;
            }
        }
        if (i==9) {
            cout << "No" << endl;
        }
    }
    return 0;
}



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

int main(){
	
	string j;
	getline(cin, j);

	if(j[0] == '7' || j[1] == '7' || j[2] == '7'){
		cout << "Yes"<< endl;
	}
	else{
		cout << "No"<< endl;
	}
}

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

int main() {
	string s;
	cin >> s;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3;
	else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) cout << 2;
	else if(s[0] != 'R' && s[1] != 'R' && s[2] != 'R') cout << 0;
	else cout << 1;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <functional>
    #include <bits/stdc++.h>
     
     
    using namespace std;
     
    int n,k, c, dp[100001];
    vector<int> h;
     
    int cost(int i)
     
    {
        if(i==n-1)
            return 0;
        if(dp[i]!=-1) return dp[i];
        else
        {
            dp[i]=999999999;
            for(int j=1;j<=k && i+j<n;j++)
            {
                        dp[i]= min(dp[i],cost(i+j)+abs(h[i]-h[i+j]));
            }
        }
        return dp[i];
    }
     
    int main()
    {
        std::ios::sync_with_stdio(false);
      	memset(dp,-1,sizeof dp);
        h.clear();
        int x;
        cin>>n>>k;
        for(int i=0; i<n; i++)
        {
            cin>>x;
            h.push_back(x);
        }
        cout<<cost(0);
      return 0;
     
    }

Measured memory_bytes: 5880
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
int main() {
    vl a(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a.begin(),a.end());
    if (a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
res = math.pi/2
hx = 0
hy = a
mx = 0
my = b
ho = res-2*math.pi*(h/12 + m/720)
mi = res-2*math.pi*m/60
hx = a*math.cos(ho)
hy = a*math.sin(ho)
mx = b*math.cos(mi)
my = b*math.sin(mi)

print(math.sqrt((hx-mx)**2 + (hy-my)**2))


Measured memory_bytes: 62564
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = 1e9 + 7;

int main() {
	ll n, m; cin >> n >> m;

	ll ans = 1900 * m + (n - m) * 100;
	ans *= pow(2, m);

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


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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  long long ans=0;
  for(int i=0; i<N; i++){
    long long temp;
    cin >> temp;
    A.at(i)=temp-i-1;
  }
  sort(A.begin(), A.end());
  long long dif;
  if(N%2==0) dif=(A.at(N/2)+A.at(N/2-1))/2;
  else dif=A.at((N-1)/2);
  for(int i=0; i<N; i++) ans+=abs(A.at(i)-dif);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll MAXN = 1e5 + 10;
ll seg[4*MAXN],lazy[4*MAXN];
ll dp[MAXN];

void propogate(ll node,ll s,ll e){
    seg[node] = min(seg[node],lazy[node]);

    if(s != e){
        lazy[2*node] = min(lazy[node],lazy[2*node]);
        lazy[2*node+1] = min(lazy[node],lazy[2*node+1]);
    }
}

void update(ll node,ll s,ll e,ll qs,ll qe,ll val){
    propogate(node,s,e);
    
    if(s > e || qs > e || qe < s) return;

    if(qs <= s && e <= qe){
        lazy[node] = min(lazy[node],val);
        propogate(node,s,e);
        return;
    }

    ll mid = (s+e)>>1;
    update(2*node,s,mid,qs,qe,val);
    update(2*node+1,mid+1,e,qs,qe,val);

    seg[node] = min(seg[2*node],seg[2*node+1]);
}

const ll INF = 1e17;
ll query(ll node,ll s,ll e,ll pos){
    propogate(node,s,e);
    if(s > e) return INF;

    if(s == e){
        return seg[node];
    }

    ll mid = (s+e)>>1;
    if(pos <= mid) return query(2*node,s,mid,pos);
    else return query(2*node+1,mid+1,e,pos);
}

vector<pair<ll,ll>> startt[MAXN];

void solve(){
    ll n,m; cin>>n>>m;

    FOR(i,0,4*n) seg[i] = lazy[i] = INF;

    FOR(i,1,m){
        ll l,r,c; cin>>l>>r>>c;
        startt[l].push_back({r,c});
    }

    dp[1] = 0;

    update(1,1,n,1,1,0);
    FOR(i,1,n){
        dp[i] = query(1,1,n,i);
        for(auto v:startt[i]){
            update(1,1,n,i,v.first,v.second + dp[i]);
        }
    }

    if(dp[n] >= INF) dp[n] = -1; 
    cout<<dp[n]<<endl;
}

signed main(){

   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 12672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int m = sc.nextInt();
			//System.out.println(String.format("面積:%d周の長さ:%d", n * m, 2 * (n + m)));
			System.out.println(String.format("%d %d", n * m, 2 * (n + m)));
		}
	}

}


Measured memory_bytes: 26304
from collections import deque

N, M, Q = map(int, input().split())

l = [list(map(int, input().split())) for _ in range(Q)]

def calc(li):
    score = 0
    for a, b, c, d in l:
        if li[b-1]-li[a-1] == c:
            score += d
    return score

que = deque([[i] for i in range(1, M+1)])
ans = 0

while que:
    li = que.popleft()
    if len(li) == N:
        score = calc(li)
        ans = max(ans, score)
    else:
        for i in range(li[-1],M+1):
            next = li + [i]
            que.append(next)
    #print(que)

print(ans)


Measured memory_bytes: 23104
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
    re int t=0;
    re char v=getchar();
    while(v<'0'||v>'9')v=getchar();
    while(v>='0'&&v<='9') {
        t=(t<<3)+(t<<1)+(v^48);
        v=getchar();
    }
    return t;
}
int n,m,ans,k;
bool vis[100002];
signed main(){
    n=read();m=read();
    while(m--){
        k=read();
        while(k--)vis[read()]=1;
    }
    for(re int i=1;i<=n;++i)if(!vis[i])++ans;
    printf("%d",ans);
}

Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<int> lstBss = new List<int>();
            for (int i = 0; i < sS.Length; i++)
            {
                lstBss.Add(int.Parse(sS[i]) - 1);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<int> lstSub = new List<int>();
            for (int i = 0; i < iN; i++) { lstSub.Add(0); }
            for (int i = 0; i < lstBss.Count; i++)
            {
                lstSub[lstBss[i]] += 1;
            }

            // 出力
            for (int i = 0; i < lstSub.Count; i++)
            {
                System.Console.WriteLine("{0}", lstSub[i].ToString().Trim());
            }

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int X,t;
  cin>>X>>t;
  cout<<max(0,X-t)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int lim=1e5;
int tot,n,ans;
int p[lim+5],vis[lim+5];
ll a[lim+5];
map<ll,ll>cnt,arc;
void getp(){
	rep(i,2,lim){
		if(!vis[i])p[++tot]=i;
		rep(j,1,tot){
			if(i*p[j]>lim)break;
			vis[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}
int main(){
	getp();
	read(n);
	rep(i,1,n){
		read(a[i]);
		ll now=1,nxt=1;
		rep(j,1,2200)if(a[i]%p[j]==0){
			int cnt=0;
			while(a[i]%p[j]==0)a[i]/=p[j],cnt++;
			cnt%=3;
			if(cnt){
				rep(i,1,cnt)now*=p[j];
				rep(i,1,3-cnt){
					if(1.*nxt*p[j]>1e10)nxt=0;
					nxt*=p[j];
				}
			}
		}
		ll j=sqrt(a[i])-5;
		while((j+1)*(j+1)<=a[i])j++;
		if(j*j==a[i]){
			now*=a[i];
			if(1.*nxt*j>1e10)nxt=0;
			nxt*=j;
		}else{
			now*=a[i];
			if(1.*nxt*a[i]*a[i]>1e10)nxt=0;
			else nxt*=a[i]*a[i];
		}
		if(nxt!=0){
			arc[now]=nxt;
			arc[nxt]=now;
			cnt[now]++;
		}else ans++;
	}
	for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();it++){
		if(it->w1==0)continue;
		ll now=it->w1;
		if(it->w2>cnt[arc[now]]||(it->w2==cnt[arc[now]]&&now<arc[now]))ans+=it->w2;
	}
	if(cnt[1])ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 22016
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	a=a*n;
	cout<<min(a,b);
	return 0;
}

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

typedef long long ll;
ll MOD = 1e9+7;
ll bit[70];

int main()
{
	ll a,b;
	ll ans=0;
	cin>>a>>b;
	fill(bit,bit+70,0);
	int i=0;
	while((ll)pow(2,i)<=b)
	{
		ll tmp=(ll)pow(2,i);
		bit[i]=(b/tmp/2-a/tmp/2)*tmp;//基本数
		cerr<<tmp<<" "<<bit[i]<<endl;
		//調整
		//下
		if(a%(tmp*2)>=tmp)
		{
			bit[i]-=a%(tmp*2)-tmp;
		}
		//上
		if(b%(tmp*2)>=tmp)
		{
			bit[i]+=b%(tmp*2)-tmp+1;
		}
		i++;
	}

	for(ll j=0;j<64;j++)
	{
		//cerr<<bit[j]<<" ";
		if(bit[j]%2==1)
			ans+=(1LL<<j);
	}
	//cerr<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
s = [int(input()) for _ in range(n)]

if np.all(np.array(s) % 10 == 0):
  print(0)
  exit()

s.sort()
score = sum(s)
i = -1
while score % 10 == 0:
  i += 1
  if s[i] % 10 == 0:
    continue
  score -= s[i]
  if i == n:
    break
  
print(score)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  
  if((b*10+c)%4==0){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

int main(){
  int W,H,N;
  cin>>W>>H>>N;
  vector<bool> A(W,true),B(H,true);
  for(int i=0;i<N;i++){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1)
      for(int i=0;i<x;i++)
        A.at(i)=false;
    else if(a==2)
      for(int i=x;i<W;i++)
        A.at(i)=false;
    else if(a==3)
      for(int i=0;i<y;i++)
        B.at(i)=false;
    else
      for(int i=y;i<H;i++)
        B.at(i)=false;
  }
  int x=0,y=0;
  for(bool b:A)
    if(b)
      x++;
  for(bool b:B)
    if(b)
      y++;
  cout<<x*y<<endl;
}

Measured memory_bytes: 256
// atcoder/sumitrust2019/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    lli x = -1;
    for (lli i = 0; i <= n; ++i) {
      lli m = i;
      m *= 108;
      m /= 100;
      if (m == n) {
        x = i;
        break;
      }
    }
    if (x == -1) cout << ":(" << endl;
    else cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        (a*b>=c*d)?cout<<(a*b)<<endl:cout<<(c*d)<<endl;
    }
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, m] <- f
  unless (n == 0 && m == 0) $ do
    solve m <$> sortBy (flip compare) <$> map g <$> replicateM n f >>= print
    main
  where
    f = map read <$> words <$> getLine
    g [d, p] = (p, d)
    
solve :: Int -> [(Int, Int)] -> Int
solve m = fst . foldl' f (0, m)
  where
    f (ct, bg) (p, d)
      | bg >= d = (ct, bg - d)
      | otherwise = (ct + (d - bg) * p, 0)



Measured memory_bytes: 11304
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  cout<<N*N<<endl;
  return 0;
}

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


int main(){
    int N,M; cin>>N>>M;
    priority_queue<long long int> q;
    long long int x;
    for(int i=0;i<N;i++){
        cin>>x;
        q.push(x);
    }
    for(int i=0;i<M;i++){
        x=q.top()/2;
        q.pop();
        q.push(x);
    }
    long long int ans=0;
    while(!q.empty()){
        ans=ans+q.top();
        q.pop();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    int A[100010];
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A,A+N,greater<int>());
    vec v;int i=0,count=0;
    while(count<2 && i<N-1){
        if(A[i]==A[i+1]){
            v.push_back(A[i]);
            count++;
            i+=2;
        }
        else i++;
    }
    if(count<2)cout<<0<<endl;
    else cout<<(ll)v[0]*(ll)v[1]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end() 
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN=410000;
const int MAXK=18;
const int INF = 1e9;
const ll MOD = 998244353;

ll N,R,Q,a,b,c,d,e,f;
vi A,B,C;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N;
	N%=1000;
  if(N==0)cout<<0;
else 	cout<<1000-N;
}

Measured memory_bytes: 3648
s = list(input())
l = len(s)
a = ''
if l%2 != 0:
    for i in range(l//2+1):
        a = a + "".join(s[2*i])
else:
    for i in range(l//2):
        a = a + "".join(s[2*i])
print(a)

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

int main(){
    int a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    if(k <= a){
        ans = k;
    }else if(k <= a + b + c){
        ans = a - (k - a - b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    for(int i=0;i<s.length();i++) {
    	if(s.substring(i, i+1).equals("7")) {
    		System.out.println("Yes");
    		System.exit(0);
    	}
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 35712
#include<stdio.h>

#include<stdlib.h>

#include<string.h>


int main(void){
char num_str[1002];
int num;
long long int sum =0;
int i;
char tmp;

	while(1){
	fgets(num_str,1002,stdin);
	if(num_str[0]=='0') break;
	for(i=0;i<strlen(num_str)-1;i++){
		tmp = num_str[i];
		num = atoi(&tmp);
		sum = sum + num;
	}

	printf("%lld\n",sum);
	sum = 0;
	memset(num_str,1002,0);
}
return 0;}

Measured memory_bytes: 532
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int cost[101][101];
int d[101];
bool used[101]={};
int n,k;
#define INF 10000000
int V;
void dijkstra(int s){
	fill(d,d+101,INF);
	fill(used,used+101,false);
	d[s]=0;
	while(1){
		int c=-1;
		for(int u=0;u<V;u++){
			if(!used[u] && (c==-1 || d[u]<d[c])){
				c=u;
			}
		}
		if(c==-1){
			break;
		}
		used[c]=true;
		for(int i=0;i<V;i++){
			d[i]=min(d[i],d[c]+cost[c][i]);
		}
	}
}
int main(){
	while(1){
	scanf("%d %d",&n,&k);
	if(!(n+k)) break;
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			cost[i][j]=INF;
		}
	}
	V=n;
	for(int i=0;i<k;i++){
		int q;
		scanf("%d",&q);
		if(q){
			int r,o,p;
			scanf("%d %d %d",&r,&o,&p);
			cost[r-1][o-1]=min(p,cost[r-1][o-1]);
			cost[o-1][r-1]=min(p,cost[o-1][r-1]);
		}else{
			int r,p;
			scanf("%d %d",&r,&p);
			dijkstra(r-1);
			if(d[p-1]==INF){
				printf("%d\n",-1);
			}else{
				printf("%d\n",d[p-1]);
			}
		}
	}
	}
	return 0;
}

Measured memory_bytes: 1068
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val L = readLine()!!.split(" ").map {it.toInt()}.sorted()

    val mp = TreeMap<Int, Long>()
    mp[0] = 0L
    L.forEach {
        if (mp.isEmpty()) {
            mp[it] = 1L
        } else if (mp.lastKey() == it) {
            mp[it] = mp[it]!! + 1L
        } else {
            mp[it] = mp.lastEntry().value + 1L
        }
    }
    val keys = mp.keys.toList()

    var res = 0L

    for (i in 1 until keys.size) for (j in i + 1 until keys.size) {
        val l = Math.max(Math.abs(keys[i] - keys[j]), keys[j])
        val u = keys[i] + keys[j]

        if (u - l < 2) continue

        val a = mp.ceilingEntry(l)
        val b = mp.lowerEntry(u)

        if (b == null) continue

        val c = count(mp, keys, i)
        val d = count(mp, keys, j)

        res += (b.value - a.value) * c * d
    }

    for (i in 1 until keys.size) {
        val m = count(mp, keys, i)

        if (m >= 2) {
            val u = keys[i] * 2

            val b = mp.lowerEntry(u)

            if (b == null) continue

            res += m * (m - 1) / 2 * (b.value - m)
        }

        if (m >= 3) {
            res += m * (m - 1) * (m - 2) / 6
        }
    }

    println(res)
}

private fun count(
    mp: TreeMap<Int, Long>,
    keys: List<Int>,
    i: Int
) = mp[keys[i]]!! - mp[keys[i - 1]]!!


Measured memory_bytes: 41684
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
S = input()
S = S.replace('><', '>,<').split(',')
ans = 0
for w in S:
    a = w.count('<')
    b = w.count('>')
    mx = max(a, b)
    mn = min(a, b)
    ans += mx * (mx + 1) // 2 + (mn - 1) * mn // 2
print(ans)



Measured memory_bytes: 19856
//header{{{
//#define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    for(int i = k; i < n; ++i){
        if(a[i] > a[i-k]){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 4696
import sys
input = sys.stdin.readline
read = sys.stdin.read

n = int(input())
A = map(int, read().split())
L = sorted([(j, i) for i, j in enumerate(A)])
count = 0
for i in range(n):
  if (L[i][1]-i)%2:
    count += 1
ans = (count+1) // 2
print(ans)

Measured memory_bytes: 23552
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, q;
    int[] s, t;
    int i, j, c;

    n = sc.nextInt();
    s = new int[n];
    for(i = 0;i < n;i++){
      s[i] = sc.nextInt();
    }
    q = sc.nextInt();
    t = new int[q];
    for(i = 0;i < q;i++){
      t[i] = sc.nextInt();
    }

    c = 0;
    for(i = 0;i < q;i++){
      for(j = 0;j < n;j++){
        if(t[i] == s[j]){
          c++;
          break;
        }
      }
    }

    System.out.println(c);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 30968
import java.util.Scanner;
import java.util.HashMap;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] a = new int[N + 10];
    int ans = 0;
    for (int i = 0; i < N; i++){
      a[i] = scanner.nextInt();
    }
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for (int i = 0; i < N; i++){
      if (!map.containsKey(a[i])){
        map.put(a[i], 1);
      } else {
        map.put(a[i], map.get(a[i]) + 1);
      }
    }
    for (int key : map.keySet()) {
      if(key <= map.get(key)){
        ans += map.get(key) - key;
      } else {
        ans += map.get(key);
      }
    }
    System.out.println(ans);
  }
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int x[N+1], y[M+1];
  cin >> x[0] >> y[0];
  for (int i=1;i<N+1;i++){
    cin >> x[i];
  }
  
  for (int j=1;j<M+1;j++){
    cin >> y[j];
  }
  sort(x, x+N+1);
  sort(y, y+M+1);
  //cout << x[0] << " " << x[N] << endl;
  //cout << y[0] << " " << y[M] << endl;
  if (y[0] - x[N] > 0){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int_;
inline int readint() {
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0' or c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c and c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
void writeint(int_ x){
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) writeint(x/10);
	putchar((x%10)^48);
}
# define MB template < typename T >
MB void getMax(T &a,const T &b){ if(a < b) a = b; }
MB void getMin(T &a,const T &b){ if(b < a) a = b; }
# define FOR(i,n) for(int i=0; i<(n); ++i)

struct Edge{
	int to, nxt;
	Edge(){}
	Edge(int T,int N):to(T),nxt(N){}
};

const int MaxN = 200005, infty = (1<<30)-1;
int a[MaxN], head[MaxN], n;
Edge edge[MaxN<<1];

int cntEdge;
void addEdge(int x,int b){
	edge[cntEdge] = Edge(b,head[x]);
	head[x] = cntEdge ++;
	edge[cntEdge] = Edge(x,head[b]);
	head[b] = cntEdge ++;
}

int g[MaxN], ans[MaxN], sxy[MaxN];
void dfs(int x,int pre){
	ans[x] = lower_bound(g+1,g+n+1,a[x])-g;
	int origin = g[ans[x]];
	g[ans[x]] = a[x];
	sxy[x] = max(sxy[pre],ans[x]);
	for(int i=head[x]; ~i; i=edge[i].nxt)
		if(edge[i].to != pre)
			dfs(edge[i].to,x);
	g[ans[x]] = origin;
}

int main(){
	cin >> n;
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		head[i] = -1, g[i] = infty;
	}
	for(int i=1; i<n; ++i){
		int p, q; cin >> p >> q;
		addEdge(p,q);
	}
	dfs(1,0);
	for(int i=1; i<=n; ++i)
		cout << sxy[i] << endl;
	return 0;
}

Measured memory_bytes: 24956
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  string s,t;
  cin>>s >> t;
  if(sz(s)!=sz(t)-1){
    cr("No");
  }
  for (ll i = 0; i < sz(s); ++i){
      if(s[i]!=t[i]){
        cr("No");
      }
  }
  cr("Yes");
  
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 998244353;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 3e3+1;
int n, s, dp[N][N], a[N];
int main()
{
  fastio;
  int n, s; cin >> n >> s;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++){
    for (int j = 0; j <= s; j++){
      dp[i][j] = 2 * dp[i - 1][j] % MOD;
      if (j - a[i] >= 0) (dp[i][j] += dp[i - 1][j - a[i]]) %= MOD;
    }
  }
  cout << dp[n][s];
  return 0;
}

Measured memory_bytes: 38740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 998244353;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

//二項係数nCrの計算
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

ll n, m, k;
ll ans;

int main() {

	COMinit();

	cin >> n >> m >> k;

	rep(i, k + 1) {
		ans = (ans + (((COM(n - 1, i) * m) % mod) * modpow(m - 1, n - 1 - i, mod) % mod)) % mod;
	}

	cout << ans << endl;

	return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
const double PI=3.14159265358979323846;

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

ll n,k;
ll a[120];
ll dp[(int)1e5+10];




int main() {


  cout<<fixed<<setprecision(10);
  cin>>n>>k;
  rep(i,n) cin>>a[i];

  memset(dp, -1, sizeof(dp));
  // dp[0] = 0;

  rep(i, k){
    if(dp[i] < 0) dp[i] = 0;
    rep(j, n){
      ll nxt = i + a[j];
      if(nxt>k) continue;
      chmax(dp[nxt], dp[i]^1);
    }
  }



  if(dp[k]) puts("First");
  else puts("Second");

}
//


Measured memory_bytes: 1024
n,m = (int(x) for x in input().split())
alist = [int(i) for i in input().split()]
ans = 0
arfa = sum(alist)/(4*m)

for i in range(n):
    if alist[i]>=arfa:
        ans += 1

if ans>=m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

struct Graph {
    static constexpr int64_t C = -1LL << 60;
    struct Edge { int i, c; };
    struct Vertex { int64_t c; };
    Graph(int n) : n(n), e(n), v(n, { C }) {}
    void add_edge(int i, int j, int c) {
        e[i].push_back({ j, c });
    }
    bool bellman_ford(int64_t& r) {
        v[0].c = 0;
        for (int k = 1; k < n * 2; k++) {
            for (int i = 0; i < n; i++) {
                if (v[i].c == C) continue;
                for (auto o : e[i]) {
                    int64_t t = v[i].c + o.c;
                    if (t > v[o.i].c) {
                        v[o.i].c = t;
                        if (k >= n && o.i == n - 1) return true;
                    }
                }
            }
        }
        r = v[n - 1].c;
        return false;
    }
    vector<vector<Edge>> e;
    vector<Vertex> v;
    int n;
};

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

    int n, m;
    cin >> n >> m;

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
    }

    int64_t r;
    bool b = g.bellman_ford(r);
    if (b) cout << "inf"; else cout << r;
    cout << endl;

    return 0;
}

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


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    ABC = []
    for x in range(X):
        for y in range(Y):
            if ((x+1)*(y+1)) > K:
                break
            for z in range(Z):
                if ((x+1)*(y+1)*(z+1)) > K:
                    break
                ABC.append(A[x]+B[y]+C[z])

    ABC.sort(reverse=True)

    for k in range(K):
        print(ABC[k])



# Generated by 1.1.4 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()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(X) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(Y) ]  # type: "List[int]"
    C = [ int(next(tokens)) for _ in range(Z) ]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iSt = int.Parse(sS[0]);
            int iEd = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = iSt; i <= iEd; i++)
            {
                string sSrc = i.ToString();
                char[] cSrc = sSrc.ToCharArray();                       // 文字列反転
                Array.Reverse(cSrc);                                    // 文字列反転
                string sRev = new string(cSrc);                         // 文字列反転
                if (sSrc == sRev) { iOut += 1; }
            }

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 17360
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
string str;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline ll check(ll l,ll r)
{
	for(register int i=l,j=r;i<=r;i++,j--)
	{
		if(str[i]!=str[j])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	cin>>str;
	if(check(0,str.length()-1)&&check(0,(str.length()-1)/2-1)&&check((str.length()+3)/2-1,str.length()-1))
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
}

Measured memory_bytes: 256