akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << std::endl; for(const auto& v : vv){ view(v); } }
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; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
vector<vector<tuple<ll,ll>>> g;
ll q,k;

vector<ll> mem;

void dfs(ll from, ll to, ll d){
    mem[to] = d;
    for(tuple<ll,ll> x : g[to]){
        ll p,cost;
        tie(p, cost) = x;
        if(p == from) continue;
        dfs(to, p, d+cost);
    }

}

int main(){
    cin >> n;
    g = vector<vector<tuple<ll,ll>>>(n+1);
    for(ll i = 0;i < n-1;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        g[a].push_back(make_tuple(b, c));
        g[b].push_back(make_tuple(a, c));
    }
    cin >> q >> k;
    mem = vector<ll>(n+1);
    dfs(0, k, 0);
    for(ll i = 0;i < q;i++){
        ll x,y;
        cin >> x >> y;
        cout << mem[x] + mem[y] << endl;
    }
}


Measured memory_bytes: 15536
EOL = '0 0'
stdin = [line for line in iter(input, EOL)]
lines = (map(int, line.split()) for line in stdin)

for H, W in lines:
    for i in range(H):
        edge = '#' * W
        mid_point = '#{}#'.format('.' * (W - 2))
        if i in [0, H - 1]:
            print(edge)
        else:
            print(mid_point)
    print()



Measured memory_bytes: 5624
[N, M] = list(map(int, input().split(' ')))
card_list = list(map(int, input().split(' ')))

card_list.sort()
compare_list = []

for i in range(M):
  (B, C) = list(map(int, input().split(' ')))
  compare_list.append((C,B))
    
compare_list.sort()

ans = 0
for i in range(N):
  if compare_list == []:
    ans += sum(card_list[i:])
    break
  if card_list[-1] > compare_list[-1][0]:
    ans += card_list.pop()
  elif compare_list[-1][1] > 0:
    ans += compare_list[-1][0]
    tmp = compare_list.pop()
    a = tmp[0]
    b = tmp[1]
    if b != 1:
      compare_list.append((a,b-1)) 
      
print(ans)

Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

vi arr;
int n;

ll cache[3005][3005][2];

//Taro - 0, Jiro - 1
ll dpSol(int l, int r, bool turn)
{
    if(l == r)
    {
        if(turn)
            return -arr[l];
        return arr[l];
    }
    
    ll &res = cache[l][r][turn];
    if(res != -1)
        return res;
    
    if(turn)
    {
        ll ans1 = -arr[l] + dpSol(l + 1, r, !turn);
        ll ans2 = -arr[r] + dpSol(l, r - 1, !turn);
        return res = min(ans1, ans2);
    }
    
    ll ans1 = arr[l] + dpSol(l + 1, r, !turn);
    ll ans2 = arr[r] + dpSol(l, r - 1, !turn);
    return res = max(ans1, ans2);
}

int main()
{
    fastIO
    cin >> n;
    
    arr = vi(n);
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
        
    memset(cache, -1, sizeof(cache));
        
    cout << dpSol(0, n - 1, 0);

    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll A,B,M;
    cin>>A>>B>>M;

    vector<ll>a(A),b(B),c,d;
    rep(i,A)cin>>a[i];
    rep(i,B)cin>>b[i];

    c=a;
    d=b;

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

    ll ans=c[0]+d[0];

    rep(i,M){
        ll x,y,c;
        cin>>x>>y>>c;

        ll sum=a[x-1]+b[y-1]-c;
        ans=min(ans,sum);
    }

    cout<<ans<<endl;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    char x = S[0];
    int cnt = 1;
    for(int i = 1; i < N; i++){
        if(x != S[i]){
            cnt++;
            x = S[i];
        }
    }
print(cnt);

}



Measured memory_bytes: 512
#include"bits/stdc++.h"
#include"math.h"
using namespace std;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using vi=vc<int>;

const ll mod=1e9+7;
const ll INF = 1e18;
const int MAX = 700000;
const int MOD = 1000000007;


long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

  
  int main(){
    int n;cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
      rep(j,n){
        if(s[i]=='Z'){s[i]='A';continue;}
        s[i]++;}
    }
    cout << s << endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  n %= 1000;
  n = 1000 - n;
  n %= 1000;
  out(n);
  memi;
}

