akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

int main(){
	
	int num;
	
	while(~scanf("%d",&num)){
		if(num==0) break;
		bool isok=false;
		map<int,ll> val;
		vector<int> order;
		for(int i=0;i<num;i++){
			int n;
			ll p,q;
			scanf("%d %lld %lld",&n,&p,&q);
			val[n] += p*q;
			if(find(order.begin(),order.end(),n) == order.end()){
				order.push_back(n);
			}
		}

		for(vector<int>::iterator it = order.begin(); it != order.end(); it++){
			if(val[*it] >= 1000000){
				cout << *it << endl;
				isok=true;
			}
		}
		if(!isok) cout <<  "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 30030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string s;
  cin>>s;
  set<char> st;
  rep(i,0,4)
  {
  	st.insert(s[i]);
  }
  if(st.size()==2)
  	cout<<"Yes";
  	else
  	cout<<"No";


}


Measured memory_bytes: 256
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	vi a(n);
	map<ll,ll> m;
	rep(i,1,n)
	{
		ll x;cin>>x;
		a[i]=x-1;
		m[x-1]++;
	}

	rep(i,0,n) cout<<m[i]<<"\n";


	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(n,INF);
    rep(i,m){
        int s,c;
        cin >> s >> c;
        s--;
        if(v.at(s) != INF && v.at(s) != c){
            cout << -1 << endl;
            return 0;
        }
        if(n > 1 && s == 0 && c == 0){
            cout << -1 << endl;
            return 0;
        }
        v.at(s) = c;
    }
    int ans = 0;
    rep(i,n){
        if(n > 1 && i == 0 && v.at(i) == INF) ans += pow(10,n-1);
        else if(n == 1 && i == 0 && v.at(i) == INF) continue;
        else if(i > 0 && v.at(i) == INF) ans += 0;
        else ans += pow(10,n-1-i) * v.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

struct ng {
	int a;
	int b;
	int c;
};



int main() {
	while (1) {
		int a, b, c; cin >> a >> b >> c;
		if (!a)break;
		int sum = a + b + c;
		vector<int>oks(sum, 2);
		vector<vector<ng>>ngs(sum);
		int N; cin >> N;
		queue<ng>que;
		while(N--){
			int i, j, k, r; cin >> i >> j >> k >> r;
			i--; j--; k--;
			if (r) {
				oks[i] = true;
				oks[j] = true;
				oks[k] = true;
			}
			else {
				ngs[i].push_back(ng{ i,j,k });
				ngs[j].push_back(ng{ i,j,k });
				ngs[k].push_back(ng{ i,j,k });
				que.push(ng{ i,j,k });
			}
		}
		while (!que.empty()) {
			ng aa(que.front());
			que.pop();
			vector<int>unknown;
			if (oks[aa.a] == 2 && oks[aa.b] == 1 && oks[aa.c] == 1) {
				oks[aa.a] = 0;
				for (auto ang : ngs[aa.a]) {
					que.push(ang);
				}
			}
			if (oks[aa.b] == 2 && oks[aa.c] == 1 && oks[aa.a] == 1) {
				oks[aa.b] = 0;
				for (auto ang : ngs[aa.b]) {
					que.push(ang);
				}
			}
			if (oks[aa.c] == 2 && oks[aa.a] == 1 && oks[aa.b] == 1) {
				oks[aa.c] = 0;
				for (auto ang : ngs[aa.c]) {
					que.push(ang);
				}
			}
		}
		for (auto a : oks) {
			cout << a << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 const int  INF= 1e9+5;
int main(){
	fastio();

 	int n;cin>>n;
 	int k;cin>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    // for (int i = 1; i < k; ++i)
    // {
    // 	dp[i]=abs(h[i]-h[0]);
    // }
    for(int i=0;i<n;i++){
    	// dp[i]=min(   dp[i-1]+abs(h[i]-h[i-1])   ,  dp[i-2]+abs(h[i]-h[i-2])        )
    	for (int j = i+1; j <= i+k; ++j)
    	{
    		dp[j]=min(   (dp[i]+abs(h[i]-h[j]))   ,  dp[j]       );
    	}


    }
    cout<<dp[n-1]<<endl;





    return 0;

}
	

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

int main(){
  LL a, b, k;
  cin>>a>>b>>k;
  if(k<=a){
    cout<<a-k<<" "<<b<<"\n";
  }else if(a<k && k<=a+b){
    cout<<0<<" "<<b-k+a<<"\n";
  }else{
    cout<<0<<" "<<0<<"\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	string s;
	ll k;
	cin >> s >> k;
	ll n = s.size();
	vector<ll> a(n);
	if (n < k) {
		put(0);
		return 0;
	}
	REP(i, n) {
		a[i] = s[i] - '0';
	}
	ll dp[200][200][2];
	REP(i, 200) {
		REP(j, 200) {
			REP(k, 2) {
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	dp[0][1][1] = 1;
	dp[0][0][1] = a[0]-1;
	REP(i, n-1) {
		if (a[i+1] == 0) {
			REP(j, n) {
				dp[i + 1][j + 1][0] += dp[i][j][0];
			}
			
		} else {
			REP(j, n) {
				dp[i + 1][j][0] += dp[i][j][0];
			}
			REP(j, n) {
				dp[i + 1][j + 1][1] += dp[i][j][0];
			}
		}
		REP(j, n) {
			dp[i + 1][j][1] += max(0ll, a[i+1] - 1ll) * dp[i][j][0];
			dp[i + 1][j][1] += dp[i][j][1]*9ll;
			dp[i + 1][j + 1][1] += dp[i][j][1];
		}
	}
	ll res = 0;
	res += dp[n - 1][n - k][0];
	res += dp[n - 1][n - k][1];
	put(res);
	return 0;
}



Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line1 = Integer.valueOf(sc.nextLine());
		int[] array = new int[line1];
		for (int i = 0; i < line1; i++) {
			array[i] = Integer.valueOf(sc.nextLine());
		}
		sc.close();
		Arrays.sort(array);
		int sum = 0;
		for (int i = 0; i < line1; i++) {
			sum += array[i];
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		boolean isExist = false;
		if (sum % 10 == 0) {
			for (int i = 0; i < line1; i++) {
				sum -= array[i];
				if (sum % 10 != 0) {
					isExist = true;
					break;
				} else {
					list.add(i);
				}
			}
			if (sum % 10 == 0) {
				sum = 0;
			}
		}
		if (isExist && list.size() > 0) {
			for (Integer index : list) {
				sum += array[index];
			}
		}
		
		System.out.println(sum);
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,m;cin>>n>>m;
  string s;cin>>s;
  vector<int>dp(n+1);
  rep(i, n+1)dp[i]=-1;
  dp[0]=0;
  rrep1(i, n){
    if(s[i]=='1')continue;
    rrep1(j, m){
      if(i-j<0 || s[i-j]=='1')continue;
      dp[i]=i-j;
      break;
    }
  }

//  for(auto t: dp)cout<<t<<' ';cout<<endl;

  int c=n;
  vector<int>results;
  while(dp[c]>0){
    results.push_back(c-dp[c]);
    c=dp[c];
//cout<<c<<' ';
  }
  if(dp[c]<0){ cout<<-1<<endl; return 0; }
  results.push_back(c-dp[c]);

//cout<<endl;

  rrep(i, results.size())cout<<results[i]<<' ';cout<<endl;

  return 0;
}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// 3
// 4
// 1 2
// 2 3
// 3 4
// 2
// 2 2
// 4
// 3 4
// 1 3
// 3 2
// 2
// 3 2
// 7
// 6 1
// 2 3
// 4 6
// 7 3
// 5 1
// 3 6
// 4
// 7 5 13 3
// 20 12 6
int main()
{
	string s;
	cin>>s;
	ll z=0;
	for(ll p=0;p<s.length();p++)
	{
		z+=s[p]-'0';
	}
	if(z%9==0)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
}

Measured memory_bytes: 3744
def abMM(head1)
    if head1 <= 12 && head1 >= 1
        return true
    else 
        return false
    end
end

def cdMM(back1)
    if back1 <= 12 && back1 >= 1
        return true
    else 
        return false
    end
end

num = gets.to_i
head = num / 100
back = num - head * 100

if abMM(head) && cdMM(back)
    puts('AMBIGUOUS')
elsif abMM(head) && !cdMM(back)
    puts('MMYY')
elsif !abMM(head) && cdMM(back)
    puts('YYMM')
else 
    puts('NA')
end



Measured memory_bytes: 1788
K = int(input())
ans = 7%K
A = 1
C = [0]*K
if K == 1 or K == 7:
  print(1)
  exit()
for i in range(K):
  A = (A*10)%K
  ans += (A*7)
  ans %= K
  if ans == 0:
    break
  if C[ans] == 0:
    C[ans] += 1
  else:
    print(-1)
    exit()
print(i+2)

Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
ll cnt[100005];

int main(int argc, char const *argv[]) {
	cin >> n >> m;
	FOR(i, m) {
		int a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		cnt[b]++;
		cnt[a]--;
	}
	bool flag = true;
	for (int i = n; i > 1; i--) {
		if (abs(cnt[i]) & 1) {
			flag = false;
			break;
		}	
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n, T;
	cin >> n >> T;
	pair <int, int> p[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> p[i].ff >> p[i].ss;
	}
	sort(p + 1, p + n + 1);
	vector <vector<int>> dp(n + 1, vector<int>(T + 1, 0));
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < T; j++)
			ans = max(ans, dp[i - 1][j] + p[i].ss);
		for (int j = 1; j <= T; j++)
		{
			if(p[i].ff <= j)
			{
				dp[i][j] = max(dp[i][j], dp[i - 1][j - p[i].ff] + p[i].ss);
			}
			dp[i][j] = max(dp[i - 1][j], dp[i][j]);
		}
	}
	cout << ans;
		
}


Measured memory_bytes: 35584
import java.util.*;

public class Main {
    static int MOD = 1000000007;
	static int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        Arrays.setAll(a, i -> sc.nextInt());
        sc.close();
        int res;
        int cnt = 0;
        int cntSame = 0;
        int i = 0;
        int j = 1;

        while (i < n) {
            if (a[i] == j) {
                cntSame++;
                i++;
                j++;
            } else if (a[i] != j){
                cnt++;
                i++;
            }
        }
        if (cntSame == n) {
            res = 0;
        } else if (cnt == n) {
            res = -1;
        } else {
            res = cnt;
        }
        System.out.println(res);
    }
}

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

int main(){
	string s;
	cin >> s;
	int l = s.size();
	int f = 0;
	for(int i = 0;i < l;i++){
		if(i % 2 == 0){
			if(s[i] == 'L'){
				f = 1;
				break;
			}
		}
		if(i % 2 == 1){
			if(s[i] == 'R'){
				f = 1;
				break;
			}
		}
	}
	if(f) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	SETP(10);
	string inp;
	while (getline(cin, inp)) {
		stringstream ss(inp);
		stack<double>st;
		for (string s; ss >> s;) {
			if (s == "+" || s == "-" || s == "*" || s == "/") {
				double arg1 = st.top(); st.pop();
				double arg2 = st.top(); st.pop();
				switch (s[0]) {
				case '+':
					st.push(arg2 + arg1);
					break;
				case '-':
					st.push(arg2 - arg1);
					break;
				case '*':
					st.push(arg2 * arg1);
					break;
				case '/':
					st.push(arg2 / arg1);
					break;
				}
			} else {
				st.push(stoi(s));
			}
		}
		cout << st.top() << endl;
	}
}


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

constexpr int INF = (1 << 30);

int main() {
    int n, k, q;
    std::cin >> n >> k >> q;
    std::vector<int> a(n + 1, -INF);
    for (int i = 0; i < n; i++) std::cin >> a[i];

    auto f = [&] (int x) -> int {
        std::vector<int> buff, dat;
        for (const int &e : a) {
            if (e >= x) {
                buff.push_back(e);
            } else {
                std::sort(buff.begin(), buff.end());
                const int _size = int(buff.size());
                for (int i = 0; i + k <= _size; i++) {
                    dat.push_back(buff[i]);
                }
                buff.clear();
            }
        }
        std::sort(dat.begin(), dat.end());
        if (dat.size() < q) return INF;
        return (dat[q - 1] - dat[0]);
    };


    int min = INF;
    for (const int &x : a) {
        min = std::min(min, f(x));
    }

    std::cout << min << '\n';

    return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>

int main(){
	int i,j;
	int num;
	int height[10];
	for(i=0;i<=9;i++)
		scanf("%d",&height[i]);
	for(i=0;i<=9;i++){
		for(j=i+1;j<=9;j++){
			if(height[i]<=height[j]){
				num=height[i];
				height[i]=height[j];
				height[j]=num;
			}
		}
	}
	for(i=0;i<=2;i++)
		printf("%d\n",height[i]);
	return 0;
}

Measured memory_bytes: 600
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
ll dp[100010], h[100010];
int k=2, n;
ll solve(int i){
    if(i==n) return 0;
    if(~dp[i]) return dp[i];
    ll ret=999999999999999999;
    for(int j=i+1; j<=min(n, i+k); j++) ret=min(ret, solve(j)+abs(h[i]-h[j]));
    return dp[i]= ret;
}
int main() {
    cin>>n;
    FILL(dp, -1);
    for(int i=1; i<=n; i++)cin>>h[i];
    cout<<solve(1);
}



Measured memory_bytes: 5248
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a % 5 == 0)&&(b % 5 == 0)&&(c % 7 == 0)||(a % 5 == 0)&&(b % 7 == 0)&&(c % 5 == 0)||(a % 7 == 0)&&(b % 5 == 0)&&(c % 5 == 0))
    printf("YES\n");
	else
    printf("NO\n");
   	   	   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm> 
#include <vector>
#include <set>

using namespace std;

int main() {

	int a, b, c = 0;

	//----------------------------------------------------------------------------------------------------


	int N;
	cin >> N;

	a = N / 10;
	N -= a * 10;

	if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon" << endl;
	}
	else if (N == 3) {
		cout << "bon" << endl;
	}
	else {
		cout << "pon" << endl;
	}
	//----------------------------------------------------------------------------------------------------

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 5001;

long dp[N];
int b[N];

int main()
{
	fio;
	int n;
	long A, B;
	cin >> n >> A >> B;
	for(int i=1; i<=n; i++)
		cin >> b[i];
	long ans = INFLL;
	for(int i=1; i<=n; i++)
	{
		dp[i] = INFLL;
		int c = 0;
		for(int j=i-1; j>=0; j--)
		{
			if(b[i] > b[j])
				dp[i] = min(dp[i], dp[j] + c * A + (i - j - 1 - c) * B);
			else
				c++;
		}
		ans = min(ans, dp[i] + (n - i) * B);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector <int> vi;
vi PRIMES,S;
int prime(int n){
    int i=0,j=1,h=(n+1)/2,x,r=(int)pow(n,.5);
    vi s(h),p;
    while(j<=n){
        s[i++]=j;
        j+=2;
    }
    for (i=1;i<h;i++)
        if (x=s[i]){
            p.push_back(x);
            if (i<=r) for (j=x*x/2;j<h;j+=x) s[j]=0;
        }
	PRIMES=p;
	S=s;
    return 0;
}
int f0056(int n){
	int x=0,i,e;
	if (n<4) return 0;
	if (n==4) return 1;
	if (n%2==1){
		if (S[(n-2)/2]) return 1;
	}
	else
		for (i=0;i<PRIMES.size();i++){
			e=PRIMES[i];
			if (e>n/2) break;
			if (S[(n-e)/2]) x++;
		}
	return x;
}
int main(void){
    int n;
    prime(105000);
    while (true){
        std::cin>>n; if (n==0) break;
        std::cout<<f0056(n)<<"\n";
    }
} 

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

int main (void) {
    int all;
    int pickup;
    
    scanf("%d %d", &all, &pickup);

    int value[all];
    int all_value = 0;

    for (int i = 0; i < all; i++) {
        scanf("%d", &value[i]);
        all_value += value[i];
    }

    float judge = (float)all_value / (4 * pickup);
    int cnt = 0;

    for (int i = 0; i < all; i++) {
        //printf("value:%d, judge:%f\n", value[i], judge);
        if (judge <= value[i]) {
            cnt++;
        }
    }
    if (cnt >= pickup) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
import math
N, K = map(int,input().split())
A = [int(i) for i in input().split()]

if K == 0:
    print(max(A))
else:
    low = 0
    high = max(A)
    while high - low > 0.1:
        mid = (low + high) / 2
        times = 0
        for a in A:
            times += math.ceil(a / mid) - 1
        if K >= times:
            high = mid
        else:
            low = mid
        #print(mid)

    ans = int(mid)
    if not ans:
        print(1)
    else:
        times = 0
        for a in A:
            times += math.ceil(a / ans) - 1
        if times <= K:
            print(ans)
        else:
            print(ans+1)


Measured memory_bytes: 93992
def main():
    N=int(input())
    P=list(map(int,input().split()))
    L=[0 for i in range(0,N)]
    L[0]=P[0]
    for i in range(0,N-1):
        L[i+1]=min(L[i],P[i+1])
    count=0
    for i in range(0,N):
        if L[i]==P[i]:
            count+=1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
n, m  =map(int, input().split())

routes = []

for i in range(m):
    a,b = map(int, input().split())
    routes.append([a,b])

routes.sort(key=lambda x: x[1])

cut = 0
ans = 0

for route in routes:
    if route[0] >= cut:
        cut = route[1]
        ans += 1

print(ans)

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

int main() {
    int N;
    ll A, B;
    cin >> N >> A >> B;
    ll X[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    ll e[N- 1];
    for (int i = 0; i < N - 1; i++) {
        e[i] = X[i + 1] - X[i];
    }
    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (e[i] * A < B) ans += e[i] * A;
        else ans += B;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5068
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    int[] A = new int[N];
    for(int i = 0; i < N; i++){
      A[i] = Integer.parseInt(sc.next());
     }

     int temp = 0;
     for(int i = 0; i < N; i++){
       if(D % A[i] == 0){
         temp +=  D / A[i];
       }else{
         temp += D / A[i] + 1;
       }
     }

     System.out.println(X + temp);
  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e7;
int n,m,q;
int t[502][502];
int main()
{
  int x,y;
  cin>>n>>m>>q;
  for(int i=0;i<m;i++)
  {
      cin>>x>>y;
      t[x][y]++;
  }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        t[i][j]+=t[i][j-1];
    }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        t[i][j]+=t[i-1][j];
    }
  for(int i=0;i<q;i++)
  {
      cin>>x>>y;
      cout<<t[y][y]+t[x-1][x-1]-t[x-1][y]-t[y][x-1]<<endl;

  }



}

Measured memory_bytes: 1920
n = int(input())
a = list(map(int,input().split()))
asum = sum(a)
cnt = [0] * (10**5+1)
q = int(input())

for i in a:
    cnt[i] += 1

for i in range(q):
    b, c = map(int,input().split())
    asum = asum + (c-b)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(asum)


Measured memory_bytes: 84708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "bust" << endl;
  exit(0);
}

void no() {
  cout << "win" << endl;
  exit(0);
}

int main() {
  vector<ll> a(3);
  ll sum = 0;
  REP(i, 3) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum >= 22)
    yes();
  else
    no();
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll x;

	cin >> x;

	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}
}

Measured memory_bytes: 256
function Main(input){
  var [a,b] = input.split(" ").map(BigInt);
  console.log(((a==1n||b==1n)?((a==b)?1n:(a==1n)?b-2n:a-2n):a*b-((a-2n)*2n+(b-2n)*2n)-4n).toString())
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

using Float = double;
using Point = complex<Float>;
struct Line{
	Point a,b;
	Line(Point a,Point b) : a(a),b(b){}
};
struct Segment : Line{ Segment(Point a,Point b) : Line(a,b){} };
struct Circle{ Point p; Float r; };

const Float EPS = 1e-8;

inline bool eq(Float a,Float b) { return abs(a - b) < EPS; }
inline Float dot(const Point &a,const Point &b){ return real(conj(a) * b); }
inline Float cross(const Point &a,const Point &b){ return imag(conj(a) * b); }

vector<Point> crosspoint(const Circle &c1,const Circle &c2){
	vector<Point> ret;
	Point d = c2.p - c1.p;
	Float rcosa = (c1.r * c1.r + norm(d) - c2.r * c2.r) / (abs(d) * 2);
	if(eq(0,abs(d)) || abs(rcosa) > c1.r) return ret;
	Float rsina = sqrt(c1.r * c1.r - rcosa * rcosa);
	ret.push_back(c1.p + d / abs(d) * Point(rcosa,rsina));
	if(!eq(rcosa,c1.r)) ret.push_back(c1.p + d / abs(d) * Point(rcosa,-rsina));
	return ret;
}

Float distance(Point &p1,Point &p2){
    return abs(p1 - p2);
}

bool contain(Circle &c,Point &p){
    return (distance(c.p,p) <= c.r + EPS);
}

int n;

void solve(){
	Circle cs[110];
	for(int i = 0;i < n;i++){
		double x,y;
		scanf("%lf,%lf",&x,&y);
		cs[i] = {Point(x,y),1};
	}
	if(n <= 1){
		printf("%d\n",n);
		return;
	}
	vector<Point> ps;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			vector<Point> cp = crosspoint(cs[i],cs[j]);
			ps.insert(ps.end(),cp.begin(),cp.end());
		}
	}
	int ans = 0;
	for(Point &p : ps){
		int sum = 0;
		for(int i = 0;i < n;i++){
			if(contain(cs[i],p)) sum++;
		}
		ans = max(ans,sum);
	}
	printf("%d\n",ans);
}

signed main(){
	while(scanf("%d",&n),n) solve();
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

#define F first
#define S second
#define pb push_back
#define int long long
#define maxn 100000
#define mod 1000000007
#define inf 1000000000000000000

#define fr(i,a,b) for(int i=a;i<b;i++)
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define all(x) begin(x), end(x)
#define PII pair<int, int>
#define VI vector<int>
#define VII vector<PII>

using namespace std;

int n, k, dp[101][maxn + 1], a[101], sum[maxn + 1], sum1[maxn + 1];
signed main()
{
    FLASH

    cin>>n>>k;
    fr(i, 1, n + 1) cin>>a[i];

    fr(i, 0, k + 1) {if(i <= a[1])dp[1][i] = 1; sum[i] =(i>0)?sum[i - 1] + dp[1][i]: dp[1][i];}
    fr(i, 2, n + 1){
        fr(j, 0, k + 1){
            dp[i][j] = sum[j];
            if(j > a[i]) dp[i][j] += mod - sum[j - a[i] - 1];
            dp[i][j] %= mod;
            sum1[j] = j > 0 ? sum1[j - 1] + dp[i][j]: dp[i][j];
            sum1[j] %= mod; 
        }
        fr(j, 0, k + 1) sum[j] = sum1[j];
    }

    cout<<dp[n][k]<<'\n';
}


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

int main(void){
  int n, ans = 0;
  cin >> n;
  vector<int> value(n), cost(n);
  for(int i = 0; i < n; i++) cin >> value[i];
  for(int i = 0; i < n; i++) cin >> cost[i];
  for(int i = 0; i < n; i++) if(value[i]-cost[i]>0) ans += value[i]-cost[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
ll MOD=998244353;
#define N 11000000

ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N-1){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(n+1-i)*inv[i]%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N-1){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll p[N+100],a[N],b[N];
main(){
    calc_inv();
    calc_product();
    p[0]=1;
    rep(i,N){
      p[i+1]=p[i]*2ll%MOD;
    }
    ll n=in();
    rep(i,n/2+1){
      a[i]=p[i]*cmb(n/2,i)%MOD;
      //cout<<a[i]<<endl;
    }
    ll t=0;
    ll ans=1;
    rep(i,n)ans=ans*3ll%MOD;
    rep(i,n/2){
      t=(t+a[i])%MOD;
      ans=(ans+MOD-t*a[n/2-1-i]%MOD*2ll%MOD)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 390912
program main;
const
  max = 100010;

var
  n, ans, i, j : longint;
  prime : array [1..max] of boolean;

begin
  readln(n);
  for i := 2 to max do
    prime[i] := true;
  for i := 2 to trunc(sqrt(max)) do
    if prime[i] then
      for j := 2 to (max div i) do
        prime[i*j] := false;
  for i := 1 to max do
    if (i >= n) and prime[i] then begin
      ans := i;
      break;
    end;
  writeln(ans);
end.



Measured memory_bytes: 1380
n = gets.to_i
ps = gets.split.map(&:to_i)

ans = 0

(1..n-2).each do |i|
  pa = ps[i-1]
  pb = ps[i]
  pc = ps[i+1]
  if pa > pb && pc <= pb || pc > pb && pa <= pb
    ans += 1
  end
end
puts ans

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    int N,x,T,ans=0;
    cin>>N>>x>>T;
    if(N%x==0) ans=N/x*T;
    else ans=(N/x+1)*T;
    p(ans);
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    vector< int > v;
    v.pb(1);
    int t = 6;
    while( t <= n ) {
        v.pb(t);
        t *= 6;

    }
    t = 9;
    while( t <= n ) {
        v.pb(t);
        t *= 9;

    }

    int dp[20][100005] = {};
    for( int i = 0; i < v.size(); ++i ) {
        for( int j = 1; j <= n; ++j ) {
            if( i == 0 ) {
                dp[i][j] = dp[i][j - 1] + 1;

            } else {
                if( j < v[i] ) {
                    dp[i][j] = dp[i - 1][j];

                } else {
                    dp[i][j] = min(dp[i][j - v[i]] + 1, dp[i - 1][j - v[i]] + 1);
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);

                }
            }
        }
    }
    cout << dp[v.size() - 1][n] << endl;
    return 0;
}



Measured memory_bytes: 8192
#include <iostream>

using namespace std;

int main() {
    int a, b, c, i;

    while (cin >> a >> b) {
        c = a + b;
        i = 0;
        while (c > 0) {
            c /= 10;
            i++;
        }
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 3040
N, = map(int, input().split())
A = list(map(int, input().split()))
s = 0
r = 0
for i, a in enumerate(A):
    s += a
    if i % 2:
        if s >= 0:
            r += s+1
            s = -1
    else:
        if s <= 0:
            r += -s+1
            s = 1
s = 0
r2 = 0
for i, a in enumerate(A):
    s += a
    if i % 2:
        if s <= 0:
            r2 += -s+1
            s = 1
    else:
        if s >= 0:
            r2 += s+1
            s = -1
print(min(r, r2))


Measured memory_bytes: 63216
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	seen := make(map[string]interface{}, 3)
	count := 1
	sc.Split(bufio.ScanWords)
	for i := 0; i < 3; i++ {
		curr := next()
		if _, ok := seen[curr]; ok {
			count++
		} else {
			seen[curr] = struct{}{}
		}
	}
	if count == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<class T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    string s; cin >> s;
    ll k = in();
    REP(i, n) {
        cout << (s[i] != s[k - 1] ? '*' : s[i]);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#define temo
 
using namespace std;
const ll N = 300000;
 
 
int main()
{
    ll n;
    cin>>n;
    ll T, A;
    cin>>T>>A;
    ll h;
    cin>>h;
    ll ans = 1;
    A *= 1000;
    for (ll i = 2; i <= n; i++){
        ll x;
        cin>>x;
        if (abs (1000 * T - 6 * x - A) < abs (1000 * T - 6 * h - A)){
            ans = i;
            h = x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H, W;
  cin >> H >> W;
  VEC<string> s(H);
  REP(i, 0, H) cin >> s[i];
  int black = 0, white = 0;
  REP(i, 0, H) {
    REP(j, 0, W) {
      if (s[i][j] != '#') ++white;
    }
  }
  queue<pair<int, int>> q;
  queue<int> dist;
  bool queued[H][W];
  REP(i, 0, H) REP(j, 0, W) queued[i][j] = 0;
  if (s[0][0] != '#') {
    q.push({0, 0});
    dist.push(1);
    queued[0][0] = 1;
  }

  bool find = 0;
  while (!q.empty()) {
    auto p = q.front();
    int h = p.first;
    int w = p.second;
    int d = dist.front();

    if (h == H - 1 && w == W - 1) {
      find = 1;
      break;
    }
    VEC<pair<int, int>> next = {{h + 1, w}, {h - 1, w}, {h, w + 1}, {h, w - 1}};
    REP(i, 0, next.size()) {
      int nh = next[i].first;
      int nw = next[i].second;
      if (0 <= nh && nh < H && 0 <= nw && nw < W && s[nh][nw] != '#' &&
          !queued[nh][nw]) {
        q.push({nh, nw});
        dist.push(d + 1);
        queued[nh][nw] = 1;
      }
    }
    q.pop();
    dist.pop();
  }
  if (find) {
    int path = dist.front();
    DUMP(black, white, path);
    cout << white - path << endl;
  } else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]

hh = list(itertools.product([0,1], repeat=h))
ww = list(itertools.product([0,1], repeat=w))

hbl = [0]*h
wbl = [0]*w
ans = 0
for l in hh:
    for m in ww:
        al = 0
        for i in range(h):
            for j in range(w):
                if l[i] == 0 and m[j] == 0 and c[i][j] == "#":
                    al += 1
                    
        if al == k:
            ans += 1
            
print(ans)

Measured memory_bytes: 68220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int h, w;
    cin >> h >> w;
    vs mp;
    mp.resize(h);
    for(int i=0; i<h; i++)
    {
        cin >> mp.at(i);
    }
    int wcnt = 0;
    int bcnt = 0;
    for(auto &s : mp)
    {
        for(auto &c : s)
        {
            if(c == '.') wcnt++;
            if(c == '#') bcnt++;
        }
    }
    vector<vector<int>> cmp(h, vector<int>(w, -1));
    cmp.at(0).at(0) = 1;
    queue<pii> q;
    q.push(make_pair(0, 0));
    while(!q.empty())
    {
        pii p = q.front();
        // cout << p.first << ", " << p.second << ", " << cmp.at(p.second).at(p.first) << endl;
        q.pop();
        if(p.first == w-1 && p.second == h-1) break;
        for(int x=-1, y=0, i=0; i<4; x+=y, y=x-y, x=y-x, i++)
        {
            int nx = p.first + x;
            int ny = p.second + y;
            if(nx < 0 || w <= nx || ny < 0 || h <= ny || mp.at(ny).at(nx) == '#' || cmp.at(ny).at(nx) != -1)
            {
                continue;
            }
            else
            {
                q.push(make_pair(nx, ny));
                cmp.at(ny).at(nx) = cmp.at(p.second).at(p.first) + 1;
            }
        }
    }
    if(cmp.at(h-1).at(w-1) == -1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << wcnt - cmp.at(h-1).at(w-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

a = [0]*(N + 1)
b = [0]*(N + 1)
for i in range(N):
    a[A[i]] += 1
    b[B[i]] += 1

ok = True
for i in range(1, N + 1):
    if a[i] + b[i] > N:
        ok = False

sa = [0]*(N + 1)
sb = [0]*(N + 1)
for i in range(N):
    sa[i + 1] = sa[i] + a[i + 1]
    sb[i + 1] = sb[i] + b[i + 1]

ans = 0
for i in range(N):
    ans = max(ans, sa[i + 1] - sb[i])

if ok:
    print("Yes")
    for i in range(N):
        print(B[(i + N - ans) % N], end='')
        if i == N - 1:
            print('')
        else:
            print(' ', end='')
else:
    print("No")

Measured memory_bytes: 44784
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>

using namespace std;

int main(){

	int n,r,table[50],p,c,work[50];

	while(true){
		scanf("%d %d",&n,&r);
		if(n == 0 && r == 0)break;

		for(int i = 0; i < n; i++){
			table[i] = n-i;
		}

		for(int i = 0; i < r; i++){
			scanf("%d %d",&p,&c);

			//???????????????????????£???????????????????????????
			for(int k = 0; k < c; k++){
				work[k] = table[p-1+k];
			}

			//?¬???????0???p-2?????§????????????
			for(int k = 0; k < p-1; k++){
				work[c+k] = table[k];
			}

			//????????????p+c-1???n-1?????§????????????
			for(int k = p+c-1; k < n; k++){
				work[k] = table[k];
			}

			for(int k = 0; k < n; k++)table[k] = work[k];
		}

		printf("%d\n",table[0]);

	}

    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 5e5+7;
vector <int> a[N];
int n,m,Pos[N],TP[N],Count = 0;
void nhap()
{
}
void solve()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    if (d & 1) {
        cout << b - a;
    }
    else {
        cout << a - b;
    }
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 13824
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	
	int lens = s.length();
	int lent = t.length();
	int ans = inf;	
	for(int i=0;i+lent <= lens ;i++){
		int res = 0;
		for(int j=0;j<lent;j++){
			if(s[i+j]!=t[j]){
				res++;
			}
		}
		ans = min(ans,res);
	}
    cout<<ans<<"\n";
    
	return 0;
} 

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int p[n];
  rep(i,n)cin >> p[i];
  ll sum = 0;
  int size = 0;
  ll res = 0;
  rep(i,n){
    if(size<k){
      sum += p[i];
      size++;
    }else if(size==k){
      sum += p[i];
      sum -= p[i-k];
    }
    chmax(res,sum);
    //cout << sum << endl;
  }
  double ans = (res+k)/2.0;
  printf("%.10f\n",ans);
}

Measured memory_bytes: 1024