akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9 + 7
using namespace std;
typedef long long ll;

ll n, w;
ll dp[100005];
pair<ll, ll> wtv[100005];

int main()
{
    cin >> n >> w;
    for(ll i = 0; i < n; i++) cin >> wtv[i].first >> wtv[i].second;
    for(ll i = 0; i < n; i++) {
        for(ll j = w; j >= wtv[i].first; j--) {
            dp[j] = max(dp[j], dp[j - wtv[i].first] + wtv[i].second);
        }
    }
    cout << dp[w];
    return 0;
}

Measured memory_bytes: 4356
var i,x,N,K,Q:Longint;
A:Array[1..100000]of Longint;
begin
read(N,K,Q);
for i:=1 to N do A[i]:=K-Q;
for i:=1 to Q do begin
read(x);
inc(A[x]);
end;
for i:=1 to N do if A[i]>0 then writeln('Yes')else writeln('No');
end.

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  int odd = 0;
  rep (i, n){
    cin >> v[i];
    if (v[i] % 2 == 1) ++odd;
  }
  if (odd % 2 == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 3728
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
using namespace std;

int main(){
    int a,b;
    string s;
    
    rep(i,0,9){
        cin >> s >> a >> b;
        cout << s << " " << a+b << " " << a*200+b*300 << endl;
    }
    return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int H, W;
  cin>>H>>W;

  if(H == 1 || W == 1) {
    cout<<1<<endl;
    return 0;
  }

  Int ans = H * W /2;
  if(H * W % 2 != 0) ans = H * W - ans;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
h_list=list(map(int,input().split()))
dp_list=[0,abs(h_list[0]-h_list[1])]
for i in range(N-2):
    dp_list.append(min(abs(h_list[i+1]-h_list[i+2])+dp_list[i+1],abs(h_list[i]-h_list[i+2])+dp_list[i]))
print(dp_list[N-1])

Measured memory_bytes: 89864
/*
 * atcoder/abc121/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

struct S {
  ll a, b;
  bool operator<(const S& o)const{
    return a < o.a;
  }
};

const int MAX = 100100;
ll N, M;
S ss[MAX];

void solve() {
  cin >> N >> M;
  ll a, b;
  loop(n,0,N) {
    cin >> a >> b;
    ss[n] = (S){ a, b };
  }
  sort(ss, ss+N);
  ll n = 0;
  ll cost = 0;
  while (M != 0) {
    if (M < ss[n].b) {
      cost += ss[n++].a * M;
      break; // M = 0
    }

    cost += ss[n].a * ss[n].b;
    M -= ss[n].b;
    n++;
  }
  cout << cost << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int main(void){
   char str[101];
   int n,i;

   scanf("%s",str);
   n=strlen(str);

   for(i=0;i<n;i++)
      str[i] = 'x';

   printf("%s\n",str);
   return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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 ll LLINF = 1e+18;

using P = pair<ll,int>;
using Edge = pair<int,ll>;
vector<vector<Edge>> G;
vector<ll> d;

//int V,E,r;
int N;

void dijkstra( int s ) {
    priority_queue<P,vector<P>,greater<P>> que;
    d[s] = 0;
    que.push(P(0,s));
     
    while( que.size() ){
        P p = que.top(); que.pop();
        ll dis = p.first;
        int v = p.second;
        if ( d[v] < dis ) continue;
        for ( int i = 0; i < G[v].size(); ++i){
            Edge e = G[v][i];
            int nv = e.first;
            ll ndis = e.second;
            if ( d[nv] > d[v] + ndis ){
                d[nv] = d[v] + ndis;
                que.push(P(d[nv],nv));
            }
        }
    }
}

int main() {
    /*cin >> V >> E >> r;
    G.resize(V);
    d.resize(V,LLINF);*/
    cin >> N;
    G.resize(N);
    d.resize(N,LLINF);
    
    REP(i,N-1){
        int s,t,d;
        cin >> s >> t >> d; --s; --t;
        G[s].push_back(Edge(t,d));
        G[t].push_back(Edge(s,d));
    }
    
    int Q,K;
    cin >> Q >> K; --K;
    dijkstra(K);
    
    REP(i,Q){
        int x,y;
        cin >> x >> y; --x; --y;
        cout << d[x] + d[y] << endl;
    }

    
    
    return 0;
}


Measured memory_bytes: 13996
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
//window
//scanf
//stdio.h>cstdio
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define wi(x) while(x)
#define fl(i,l,r) for(register int i=(l);i<(r);++i)
#define xfl(i,x,l,r) int *lf=&x[l],*rf=&x[r]; for(register int *i=(lf);i<(rf);++i)
#define xpfl(lf,rf,p,i,x,l,r) p *lf=&x[l],*rf=&x[r]; for(register p *i=(lf);i<(rf);++i)
#define fr(i,r,l) for(register int i=(r-1);i>=(l);--i)
#define ksm(i,x) for(register int i=0;x;x>>=1,i++)
#define pq priority_queue
#define xg(i) vector<i>,greater<i> 
#define fbo friend bool operator 
#define vpb push_back
#define vpp pop_back()
#define ppb push
#define ppp pop()
#define sz size()
#define fun(x) std::cerr << #x << ':' << ' '
#define fu(x) std::cerr << #x << ' '
#define de(x) std::cerr << #x << '=' << x << ' '
#define pi(x) cerr << x <<' ' 
#define petr printf("\n");
#define qwq printf("qwq\n");
#define fmnt 0x3fffffff
#define mnt 0x7fffffff  
#define ll long long
#define mod 
#define maxn 
using namespace std;
/*模板规定:
    1.常使用函数名称固定， 有不同模板库（可建立） 
    2.函数进入模板符合三个条件：
	    （1）正确，得到oj题目验证
		（2）实用，某部分常使用
		（3）在附带注释中注明用途 
	3.模板必须背过 
    4.一般变量名称、define固定含义，如下： 
    #define ll long long
    #define mod //模数 
    #define maxn //n数组大小 或n最大值
	a b c d 函数参数
	x y 变量
	n m t 数据相关
	u v 累计数据
	i j k w 循环
	r ans 返回值
	temp 临时中间变量 
*/ 
//window read()>scanf()
//linux read()<scanf()
template <class T> inline void read(T &x) {
	//读入整型数据 
	x=0;
	char ch=getchar(),w=0;
	while (!isdigit(ch)) w=(ch=='-'),ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=w?-x:x;
	return;
}
template <class T> inline T maxx(T a,T b){
	//取最大值 
	return a>b?a:b;
}
template <class T> inline T minn(T a,T b){
	//取最小值 
	return a>b?b:a;
}
template <class T> inline void swapp(T &a,T &b){
	//交换单个同类数据 
	T c=a;a=b,b=c;
}
template <class T> inline T abss(T a){
	//取绝对值 
	return a?a:(-a);
}
template <class T> inline void piz(T *a,int siza){
	xfl(i,a,0,siza) cerr<<*i<<' ';
	petr;
}
inline int random(int l,int r){
	return (((rand()<<30)+(rand()<<15)+rand())%(r-l+1)+l);
}
inline int randf(int x,int y){
	return random(1,y)<=x;
}
ll n;
vector<ll> a;
ll ans;
void scan(){
	ll x;
	read(n);
	n=(n<<1)-1;
	fl(i,0,n) read(x),a.vpb(x);
}
bool calc(ll z){
	int mid=(n>>1);
	int x,y;
	bool i,j;
	x=mid-1,y=mid+1;
	bool c=(a[mid]>=z);
	wi(y<n){
		i=(a[x]>=z),j=(a[y]>=z);
		if(i==j){
			if(i==c) {/*fu(return:0),pi(c);*/return c;}
	        else c=i; 
		}
		else{
			{/*fu(return:1),pi(c);*/return c;}
		}
		x--,y++; 
	}
	{/*fu(return:2),pi(c);*/return c;}
}
ll erfen(){
	ll l=1,r=n;
	int mid;
	wi(l!=r-1){
		mid=(l+r)>>1;
		//pi(l),pi(mid),pi(r),petr
		if(calc(mid)) { l=mid;}
		else r=mid;
	}
	return l;
}
void deal(){
	ans=erfen();
}
void print(){
	printf("%lld\n",ans);
}

int main(){
	srand((int) time(0));
	scan();
	deal();
	print();
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"
typedef long long ll;

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

  int l = s.size();

  int ans = 0;
  for (int i = 0; i < l; i++)
  {
    if (s[i] != t[i])
    {
      ++ans;
    }
  }

  cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int h,w; cin>>h>>w;
        char ans[h+2][w+2];
        rep(i,h+2)rep(j,w+2)ans[i][j]='#';
        rep(i,h)rep(j,w)cin>>ans[i+1][j+1];
        rep(i,h+2)
        {
                rep(j,w+2)cout<<ans[i][j];
                cout<<endl;
        }
}


Measured memory_bytes: 256
S = gets.chomp
A = S[0,2].to_i
B = S[2,2].to_i

ans = ''

if A <= 12
  if A > 0
    ans << 'MM'
  else
    ans << 'YY'
  end
else
  ans << 'YY'
end

if B <= 12
  if B > 0
    ans << 'MM'
  else
    ans << 'YY'
  end
else
  ans << 'YY'
end

if ans == '' || ans == 'YY' || ans == 'MM' || ans == 'YYYY'
  puts 'NA'
elsif ans == 'MMMM'
  puts 'AMBIGUOUS'
else
  puts ans
end


Measured memory_bytes: 1788
S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    if S[j] == 0:
        continue

    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

    for k in range(len(IDXs)):
        S[IDXs[k]] = 0
        T[IDXs[k]] = 0

print(ans)

Measured memory_bytes: 18512
#python3
def main():
    n = int(input())
    s = input()
    cnt = 0
    for i in range(10):
        ind_i = s.find(str(i))  
        if ind_i == -1:
            continue
        for j in range(10):
            ind_j = s.find(str(j), ind_i+1)
            if ind_j == -1:
                continue
            for k in range(10):
                ind_k = s.find(str(k), ind_j+1)
                if ind_k == -1:
                    continue
                cnt += 1
    print(cnt)
main()


Measured memory_bytes: 3060
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=2e5+99;

ll count(ll A, ll B, ll M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
    return (B / M) - (A / M); 
}

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

    ll ans=count(a,b,c) + count(a,b,d);

    ll x=__gcd(c,d);
    ll ta=c/x;
    ta=ta*d;

    ans-=count(a,b,ta);
    ans=b-a+1-ans;
    cout<<ans<<endl;


}




 


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
vector<int> V[MC];
int d[2][MC];
int ans;