Measured memory_bytes: 3620
N = int(input())
ans = ["a"]
for i in range(N-1):
    new = []
    for j in range(len(ans)):
        l = ord(max(ans[j]))-95
        add = [chr(ord("a") + idx) for idx in range(l)]
        for k in add :
            new.append(ans[j] + k)
    ans = new

ans.sort()
for p in ans:
    print(p)

Measured memory_bytes: 12984
#include<stdio.h>

int i, h, max1 , max2 , max3;
int max1 = 0;
int max2 = 0;
int max3 = 0;

int main(void){
  for(i = 0;i < 10;i++){
    scanf("%d", &h);
    if(max1 < h){
      max3 = max2;
      max2 = max1;
      max1 = h;
    }
    else if(max2 < h){
      max3 = max2;
      max2 = h;
    }
    else if(max3 < h){
      max3 = h;
    }
  }
  printf("%d\n%d\n%d\n", max1, max2, max3);
  
  return 0;
}

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

#define scd second;
#define fst first;
#define mkp make_pair
#define pb push_back
#define pf push_front

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;

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

	ll n;
	cin>>n;
	cout<<n*(n+1)/2-3*((n/3)*(n/3+1)/2)-5*((n/5)*(n/5+1)/2)+15*((n/15)*(n/15+1)/2)<<endl;
}

Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int k = cin.Int();
			int s = cin.Int();

			var sb = new StringBuilder();
			if (s > n) {
				for (int i = 0; i < n; i++) {
					if (i < k) {
						sb.Append($"{s} ");
					} else {
						sb.Append($"{1} ");
					}
				}
			} else {
				for (int i = 0; i < n; i++) {
					if (i < k) {
						sb.Append($"{s} ");
					} else {
						sb.Append($"{s + 1} ");
					}
				}
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 22616
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	N = int(input())
	S = input()
	
	if N == 1:
		print(0)
		sys.exit()
	
	kuro = []
	for i, val in enumerate(S):
		if i == 0:
			if val == "#":
				kuro.append(1)
			else:
				kuro.append(0)
			continue
		if val == "#":
			kuro.append(kuro[i-1] + 1)
		else:
			kuro.append(kuro[i-1])
	
	shiro = [0 for _ in range(N)]
	for i in range(N-1, -1, -1):
		if i == N-1:
			if S[i] == ".":
				shiro[i] = 1
			else:
				shiro[i] = 0
			continue
		if S[i] == ".":
			shiro[i] = shiro[i+1] + 1
		else:
			shiro[i] = shiro[i+1]
			
	ans = -1
	for i in range(N):
		if i == 0:
			continue
		tmp = kuro[i-1] + shiro[i]
		if ans > tmp or ans == -1:
			ans = tmp
	
	#print(kuro)
	#print(shiro)
	print(min(ans,shiro[0],kuro[N-1]))
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13544
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
string s;
rep(i,6)cin>>s[i];

if((s[2]==s[3])&&(s[4]==s[5])){
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}

	  return 0;
	}





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

int main() {
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  for(;;){
    c-=b;
    if(c<=0){
      cout << "Yes";
      break;
    }
    a-=d;
    if(a<=0){
      cout << "No";
      break;
    }
  }
}

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

using namespace std;

int n, m;

bool check(int a[], int b[]) {
	int suma = 0;
	int sumb = 0;
	for (int i = 0; i < n; i++) {
		suma += a[i];
	}
	for (int i = 0; i < m; i++) {
		sumb += b[i];
	}
	return suma == sumb;
}

