akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	ll L;
	ll dis[301][301];
	int ans[301][301];
	scan(N>>M>>L);
	fill(dis[0],dis[301],INFl);
	fill(ans[0],ans[301],INF);
	rep(i,N) dis[i][i]=0;
	rep(i,M){
		int A,B;
		ll C;
		scan(A>>B>>C);
		A--; B--;
		dis[A][B]=C;
		dis[B][A]=C;
	}
	rep(k,N){
		rep(i,N){
			rep(j,N){
				if(k==i||k==j) continue;
				if(dis[i][j]>dis[i][k]+dis[k][j]) dis[i][j]=dis[i][k]+dis[k][j];
			}//添字の順番はWikipedia通りにやってまふ
		}
	}
	rep(i,N){
		rep(j,N){
			if(dis[i][j]<=L){
				ans[i][j]=1;
			}
		}
	}
	rep(k,N){
		rep(i,N){
			rep(j,N){
				if(k==i||k==j) continue;
				if(ans[i][j]>ans[i][k]+ans[k][j]) ans[i][j]=ans[i][k]+ans[k][j];
			}//添字の順番はWikipedia通りにやってまふ
		}
	}
	int Q;
	scan(Q);
	rep(i,Q){
		int s,t;
		scan(s>>t);
		s--; t--;
		if(ans[s][t]==INF) prin(-1);
		else prin(ans[s][t]-1);
	}
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(void) {
	string s,t;
	cin >> s >> t;
	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] > s[j])swap(s[i], s[j]);
		}
	}

	for (int i = 0; i < t.size() - 1; i++) {
		for (int j = i + 1; j < t.size(); j++) {
			if (t[i] < t[j])swap(t[i], t[j]);
		}
	}
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = Long.parseLong(sc.next());
        double money = 100.0;
        double rate = 1.01;

        int count = 0;
        while(money <= X) {
            // 小数点以下切り捨て
            money = Math.floor(money);
            money = money * rate;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35772
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 
 

 
int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> n;
    vi v(n+2);
    a=0;
    for(int i=1; i<=n; i++){
        cin >> v[i];
        a^=v[i];
    }
    for(int i=1 ;i<=n; i++){
        cout << (a^v[i]) << ' ';
    }
    cout << el;
    return 0;
}


Measured memory_bytes: 3984
#include "iostream"
using namespace std;

int main()
{
	int card[128];
	int a=0,b=0,n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> card[i];

	int c;
	for (int i=0;i<n;i++)
	{
		for (int j = i + 1;j<n;j++)
			if(card[i]<card[j])
			{
				c = card[i];
				card[i] = card[j];
				card[j] = c;
			}
	}
	for (int i = 0; i < n; i++)
	{
		if (0==i % 2)
		{
			a+=card[i];
		}
		else
		{
			b+=card[i];
		}
	}
	cout << a - b;
    return 0;
}

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

int main() {
  
  int d;
  cin >> d;
  
  cout << "Christmas";
  
  if (d<=24) cout << " Eve";
  
  if (d<=23) cout << " Eve";
  
  if (d==22) cout << " Eve";
  
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)

