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

#define for_(i,a,b) for(int i=a;i<b;++i)

struct Edge {
	int v, c, h, r;
	Edge(int v_, int c_, int h_, int r_ = 0) : v(v_), c(c_), h(h_), r(r_) {}
	bool operator > (const Edge& e) const { return c > e.c; }
};

void update(int& a, int b) { a = min(a, b); }

int N, M, H, K, s, t, P, d[1 << 8], pas[1 << 8];
vector< vector< Edge > > edges;

int dp[2][1 << 8], cost[110][25];

int djk(int S) {
	for_(i,0,N) for_(j,0,25) cost[i][j] = 1e9;
	
	priority_queue< Edge, vector< Edge >, greater< Edge > > q;
	q.push(Edge(s, 0, 0));
	cost[s][0] = 0;
	
	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		
		if (cost[e.v][e.h] < e.c) continue;
		
		for_(i,0,(int)edges[e.v].size()) {
			Edge ei = edges[e.v][i];
			int c = (S >> ei.r & 1) ? 0 : ei.c;
			
			if (e.h + ei.h <= H && cost[ei.v][e.h + ei.h] > e.c + c) {
				cost[ei.v][e.h + ei.h] = e.c + c;
				q.push(Edge(ei.v, e.c + c, e.h + ei.h));
			}
		}
	}
	
	int res = 1e9;
	for_(i,0,H+1) update(res, cost[t][i]);
	return res;
}

void solve() {
	for_(S,0,(1<<K)+1) dp[0][S] = 1e9;
	dp[0][0] = 0;
	
	for_(i,0,P) {
		for_(S,0,(1<<K)) dp[1][S] = 1e9;
		
		for_(S,0,(1<<K)) {
			if (dp[0][S] == 1e9) continue;
			update(dp[1][S], dp[0][S]);
			update(dp[1][S | pas[i]], dp[0][S] + d[i]);
		}
		
		swap(dp[0], dp[1]);
	}
	
	int ans = 1e9;
	for_(S,0,(1<<K)) {
		if (dp[0][S] == 1e9) continue;
		update(ans, djk(S) + dp[0][S]);
	}
	
	cout << (ans < 1e9 ? ans : -1) << endl;
}