int main() {
	while (true) {
		cin >> n >> m;
		if (n == 0) {
			break;
		}
		int ans = 100000;
		int ans2 = ans;
		int taro[n];
		int hanako[m];
		for (int i = 0; i < n; i++) {
			taro[i] = 0;
			cin >> taro[i];
		}
		for (int i = 0; i < m; i++) {
			hanako[i] = 0;
			cin >> hanako[i];
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				swap(taro[i], hanako[j]);
				if (check(taro, hanako)) {
					int tmp = taro[i] + hanako[j];
					if (tmp < ans + ans2) {
						ans = hanako[j];
						ans2 = taro[i];
					}
				}
				swap(taro[i], hanako[j]);
			}
		}
		if (ans == 100000) {
			cout << "-1" << endl;
		} else {
			cout << ans << " " << ans2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
(n,s),a,b=$<.map{_1.split.map &:to_i}
b.reverse!
n.times{|i|$*[v=a[i]]||=i;v!=b[i]||(s=v;$r=i)}
s&&b=(t=[s])*(k=[$*[s],b[..$r].count(s)].min)+(b-t)+t*=b.count(s)-k
puts n<(a+b).count(s)?:No:[:Yes,b]

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

int main()
{		
	int n, m;
	int p[1000];

	cin >> n >> m;

	while (n != 0 || m != 0) {
		for (int i = 0; i < n; i++)
			cin >> p[i];

		sort(p, p + n, greater<int>());

		int s = 0;
		for (int i = 0; i < n; i++) {
			if (i % m != m - 1)
				s += p[i];
		}
		cout << s << endl;

		cin >> n >> m;
	}

	return 0;
}



Measured memory_bytes: 3148
#include<cstdio>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
int n,m;
struct node {
    int A,B;
    int id;
}a[MAXN];
bool cmp(node x,node y) {
    return x.B<y.B;
}
bool cmp1(node x,node y) {
    return x.A>y.A;
}
int dp[MAXN];
//vector<int>G[MAXN];
priority_queue<int>Q;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%d%d",&a[i].B,&a[i].A);
        a[i].B=m-a[i].B;
    }
    sort(a+1,a+n+1,cmp);
    int ed=n;
    for(int i=1;i<=n;i++)
        if(a[i].B>m) {
            ed=i;
            break;
        }
    int ans=0;
    //sort(a+1,a+ed+1,cmp1);
    while(m>=0) {
        while(ed&&a[ed].B==m) {
            Q.push(a[ed].A);
            ed--;
        }
        m--;
        if(!Q.empty()) {
            ans+=Q.top();
            Q.pop();
        }
    }
    printf("%d",ans);
}


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

struct node
{
    ll x;
    ll y;
};
node a[5007];
int n;