int main()
{
	unordered_map<char,function<string(string)>> inv;
	inv['J']=[](string s){
		rotate(s.begin(),s.end()-1,s.end());
		return s;
	};
	inv['C']=[](string s){
		rotate(s.begin(),s.begin()+1,s.end());
		return s;
	};
	inv['E']=[](string s){
		rep(i,s.size()/2) swap(s[i],s[(s.size()+1)/2+i]);
		return s;
	};
	inv['A']=[](string s){
		return string(s.rbegin(),s.rend());
	};
	inv['P']=[](string s){
		char ds[]="9012345678";
		rep(i,s.size()) if(isdigit(s[i])) s[i]=ds[s[i]-'0'];
		return s;
	};
	inv['M']=[](string s){
		char ds[]="1234567890";
		rep(i,s.size()) if(isdigit(s[i])) s[i]=ds[s[i]-'0'];
		return s;
	};
	
	int tc; cin>>tc;
	while(tc--){
		string m,s; cin>>m>>s;
		per(i,m.size()) s=inv[m[i]](s);
		cout<<s<<endl;
	}
	
	return 0;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,t,q,sum=0;
    cin >> n;
    vector<int> cnt(100001,0);
    rep(i,n){
        cin >> t;
        cnt[t]++;
        sum+=t;
    }
    cin >> q;
    ll b,c;
    rep(i,q){
        cin >> b >> c;
        sum += (c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        print(sum);
    }
    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    char b; cin >> b;
    if(b=='A') cout << "T" << endl;
    if(b=='T') cout << "A" << endl;
    if(b=='C') cout << "G" << endl;
    if(b=='G') cout << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll k,a,b;
  cin >> k >> a >> b;
  if((b/k)==((a-1)/k)){
    cout << "NG" << endl;
  }
  else{
    cout << "OK" << endl;
  }
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var n int
var w int
var weight []int
var value []int
var dp [][]float64

func main() {
	sc.Split(bufio.ScanWords)

	n, w = nextInt(), nextInt()
	weight = make([]int, n)
	value = make([]int, n)
	for i := 0; i < n; i++ {
		weight[i] = nextInt()
		value[i] = nextInt()
	}

	dp = make([][]float64, n+100)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]float64, w+100)
	}

	for i := 0; i < n; i++ {
		for sumW := 0; sumW <= w; sumW++ {

			// i番目の品物を選ぶ
			if sumW-weight[i] >= 0 {
				chmax(&dp[i+1][sumW], dp[i][sumW-weight[i]]+float64(value[i]))
			}

			// i番目の品物を選ばない
			chmax(&dp[i+1][sumW], dp[i][sumW])

		}
	}

	// 最適値の出力
	fmt.Println(int(dp[n][w]))
}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 84352
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int coin[17];
int memo[17][301];

int dp(int c, int r){
  if(c == 17 && r == 0) return 1;
  if(c == 17) return 0;
  if(memo[c][r] != -1) return memo[c][r];
  int ret = 0;
  int tmp = r;
  while(tmp >= 0){
    ret += dp(c+1, tmp);
    tmp -= coin[c];
  }
  return memo[c][r] = ret;
}