void dfs(int p , int q , int z){
	for(auto u : V[q]){
		if(u == p) continue;
		d[z][u] = d[z][q] + 1;
		dfs(q,u,z);
	}
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N){
		int a,b;
		scanf("%d%d" , &a , &b);
		V[a].PB(b);
		V[b].PB(a);
	}
	dfs(-1,1,0);
	dfs(-1,N,1);
	repp(i,1,N+1){
		if(d[0][i] > d[1][i]) --ans;
		else ++ans;
	}
	printf("%s\n" , ans > 0 ? "Fennec" : "Snuke");
	return 0;
}


Measured memory_bytes: 14336
D,G = map(int,input().split())

p = [0] * (D+1)
c = [0] * (D+1)

for i in range(1,D+1):
    p[i],c[i] = map(int,input().split())

#print(p,c)
can = []
for k in range(2 ** D):
    x = [0] * (D+1)
    kk = k
    score = [0] * (D+1)
    count = 0
    for j in range(1,D+1):
        x[j] = kk % 2
        kk //= 2
        score[j] = x[j] * (j * p[j] + c[j]//100)
        count += x[j] * p[j]
    s = sum(score)
    deffer = G//100 - s
    num = D
    left = p[:]
    while deffer > 0 and num > 0:
        if x[num] == 1 or left[num] == 1:
            num -= 1
        else:
            deffer -= num
            left[num] -= 1
            count += 1
    if deffer <= 0:
        #print(x,count,score)
        can.append(count)

print(min(can))  

Measured memory_bytes: 41452
from collections import deque
n=int(input())
ans=deque(['a'])
while True:
  a=ans.popleft()
  if len(a)==n:
    ans.appendleft(a)
    break
  m=max(a)
  for i in range(ord(m)-96+1):
    ans.append(a+chr(97+i))
print(*ans,sep='\n') 

Measured memory_bytes: 88904
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();

		int[] a = new int[n];

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

		Arrays.sort(a);


		boolean flag = false;

		for(int i = 0; i < n-1; i++) {
			if(a[i]==a[i+1]) {
				flag = true;
			}
		}

		if(flag) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}

	}

}