int main() {
	while (cin >> N >> M >> H >> K, N) {
		edges.assign(N, vector< Edge >());
		
		for_(i,0,M) {
			int a, b, c, h, r;
			cin >> a >> b >> c >> h >> r;
			--a; --b; --r;
			edges[a].push_back(Edge(b, c, h, r));
			edges[b].push_back(Edge(a, c, h, r));
		}
		
		cin >> s >> t >> P;
		--s; --t;
		
		for_(i,0,P) {
			int l; cin >> l >> d[i];
			
			pas[i] = 0;
			for_(j,0,l) {
				int k; cin >> k; --k;
				pas[i] |= 1 << k;
			}
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1352
program main
	implicit none
    integer(8)::len1,a,b,c,i,nmax,nmin
    character(10**5+1)::s
    read(*,*) s
    a=0
    b=0
    c=0
    len1=len_trim(s)
    do i=1,len1
    	if(s(i:i)=='a')then
        	a=a+1
        else if (s(i:i)=='b')then
        	b=b+1
        else
        	c=c+1
        end if
    end do
    nmax=max(a,max(b,c))
    nmin=min(a,min(b,c))
    if(nmax-nmin<=1)then
    	write(*,*) 'YES'
    else 
    	write(*,*)'NO'
    end if
    stop
end program main
    	



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

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

        ll N;
        ll i,k;
        ll ans=0;
        ll ctr=0;

        cin >> N;

        vector<ll> gv(N);
        rep(i,N) cin >> gv[i];

        for(i=1;i<N;i++){
                if(gv[i-1]>gv[i]){
                        ans+=gv[i-1]-gv[i];
                        gv[i]+=gv[i-1]-gv[i];
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 4776
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  
  cin >> x;
  ll y=0;
  for(ll i=0;i<360;i++){
    y+=x;
    y%=360;
    ans++;
    if (y==0)break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
var
  s:string;
  i,sc,sf:longint; 
 begin
  read(s);
  sc:=123456789;
  for i:=1 to length(s) do if s[i]='F'then sf:=i; 
  for i:=length(s) downto 1 do if s[i]='C'then sc:=i;
  if sc<sf then writeln('Yes')
           else writeln('No');
 end.

Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
x = int(input())
result = 0
for num_a in range(a+1):
  for num_b in range(b+1):
    rest = x - 500*num_a - 100*num_b
    if rest >= 0 and c >= int(rest / 50):
      result += 1
print(result)

Measured memory_bytes: 3060
from collections import deque

h,w=map(int,input().split())
a=[list(input()) for j in range(h)]
x=[0,0]#xが"#"を仮定

def next_point_is_ok1(i,j):
    global a,h
    if i < h-1:
        return a[i+1][j]=="#"
    else:
        return False

def next_point_is_ok2(i,j):
    global a,w
    if j < w-1:
        return a[i][j+1]=="#"
    else:
        return False


def next_points():
    global x,a
    #print(x)
    if x==[h-1,w-1]:
        #print(0)
        if a == [["." for i in range(w)] for j in range(h)]:
            print("Possible")
        else:
            print("Impossible")
    elif next_point_is_ok1(x[0],x[1]):
        #print(1)
        x[0]+=1
        a[x[0]][x[1]]="."
        next_points()
    elif next_point_is_ok2(x[0],x[1]):
        #print(2)
        x[1]+=1
        a[x[0]][x[1]]="."
        next_points()
    else:
        #print(3)
        print("Impossible")

#print(a)
if a[0][0]==".":
    print("Impossible")
else:
    a[0][0]="."
    next_points()


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

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

    int n, x;
    cin >> n >> x;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    long long cost = 0;
    for(int i = 1; i < n; i++){
        if(A[i - 1] + A[i] > x){
            cost += A[i - 1] + A[i] - x;
            A[i] -= A[i - 1] + A[i] - x;
            A[i] = max(0LL, A[i]);
        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
	char x,y;
	scanf("%c %c",&x,&y);
	if(x > y) printf(">\n");
	else if(x < y) printf("<\n");
	else if(x = y) printf("=\n");
	return 0;
	}

Measured memory_bytes: 256
def solve():
    n = int(input())
    s = input()
    ans = 1
    mod = 1000000007
    for i in range(26):
        c = chr(ord('a') + i)
        a = s.count(c)
        a = (a + 1) % mod
        ans = (ans * a) % mod

    ans = (ans + mod - 1) % mod
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
S = list(input())
for i in range(len(S)):
    if S[i] != '?':
        S[i] = int(S[i])
    else:
        S[i] = -1

R = [[None]*10 for i in range(13)]
for i in range(13):
    for j in range(10):
        R[i][j] = (10*i+j) % 13

Q = [[] for i in range(13)]
for j in range(10):
    for i in range(13):
        Q[R[i][j]] += [[i,j]]

dp = [[0]*13 for i in range(len(S)+1)]
dp[0][0] = 1

for i in range(len(S)):
    for j in range(13):
        if S[i]!=-1:
            dp[i+1][j] += dp[i][Q[j][S[i]][0]]%1000000007
        else:
            for k in range(10):
                dp[i+1][j] += dp[i][Q[j][k][0]]%1000000007

print(dp[len(S)][5]%1000000007)

Measured memory_bytes: 70392
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int ans=-1;
    char pre='a';
    string s;cin >>s;
    int n=s.size();
    for (int i = 0; i < n; ++i) {
        if(pre!=s[i]){
            ans++;
            pre=s[i];
        }
    }
    cout <<ans <<endl;
}



Measured memory_bytes: 3688
a, b = map(int, input().split())
ans = 0
if a < b:
  for i in range(b):
    ans = ans + a * (10 ** i)
elif a > b:
  for i in range(a):
    ans = ans + b * (10 ** i)
else:
  for i in range(a):
    ans = ans + a * (10 ** i )
    
print(ans)

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

int N, M;
std::vector<int> p, x, y;
vector<int> flag;
vector<set<int> > to;
vector<set<int> > youso;

void dfs(int i)
{
    if (flag[i] == 1) return;
    flag[i] = 1;
    youso.back().insert(i);
    for (auto j : to[i]) dfs(j);
    return;
}

int main()
{
    cin >> N >> M;
    p.resize(N);
    x.resize(M);
    y.resize(M);
    for (int i=0; i<N; i++) cin >> p[i];
    for (int i=0; i<M; i++)
    {
        cin >> x[i] >> y[i];
    }

    // 置換で移りあえるやつらを同値関係としてN点のノードを分類したい
    to.resize(N);
    for (int i=0; i<M; i++)
    {
        // x[i], y[i] 同士が新たに同値とわかる
        to[x[i]-1].insert(y[i]-1);
        to[y[i]-1].insert(x[i]-1);
    }

    // 各同値類の代表元をとる
    vector <int> daihyo;
    flag = vector<int>(N, 0);

    for (int tmp=0; tmp<N; tmp++)
    {
        if (flag[tmp] == 0)
        {
            daihyo.push_back(tmp);
            youso.push_back(set<int>{tmp});
            dfs(tmp);
        }
    }

    int ans = 0;
    for (int i = 0; i < daihyo.size(); i++)
    {
        for (auto j : youso[i])
        {
            if (youso[i].find(p[j]-1) != youso[i].end()) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 27568
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<int> arr(n * 2), vis(n * 2);
  for (int i = 0; i < n * 2; i++) {
    cin >> arr[i];
    if (~arr[i]) {
      arr[i]--;
      vis[arr[i]] = true;
    }
  }
  vector<int> del(n * 2);
  for (int i = 0; i < n * 2; i += 2) {
    if (~arr[i] && ~arr[i + 1]) {
      del[arr[i]] = del[arr[i + 1]] = true;
    }
  }
  vector<vector<int> > dp(n * 2 + 1, vector<int>(n * 2 + 1));
  dp[0][0] = 1;
  for (int i = 0; i < n * 2; i++) {
    if (del[i]) {
      continue;
    }
    vector<vector<int> > nxt(n * 2 + 1, vector<int>(n * 2 + 1));
    for (int x = 0; x <= n * 2; x++) {
      for (int y = 0; y <= n * 2; y++) {
        if (dp[x][y]) {
          if (vis[i]) {
            if (y < n * 2) {
              (nxt[x][y + 1] += dp[x][y]) %= MOD;
            }
            if (x) {
              (nxt[x - 1][y] += (long long)dp[x][y] * x % MOD) %= MOD;
            }
          } else {
            if (x < n * 2) {
              (nxt[x + 1][y] += dp[x][y]) %= MOD;
            }
            if (y < n * 2) {
              (nxt[x][y + 1] += dp[x][y]) %= MOD;
            }
            if (y) {
              (nxt[x][y - 1] += dp[x][y]) %= MOD;
            }
          }
        }
      }
    }
    dp.swap(nxt);
  }
  long long ans = dp[0][0];
  for (int i = 0, j = 0; i < n * 2; i += 2) {
    if (arr[i] == -1 && arr[i + 1] == -1) {
      j++;
      ans = ans * j % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a[3];
    for(int i=0;i<3;i++)cin>>a[i];

    sort(a,a+3);
    cout<<a[2]*10+a[1]+a[0]<<endl;

 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
	long N;
	cin >> N;
	vector<long> a(N);
	rep(i, 0, N)
	{
		cin >> a[i];
	}
	long min_1 = 1e+6;
	long count = 0;
	rep(i, 0, N)
	{
		if (min_1 >= a[i])
		{
			count++;
			min_1 = min(min_1, a[i]);
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static int N = 0;
        static void Main(string[] args)
        {
            var a = new int[5];
            for (int i = 0; i < 5; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            var k = int.Parse(Console.ReadLine());

            var can = true;
            for (int i = 0; i < 5; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    if (Math.Abs(a[i] - a[j]) > k)
                    {
                        can = false;
                        break;
                    }
                }
                if (can == false)
                {
                    break;
                }
            }

            Console.WriteLine(can ? "Yay!" : ":(");
        }
    }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, W;
ll w[105], v[105], DP[105][int(1e5+5)];

int main(){
  cin >> N >> W;
  for (int i = 1; i <= N; i++){
    cin >> w[i] >> v[i];
  }

  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= W; j++){
      DP[i][j] = DP[i-1][j];
    }
    for (int j = 0; j + w[i] <= W; j++){
      DP[i][j+w[i]] = max(DP[i][j+w[i]], DP[i-1][j] + v[i]);
    }
  }
  cout << DP[N][W] << endl;

  return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }

    vector<ll> c(n);
    ll sum = 0LL;
    rep(i, n){
        c[i] = a[i] + b[i];
        sum += b[i];
    }

    sort(c.rbegin(), c.rend());
    ll ans = 0LL;
    for(int i = 0; i < n; i += 2){
        if(i < n)ans += c[i];
    }
    ppp(ans - sum);


    return 0;
}


Measured memory_bytes: 2560
from itertools import product

N=int(input())

k=len(str(N))

l=[3,5,7]

P_list=[]

for j in range(3,k+1):
    for i in product(l,repeat=j):
        temp=list(map(str,i))
        P_list.append("".join(temp))

cnt=0

for i in P_list:
    if ("3" in i) and ("5" in i) and ("7" in i):
        if int(i)<=N:
            cnt+=1
print(cnt)

Measured memory_bytes: 5236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   string S;
   cin>>S;
   
   ll n;
   n= S.size() ;
   char s='s';
    if(S[n-1]==s){
      cout<<S<<"es"<<endl;
    }
    else{
      cout<<S<<"s"<<endl;
    }

  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

struct Data{
    int st,gt,w;
    Data(int st, int gt, int w) : st(st),gt(gt),w(w){}
};

bool operator < (const Data &e, const Data &f){
    return e.st < f.st;
}

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

    int n;
    while(cin>>n,n){
        vector<vector<ll>> dp(400,vector<ll>(400,0)),tmp(400,vector<ll>(400,0));
        vector<Data> v;
        for(int i=0;i<n;i++){
            int st,gt,w;cin>>st>>gt>>w;
            v.push_back(Data(st,gt,w));
        }
        sort(v.begin(),v.end());
        for(int i=0;i<n;i++){
            int st=v[i].st,gt=v[i].gt,w=v[i].w;
            for(int j=365;j>=1;j--){
                ll ma=0;
                for(int k=0;k<=st-1;k++) ma=max(ma,dp[k][j]);
                tmp[gt][j]=max(dp[gt][j],ma+w);
                ma=0;
                for(int k=0;k<=st-1;k++) ma=max(ma,dp[j][k]);
                dp[j][gt]=max(dp[j][gt],ma+w);
            }
            for(int j=1;j<=365;j++){
                dp[gt][j]=max(dp[gt][j],tmp[gt][j]);
            }
        }
        ll res=0;
        for(int i=0;i<400;i++)for(int j=0;j<400;j++) res=max(res,dp[i][j]);
        cout<<res<<endl;
    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)-form-)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };


inline int ri() { int in; int y = scanf("%d", &in); return in; }
inline LL rl() { LL in; int y = scanf("%lld", &in); return in; }
inline void oi(int i) { printf("%d\n", i); }
inline void od(double i) { printf("%.9f\n", i); }


int main() {
	int N = ri();
	vector<LL> a(N);
	set<PLL>se;
	for (int i = 0; i < N; ++i) {
		a[i] = rl();
		se.insert(PLL(a[i], i));
	}
	VL sub(N, 1);
	auto NG = []() {
		cout << -1 << endl;
		exit(0);
	};
	vector<vector<int>>G(N);
	while (SZ(se) > 1) {
		auto it = se.end();
		--it;
		PLL a = *it;
		se.erase(it);
		LL sa = a.first;
		int v = a.second;
		DD(de(sa, v));
		LL parval = sa + 2 * sub[v] - N;
		auto parnode = se.lower_bound(PLL(parval, 0));
		if (parnode->first != parval)NG();
		int par = parnode->second;
		sub[par] += sub[v];
		G[par].push_back(v);
	}

	function<LL(int)> f = [&](int v) {
		LL ret = 0;
		for (auto nx : G[v]) {
			ret += f(nx) + sub[nx];
		}
		return ret;
	};
	LL res = f(se.begin()->second);
	if (res != se.begin()->first)NG();
	FOR(i, 0, N) {
		for (auto nx : G[i]) {
			cout << i + 1 << " " << nx + 1 << endl;
		}
	}

}

Measured memory_bytes: 14720
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include <cmath>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;

	vector<int> a(n), b(n), c(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += (upper_bound(a.begin(), a.end(), b[i] - 1) - a.begin()) * (n - (lower_bound(c.begin(), c.end(), b[i] + 1) - c.begin()));
	}
	cout << sum << endl;
}

Measured memory_bytes: 1408
program bbb
implicit none

integer :: n, i
integer,allocatable,dimension(:) :: v, c, dp

read*, n
allocate(v(n),c(n),dp(0:n))
read*, v
read*, c
dp=0

do i=1, n
dp(i)=max(dp(i-1),dp(i-1)+v(i)-c(i))
end do

write(*,'(i0)') dp(n)

end program

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long N){
    map<ll, ll> R;
    for(ll x = 1; x <= 110; x++){
        for(ll y = 1; y <= 110; y ++){
            for(ll z = 1; z <= 110; z++){
                ll t = (x + y + z) * (x + y + z) - x*y - y*z - z*x;
                R[t]++;
            }
        }
    }
    for(ll i = 1; i <= N; i++){
        if(!R.count(i)) cout<<0<<endl;
        else cout<<R[i]<<endl;
    }
}
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 6160
import collections
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N = int(input())

    s = [""] * N
    for i in range(N):
        s[i] = ''.join(sorted(input()))
    S = collections.Counter(s)
    
    cnt = 0
    for i in S.values():
        if i > 1:
            cnt += combinations_count(i, 2)

    print(cnt)
main()

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

void a();
void b();
void c();
void d();
void e();
void f();

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

void a() {
	int A, B;
	std::cin >> A >> B;
	std::cout << std::max({A + B, A - B, A * B}) << std::endl;
}

void b() {
	int K, X;
	std::cin >> K >> X;
	if (K == 0) {
		std::cout << X << std::endl;
		return;
	}
	int lim = X + K;
	for (int i = X - K + 1; i < lim; i++) {
		std::cout << i;
		if (i < lim - 1) std::cout << ' ';
	}
	std::cout << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
#define int LL
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

PII operator-(const PII &a, const PII &b){
    return PII(a.first - b.first, a.second - b.second);
}
bool operator==(const PII &a, const PII &b){
    return (a.first == b.first) && (a.second == b.second);
}

signed main(){
    int X, A;
    cin >> X >> A;
    if(X < A){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    return 0;
}


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

int main() {
	int H, W;
	scanf("%d %d", &H, &W);
	char m1[H][W];
	cin.ignore();
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%c", &m1[i][j]);
		}
		cin.ignore();
	}
	

	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			int aux = (int)(i + 1 + 1)/2 - 1;
			//cout << aux << endl;
			printf("%c", m1[aux][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h_list = [int(x) for x in input().split()]

c_list = [0] * n
c_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    c_list[i] = min(c_list[i - 1] + abs(h_list[i] - h_list[i - 1]), c_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(c_list[n - 1])

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

int main(void) {
int N;
unsigned long int a[300000];
unsigned long int b;
b = 0;
cin >> N;
for (int i = 0; i < 3 * N; i++) {
cin >> a[i];
}
sort (a, a + 3 * N, greater<int>());
for (int i = 1; i < 2 * N; i += 2) {
b = b + a[i];
}
cout << b << endl;
}

Measured memory_bytes: 2560
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int a, b, x;

int main()
{
	init_ios();
	cin >> a >> b >> x;
	if (x >= a && x <= a+b) {
		cout<<"YES\n";
		return 0;
	}
	cout<<"NO\n";
}

Measured memory_bytes: 256
import math
while True:
    list = input().split()
    a = int(list[0])
    op = list[1]
    b = int(list[2])
    
    if op == "?":
        break
    else:
         if op == "+":
                print(int(a) + int(b))
         elif op == "-":
                print(int(a) - int(b))
         elif op == "*":
                print(int(a) * int(b))
         elif op == "/":
                print(math.floor(int(a) / int(b)))


Measured memory_bytes: 5660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll n,m,x;
vector<ll>c,res;
vector<vector<ll>>a;
ll ans=1001002003004005006ll;
vector<bool>u;
void solve(ll price,int pos){
    int is=0;
    rep(i,m){
        if(res[i]<x)is=1;   
    }
    if(!is){
        chmin(ans,price);
        return;
    }
    if(pos>=n)return ;
     for(int i=pos;i<n;i++){
        if(u[i])continue;
        u[i]=1;
        rep(j,m){
            res[j]+=a[i][j];
        }
        solve(price+c[i],i+1);
        rep(j,m){
            res[j]-=a[i][j];
        }
        u[i]=0;
    }


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

    cin>>n>>m>>x;
    c.resize(n);
    a.resize(n);
    u.resize(n);
    res.resize(n);
    rep(i,n){
        cin>>c[i];

        rep(j,m){
            ll aij;
            cin>>aij;
            a[i].push_back(aij);
        }
    }
    solve(0ll,0);
    if(ans!=1001002003004005006ll)
    cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define BOX 1000000000000000LL
const int WID = 10000;
long long n, k, l; unsigned long long p, q;
vector<long long>vec;
long long sum[WID * 10];
int main() {
	cin >> n >> k >> p; q = p;
	if (p == 0) { cout << "0" << endl; return 0; }
	for (int i = 0; i < n; i++) {
		long long r = p;
		long long L = r / BOX; if (r < 0LL)L--;
		sum[L + WID]++;
		p ^= p << 13; p ^= p >> 7; p ^= p << 17;
	}
	for (int i = 1; i <= WID * 2; i++) sum[i] += sum[i - 1];
	for (int i = 0; i < WID * 2; i++) { if (sum[i] >= k) { l = i - WID; break; } }
	for (int i = 0; i < n; i++) {
		long long K = (long long)q / BOX; if ((long long)q < 0)K--;
		if (l == K) vec.push_back((long long)q);
		q ^= q << 13; q ^= q >> 7; q ^= q << 17;
	}
	sort(vec.begin(), vec.end());
	cout << vec[k - sum[l + WID - 1] - 1] << endl;
	return 0;
}

Measured memory_bytes: 3392
#include<bits/stdc++.h>
#include<algorithm>
#include<list>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    int count,a;
    count = 0;
    for(int i = 0; i < n;i++){
        cin >> a;
        if(a%2!=0)count++;
    }
    string ans ="YES";
    if(count%2!=0)ans ="NO";
    
    cout << ans << endl;
    
    return 0;

    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int Collatz(int inn){
    if(inn%2==0){
        return inn/2;
    }
    else{
        return 3*inn+1;
    }
}

int main(){
    int ans=0;
    int n;
    cin>>n;
    vector<int> a(1000005,0);
    a[n-1]=1;
    for(int i=1;;i++){
        a[Collatz(n)-1]++;
        if(a[Collatz(n)-1]==2){
            ans=i+1;
            break;
        }
        n=Collatz(n);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7180
def main():
    n,k = tuple([int(t)for t in input().split()])

    a = tuple([int(t)-1 for t in input().split()])

    route = []
    se = set([])

    t = -1
    s = -1

    looplen = 0

    pos = 0
    for i in range(n):
        route.append(pos)
        se.add(pos)
        if a[pos] in se:
            t = len(route)
            s = route.index(a[pos])
            looplen = t-s
            break  
        pos = a[pos]

    if t>k:
        print(route[k]+1)
    else:
        pos = s+(k-s)%looplen
        print(route[pos]+1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 32944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ' ';  } return os;  }

int main() {
  string s;
  int n,m; cin >> n >> m >> s;
  int len=0;
  vector<int> ans;
  loop(i,1,n+1) {
    len++;
    if (len > m) {
      cout << -1 << endl;
      return 0;
    }

    if (s[i] == '0') {
      ans.push_back(len);
      len = 0;
      continue;
    }
  }

  reverse(ans.begin(), ans.end());
  vector<int> ans2;
  ans2.push_back(ans[0]);
  loop(i,1,ans.size()) {
    if (ans2.back() + ans[i] <= m) {
      ans2.back() += ans[i];
    }
    else ans2.push_back(ans[i]);
  }
  reverse(ans2.begin(), ans2.end());
  cout << ans2 << endl;
  return 0;
}


Measured memory_bytes: 4408
N,M = list(map(int,input().split()))
C = []
for i in range(N):
    C.append(list(map(int,input().split())))
    
C = sorted(C,key=lambda x: x[0])

count = 0
ans = 0
for i in range(N):
    if count + C[i][1] > M:
        ans+=(M-count)*C[i][0]
        break
    else:
        ans+=C[i][0]*C[i][1]
        count+=C[i][1]
print(ans)

Measured memory_bytes: 29792
x1, y1, x2, y2 = gets.split.map(&:to_f)
ux = x2 - x1
uy = y2 - y1
d = ux**2 + uy**2
gets.to_i.times do
  x, y = gets.split.map(&:to_f)
  vx, vy = x - x1, y - y1
  k = (vx * ux + vy * uy) / d
  puts '%.8f %.8f' % [x1 + k * ux, y1 + k * uy]
end

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef long long LL;
LL read() {
	LL q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+(LL)(ch-'0'),ch=getchar();
	return q;
}
const int N=100005;
int n,Q,top;
LL st[N],num[N],ans[N];
void work(LL len,LL s) {
	int k=lower_bound(st+1,st+1+top,len)-st-1;
	if(!k) {ans[1]+=s,ans[len+1]-=s;return;}
	num[k]+=s*(len/st[k]),work(len%st[k],s);
}
int main()
{
	LL x;
	n=read(),Q=read(),st[++top]=n;
	while(Q--) {
		x=read();
		while(top&&st[top]>x) --top;
		st[++top]=x;
	}
	num[top]=1;
	for(RI i=top;i>=1;--i) work(st[i],num[i]);
	for(RI i=1;i<=n;++i) ans[i]+=ans[i-1];
	for(RI i=1;i<=n;++i) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());//int型
		int b = Integer.parseInt(sc.next());
		sc.close();
		int ans = 0;
		if (a>=b) {
			ans += a;
			a--;
		} else {
			ans += b;
			b--;
		}
		
		if (a>=b) {
			ans += a;
			a--;
		} else {
			ans += b;
			b--;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23636
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

int a,b;

int read(){
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

int main()
{
    cin>>a>>b;a--;b--;
    cout<<(b+a-1)/a<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout << a[a.size()-1]-a[0] << endl;

    return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    x = x-a;
    cout << x%b << endl;
    return 0;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a[0]!=a[1]&&a[2]!=a[1]&&a[0]!=a[2])
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<int>> G(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>G[i][j];
    }
  }
  vector<int> p;
  for(int i=1;i<H*W;i++){
    int a,b,c,d;
    a=(i-1)/W,b=(i-1)%W,c=i/W,d=i%W;
    if(a%2==1){
      b=W-1-b;
    }
    if(c%2==1){
      d=W-1-d;
    }
    if(G[a][b]%2){
      G[c][d]++;
      p.push_back(i);
    }
  }
  int N=p.size();
  cout<<N<<endl;
  for(int i=0;i<N;i++){
    int a,b,c,d;
    a=(p[i]-1)/W,b=(p[i]-1)%W,c=p[i]/W,d=p[i]%W;
    if(a%2==1){
      b=W-1-b;
    }
    if(c%2==1){
      d=W-1-d;
    }
    a++,b++,c++,d++;
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
  }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  reverse(ALL(a));
  vector<ll> dp(n, INF64);
  rep(i, n) *upper_bound(ALL(dp), a[i]) = a[i];
  cout << distance(dp.begin(), lower_bound(ALL(dp), INF64)) << endl; 
}


Measured memory_bytes: 4836
N = int(input())

s = [0] * 5
for i in range(5):
    s[i] = int(input())


min_i = s.index(min(s))
min = min(s)
time = 0
if N%min != 0:
    time = N//min + 1 + 4
else:
    time = N//min + 4

# print(10//123)
print(time)


Measured memory_bytes: 3060
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,k,x,y,s=0;
    cin>>n>>k>>x>>y;
    for(int i=1;i<=n;i++){
        if(i<=k)s=s+x;
        else s=s+y;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    S = input()

    res = 0
    for i in range(N):
        sub1 = set(S[:i])
        sub2 = set(S[i:])

        if len(sub1 & sub2) > res:
            res = len(sub1 & sub2)

    print(res)

Measured memory_bytes: 3060
Q = int(input())

for i in range(Q):
    A, B = map(int, input().split())
    A, B = min(A, B), max(A, B)

    if A == B:
        print((A - 1) + (B - 1))
        continue

    ok, ng = 0, A + B - 1
    while abs(ok - ng) > 1:
        K = (ok + ng) // 2
        m = (K + 2) // 2

        if m * (K + 2 - m) < A * B:
            ok = K
        else:
            ng = K

    print(ok)


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された

    if(n%2 == 0) return false;

    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }

    return true;
}

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

    if(a < b){
    ll tmp = a;
    a = b;
    b = tmp;
    }
    ll r = a % b;
    while(r!=0){
    a = b;
    b = r;
    r = a % b;
    }
    
    ll juge = 0;
    ll ans = 1;
    ll num = pow(b, 0.5);
    ll numm = b;
    for(ll i = 2; i <= num; i++){
        while(b % i == 0){
            juge = 1;
            b /= i;
        }
        if(juge == 1){ 
            ans ++; juge = 0;
        }
    }
    if(b != 1)ans++;
    
    cout << ans << endl;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	map<int,bool> hoge;

	for(int i=0;i<n;i++){
		int teresa;
		cin>>teresa;

		if(hoge.count(teresa)) hoge.erase(teresa);
		else hoge[teresa]=false;
	}

	cout<<hoge.size()<<endl;

	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int main()
{
	long i,n,k,ans=0;
	cin >> n;
	long a[n+1];
	for(i=0;i<n;i++){
		cin >> a[i];
	} 
	for(i=0;i<n;i++){
		k=a[i];
		if(a[k-1]==i+1){
			ans++;
		}
	} 
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 1024
//Atcoder Code Festvial 2017 Final J
//https://cf17-final.contest.atcoder.jp/tasks/cf17_final_j?lang=en
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=200010,INF=0x3f3f3f3f;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
struct Edge{
	int u,v;ll w;
	Edge(const int _u=0,const int _v=0,const ll _w=0ll){u=_u;v=_v;w=_w;}
	bool operator < (const Edge &b)const{return w<b.w;}
};
struct data{int v,w,nxt;}edge[maxn<<1];
int n,p,sn,rt,top,a[maxn],head[maxn],sz[maxn],mx[maxn],vis[maxn],stk[maxn];
ll ans,sum[maxn];
vector<Edge> G;
vector<Edge>::iterator itr;
struct Dsu{
	int f[maxn];
	void init(int n){for(int i=1;i<=n;i++) f[i]=i;}
	int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
	int merge(int x,int y)
	{
		int fx=find(x),fy=find(y);
		if(fx==fy) return 0;
		return f[fy]=fx;
	}
}dsu;
void insert(int u,int v,int w)
{
	edge[++p]=(data){v,w,head[u]};head[u]=p;
	edge[++p]=(data){u,w,head[v]};head[v]=p;
}
void getrt(int x,int pre)
{
	sz[x]=1;mx[x]=0;
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v]&&edge[i].v^pre)
	  {
	  	getrt(edge[i].v,x);
	  	sz[x]+=sz[edge[i].v];
	  	getmax(mx[x],sz[edge[i].v]);
	  }
	getmax(mx[x],sn-sz[x]);
	if(mx[x]<mx[rt]) rt=x;
}
void input()
{
	int u,v,w;
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<n;i++){read(u);read(v);read(w);insert(u,v,w);}
	dsu.init(n);
	sn=n;mx[rt=0]=INF;getrt(1,1);
}
void getdis(int x,int pre)
{
	stk[++top]=x;sz[x]=1;
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v]&&edge[i].v^pre)
	  {
	  	sum[edge[i].v]=sum[x]+edge[i].w;
	  	getdis(edge[i].v,x);
	  	sz[x]+=sz[edge[i].v];
	  }
}
void dfs(int x)
{
	int id;ll mn=1e18;
	vis[x]=1;top=0;sum[x]=0ll;
	getdis(x,x);
	for(int i=1;i<=top;i++)
	  if(getmin(mn,a[stk[i]]+sum[stk[i]]))
	    id=stk[i];
	for(int i=1;i<=top;i++)
	  G.push_back(Edge(id,stk[i],a[stk[i]]+sum[stk[i]]+a[id]+sum[id]));
	for(int i=head[x];i;i=edge[i].nxt)
	  if(!vis[edge[i].v])
	  {
	  	sn=sz[edge[i].v];rt=0;
	  	getrt(edge[i].v,x);
	  	dfs(rt);
	  }
}
int main()
{
	input();
	dfs(rt);
	sort(G.begin(),G.end());
	for(itr=G.begin();itr!=G.end();++itr)
	  if(dsu.merge(itr->u,itr->v))
	    ans+=itr->w;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 88928
#include <iostream>

using namespace std;

int main(){

	int n = 0;
	int m = 0;
	int a[100][100] = { 0 };
	int b[100] = { 0 };
	long c[100] = { 0 };

	cin >> n >> m;

	for (int i = 0; i < n; i++) {

		for (int u = 0; u < m; u++) {

			cin >> a[i][u];

		}

	}

	for (int u = 0; u < m; u++) {

		cin >> b[u];

	}

	for (int i = 0; i < n; i++) {

		for (int u = 0; u < m; u++) {

			c[i] += a[i][u] * b[u];

		}

	}

	for (int i = 0; i < n; i++) {

		cout << c[i] << endl;

	}
	

	return 0;

}



Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
using namespace std;

int main(){
    int N,A;
    cin >> N >> A;
    
    N%=500;
    if(N<=A){
        cout<<"Yes"<<endl;
        
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

int main(int argc,char* argv[]){
  int count=0;
  string S;
  cin >> S;
  for(int i=0;i<S.length();i++){
    if(S[i]=='+') count++;
    else count--;
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
a=[]
a=list(input().split())

stack=[]

for i in range(len(a)):
    if a[i]=='+':
        stack.append(stack.pop()+stack.pop())

    elif a[i]=='-':
        stack.append(-(stack.pop()-stack.pop()))

    elif a[i]=='*':
        stack.append(stack.pop()*stack.pop())

    else:
        stack.append(int(a[i]))

print(stack[-1])



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

int main() {
  string s;
  cin >> s;
  long long q;
  cin >> q;
  string str;
  for(int i = 0; i < q; i++){
    int a;
    cin >> a;
    if(a == 1){
      swap(s, str);
    }else{
      int b;
      string c;
      cin >> b >> c;
      if(b == 1){
        str += c;
      }else{
        s += c;
      }
    }
  }
  reverse(str.begin(), str.end());
  str += s;
  cout << str << endl;
  return 0; 
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    vector<int> list={0,300000,200000,100000};
    int x,y,ans=0;
    cin>>x>>y;
    if(x<=3)ans+=list[x];
    if(y<=3)ans+=list[y];
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import radians,cos

def main():
    a,b,H,M = map(int,input().split())
    H *= 30
    H += M/2
    M *= 6
    x = min(360-abs(H - M),abs(H-M))
    x = radians(x)
    ans = a*a + b*b - 2*a*b*cos(x)
    print(ans**0.5)
if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  int a, b;
  cin >> a >> b;
  repi(100000) {
    if (floor(0.08 * i) == a && floor(0.1 * i) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);

  if ( s[2] == s[3] && s[4] == s[5] ) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
S=int(input())
C=10**9+7

def comb(n,k):
    c,d=1,1
    for i in range(k):
        c*=n-i
        d*=i+1
    d=pow(d,C-2,C)
    return (c*d)%C

ans=0
for i in range(1,(S//3)+1):
    ans+=comb(S-2*i-1,i-1)
print(ans%C)


Measured memory_bytes: 67660
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
		c=a*b;
		printf("%dx%d=%d\n",a,b,c);
	}
	}
	return 0;
}


Measured memory_bytes: 2684
#include<stdio.h>

int main(void){
  
  int r,c,i,j;
  int s[102][102]={};

  scanf("%d %d",&r,&c);
 
  for(i=1; i<=r; i++)
    for(j=1; j<=c; j++){
      scanf(" %d",&s[i][j]);
      s[i][c+1] += s[i][j];
    }
  for(j=1; j<=c+1; j++)
    for(i=1; i<=r; i++)
      s[r+1][j] += s[i][j];
 
  for(i=1; i<=r+1; i++){
    for(j=1; j<=c+1; j++){
      printf("%d",s[i][j]);
      if(j!=c+1) putchar(' ');
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1832
import math

def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    req = int(math.ceil(x/d))-1
    if req >= k:
        print(x-k*d)
    else:
        x -= req*d
        k -= req
        x1 = x
        x2 = abs(x1-d)
        if x1 <= x2:
            if k%2 == 0:
                print(x1)
            else:
                print(x2)
        else:
            if k%2 == 1:
                print(x2)
            else:
                print(x1)


main()


Measured memory_bytes: 62156