int main(){
  int n;
  REP(i,17) coin[16-i] = (i+1)*(i+1);
  memset(memo, -1, sizeof(memo));

  while(scanf("%d",&n), n)
    printf("%d\n",dp(0,n));

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int main() {
  int n, sum, a;
  vector<int> v;

  while (cin >> n && n) {
    v.resize(n);
    for (int i=0; i<n; i++) v[i] = 0;
    for (int i=0; i<n; i++) {
      sum = 0;
      for (int j=0; j<n; j++) {
        cin >> a;
        cout << setw(5) << a;
        v[j] += a;
        sum += a;
      }
      cout << setw(5) << sum << endl;
    }
    sum = 0;
    for (int i=0; i<n; i++) {
      sum += v[i];
      cout << setw(5) << v[i];
    }
    cout << setw(5) << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    std::vector<int> x(M), y(M);
    for(int i=0; i<M; i++){
        scanf(" %d %d", &x[i], &y[i]);
        x[i]--; y[i]--;
    }

    bool red[N];
    red[0] = true;
    for(int i=1; i<N; i++) red[i] = false;
    std::vector<int> ball(N, 1);

    for(int i=0; i<M; i++){
        ball[x[i]]--; ball[y[i]]++;
        if(red[x[i]] == true) red[y[i]] = true;
        if(ball[x[i]] == 0) red[x[i]] = false;
    }

    int count = 0;
    for(int i=0; i<N; i++){
        if(red[i] == true) count++;
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 1536
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var h = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var dp = new int[n + 1, 3];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 3; j++)
				dp[i + 1, (j + 2) % 3] = Math.Max(dp[i, j] + h[i][j], dp[i, (j + 1) % 3] + h[i][(j + 1) % 3]);
		Console.WriteLine(Enumerable.Range(0, 3).Max(i => dp[n, i]));
	}
}


Measured memory_bytes: 27832
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
pii x1[200005];
int x2[200005];
int cnt1=0,cnt2=0;
int dp[32];
int n=read(),t=read();
inline bool cmp(pii i,pii j){
	return i.se*j.fi<j.se*i.fi;
}
signed main(){
	dp[0]=0;
	fz(i,1,31)	dp[i]=t+1;
	fz(i,1,n){
		int a=read(),b=read();
		b++;b+=a;
		if(a==0)	x2[++cnt2]=b;
		else		x1[++cnt1]={a,b};
	}
	sort(x1+1,x1+cnt1+1,cmp);
	sort(x2+1,x2+cnt2+1);
	fz(i,1,cnt1){
		fd(j,30,0){
			if(dp[j]<=t)
				dp[j+1]=min(dp[j+1],dp[j]+x1[i].fi*dp[j]+x1[i].se);
		}
	}
	int ans=0;
	fz(i,0,30){
//		cout<<dp[i]<<endl;
		if(dp[i]<=t){
			int lft=t-dp[i],num=i;
			fz(j,1,cnt2){
				if(lft<x2[j]){
					break;
				}
				lft-=x2[j];
				num++;
			}
			ans=max(ans,num);
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*
t+ai(t+1)+bi+aj(t+ai(t+1)+bi+1)+bj
=t+t*ai+ai+bi+aj*(t+ai*t+t+bi+1)+bj
=t+t*ai+ai+bi+aj*t+aj*ai*t+bi*aj+aj+bj

bi*aj
<
bj*ai
*/

Measured memory_bytes: 3584
N = int(input())
h = list(map(int,input().split()))

cost = [0]

cost.append(abs(h[0]-h[1]))

for i in range(2,N):
    cost.append(min(cost[i-1]+abs(h[i-1]-h[i]),cost[i-2]+abs(h[i-2]-h[i])))

print(cost[N-1])

Measured memory_bytes: 13980
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
 
int main() {
        string l;
        readln();
        while((l = readln(), l.length)){
                l = l.split("\n")[0];
                float x1, y1, x2, y2, x3, y3;
                x1 = to!float(l.split[0]), y1 = to!float(l.split[1]);
                x2 = to!float(l.split[2]), y2 = to!float(l.split[3]);
                x3 = to!float(l.split[4]), y3 = to!float(l.split[5]);
                float a, b, c, d, e, f;
                a = 2 * (x1 - x2), b = 2 * (y1 - y2), c = (x1 + x2) * (x1 - x2) + (y1 + y2) * (y1 - y2);
                d = 2 * (x1 - x3), e = 2 * (y1 - y3), f = (x1 + x3) * (x1 - x3) + (y1 + y3) * (y1 - y3);                
                float px, py, r;
                px = c / (a - d * b / e) - f / (a * e / b - d), py = c / (b - e * a / d) - f / (b * d / a - e);
                r = sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));
/*              px = to!float(to!int(px * 1000)) / 1000, py = to!float(to!int(py * 1000)) / 1000;
                r = to!float(to!int(r * 1000)) / 1000;
*/              printf("%.3f %.3f %.3f\n", px, py, r);
                }
        return 0;
        }
 

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    
    int n;
    cin >> n;
    
    h = min(2*q, h);
    s = min(2*h, s);
    
    if ( 2*s <= d ) {
        cout << (ll)n*s << endl;
    } else {
        cout << (ll)(n/2)*d + (ll)(n%2)*s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    long long int n,i;
    cin>>n;
    long long int a[n],b[n];
    b[0]=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            b[i]=1000000000;
        }
    }
    b[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        b[i]=min(b[i],b[i-2]+abs(a[i-2]-a[i]));
        b[i]=min(b[i],b[i-1]+abs(a[i-1]-a[i]));
    }
    /*for(i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }*/
    cout<<b[n-1];
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
      {
        cin>>a[i];
      }
    int dp[n];
    for(int i=1;i<n;i++)
    {
        dp[i]=10e9;
    }
    dp[0] = 0;

  for(int i=1;i<n;i++)
  {
    for(int j=i-1;j>=max(0,i-k);j--)
    {
      dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
  }
  cout<<dp[n-1];
}
                                
                                
                                
    
  

Measured memory_bytes: 1024
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int MOD = (1e9) + 7;
	int64_t ans = 0, b = 0;
	for(int i=0; i<N; ++i){
		int a; cin>>a;
		ans += a * b % MOD;
		b += a;
		b %= MOD;
	}
	cout<< ans % MOD <<endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

#define M 1046527
#define h1(key) (key%M)
#define h2(key) (1+(key%(M-1)))
string s[M];

int getCode(char c){
  switch(c){
  case 'A':
    return 1;
    break;
  case 'C':
    return 2;
    break;
  case 'G':
    return 3;
    break;
  }
  return 4;
}

long long getKey(string in){
  long long sum = 0, p = 1;
  for(int i = 0 ; i < (int)in.size() ; i++){
    sum += (getCode(in[i]) * p);
    p *= 5;
  }
  return sum;
}

long long hash_f(long long key, int i){
  return (h1(key) + i * h2(key)) % M;
}

bool find(string in){
  long long key = getKey(in);
  
  for(int i=1;;i++){
    long long h = hash_f(key, i);
    if(s[h] == in) return true;
    else if(s[h].size() == 0) return false;
  }
}

void insert(string in){
  long long key = getKey(in);
  int i;
  for(i=1;;i++){
    long long h = hash_f(key, i); 
    if(s[h].size() == 0){
      s[h] = in;
      break;
    }
  }
}

int main(){
  int n;
  string command, in;
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> command >> in;
    if(command == "insert"){
      insert(in);
    }else{
      if(find(in)){
    cout << "yes" << endl;
      }else{
    cout << "no" << endl;
      }
    }
  }
    
}


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