Measured memory_bytes: 64932
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

int main(void){
    
    int n;
    int cnt=1, ans=0;
    int flag=0;
    
    scanf("%d", &n);
    
    for (int z=1; z<=n-1; z++) {
        flag=0;
        cnt=0;
        for (int i=1; i<=sqrt(z); i++) {
            if (z%i==0) {
                cnt++;
                if (z==i*i) {
                    flag++;
                }
            }
        }
        cnt*=2;
        if (flag) {
            cnt-=flag;
        }
        ans+=cnt;
    }
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, M;
  cin>>N>>M;

  vector<Int> A(N);
  cin>>A;

  vector<P> q(M);
  for(Int i=0;i<M;i++){
    Int b, c;
    cin>>b>>c;
    q[i] = P(c, b);
  }

  sort(A.begin(), A.end());
  sort(q.begin(), q.end(), greater<P>());

  Int j = 0;
  for(Int i=0;i<N;i++){
    if(j < (int)q.size() && q[j].second == 0) j++;
    if(j == (int)q.size()) break;
    if(A[i] < q[j].first) A[i] = q[j].first, q[j].second--;
  }


  Int ans = 0;
  for(Int i=0;i<N;i++) ans += A[i];
  cout<<ans<<endl;
  

  
  
  

  return 0;
}


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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c =='e' || c =='i' || c =='o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string str;
  std::cin >> str;
  int ans;
  std::cin >> ans;
  std::vector<std::string> dic;
  for (int i = 0; i < str.length(); i++) {
    for (int j = 1; j <= str.length() - i && j <= ans; j++) {
      dic.push_back(str.substr(i, j));
    }
  }
  // for (int i = 0; i < dic.size(); i++) std::cout << dic[i] << std::endl;
  std::sort(dic.begin(), dic.end());
  dic.erase(std::unique(dic.begin(), dic.end()), dic.end());