bool cmp(node p,node q)
{
    if (p.x+p.y==q.x+q.y) return p.y<q.y;
    return p.x+p.y<q.x+q.y;
}
int main(){
    ios::sync_with_stdio(false);
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    scanf("%lld%lld",&a[i].x,&a[i].y);

    priority_queue<int>q;
  //  n=n+1;
  //  a[n].x=1e9+10;
  //  a[n].y=1e9+10;
    sort(a+1,a+n+1,cmp);

    ll tmp=0;

    ll t=0;
    int ans=0;
    for (int i=1;i<=n;i++)
    {
       // cout<<ans<<" "<<a[i].x<<a[]
        if (tmp<=a[i].x)
        {
            tmp+=a[i].y;
            q.push(a[i].y);
            ans++;
        }
        else
        {
            if (a[i].y<q.top())
            {
                tmp-=q.top();
                q.pop();
                tmp+=a[i].y;
                q.push(a[i].y);
            }
        }




    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define D second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll x, k, d;
    cin>>x>>k>>d;

    if(x>=0){
        if(abs(x-d)>x){
            if(k%2 == 0)RT(x);
            else RT(min(abs(x-d), x+d));
        }
        else{
            ll div = (x+d-1)/d;
            ll tk = min(div, k);
            ll cur = x - tk*d;
            k -= tk;
            if(k%2 == 0)RT(abs(cur));
            else RT(min(abs(cur-d), abs(cur+d)));
        }
    }
    else{
        if(abs(x+d)>abs(x)){
            if(k%2 == 0)RT(abs(x));
            else RT(min(abs(x-d), abs(x+d)));
        }
        else{
            ll div = (abs(x)+d-1)/d;
            ll tk = min(div, k);
            ll cur = x + tk*d;
            k -= tk;
            if(k%2 == 0)RT(abs(cur));
            else RT(min(abs(cur-d), abs(cur+d)));
        }
    }

}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll n;
	cin >> n;
	n %= 10;
	if(n==2 or n==4 or n==5 or n==7 or n==9) cout << "hon";
	else if(n==0 or n==1 or n==6 or n==8) cout << "pon";
	else if(n==3) cout << "bon";
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
A = [int(input()) for _ in range(N)]
X = [0] * N

if A[0] > 0:
    print(-1)
    exit()

ans = 0
for i in range(1, N):
    if A[i] - 1 == A[i - 1]:
        ans += 1
    elif A[i] - 1 > A[i - 1]:
        print(-1)
        exit()
    else:
        ans += A[i]
print(ans)

Measured memory_bytes: 89468
fun main(args: Array<String>) {
    val suitList = listOf<String>("S", "H", "C", "D")

    var fullSet = mutableListOf<String>()
    for (s in suitList) {
        for (n in 1..13) {
            fullSet.add("%s %d".format(s, n))
        }
    }

    val inStr = readLine() ?: return
    val n = inStr.toInt()

    var inputList = mutableListOf<String>()
    for (i in 1..n) {
        val card = readLine() ?: ""
        inputList.add(card)
    }

    val lostList = fullSet.subtract(inputList)

    for (card in lostList) {
        println(card)
    }
}



Measured memory_bytes: 29460
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	LL X, t;
	cin >> X >> t;
	X -= t;
	if (X >= 0)
		cout << X;
	else
		cout << 0;
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e7 + 10;
const ll mod = 1e9 + 7;
int x[maxn],y[maxn];
int main(){
	int n;
	ll ans;
    cin>>n;
    for(int i = 1;i <= n; i++){
        int a,b;
		cin>>a>>b;
        x[i] = a - b;
        y[i] = a + b;
    }
    sort(x + 1,x + n + 1);
    sort(y + 1,y + n + 1);
    ans = max(x[n] - x[1],y[n] - y[1]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<double> p(n);
	for(int i = 0; i < n; i++) cin>>p[i];
	vector<double> dp(n + 1);
	dp[0] = 1.0;
	for(int i = 1; i <= n; i++) dp[i] = 0.0;
	for(int i = 0; i < n; i++){
		vector<double> dp_copy = dp;
		dp_copy[0] = dp[0] * (1.0 - p[i]);
		for(int j = 1; j <= i + 1; j++){
			dp_copy[j]  = dp[ j - 1] * p[i] + dp[j] * (1.0 - p[i]);
		}
		dp = dp_copy;
	}
	double answer = 0.0;
	for(int i = 0; i <= n; i++){
		if (i >= (n + 1)/2) answer += dp[i];
	}
	cout<<setprecision(15)<<answer<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
   pii a[n-1];
    
    int u,v;
    f(i,n-1) cin >> a[i].F >> a[i].S;
    
   int res = 0;
    for(int i=1;i<=n;i++) res+=(i*(n+1-i));
    
    f(i,n-1)
    {
        int x = a[i].F;
        int y = a[i].S;
        
        if(x > y) swap(x,y);
        
        res-=(x*(n+1-y));
    }
    
    cout << res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 6752
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

        string n,give;
        cin>>n;
        int val[1000006]={};

        give = n;
        reverse(give.begin(),give.end());
        int len=give.size();
        ll tot=0;
        for(int i=0;i<len;++i) val[i]=give[i]-'0';
        for(int i=0;i<len;++i)
        {

            if(val[i]<5)
                tot+=val[i];
            else if(val[i]>5)
            {
                tot+=(10-val[i]);
                val[i]=0;
                ++val[i+1];
            }
            else
            {
                if(val[i+1]>=5){
                    val[i]=0;
                    ++val[i+1];
                    }
                    tot+=5;
            }
            if(val[i+1]>=10) val[i+1]-=10,++val[i+2];

        }
        tot+=val[len]+val[len+1];
        cout<<tot;

    return 0;
}

Measured memory_bytes: 6300
n = input()
a = list(map(int, input().split()))

b = [0]*(10**5+1)
ans = 0

for x in a:
    if x <= 10**5:
        b[x] += 1
    else:
        ans +=1

for i in range(len(b)):
    if b[i] > i:
        ans += b[i]-i
    if b[i] < i:
        ans += b[i]

print(ans)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int n, m;
vector<vector<int>> ship;
int ans = INF;
bool flg = false;
void dfs (int p, int cnt) {
	if (ship[p].size() == 0)  {
		if (p + 1 == n && cnt == 2) flg = true;
		return;
	}
	for (int i = 0; i < ship[p].size(); ++i) {
		dfs(ship[p][i], cnt + 1);
	}
	return;
}

void solve() {
	cin >> n >> m;
	ship.resize(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		ship[a].push_back(b);
	}
	for (int i = 0; i < ship[0].size(); ++i) {
		dfs(ship[0][i], 1);
	}	
	cout << (flg == true ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX=510000;
long long fac[MAX], fiv[MAX], inv[MAX];

void Com(){
  fac[0]=1;
  fac[1]=1;
  fiv[0]=1;
  fiv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fiv[i]=fiv[i-1]*inv[i]%MOD;
  }
}
long long COMBO(int n, int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(fiv[n-k]*fiv[k]%MOD)%MOD;
}
int main(){
  Com();
  int H, W, A, B;
  long long C=0;
  cin >> H >> W >> A >> B;
  for(int i=B;i<W;i++){
    C+=COMBO(H-A+i-1, i)*COMBO(W+A-2-i, A-1)%MOD;
  }
  cout << C%MOD << endl;
}


Measured memory_bytes: 12160
s = raw_input().split()
c1 = 0
c2 = 0
for w in set(s):
    c=s.count(w)
    if c>c1: c1,w1 = c,w
    c=len(w)
    if c>c2: c2,w2 = c,w
print w1, w2

Measured memory_bytes: 4204
import math
import sys
input = sys.stdin.readline

k = int(input())

n = 512
pattern = 0
a = []
for i in range(n):
    val = math.factorial(7 + i) // math.factorial(i) // math.factorial(7)
    a.append(val)
a.reverse()

cnt = 600 * 7 
ans = ["FESTIVA" for _ in range(n)]
for i, item in enumerate(a):
    ans[i] += ("L" * (k // item))
    k %= item
ans.reverse()
print("".join([str(item) for item in ans]))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
#include <cstdlib>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int N;
  cin >> N;
  int dp[(int) 1e5]={0};
  int H[(int) 1e5]={0};
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  dp[1] = abs(H[1]-H[0]);
  for (int i = 2; i < N; ++i) {
    dp[i] = min( dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]));
  }
  cout << dp[N-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
check = [chr(i) for i in range(97, 97+26)]
n = int(input())
li = [input() for _ in range(n)]
ans = [0] * 26


for i in range(26):
    cnt = 1000
    for j in range(n):
        cnt = min(cnt, li[j].count(check[i]))
    ans[i] = cnt

char = ''

for x, y in zip(check, ans):
    char += x*y

print(char)

Measured memory_bytes: 3064
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
 //  cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        ld d,t,s;
        cin>>d>>t>>s;
        ld op=d/s;
        if(op<=t)
        {
        	cout<<"Yes";
        }
        else
        	cout<<"No";
     
    }
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    int f; cin>>f;
    int jud=0,sum=1;
    for(int i=1;i<n;i++){
        int nw; cin>>nw;
        if(jud>0&&nw<f||jud<0&&nw>f){
            jud=0;
            sum++;
        }
        else if(!jud)
            jud=nw-f;
        f=nw;
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define INFTY 1000000000

int L[MAX / 2+2];
int R[MAX / 2 +2];
int cnt;

void merge(int s[], int left,int mid,int right){
	int i,j,k,n1,n2;
	
	n1 = mid - left;
	n2 = right - mid;
	
	//L[0...n1], R[0...n2] を生成
	for (i = 0;i< n1;i++){
		L[i] = s[left + i];
	}
	for (i = 0 ;i< n2;i++){
		R[i] = s[mid + i];
	}
	
	L[n1] = INFTY;
	R[n2] = INFTY;
	
	i = 0;
	j = 0;
	
	for (k = left; k< right;k++){
		cnt++;
		if (L[i] <= R[j]){
			s[k] = L[i];
			i = i + 1;
		}else {
			s[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(int s[],int left,int right){
	if(left+1 < right){
		int mid;
		mid = (left + right)/2;
		mergeSort(s, left, mid);
		mergeSort(s, mid, right);
		merge(s, left, mid, right);
	}
}

int main(){
	int n,i;
	int s[MAX];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	
	mergeSort(s,0,n);
	
	for(i=0;i<n-1;i++){
		printf("%d ",s[i]);
	}
	printf("%d\n",s[n-1]);
	printf("%d\n",cnt);
	
	return 0;
}


Measured memory_bytes: 5624
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<time.h>
#include<iostream>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<ext/rope>
#define ll long long
#define oo 0x7fffffff
using namespace std;
using namespace __gnu_cxx;
inline int read()
{
	int out=0,fh=1;
	char cc=getchar();
	while ((cc>'9'||cc<'0')&&cc!='-')
		cc=getchar();
	if (cc=='-')
		{
			fh=-1;
			cc=getchar();
		}
	while (cc>='0'&&cc<='9')
		{
			out=out*10+cc-'0';
			cc=getchar();
		}
	return out*fh;
}
const int MAXN=2e5+10;
int lpos[MAXN],rpos[MAXN],n,k;
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),k=read();
	int cnt=0,lcnt=0,rcnt=0;
	int ans=oo;
	for(register int i=1;i<=n;++i)
		{
			int x=read();
			if(x==0)
				--k;
			else
				{
					if(x<0)
						lpos[++lcnt]=x;
					else
						rpos[++rcnt]=x;
				}
		}
	if(k<=0)
		{
			printf("0");
			return 0;
		}
	sort(lpos+1,lpos+1+lcnt,cmp);
	if(lcnt==0)
		{
			printf("%d",rpos[k]);
			return 0;
		}
	if(rcnt==0)
		{
			printf("%d",-lpos[k]);
			return 0;
		}
	int len=min(k,lcnt);
	for(register int i=1;i<=len;++i)
		{
			int j=k-i;
			int sum;
			if(j==0)
				sum=-lpos[k];
			if(j>rcnt)
				continue;
			else
				{
					if(rpos[j]<(-lpos[i]))
						sum=2*rpos[j]-lpos[i];
					else
						sum=rpos[j]-2*lpos[i];
				}
			ans=min(ans,sum);
		}
	printf("%d",ans);
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


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

int main(){
  int d,n,out;
  cin >> d >> n;
  
  if(n!=100){
  	out = n * pow(100,d);
  }else{
    out = 101*pow(100,d);
  }
  
  cout << out << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
ll ans;
vector<ll> a,b,c,d;
vector<ll>temp;
ll n,m,q;

ll fun()
{
    ll ans=0;
    for(ll i=0;i<q;i++)
        if(temp[b[i]]-temp[a[i]]==c[i])
            ans+=d[i];
        return ans;
}

void dfs(ll lim)
{
    if(temp.size()==n+1)
    ans=max(ans,fun());
    else
    {
        for(ll i=lim;i<=m;i++)
           {
            temp.pb(i);
            dfs(i);
            temp.pop_back();
           }
    }
}


int main()
{ 
fast;

cin>>n>>m>>q;

a.assign(q,0);
b.assign(q,0),c.assign(q,0),d.assign(q,0);
for(ll i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    ans=0;

for(ll i=1;i<=m;i++)
    temp.clear(),temp.pb(i),dfs(i);

cout<<ans;

}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#define MAX 2000005

int d[MAX];
char s[15], inst[15];

int getC(char a) {
  if(a=='A') return 1;
   if(a=='C') return 2;
   if(a=='G') return 3;
   return 4;
}

int getPos(){
	int count=0, pos=1, i;
    
    for(i=0; i<strlen(s); i++){
        count += pos*(getC(s[i]));
        //printf("%d",count);
        pos *= 5;
    }
    
    return count;
}

void insert(){
    d[getPos()] = 1;
}

int find(int w, int x, int y, int z) {
    if(w == strlen(s)){
        if(z==0)
            d[x] = 1;
        return d[x];
    } 
    
    return find(w+1,x+getC(s[w])*y,y*4,z);
}

int main() {
  int n;
  
  scanf("%d",&n);
  while(n--) {
    scanf("%s %s",inst ,s);
    
    if(inst[0]=='i') 
        find(0,0,1,0);
    else {
      if(find(0,0,1,1))
        printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 7136
n,m = map(int, raw_input().split())

stu = []
for _ in range(n):
    stu.append((map(int, raw_input().split())))

che = []
for _ in range(m):
    che.append((map(int, raw_input().split())))


for st in range(n):
    min_dis = float("inf")
    idx = -1
    for ch in range(m):
        dist = abs(stu[st][0] - che[ch][0]) + abs(stu[st][1] - che[ch][1])
        if dist < min_dis:
            min_dis = dist
            idx = ch
    print idx + 1


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll func(ll n)
{
    ll x= 5ll, ret= 0;
    while(x<=n)ret+= (n/x), x*= 5ll;
    return ret;
}
int main()
{
    ll n;
    scanf("%lld", &n);
    if(n&1ll)printf("0\n");
    else printf("%lld\n", func(n/2ll));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   sort(arr,arr+n); 
   ll ans = 0;
   rep(n)
        for(ll j=i+1;j<n;j++)
            for(ll k=j+1;k<n;k++)
            {
                if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
                        continue;
                if(arr[k]<arr[i] + arr[j])
                    ans++; 
            }
    cout<<ans;        
   
   return 0;        
}  
  
          
   

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

int main() {
  int N;
  cin >> N;
  if (N/1000 == N%1000/100 && N%1000/100 == N%100/10) {
     cout << "Yes" << endl;
  }
  else if (N%100/10 == N%10 && N%1000/100 == N%100/10) {
     cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define arry(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
const int MAX = 100001;


void solve()
{
        int x;
        cin>>x;
        int z=7%x;
        
        for(int i=0;i<3*x;i++)
        {
            if(!z)
            {
                cout<<i+1<<"\n";
                return;
            }
            z = (z*10+7)%x;
        }
        cout<<"-1\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif


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


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

#define Rep(i,n) for(int i=0;i<(n);i++)
#define For(i,n1,n2) for(int i=(n1);i<(n2);i++)
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=(n-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(n1);i<(n2);i++)
#define put(a) cout<<(a)<<"\n";
#define all(a)  (a).begin(),(a).end();
#define SORT(a) sort((a).begin(),(a).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> 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;}

int n;


int main(){
    cin >> n;
    int maxres = 0;
    int minres = 0;
    vector<int> color(9,0);
    REP(i,n){
        int rate;
        cin >> rate;
        rate/=400;
        if(rate>=8){
            color[8]++;
        }else{
            color[rate]++;
        }
    }
    REP(i,8){
        if(color[i]>0){
            minres++;
        }
    }
    maxres = minres+color[8];
    cout << max(1,minres) << " " << maxres << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            int X = int.Parse (str[0]);
            int Y = int.Parse (str[1]);

            for (int i = 0; i <= X; i++)
            {
                if (2 * i + 4 * (X - i) == Y)
                {
                    Console.WriteLine ("Yes");
                    return;
                }
            }

            Console.WriteLine ("No");
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27520
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;
	i64 max_a = 0;
	i64 min_a = pow(10, 9);
	REP(i, N)
	{
		i64 a;
		cin >> a;
		if (a > max_a)
			max_a = a;
		if (a < min_a)
			min_a = a;
	}
	cout << abs(max_a - min_a) << endl;
	return 0;
}


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

using namespace std;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	if(a==b || b==c || c==a){
		if(a==b && b==c && c==a){
			cout << 1 << endl;
		}
		else{
			cout << 2 << endl;
		}
	}
	else{
		cout << 3 <<endl;
	}

	return 0;


}


Measured memory_bytes: 256
from collections import OrderedDict

def solve(n, s):
    d = OrderedDict([
        ("AC", 0),
        ("WA", 0),
        ("TLE", 0),
        ("RE", 0)
    ])
    for i in range(n):
        d[s[i]] += 1
    for k, v in d.items():
        print("%s x %d" % (k, v))

n = int(input())
s = [input() for i in range(n)]
solve(n, s)

Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    rep(i,n) cin >> a.at(i);
    sort(all(a));
    rep(i,n-1){
        if(a.at(i) == a.at(i+1)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, t[106], v[106], m[106], i, j, akt;
double res;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &t[i]);
for (i=0;i<n;i++) scanf("%d", &v[i]);
m[n-1] = 0;
for (i=n-2;i>=0;i--) m[i] = min(v[i+1], m[i+1] + t[i+1]);
res = 0.0;
akt = 0;
for (i=0;i<n;i++) {
	for (j=0;j<t[i];j++) {
		if (akt < v[i] && akt + 1 - m[i] <= t[i] - 1 - j) {
			akt++;
			res += akt  - 0.5;
		} else if (akt == v[i] && akt - m[i] <= t[i] - 1 - j) {
			res += akt;
		} else if (akt - m[i] == t[i] - j) {
			akt--;
			res += akt + 0.5;
		} else if (akt < v[i]) {
			res += akt + 0.25;
		}
	}
}
printf("%.9lf\n", res);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int data[101]={0};
  int a,b,c,d;cin >> a >> b >> c >> d;
  int ans = 0;
  for(int i=a;i<=b;i++){
    data[i]++;
  }
  for(int i=c;i<=d;i++){
    data[i]++;
  }
  for(int i=0;i<101;i++){
    if(data[i]==2) ans++;
  }
  cout << (ans==0?0:ans-1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a==2 || b==2){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
  }
}


Measured memory_bytes: 256