struct Card {
    char suit;
    char value;
};

void bubble(struct Card A[], int N) {
    for(int i = 0; i < N; i++)
    {
        for(int j = N -1; j >= i; j--)
        {
            if (A[j].value < A[j - 1].value) {
                auto t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for(int i = 0; i < N; i++)
    {
        auto minj = i;
        for(int j = i; j < N; j++)
        {
            if (A[j].value < A[minj].value) {
                minj = j;
            }            
        }
        auto t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for(int i = 0; i < N; i++)
    {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for(int i = 0; i < N; i++)
    {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }        
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;

    print(C2, N);
    auto stableStr = isStable(C1, C2, N) ? "Stable" : "Not stable";
    cout << stableStr << endl;

    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
  }
  
  sort(data.begin(),data.end());
  int min,max;
  min = data.at(n/2-1);
  max = data.at(n/2);
  
  int count=0;
  while(min != max){
    count++;
    min++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;

typedef complex<int> P;

int b[19][19];
void tansaku(){
	
	string s;
	
	cin>>s;
	if(s.size()<=1){
		cout<<"-1 -1"<<endl;
		return ;
	}
	
	for(int i=0;i<s.size()-2;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return ;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return ;
		}
			
	}
	
	if(s[s.size()-2]==s[s.size()-1]){
	cout<<s.size()-1<<" "<<s.size()<<endl;
		return ;
	}
	
	cout<<"-1 -1"<<endl;
	return ;
}

int main(){
	
	tansaku();

	
}

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

#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 10e9+7

using namespace std;

int main(){
int A,P;
cin >> A >> P;
cout << (A*3+P)/2<< endl;
return 0;
}


Measured memory_bytes: 3592
from collections import Counter
H, W = map(int, input().split())
cnt4, cnt2, cnt1 = 0, 0, 0
for v in Counter(''.join(input() for _ in range(H))).values():
    if v % 4 == 0:
        continue
    elif v % 2 == 0:
        cnt2 += 1
    else:
        cnt1 += 1
        if (v - 1) % 4 != 0:
            cnt2 += 1
odd = (H % 2 == 1) + (W % 2 == 1)
if odd == 2:
    if cnt1 <= 1 and cnt2 <= (H + W - 2) // 2:
        print("Yes")
    else:
        print("No")
elif odd == 1 and H % 2 == 1:
    if cnt1 == 0 and cnt2 <= W // 2:
        print("Yes")
    else:
        print("No")
elif odd == 1 and W % 2 == 1:
    if cnt1 == 0 and cnt2 <= H // 2:
        print("Yes")
    else:
        print("No")
else:
    if cnt1 == 0 and cnt2 == 0:
        print("Yes")
    else:
        print("No")


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

using namespace std;

const int nmax = 1e5 + 5;

int pref[nmax], suff[nmax];
int v[nmax];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	pref[1] = v[1];
	for (int i = 2; i <= n; i++)
		pref[i] = __gcd(pref[i - 1], v[i]);
	suff[n] = v[n];
	for (int i = n - 1; i >= 1; i--)
		suff[i] = __gcd(suff[i + 1], v[i]);
	int mx = pref[n-1];
	for (int i = 1; i <= n - 2; i++)
		mx = max(mx, __gcd(pref[i], suff[i + 2]));
	mx = max(mx, suff[2]);
  	cout<<mx;
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

// #define INF 1000000000
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using P       = pair<int, int>;
const int INF = 1LL << 50;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

int H, W, N;
vector<vector<char>> g_graph;
vector<vector<int>> g_distance;
const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};

int bbfs(const int sy, const int sx, const int gy, const int gx) {
    g_distance[sy][sx] = 0;
    queue<P> q;
    q.push(P(sy, sx));
    while (!q.empty()) {
        P now = q.front();
        q.pop();
        int y = now.first, x = now.second;
        if (y == gy && x == gx) {
            break;
        }

        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) {
                continue;
            }
            if (g_graph[ny][nx] == 'X') {
                continue;
            }

            bool update = chmin<int>(g_distance[ny][nx], g_distance[y][x] + 1);
            if (update) {
                q.push(P(ny, nx));
            }
        }
    }
    return g_distance[gy][gx];
}

int g_path = 0;

void bfs(const int gy, const int gx) {
    g_distance[0][0] = 0;
    queue<P> q;
    q.push(P(0, 0));
    while (!q.empty()) {
        P now = q.front();
        q.pop();
        int y = now.first, x = now.second;
        if (y == gy && x == gx) {
            break;
        }

        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) {
                continue;
            }
            if (g_graph[ny][nx] == '#') {
                continue;
            }

            if (chmin(g_distance[ny][nx], g_distance[y][x] + 1)) {
                q.push(P(ny, nx));
                g_graph[ny][nx] = 'o';
            }
        }
    }
}