//for (int i = 0; i < dic.size(); i++) std::cout << dic[i] << std::endl;
  std::cout << dic[ans - 1] << std::endl;
  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;

int main() {
	ll n, r;
	cin >> n >> r;
	if (n >= 10) { cout << r << endl; }
	else cout << 100 * (10 - n) + r << endl;
	return 0;
}

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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include "atcoder/fenwicktree.hpp"
using namespace std;
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
class BIT{
public:
    int n;
    vector<T> bit; // 1-indexed

    BIT():n{0}{}
    BIT(int n_in):n{n_in}{
        bit.assign(n+1,0);
    }

    void init_u(){
        for(int i=1;i<n;i++)if(i+(i&-i)<=n) bit[i+(i&-i)]+=bit[i];
    }

    void add(int k,T w){
        if(k<=0) return;
        for(int i=k;i<=n;i+=i&-i) bit[i]+=w;
    }

    //(0,k]
    T sum(int k) const{
        T res=0;
        for(int i=k;i>0;i-=i&-i) res+=bit[i];
        return res;
    }

    //(l,r] 累積和区間と同じ
    T secsum(int l,int r) const{
        return sum(r)-sum(l);
    }

    //各要素は非負整数とする
    //w->w+1でupper_bound
    int lower_bound(T w) const{
        if(sum(n)<w) return n+1; //範囲外
        int idx=0,r=1;
        while(r<n) r<<=1;
        for(int len=r;len>0;len>>=1){
            if(idx+len<n && bit[idx+len]<w){
                w-=bit[idx+len];
                idx+=len;
            }
        }
        return idx+1;
    }
};

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

    int n,q; cin>>n>>q;
    BIT<ll> bit{n};
    rep(i,n){
        int a; cin>>a;
        bit.bit[i+1]=a;
    }
  	bit.init_u();    
    rep(_,q){
        int t,l,r; cin>>t>>l>>r;
        if(t==0){
            bit.add(l+1,r);
        }
        else{
            printf("%lld\n",bit.secsum(l,r));
        }
    }
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	string  S, T; cin >> S >> T;
	T.pop_back();
	std::cout << (S==T ? "Yes" : "No")<< std::endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python

def main():
    n = int(input())
    cnt = 0

    for i in range(1, n+1, 2):
        div = 0
        for j in range(1, i+1, 2):
            if i % j == 0:
                div += 1
            if div > 8:
                break
        if div == 8:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import math

d,gg = map(int,input().split())

p,c = [],[]

for i in range(d):
    pp,cc = map(int,input().split())
    p.append(pp)
    c.append(cc)

ans = 1145141919
for i in range(1 << d):
    g = gg
    cnt = 0
    sum = 0
    for j in range(d):
        if (1 << j) & (i):
            sum += (p[j]*(1+j)*100+c[j])
            cnt += p[j]
    
    g -= sum
    if (g <= 0) : 
        ans = min(ans,cnt)
        continue
    for j in list(reversed(range(d))):
        if (1 << j) & (i) == 0:
            aa = math.ceil(g/((1+j)*100))
            g -= ((1+j)*100)*min(aa,p[j]-1)
            cnt += min(aa,p[j]-1)
            break
    if (g <= 0) : ans = min(ans,cnt)

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    char c[202020];
    scanf("%s", c);
    int l = strlen(c);
    
    // 2. ? を 'D' に 置き換える.
    rep(i, l) if(c[i] == '?') c[i] = 'D';
    
    // 3. 出力.
    string ans(c);
    printf("%s\n", ans.c_str());
    return 0;
    
}

Measured memory_bytes: 3884
n = gets.to_i
hotels= gets.split.map(&:to_i)
count = 0
max = 0

(1..n-1).each do |i|
  if hotels[i-1] > max
    max = hotels[i-1]
  end
  
  if hotels[i] >= max
    count += 1
  end
end

puts count + 1

Measured memory_bytes: 3836
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let a = read::<i32>();
  let b = read::<i32>();
  let t = read::<i32>();

  println!("{:?}", (t / a) * b);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;

vector<int>g[N];
int dp[N];

int dfs(int u){
    if(dp[u]) return dp[u];
    if(g[u].size() == 0)return 0;
    for(int to: g[u]){
        int ans = dfs(to);
        dp[u] = max(dp[u], (ans + 1));
    }
    return dp[u];
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
    }
    for(int i = 1; i <= n; i++){
        if(dp[i] == 0){
            dfs(i);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dp[i]);
    }
    printf("%d\n", ans);

    
}

Measured memory_bytes: 11736
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    int d,t,s;
    cin>>d>>t>>s;
    if((int)ceil(1.0*d/s)>t)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const int mod = int(1e9 + 7);
const int N = int(1.1e5);
int dp[N][2];
vector<int> g[N];
int n;