signed main() {
    cin >> H >> W;
    g_graph.assign(H + 10, vector<char>(W + 10));
    int white = 0;
    rep(i, H) {
        rep(j, W) {
            char c;
            cin >> c;
            g_graph[i][j] = c;
            if (c == '.') {
                white++;
            }
        }
    }

    g_distance.assign(H + 10, vector<int>(W + 10, INF));
    bfs(H - 1, W - 1);
    if (g_distance[H - 1][W - 1] != INF) {
        int ans = white - g_distance[H - 1][W - 1] - 1;
        cout << ans << endl;
    } else {
        puts("-1");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 9223372036854775807
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int t,a,b,c,n,d,l,r,k;
int h[maxn];
int dp[maxn];

int32_t main(){
io();
IOS;    
		cin>>n;
		cin>>k;
		for(int i=1;i<=n;i++)cin>>h[i];

		dp[n]=0;
		for(int i=n-1;i>=1;i--){
			dp[i]=inf;
			for(int j=i+1;j<=i+k && j<=n;j++){
				dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
			}
		}
		cout<<dp[1]<<endl;

       



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

Measured memory_bytes: 5176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N, R;
    cin >> N >> R;

    if(N>=10){
      cout << R <<endl;
    }else{
      cout << R + 100*(10-N) <<endl;
    }


  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

class Combination {
   public:
    Combination(int n) {
        fac = new ll[n];
        inv = new ll[n];
        finv = new ll[n];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP(i, 2, n) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll cnr(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

   private:
    ll *fac, *inv, *finv;
};

int main() {
    int x, y; cin >> x >> y;

    int a = 0, b = 0;
    while (x > 0 && y > 0) {
        if (x >= y) {
            x = x - 2;
            y = y - 1;
            a++;
        }  else {
            x = x - 1;
            y = y - 2;
            b++;
        }
    }

    if (x != 0 || y != 0) {
        cout << 0 << endl;
        return 0;
    }
    
    Combination comb(a + b + 1);
    cout << comb.cnr(a + b, b) << endl;
    return 0;
}

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

using namespace std;

long long gcd(long long i, long long j) {

	//ユークリッドの互除法で最大公約数を求める
	//2変数の場合

	if (i < j) { swap(i, j); }

	while (i%j != 0) {
		long long r;
		r = i % j;
		if (r == 0) { return j; }
		else { i = j; j = r; }
	}
	return j;
}

long long lcm(vector<long long> &a, int n) {

	//2変数のlcmはa*b/gcdこれを繰り返す

	long long i1 = a[0];
	long long i2 = a[1];
	long long tlcm = (i1 / gcd(i1, i2))*i2;

	for (int i = 2; i < n; i++) {
		tlcm = (a[i] / gcd(a[i], tlcm))*tlcm;
	}
	return tlcm;
}

int main() {

	long n = 2;

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

	long long lcmout = lcm(a, n);

	cout << lcmout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, k);
	OUT((k/2)*((k+1)/2))BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int i,j,k=0,l;
    int f=0;
    string str;
    string max="\0";
    int count[100]={0};
    string count_str[100];
    int count_max=0;
    
    while(cin>>str){
        if(max.size()<str.size()){
            max=str;
        }
        for(i=0;i<k;i++){
            if(count_str[i]==str){
                count[i]++;
                f=1;
                break;
            }
        }
        if(f==0){
            count_str[k]=str;
            k++;
        }
    }
    
    for(i=0;i<k;i++){
        if(count[count_max]<=count[i]){
            count_max=i;
        }
    }
    cout<<count_str[count_max]<<" "<<max<<endl;
    return(0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

#define MAX_N 200001
struct UnionFind{

	int parent_id[MAX_N];
	int rank[MAX_N];//本当は高さだけれど、ここではsizeで扱う
	//最初は親は自分
	void init(int n){
		for(int i = 0; i < n; i++){
			parent_id[i] = i;
			rank[i] = 1;
		}
	}

	//root nodeを探す
	int find(int x){
		if(parent_id[x] == x){
			return x;
		}
		else{
			//parentに代入しつつparent_idを返す(枝をrootに付け替えて短くする作業)
			return parent_id[x] = find(parent_id[x]);
		}
	}

	void unite(int x, int y){
		int x_parent = find(x);
		int y_parent = find(y);

		if(x_parent == y_parent){
			return;
		}

		//rankが大きいyに小さいxが併合される
		if(rank[x_parent] < rank[y_parent]){
			parent_id[x_parent] = y_parent;
			rank[y_parent] += rank[x_parent];
		}
		else{
			parent_id[y_parent] = x_parent;
			rank[x_parent] += rank[y_parent];
			//if(rank[x_parent] == rank[y_parent]) rank[x_parent]++;
		}
	}

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

	int count(int x){
		return rank[find(x)];
	}
};


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


	UnionFind friend_graph;
	vector<vector<int>> block_graph;
	
	friend_graph.init(N+1);
	block_graph.resize(N+1);


	REP(i,M){
		int a,b;
		cin>>a>>b;
		friend_graph.unite(a,b);
		block_graph[a].push_back((b));
		block_graph[b].push_back((a));
	}
	REP(i,K){
		int c,d;
		cin>>c>>d;
		block_graph[c].push_back(d);
		block_graph[d].push_back(c);
	}
	

	for(int i = 0; i < N-1; i++){
		int ans = friend_graph.count(i+1) - 1;	
		//cout<<ans<<":"<<endl;
		REP(j,block_graph[i+1].size()){
			if(friend_graph.same(i+1,block_graph[i+1][j])){
				ans -= 1;
			}
		}
		cout<<ans<<" ";
	}
	int ans = friend_graph.count(N-1+1) - 1;	
	//cout<<ans<<":"<<endl;
	REP(j,block_graph[N-1+1].size()){
		if(friend_graph.same(N-1+1,block_graph[N-1+1][j])){
			ans -= 1;
		}
	}
	cout<<ans<<endl;



	return 0;
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[30] ={};
  int b[30] ={};
  string s,s2,s3;
  int n,mn =0;

  cin >> n >> s;


  for(int i=0;i<s.size();i++)
    {
      int cnt =0;
      s2 =s.substr(0,i);
      s3 = s.substr(i);
      for(int j=0;j<s2.size();j++)
	{
	  a[s2[j ]-'a']++;
	}
      for(int k=0;k<s3.size();k++)
	{
	  b[s3[k]-'a']++;
	}

      for(int l =0;l<30;l++)
	{
	  if(a[l] > 0 && b[l] > 0)
	    {
	      cnt++;
	      a[l] = b[l] = 0;
	    }
	  else{
	    a[l] = b[l] =0;
	  }
	}
      mn = max(cnt,mn);
      cnt =0;
    }
  cout << mn << endl;

  return 0;
}


Measured memory_bytes: 256
using System;using System.Linq;
class A {
	static void Main() {

		var n = Console.ReadLine().Split().Select(long.Parse).ToArray();

		if(Array.Exists(n,(a) => { return a % 2 == 0; })) {
			Console.WriteLine(0);
		} else {
			Array.Sort(n);
			Console.WriteLine(n[0]*n[1]);
		}
	}
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i< int (n); i++)
using namespace std;
typedef long long ll;
int main(){
int a, b, c;
int n;
cin >>n;
a=n%10;
n/=10;
b=n%10;
n/=10;
c=n%10;
if (a==7|| b==7 || c==7) cout << "Yes" << endl;
else cout << "No" << endl;


}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            } else {
                map.put(a, 1);
            }
        }
        sc.close();

        // 主処理
        int result = 0;
        for (int key : map.keySet()) {
            if (map.get(key) % 2 == 1) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
    }
}


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

#define NIL NULL

struct node{

  struct node *right;

  struct node *left;

  struct node *parent;

  int key;
};

typedef struct node * Node;
 
Node root;


void treeD(Node);
void treeInsert(int);
void inorder(Node);
void preorder(Node);
Node treeMin(Node);
Node treeS(Node,int);
Node treeSuc(Node);

int main(){

  int n, i, x;

  char com[20];
  
  scanf("%d", &n);
 
  for (i = 0;i < n;i ++ )
    {
    scanf("%s", com);

    if (com[0] == 'f' )
      {
	scanf("%d", &x);
	Node t = treeS(root, x);
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    else if ( com[0] == 'i' )
      {
	scanf("%d", &x);
	treeInsert(x);
      }
    else if ( com[0] == 'p' )
      {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    else if ( com[0] == 'd' )
      {
	scanf("%d", &x);
	treeD(treeS(root, x));
      }
    }
  return 0;
}

Node treeMin(Node x){

  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}
 
Node treeS(Node u, int k){

  if(u == NIL || k == u->key)
    {
      return u;
    }
  
  if(k < u->key)
    {
      return treeS(u->left, k);
    }
  else{
    return treeS(u->right,k);
  }
}

Node treeSuc(Node x){

  Node y;
  
  if(x->right != NIL)
    {
      return treeMin(x->right);
    }
  
  y = x->parent;

  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}

void treeD(Node z){
  Node y; 
  Node x; 
}
 
void treeInsert(int k){

  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while (x!=NIL)
    {
      y = x;
      if (z->key < x->key)
	{
	  x = x->left;
	}
      else {
	x = x->right;
      }
    }
  
  z->parent = y;
  
  if(y == NIL)
    {
      root = z;
    }
  else if(z->key < y->key)
    {
      y->left = z;
    }
  else{
    y->right = z;
  }
  
}

void inorder(Node u){

  if (u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
}

void preorder(Node u){

  if (u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}

Measured memory_bytes: 24040
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


vector<ll> getDivisorsList(ll n)
{
	vector<ll> ret;

	for (ll i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}

	sort(begin(ret), end(ret));
	return ret;
}

vector<pair<ll, ll>> getDivisorsList2(ll n)
{
	auto list = getDivisorsList(n);

	vector<pair<ll, ll>> ret;
	ll tmp = n;

	for(auto i : list)
	{
		if (i == 1) continue;

		ll count = 0;

		while (tmp % i == 0)
		{
			count++;
			tmp /= i;
		}

		if(count > 0) ret.push_back(make_pair(i,count));
	}

	return ret;
}

int main()
{
	ll N;
	cin >> N;

	auto d = getDivisorsList2(N);

	ll count = 0;
	ll p = 2;

	for (auto p : d)
	{
		ll tmp = 0;
		for (ll i = 1; i <= p.second; i++)
		{
			tmp++;
			p.second -= i;
		}

		count += tmp;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3652
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
   int m, n;
   cin >> m >> n;
   if (n == m)
   {
      cout << "Yes";
   }
   else
      cout << "No";
}
int main()
{
	int t = 1;
//	cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll int
#define ci cin>>
#define co cout<<
#define l <<endl
#define mp make_pair
#define v vector<int> v;
#define vv vector<vector<int>> vv
#define v_print for(auto x:v){cout<<x<<"\n";}
#define floop(i,a,b) for(int i=a;i<b;i++)
#define w(n) while(n--)
#define mod 1000000007
using namespace std;

int dp[3002][3002];


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s,t;	cin>>s>>t;
	ll l_s,t_s,k,len,i,j,index;
	l_s=s.size();
	t_s=t.size();
    //co l_s<<endl;
    //co t_s<<endl;
	

	memset(dp,0,sizeof(dp));
	k=1;
	floop(i,1,l_s+1)
	{
		floop(j,1,t_s+1)
		{
			

			if(s[i-1]==t[j-1])
				{
					dp[i][j]=1+dp[i-1][j-1];
				
				}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

			//co dp[i][j]<<" ";


		}
		//co endl;
	}
	len=dp[l_s][t_s];
	//co len;
	if(len==0)
	{
		co " ";
		exit(0);
	}
	i=l_s;	j=t_s;
	index=len-1;
	char ans[len];
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans[index]=s[i-1];
			index--;
			i--;	j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	floop(i,0,len)
	{
		co ans[i];
	}	
}

Measured memory_bytes: 35584
# -*- coding: utf-8 -*-
"""
B - Acrostic
https://beta.atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    S = input().strip()
    w = int(input())
    ans = [S[i] for i in range(0, len(S), w)]
    print(''.join(ans))


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
/*
 * ALDS1_10_B.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<iostream>
#include<algorithm>

using namespace std;

struct Mat {
	int row;
	int col;
};

long mcm(Mat* M, int n) {
	long dp[101][101];
	for(int i=2; i<=n; i++) {
		for(int j=0; j<=n-i; j++) {
			dp[i][j] = 99999999999L;
			for(int k=1; k<i; k++) {
				dp[i][j] = min(dp[k][j]+dp[i-k][j+k]+M[j].row*M[j+k].row*M[j+i-1].col, dp[i][j]);
			}
		}
	}
	return dp[n][0];
}

int main() {
	int n;
	Mat M[100];

	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> M[i].row >> M[i].col;
	}

	cout << mcm(M, n) << endl;

}





Measured memory_bytes: 3148
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    answer = 1
    modulo = 10**9+7
    for i in range(1, N+1):
        answer = (answer*i)%modulo
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 62820
#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>
using namespace std;
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
int mod = 1e9+7;
int inf = 1e18;
//int m_inf = INT_MIN;


void solve()
{
	int n;
	cin>>n;
	vi arr(n);
	scan(arr,n);
	int mx = n+1;
	int ans = 0;
	loop(i,0,n)
	{
		if(arr[i]<mx)
			ans++;
		mx = min(mx,arr[i]);
	}
	cout<<ans<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
} 

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc128/tasks/abc128_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,Q; cin >> N >> Q;
    
    using Item = tuple<ll,ll,ll>;
    vector<Item> events(N);
    for(int i = 0; i < N;i++){
        ll S,T,X; cin >> S >> T >> X;
        events[i] = Item(S,T,X);
    }
    sort(events.begin(),events.end());
    vector<ll> D(Q);
    for(auto& in:D) cin >> in;
    
    map<ll,ll> mp;
    vector<vector<ll>> E(Q+1);
    for(int i = 0; i < N;i++){
        ll S,T,X; tie(S,T,X) = events[i];
        
        ll LT = S-X, RT = T - X;
        ll LD = lower_bound(D.begin(),D.end(),LT) - D.begin();
        ll RD = lower_bound(D.begin(),D.end(),RT) - D.begin();
        
        E[LD].push_back(X);
        E[RD].push_back(-X);
    }
    
    
    for(int i = 0; i < Q;i++){
        for(auto x:E[i]){
            if(x>=0){
                mp[x]++;
            }else{
                x = -x;
                mp[x]--;
                
                if(mp[x]==0){
                    mp.erase(x);
                }
            }
        }
        if(mp.empty()){
            cout << -1 << endl;
        }else{
            cout << mp.begin()->first << endl;
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 32500