int dfs(int u, int p, int c) {
  if(dp[u][c] != -1) return dp[u][c];
  int res = 1;
  for(int x: g[u]) if (x != p) {
    if(!c) {
      res = ((ll) res *  (ll) dfs(x, u, 1)) % mod;
    } else {
      int nx = (dfs(x, u, 0) % mod + dfs(x, u, 1) % mod) % mod;
      res = ((ll) res * (ll) nx) % mod;
    }
  }
  return dp[u][c] = res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  memset(dp, -1, sizeof dp);
  for(int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v;
    u--, v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  int res = (dfs(0, -1, 0) % mod + dfs(0, -1, 1) % mod) % mod;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 13824
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  vector<ll>A(3);
  rep(i,3)cin>>A[i];
  sort(all(A));
  cout<<abs(A[1]-A[0])+abs(A[1]-A[2])<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let k: usize = read();
    let s: String = read();
    if s.len() <= k {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k]);
    }
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    bool judge = false;
    if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2])judge = true;
    else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1])judge = true;
    else if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1])judge = true;
    if(judge)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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




Measured memory_bytes: 29664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  string s;
  int ans;
  
  cin >> s;
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner sc     = new Scanner(System.in);
  double r       = sc.nextDouble();
  double pi      = Math.PI;
  double area    = r*r*pi;
  double length  = 2*r*pi;
  System.out.printf("%f %f\n", area,length);
  }
}



Measured memory_bytes: 28116
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

using ll = long long;
using ld = long double;
using vll = std::vector< ll >;
using pll = std::pair< ll, ll >;
using vvll = std::vector<vll>;
using vpll = std::vector< pll >;


#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for(__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define cntll(a) __builtin_popcountll((a))
#define ff first
#define ss second
#define mk make_pair
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){}
template<typename T , typename... Args>
void err(istream_iterator<string> it , T a , Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it , args ... );
}

ll sum(){ return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args){ return a + sum(args...);}
const ll MOD = 1e9+7;
////////////////////////////////////////////////////////////////////////////////////////////////////////

ll k[11];
ll s[11][11];
ll p[11];

signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////


	ll n , m;
	cin >> n >> m;

	rep(i,0,m){
		cin >> k[i];
		rep(j,0,k[i]){
			cin >> s[i][j];
			s[i][j]--;
		}
	}

	rep(i,0,m){
		cin >> p[i];
	}

	ll ans = 0;
	for(ll mask = 0 ; mask<(1<<n) ; ++mask){
		ll on[11];
		rep(i,0,n)
			on[i] = 0;

		for(ll i = 0 ; i<n ; ++i){
			if(1&(mask>>i)){
				on[i] = 1;
			}
		}

		ll cnt = 0;
		for(ll i = 0 ; i<m ; ++i){
			ll g = 0;
			rep(j,0,k[i]){
				if(on[s[i][j]]){
					g++;
				}
			}

			if(g%2 == p[i]%2){
				cnt++;
			}
		}

		if(cnt == m){
			// cout<<mask<<endl;
			// for(ll i = 0 ; i<n ; ++i){
			// 	cout<<on[i]<<" ";
			// }
			// cout<<endl;
			ans++;
		}
	}
	cout<<ans<<endl;

	
	return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std; 

int main (void) {

  int N;
  int a[1100];
  int i,j;

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

  int color[10] = {0};
  int count = 0;
  for (i=0; i<N; i++) {
    for (j=0; j<8; j++) {
      if(400*j <= a[i] && a[i] < 400*(j+1)){
	color[j] = 1;
      }
    }
    if(a[i]>=3200){
      count++;
    }
  }

  int min_ans = 0;

  for (i=0; i<8; i++){
    min_ans += color[i];
  }

  if(min_ans==0){
    cout << 1 << " " << min_ans + count << endl;
  } else {
    cout << min_ans << " " << min_ans + count << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
 
int main(){
    bool f[101];for(int i=0;i<101;i++){f[i]=true;}
    int x, n;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        int tmp;cin>>tmp;
        f[tmp] = false;
    }
    int lx = x;
    int rx = x;
    while(1){
        if(lx<0 || (f[lx])){co(lx);return 0;}
        if(f[rx]){co(rx);return 0;}
        lx--;rx++;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{

   int n;
   cin >> n;
   n--;
   int v[n+1];
   for(int i  = 1; i <=n; i++) cin >> v[i];

   int sum = v[1];
   for(int i = 1; i < n; i++) sum += min(v[i],v[i+1]);
   sum+=v[n];  cout << sum;


}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

vector<int> V[210000];
int d[210000];
int color[210000];

//二部グラフならtrueを返す
void dfs(int x){
  color[x]=1;
  //cout<<endl;
  //cout<<x<<endl;
  for(int i=0;i<(int)V[x].size();i++){
    //cout<<V[x][i]<<endl;
    //隣接している頂点が同じ色ならfalse
    if(color[V[x][i]]==0){
      d[V[x][i]]+=d[x];
      dfs(V[x][i]);
    }
    //隣接している頂点がまだ塗られていないなら-cで塗る
  }
}

int main(){
  int N,Q,a,b,p,x;
  cin>>N>>Q;

  for(int i=0;i<N-1;i++){
    cin>>a>>b;
    V[a].push_back(b);
    V[b].push_back(a);
  }

  for(int i=0;i<Q;i++){
    cin>>p>>x;
    d[p]+=x;
  }
  //cout<<V[4].size()<<endl;
  //cout<<"unko"<<endl;
  dfs(1);
  for(int i=1;i<=N;i++) cout<<d[i]<<endl;
}


Measured memory_bytes: 24576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong()-1;		
        long c = 0;
        for(long i=2;i<=Math.sqrt(a);i++){if(a%i==0){c+=2;}if(i==Math.sqrt(a)){c--;}
                                         }
        if(a>=2){c++;}
        a++; 
        long e,f,g;
        for(long i=2;i<=Math.sqrt(a);i++){
          if(a%i==0){
          if(i<Math.sqrt(a)){g=a;e=i;f=a/i;                                                              
                             while(g%e==0){g/=e;}                                                                     
                             if(g%e==1){c++;}                                                                     
                             g=a;
                             while(g%f==0){g/=f;}                                                                  
                             if(g%f==1){c++;}                                                                  
                            }
                              else{c++;}                                                                          
                    }                                        
        }
        c++;
        System.out.println(c);                                  
	}
}


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

int main(){
    int N;
    cin >> N;
    int check = 0;
    for(int i=0;i<=N;i++){
        if(i % 4 == 0 && (N - i) % 7 == 0){
            check = 1;
        } 
    }
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
const int N=2e5+100;
vector <int> g[N];
ll dis[N];
queue <int> q;
ll bfs(){
    while(q.size()){
        ll v=q.front();
        q.pop();
        for (int i=0;i<g[v].size();i++){
            ll u=g[v][i];
            if (dis[u]>dis[v]+1){
                dis[u]=dis[v]+1;
                q.push(u);
            }
        }
    }
}
int32_t main(){
    ll n,k;
    cin >> n >> k;
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    ll ans=0;
    for (int i=1;i<=n;i++){
        memset(dis,69,sizeof dis);
        dis[i]=0;
        q.push(i);
        bfs();
        ll ma=0;
        for (int j=1;j<=n;j++){
            if (dis[j]<=k/2){
                ma++;
            }
        }
        ans=max(ans,ma);
    }
    for (int i=1;i<=n;i++){
        for (int l=0;l<g[i].size();l++){
            ll v=g[i][l];
            memset(dis,69,sizeof dis);
            dis[i]=0;
            dis[v]=0;
            q.push(i);
            q.push(v);
            bfs();
            ll ma=0;
            for (int j=1;j<=n;j++){
                if (dis[j]<=(k-1)/2){
                    ma++;
                }
            }
            ans=max(ans,ma);
        }
    }
    cout << n-ans;

}


Measured memory_bytes: 6656
a, b = map(int, input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

print(len(set(factorize(a))&set(factorize(b)))+1)

Measured memory_bytes: 3060
// Code using recursion.

#include <stdio.h>
#include <vector>

using namespace std;

// TODO: replace with DP
class Solver {
 public:
  Solver(const int* A, size_t n, int max)
      : A_(A), n_(n), max_(max) {
    memo_.resize(20);
    for (size_t i = 0; i < 20; ++i) {
      memo_[i].resize(max_);
    }
  }

  int solve(size_t i, int m) {
    if (m == 0) return 1;
    if (i >= n_ || m < 0 || m > max_) return 0;
    if (memo_[i][m]) return 1;

    const int res = solve(i + 1, m) || solve(i + 1, m - A_[i]);
    if (res) {
      memo_[i][m] = 1;
    }
    return res;
  }

 private:
  const int* A_;
  size_t n_;
  int max_;

  vector<vector<int> > memo_;
};

int main() {
  size_t n;
  int A[20];

  scanf("%lu", &n);
  int max = 0;
  for (size_t i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
    max += A[i];
  }

  Solver solver(A, n, max);

  int q;
  scanf("%d", &q);
  int m = 0;
  for (int i = 0; i < q; ++i) {
    scanf("%d", &m);
    if (solver.solve(0, m)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 1080
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

void solve(){
    int n, m;
    cin >> n >> m;
    vector<bool> oks(n+1, true);
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        oks[a] = false;
    }

    vector<long long int> dp(n+1);
    dp[0] = 1;
    for(int now=0; now < n; now++){
        for(int next=now+1; next <= min(n, now+2); next++){
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[n] << endl;
}

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

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

lli mod_pow(lli n, lli p, lli mod) {
    lli res = 1;
    while (p > 0) {
        if (p & 1) {
            res = res * n % mod;
        }
        n = n * n % mod;
        p >>= 1;
    }
    return res;
}
int main() {
    lli n;
    cin1(n);
    lli d[n];
    ncin1(n,d);
    lli count[n] = {0}; // i の数
    REP(i,0,n) {
        count[d[i]]++;
    }
    if (count[0] != 1 || d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    bool exist = true;
    REP(i,0,n) {
        if (!count[i])
            exist = false;
        if (!exist && count[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    //REP(i,2,n) {
    //    if (count[i] == 0)
    //        break;
    //    cout2(i, count[i]);

    //}
    lli ans = 1;
    lli mod = 998244353;
    REP(i,1,n) {
        if (count[i] == 0)
            break;
        ans = (ans * mod_pow(count[i], count[i+1], mod)) % mod;

    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(){
    int a,b;
    char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '?'){
        break;
    }if(op == '+'){
        printf("%d\n",a+b);
    }if(op == '-'){
        printf("%d\n",a-b);
    }if(op == '*'){
        printf("%d\n",a*b);
    }if(op == '/'){
        printf("%d\n",a/b);
    }
    }
    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char *argv[] )
{
	int x,y;

	scanf("%d%d",&x,&y);
	int ans=0,tmp=abs(y)-abs(x);
	if(x>=0 && y>0){
		if(tmp>0)ans=tmp;
		else if(tmp<0)ans=-tmp+2;
	}
	else if(x>=0 && y<=0){
		if(tmp>0)ans=tmp+1;
		else if(tmp<0)ans=-tmp+1;
		else ans=1;
	}
	else if(x<0 && y>0){
		if(tmp>0)ans=tmp+1;
		else if(tmp<0)ans=-tmp+1;
		else ans=1;
	}
	else if(x<0 && y<=0){
		if(tmp>0)ans=tmp+2;
		else if(tmp<0)ans=-tmp;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string S;
	cin >> S;
	int ret = 0;
	for (char ope : S) {
		if (ope == '+') {
			ret++;
		}
		else {
			ret--;
		}
	}

	cout << ret;
	return 0;
}

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

int main(){
    int H, W;

    while( cin>>H>>W ){
        if(H==0 && W==0){
            break;
        }else{
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    return 0;
}
            

Measured memory_bytes: 1152