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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, K; cin >>N>>K;

    int A;
    vector<int> counter(N+1, 0);

    rep(i, N) {
        cin >> A;
        counter[A]++;
    }

    sort(ALL(counter), greater<int>());

    int no_change = 0;
    rep(i, K)
        no_change += counter[i];


    cout << N - no_change << endl;
}


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

void solve() {
  string s, t; cin >> s >> t;
  int a = s.size(), b = t.size();
  int ans = b;
  for(int i=0; i<=a-b; ++i) {
    int ret = 0;
    for(int j=0; j<b; ++j) {
      ret += s[i+j] != t[j];
    }
    ans = min(ans, ret);
  }
  cout << ans << endl;
}

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


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

const int MAX = 100'001;

vector<vector<int>> xy(MAX);
vector<int> dp(MAX, -1);

int dfs(int s) {
  if (dp[s] >= 0) return dp[s];

  int ret = 0;
  for (int n : xy[s]) {
    ret = max(ret, 1 + dfs(n));
  }

  return dp[s] = ret;
}

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

  rep(i, m) {
    int x, y;
    cin >> x >> y;
    xy[x].push_back(y);
  }

  rep(i, n + 1) { dfs(i); }

  int ans = 0;
  for (int l : dp) {
    ans = max(ans, l);
  }

  cout << ans << endl;
  return 0;
}


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


using namespace std;

int main(){
    int H,N;
    int sum = 0;
    cin >> H >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        sum += (A.at(i));
    }
    if(sum >= H)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#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 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 main(){
    int a,b;
    cin >> a >> b;
    put((a-1)*(b-1));
    return 0;
}


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

int main(){
  char c;
  cin >> c;
  vector<char> Alp{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  
  for(int i = 0; i < 25; i++){
  	if(Alp[i] == c){
    	cout << Alp[i + 1] << endl;
    }
  }
}


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

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

    int ans = 0;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        ans += 2*min(x, k-x);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
n=int(input())
s=sys.stdin.readlines()
A=list(map(int,s[0].split()))
C=Counter(A)
R=0
for v in C.values():
    R+=v*(v-1)//2
for i in range(n):
    r=C[A[i]]
    X=R
    if r>=2:
        x=((r-1)*(r-2)//2-(r)*(r-1)//2)
        X+=x
    print(X)

Measured memory_bytes: 25816
#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n%3==0||m%3==0||(n+m)%3==0)
    {
        cout<<"Possible"<<endl;
    }
    else
    {
        cout<<"Impossible"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds; 
#define     mod             1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif




int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    IOS;
   
     int x;

     cin>>x;

     

     

     cout<< 360 / __gcd(360, x)<<endl;
}
            

    
    



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int N=5000+5;
int n,m,a[N],b[N],f[N][N];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++)scanf("%lld",&b[i]);
	f[0][0]=1;
  	for(int i=0;i<=n;i++)
	  	for(int j=0;j<=m;j++)
		{
			if(i==0&&j==0)continue;
			int sum=0;
			if(i)sum+=f[i-1][j];
			if(j)sum+=f[i][j-1];
			if(i>0&&j>0)
			{
			  	sum-=f[i-1][j-1];
			  	if(a[i]==b[j])sum+=f[i-1][j-1];
			}
			sum=(sum%mod+mod)%mod;
    		f[i][j]=sum;
  		}
  	cout<<f[n][m];
}
/*
f[i][j],i和j配对的方案数
f[i][j]+=f[i+1][j+1]+1 (a[i]==b[j])
f[i][j]+=f[i+1][j]+f[i][j+1]-f[i+1][j+1]
告非，我就是那个f[i+1][j+1]没想到，没想到会有重复的
就是(i+1,j)->(i+1,j+1)，(i,j+1)->(i+1,j+1),然后f(i+1,j+1)多加了一遍 
*/

Measured memory_bytes: 79104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>c(n,0),s(n,0),f(n,0);
	vector<int>sum(n+1,0);
	repp(i, 1, n)cin >> c[i] >> s[i] >> f[i];
	for (int i = 1; i < n; ++i) {
		sum[i] = s[i] + c[i];
		for (int j = i + 1; j < n; ++j) {
			int left = s[j];
				if (sum[i] >left) {
					while (sum[i] > left) left += f[j];
				}
				sum[i] = left;
				sum[i] += c[j];
			}
		}
	for (int i = 1; i <= n; ++i)cout << sum[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;






void Main() {

  int n, a, b;
  cin >> n >> a >> b;

  int cnt0 = 0, cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    if (p <= a) ++cnt0;
    else if (p >= a+1 && p <= b) ++cnt1;
    else if (p >= b+1) ++cnt2;
  }

  cout << min({cnt0, cnt1, cnt2});
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define all(a) a.begin(), a.end()

const ll INF = (ll)(1e18)+1;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll l = -INF, r = INF;
  while (r - l > 1) {
    ll x = (r+l)/2;
    bool ok = [=] {
      ll total = 0;
      rep(i, n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (r - l > 1) {
            int id = (r+l) / 2;
            if (a[i] * a[id] < x) r = id;
            else l = id;
          }
          total += n-r;
        } else {
          int l = -1, r = n;
          while (r - l > 1) {
            int id = (r+l) / 2;
            if (a[i] * a[id] < x) l = id;
            else r = id;
          }
          total += r;
        }
        if (a[i] * a[i] < x) --total;
      }
      return total < 2*k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l;
}

Measured memory_bytes: 3428
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        try {
            main.solve(args);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void solve(String[] args) throws Exception {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] ways = new int[N];
        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt() -1;
            int b = scanner.nextInt() -1;
            ways[a]++;
            ways[b]++;
        }

        for (int i = 0; i < N; i++) {
            System.out.println(ways[i]);
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 20308
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int N, M, Q;
vector<ll> a, b, c, d;

ll score(vector<int> A) {
    ll res = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

ll dfs(vector<int> A) {
    if (A.size() == N) {
        return score(A);
    }

    ll res = 0;
    int last = 0;
    if (!A.empty()) last = A.back();
    repi(i, last, M){
        A.push_back(i);
        res = max(res, dfs(A)); // 再帰呼出しながら、スコア最大値を更新
        A.pop_back();
    }
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> A;
    cout << dfs(A) << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

int num[12][12];

int main(){
    int n;
    cin >> n;
    memset(num, 0, sizeof(num));
    for(int k = 1; k <= n; k++){
        int last = k % 10;
        int top = k;
        while(top >= 10){
            top /= 10;
        }
        num[top][last]++;
    }
    long long int ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++)ans += (long long int)num[i][j] * num[j][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem: A - Don't be late
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;
 
void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	
	if(s*t>=d){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
    return;
}
// how r u bro

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
int n,m;
int fa[100001],ans;
using namespace std;

int fin(int x)
{
	return (fa[x]==x)?x:fa[x]=fin(fa[x]);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
	}
	for(int i=1;i<=m;i++)
	{
		int u,o;
		scanf("%d%d",&u,&o);
		int uu=fin(u),oo=fin(o);
		fa[oo]=uu;
	}
	for(int i=2;i<=n;i++)
	{
		int j=fin(i),k=fin(i-1);
		if(j!=k) ans++,fa[j]=k;
		else continue;
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 4072
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
string s;
int main(){
    cin>>n>>s;
    ll cur=0;
    for(int i=0;i<n;i++)cur+=(s[i]=='#');
    ll ans=cur;
    for(int i=n-1;i>=0;i--){
	if(s[i]=='#')cur--;
	if(s[i]=='.')cur++;
	ans=min(ans,cur);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def is_median(k, xl, is_odd):
	over = 0
	under = 0
	inner = 0
	same = 0
	for a,b in xl:
		if b < k:
			under+=1
		elif k<a:
			over+=1
		elif a==k and b == k:
			same+=1
		else:
			inner+=1
	
	if abs(under-over) < same+inner:
		return 0
	else:
		return 1 if under > over else -1

def main2():
	n = int(input())
	#b , c = tin()
	xl=[]
	for _ in range(n):
		a,b = tin()
		xl.append((a,b))
	#s = input()
	min_v=0
	max_v=mod
	for a,b in xl:
		min_v=min(min_v, a)
		max_v=max(max_v, b)
	
	d = 1 if n % 2 == 0 else 1/2
	
	k_max_ok = min_v
	k_max_ng = max_v
	while k_max_ng - k_max_ok > d:
		pass
	
	k_min_ok = min_v
	
def main():
	n = int(input())
	al=[]
	bl=[]
	for i in range(n):
		a,b = tin()
		al.append(a)
		bl.append(b)
		
	al.sort()
	bl.sort()
	
	if n % 2 == 1:
		pos = ((n + 1) // 2) - 1
		d = bl[pos] - al[pos] + 1
		return d
	else:
		pos_l = ((n) // 2) - 1
		pos_r = pos_l + 1
		
		if al[pos_r] < bl[pos_l]:
			r = bl[pos_l] - al[pos_l] + bl[pos_r] - al[pos_r] + 1 - max(0, al[pos_r]-bl[pos_l])
		else:
			#return 1/0
			median_min = al[pos_l] + al[pos_r]
			median_max = bl[pos_l] + bl[pos_r]
			r = median_max - median_min + 1
			#pa((median_min,median_max))
		return r
		
			
		
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 102224
import math
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
def function(m, a):
  count = 0
  for i in a:
    count += m%i
  return count
def lcm_base(x, y):
    return (x * y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
max_num = lcm(*a)-1
print(function(max_num, a))

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		BigInteger[] a = new BigInteger[n];
		for (int i = 0; i < n; i++) {
			a[i] = BigInteger.valueOf(Integer.parseInt(sa[i]));
		}
		br.close();

		BigInteger lcm = BigInteger.ONE;
		for (int i = 0; i < n; i++) {
			lcm = lcm.divide(lcm.gcd(a[i])).multiply(a[i]);
		}
		BigInteger m = BigInteger.valueOf(1000000007);
		lcm = lcm.mod(m);

		BigInteger ans = BigInteger.ZERO;
		for (int i = 0; i < n; i++) {
			ans = ans.add(lcm.multiply(a[i].modInverse(m)));
			ans = ans.mod(m);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 153872
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

const int INF=1e9;
void solve() {
    cini(n);

    vi a(n+1);
    vi aa(n);
    for(int i=0; i<n; i++) {
        cin>>aa[i];
        a[aa[i]]++;
    }

    vi b(n+1);
    vi bb(n);
    bool imp=false;
    for(int i=0; i<n; i++) {
        cin>>bb[i];
        b[bb[i]]++;

        if(a[bb[i]]+b[bb[i]]>n)
            imp=true;
    }

    if(imp) {
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;

    set<pii> q;
    vi cnt(n+1);
    for(int i=1; i<=n; i++) {
        cnt[i]=a[i]+b[i];

        if(b[i]>0)
            q.emplace(-cnt[i], i);
    }

    vi ans(n);
    for(int i=0; i<n; i++) {
        assert(q.size()>0);
        auto it=q.begin();
        if(aa[i]==it->second)
            it++;
        ans[i]=it->second;

        q.erase({-cnt[aa[i]], aa[i]});

        cnt[aa[i]]--;
        if(b[aa[i]]>0)
            q.emplace(-cnt[aa[i]], aa[i]);

        it=q.lower_bound({-cnt[ans[i]], ans[i]});
        assert(it!=q.end());
        q.erase(it);
        cnt[ans[i]]--;
        b[ans[i]]--;
        if(b[ans[i]]>0)
            q.emplace(-cnt[ans[i]], ans[i]);
    }

    for(int i=0; i<n; i++)
        cout<<ans[i]<<" ";
    cout<<endl;

}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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

int main(void){
    int N,i,j,k,cnt=0;
    long long int L[110];
    long long int tmp;

    scanf("%d",&N);

    for(i=1;i<=N;i++){
        scanf("%lld",&L[i]);
    }


    for (i=1; i<=N; ++i) {
        for (j=i+1; j<=N; ++j) {
            if (L[i] > L[j]) {
                tmp =  L[i];
                L[i] = L[j];
                L[j] = tmp;
            }
        }
    }






    for(i=1;i<=N-2;i++){
        for(j=i+1;j<=N-1;j++){
            for(k=j+1;k<=N;k++){
                if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i]){

                }else{
                    if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]){
                        cnt++;
                    }
                }
            }
        }
    }

    printf("%d\n",cnt);

    return 0;


}

Measured memory_bytes: 2156
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;

struct edge {
	int from, to, cost;
	edge(int f, int t, int c): from(f), to(t), cost(c) {}
};

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

	vector<edge> edges;
	vector<i64> dist(n, INF);
	rep(i, 0, m) {
		i64 a, b, c;
		cin >> a >> b >> c;
		--a, --b;
		edges.emplace_back(a, b, -c);
	}

	dist[0] = 0;
	rep(i, 0, n * 2) {
		bool updated = false;

		for (auto e : edges) {
			if (dist[e.from] != INF && dist[e.from] + e.cost < dist[e.to]) {
				updated = true;
				dist[e.to] = dist[e.from] + e.cost;
				// 閉路の後にゴールがないとだめ
				if (i >= n && e.to == n - 1) {
					cout << "inf" << endl;
					return 0;
				}
			}
		}
	}
	cout << -dist[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 3680
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
v = readints()
cnt = 0
tmp = [0]*(10**5+1)
tmp2 = [0]*(10**5+1)
for i in range(n):
    if i % 2 == 0:
        tmp[v[i]] += 1
    else:
        tmp2[v[i]] += 1
tmp_max = 0
tmp2_max = 0
for i in range(len(tmp)):
    if tmp[tmp_max] < tmp[i]:
        tmp_max = i
for i in range(len(tmp2)):
    if tmp2[tmp2_max] < tmp2[i]:
        tmp2_max = i
if tmp_max != tmp2_max:
    cnt += (n//2)-tmp[tmp_max]
    cnt += (n//2)-tmp2[tmp2_max]
    print(cnt)
    exit()
tmp_max2 = 0
tmp2_max2 = 0
cnt2 = 0
cnt3 = 0
for i in range(len(tmp)):
    if i != tmp_max:
        if tmp[tmp_max2] < tmp[i]:
            tmp_max2 = i
for i in range(len(tmp2)):
    if i != tmp2_max:
        if tmp2[tmp2_max2] < tmp2[i]:
            tmp2_max2 = i
cnt2 = (n//2)-tmp[tmp_max]+(n//2)-tmp2[tmp2_max2]
cnt3 = (n//2)-tmp2[tmp2_max]+(n//2)-tmp[tmp_max2]
print(min(cnt2, cnt3))
# print(tmp_max)
# print(tmp2_max)
# print(tmp_max2)
# print(tmp2_max2)


Measured memory_bytes: 53168
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
	int N, K; cin >> N >> K;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];

	int res = 0; int i = 0;
	res++; i += K;
	while(i < N){
		i += K-1;
		res++;
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	char pattern[]="CODEFESTIVAL2016";
	char input[17];
	int loop=0,i;
	scanf("%s",input);
	for(i=0;i<16;i++){
		if(input[i]!=pattern[i]){
			loop++;
		}
	}
	printf("%d\n",loop );
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define N 10000
#define NIL -1

int n,parent[N], left[N], right[N],D[N], H[N];

int GetDepth(int);

void SetDepth(int,int);

int seTHeight(int);

int seTSibling(int);

void PrintChildren(int);



int main(){
  
  int i, d, v, l, r;
  
  scanf("%d", &n);
  
  for(i = 0 ; i < n ; i++) {
    parent[i] = NIL;
    left[i] = NIL;
    right[i] = NIL;
  }

  for( i = 0 ; i < n ; i++){
    scanf("%d%d%d", &v,&l,&d);
    left[v] = l;
    right[v] = d;
    if(l != NIL ){
      parent[l] = v;
    }
    if(d != NIL ){
      parent[d] = v;
    }
  }
  for( i = 0 ; i < n ; i++){
    if( parent[i] == NIL ) {
      r = i;
    }
  }

  SetDepth(r, 0);
  seTHeight(r);

  for( i = 0 ; i < n ; i++) {
    PrintChildren(i);
  }

  return 0;
}
int GetDepth(int u){
  int d = 0;
  while(parent[u] != NIL){
    u = parent[u];
    d++;
  }
  return d;
}


void SetDepth(int u, int p){
  D[u] = p;
  if(right[u] != NIL){
    SetDepth(right[u], p+1 );
  }
  if(left[u] != NIL){
    SetDepth(left[u], p+1 );
  }
}


int seTHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if( right[u] != NIL ){
    h1 = seTHeight(right[u]) + 1;
  }
  if( left[u] != NIL ){
    h2 = seTHeight(left[u]) + 1;
  }
  return H[u] =(h1 > h2 ? h1 : h2);
}


int seTSibling(int u){
  if(parent[u] == NIL ) {
    return NIL;
  }
  if(left[parent[u]] != u && left[parent[u]] != NIL ){
    return left[parent[u]];
  }
  if(right[parent[u]] != u && right[parent[u]] != NIL) {
    return right[parent[u]];
  }
  return NIL;
}

void PrintChildren(int u){

  int i, c;
  int deg = 0;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("sibling = %d, ", seTSibling(u));
  if(left[u] != NIL ) {
    deg++;
  }
  if(right[u] != NIL ) {
    deg++;
  }
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(parent[u] == NIL) {
    printf("root\n");
  }
  else if(left[u] == NIL && right[u] == NIL ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long K,A,B;
    cin>>K>>A>>B;
    
    long long sum=1;
    
    if(A>=B||B==A+1){
        cout<<K+sum<<endl;
        return 0;
    }
        
    for(long long i=1;i<=K;i++){
        if(sum>=A&&i!=K){
            sum-=A;
            i++;
            sum+=B;
        }else{
            sum++;
        }
        
    }
    
    cout<<sum<<endl;
    
}

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

int main(){
  int a,b;
  cin >> a>>b;
  if (a%2!=0){
    a++;
  }
  if (a/b>=2){
    cout <<"YES"<<endl;
  }
  else{
    cout <<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string n;
  cin >> n;
  rep(i,n.size()) {
    if (n[i] == n[i+1] && n[i+1] == n[i+2]) {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
}


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

int main(){
  ll x,money=100;cin>>x;
  int count=0;  
  while(money<x){
    money*=1.01;
    count++;
  }

  cout<<count;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cctype>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

char s[1000][1000];

char state[1000][1000];

int H, W, N;


int main()
{
	//freopen("in.txt", "r", stdin);

	while (scanf("%d%d%d", &H, &W, &N)==3) {
		if (H==0 && W==0) break;
		int i, j;
		char c;
		int si, sj;

		for (i=0; i<H; i++) {
			for (j=0; j<W; j++) {
				do { c=getchar();
				} while (c!='.' && c!='S' && c!='X' && !isdigit(c));
				s[i][j] = c;
				if (c=='S') {
					si = i; sj = j;
				}
			}
		}

		memset(state, 0, sizeof(state));
		state[si][sj] = 1;
		
		int step=0;
		int want=1;
		queue<int> q1, q2, *q, *nq, *qtmp;

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

		q = &q1; nq = &q2;
		q1.push((si<<16)|sj);

		while (want<=N) {
			int old_want=want;
			while (!nq->empty()) nq->pop();
			step++;
			while (!q->empty()) {
				
				int i, j, value;
				value = q->front(); q->pop();
				i = value>>16; j = value&0xffff;

				int k;
				for (k=0; k<4; k++) {
					int ti, tj;
					ti = i+dy[k]; tj = j+dx[k];
					if (ti<0 || ti>=H || tj<0 || tj>=W || s[ti][tj]=='X') continue;
					if (state[ti][tj]==want) continue;
					if (s[ti][tj]==want+'0') {
						want++; 
					}
					
					state[ti][tj] = want;
					nq->push((ti<<16)|tj);
					if (want!=old_want) break;
				}
				if (want!=old_want) break;
			}

			if (want!=old_want) {
				while (nq->size()>1) nq->pop();
			}

			qtmp = q; q = nq; nq = qtmp;



		}

		printf("%d\n", step);

	}

	return 0;
}

Measured memory_bytes: 3008
N,L = map(int,input().split())
src = list(map(int,input().split()))

for i,(a,b) in enumerate(zip(src, src[1:])):
    if a+b >= L:
        print('Possible')
        for j in range(1,i+1): print(j)
        for j in range(N-1,i,-1): print(j)
        exit()
print('Impossible')


Measured memory_bytes: 14668
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m=0;
	string s[200005];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++){
		if(s[i]!=s[i+1])
			m++;
	}
	cout<<m;
	return 0;
} 

Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+1); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define QUICK ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define srt(a); sort(a.begin(), a.end())
#define CASE int t; cin>>t; while(t--)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
#define upcase(s)  transform(s.begin(), s.end(), s.begin(), ::toupper)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define int ll
const int INF = 1e9 + 7;
const int maxn = 1e5 + 3;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////



void solve(){

	inp(h); inp(w);
	vec(vec(char))a(1003, vec(char)(1003, 0));
	vec(vec(int))dp(1003, vec(int)(1003, 0));

	dp[1][0] = 1;

	FOR(i,1,h){
		FOR(j,1,w){
			cin>>a[i][j];
		}
	}

	FOR(i,1,h){
		FOR(j,1,w){
			if(a[i][j] == '#')
				continue;
			
			dp[i][j] = (dp[i][j-1]+dp[i-1][j]) % MOD;
		}
	}

	cout << dp[h][w] % MOD;

}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	QUICK;
	//CASE{
		solve();
	//}
	printclock;
}

Measured memory_bytes: 12156
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

  string C;
  cin >> C;

  int nRed = 0;
  int nWhite = 0;
  for (int i = 0; i < N; i++) {
    if (C[i] == 'R') {
      nRed++;
    } else {
      nWhite++;
    }
  }

  if (nRed == N) {
    cout << 0 << endl;
    return 0;
  }

  int counter = 0;
  for (int i = 0; i < nRed; i++) {
    if (C[i] == 'W') {
      counter++;
      nWhite--;
    }
  }

  cout << counter << endl;

  return 0;
}


Measured memory_bytes: 3388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

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

    REP(i,3)
        if (s[i] == t[i])
            ans++;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vp vector<pii>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define INF 1e9
#define LLINF 1e18
#define PI (acos(-1))
#define MOD 1e9+7
 
int main(){
	int n;
	cin >> n;
	vi v(n);
	rep(i ,n) cin >> v[i];
	sort(all(v));
	
	int ans = 0;
	rep(i ,n - 2){
		int a = v[i];
		
		FOR(j, i + 1,n - 1){
			int b = v[j];
			
			FOR(k, j + 1, n){
				int c = v[k];
				if(c < a + b)
					ans++;
				else
					break;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
					
	
	
	
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
 
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

/////////////////////////


//Answer


int main() {

string N;
cin>>N;
vector<int> X(N.size());
int ans=0;
transform(N.begin(), N.end(), X.begin(), [](char ch) { return ch - '0';});
for(int i=0;i<N.size();i++){
ans=(ans+X.at(i))%9;
}
if(ans==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}


}


Measured memory_bytes: 238764
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,temp,count=0;
	int lastdigit,firstdigit;
	cin>>n;
	int dp[10][10]={0};
	for (int i = 1; i <n+1; i++) {
		lastdigit=i%10;
		temp=(int)log10(i);
		firstdigit=i/pow(10,temp);
		dp[lastdigit][firstdigit]++;
	}
	for (int i = 1; i <10; i++) {
		for (int j = 1; j < 10; j++) {
			count+=dp[i][j]*dp[j][i];
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s;
    cin >> s;
    int len = s.size();

    vector<vector<ll>> dp(len+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    REP(i, len) {
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';

        REP(j, 13) {
            if (c == -1) {
                REP(k, 10) {
                    dp[i+1][(j*10 + k + 13)%13] += dp[i][j];
                    dp[i+1][(j*10 + k + 13)%13] %= MOD;
                }
            } else {
                dp[i+1][(j*10 + c + 13)%13] += dp[i][j];
                dp[i+1][(j*10 + c + 13)%13] %= MOD;
            }
        }
    }

    std::cout << dp[len][5] << '\n';

    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    cout<<"\n";
}

int main()
{
    int n;
    cin>>n;
    ll a;
    vector<ll> ar;
    map<ll,ll> m;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        
        if(m[a]++==0)
        {
            ar.push_back(a);
        }
    }

    sort(ar.begin(),ar.end());

    ll ans = 0;

    for(int i=0; i<ar.size(); i++)
    {
        for(int j=i+1; j<ar.size(); j++)
        {
            for(int k=j+1; k<ar.size(); k++)
            {
                if(ar[i]+ar[j]>ar[k])
                {
                    ans += (m[ar[i]]*m[ar[j]]*m[ar[k]]);
                }
            }
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 3640
import sys
a, b, c = map(int, input().split())
k = int(input())
while True:
    if b <= a:
        b = b*2
        k += -1
        if k < 0:
            print('No')
            sys.exit()
    else:
        break
while True:
    if c <= b:
        c = c*2
        k += -1
        if k < 0:
            print('No')
            sys.exit()
    else:
        break
print('Yes')

Measured memory_bytes: 9128
N=int(input())
alist=list(map(int,input().split()))

if N%2==0:
  dp=[]
  for i in range(2):
    array=[0]*N
    dp.append(array)
    
  #init
  dp[0][0]=alist[0]
  dp[1][1]=alist[1]
  for i in range(2,N):
    dp[0][i]=dp[0][i-2]+alist[i]
    dp[1][i]=max(dp[1][i-2]+alist[i],dp[0][i-3]+alist[i])
    
  print(max(dp[0][-2],dp[1][-1]))
else:
  dp=[]
  for i in range(3):
    array=[0]*N
    dp.append(array)

  #init
  dp[0][0]=alist[0]
  dp[0][2]=alist[0]+alist[2]
  dp[1][1]=alist[1]
  dp[2][2]=alist[2]
  for i in range(3,N):
    dp[0][i]=dp[0][i-2]+alist[i]
    dp[1][i]=max(dp[1][i-2]+alist[i],dp[0][i-3]+alist[i])
    dp[2][i]=max(dp[2][i-2]+alist[i],dp[1][i-3]+alist[i],dp[0][i-4]+alist[i])

  #dp[0][-1] is NG
  print(max(dp[0][-3],dp[1][-2],dp[2][-1]))

Measured memory_bytes: 51924
#include <stdio.h>

int main()
{
    char key[5],flag = 0,i;
    
    scanf("%s",key);

    for (i = 1; i < 4; i++)
    {
        if(key[i] == key[i - 1])
        {
            break;
        }
    }
    if (i == 4)
    {
        printf("Good");
    }
    else
    {
        printf("Bad");
    }
    
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
struct Point {
	int x, y;

	double dis(Point a, Point b) {
		double x = a.x - b.x;
		double y = a.y - b.y;
		return sqrt(x*x + y * y);
	}
};

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

	string s;
	cin >> s;
	int num_c = 0, num_f = 0;
	bool flg1 = false;
	bool flg2 = false;

	for (int i = 0; i < (int)s.size(); i++)
	{
		if (!flg1) {
			if (s[i] == 'C') {
				flg1 = true;
			}
		}
		else {
			if (s[i] == 'F') {
				flg2 = true;
			}
		}
	}

	if (flg1&&flg2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int A,B,K,i;
    int num=0;
    int ans[110];

    cin >> A >> B >> K;

    for (i=1; i < 110; i++){
        if ((A % i == 0)&&(B % i == 0)){
            ans[num]=i;
            num++;
        }
    }
    cout << ans[num-K] << endl;
 }



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

q=['WA' for i in range(n)]
w=[0 for i in range(n)]
ans=0
pen=0
for i in range(m):
    p,s=input().split()
    pi=int(p)-1
    if s=='AC' and q[pi]=='WA':
        ans+=1
        pen+=(w[pi])
        q[pi]='AC'
    else:
        w[pi]+=1
        

        
print(ans,pen)


Measured memory_bytes: 10440
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[200001];
int main(){
	int K,N;scanf("%d %d",&K,&N);
	for(int i=0;i<N;i++) scanf("%d",arr+i);
	int Max=K-arr[N-1]+arr[0];
	for(int i=1;i<N;i++) Max=max(Max,arr[i]-arr[i-1]);
	printf("%d",K-Max);
}

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

#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

ll N, dp[MAXN], ans;
pll A[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) {
		ll a, b; cin >> a >> b;
		A[i] = {a + b, a - b};
	}
	sort(A+1, A+1+N);
	for(int i=1; i<=N; i++) {
		int idx = lower_bound(A+1, A+1+N, pll(A[i].se+1, -1e18)) - A - 1;
		dp[i] = max(dp[i-1], dp[idx] + 1);
		ans = max(dp[i], ans);
	}
	cout << ans;
}

Measured memory_bytes: 2560
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro split-ints-bind (vars string &body body)
  (let ((position (gensym))
        (s (gensym)))
    (labels ((expand (vars &optional init-pos)
               (if (null vars)
                   body
                   `((multiple-value-bind (,(car vars) ,position)
                         (parse-integer ,s :start ,(or init-pos position)
                                           :junk-allowed t)
                       ,@(when (null (cdr vars)) `((declare (ignore ,position))))
                       ,@(expand (cdr vars)))))))
      `(let ((,s ,string))
         (declare (string ,s))
         ,@(expand vars 0)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (hxy-table (make-array n :element-type '(cons uint32 (cons uint32 uint32)))))
    (dotimes (i n)
      (split-ints-bind (x y h) (read-line)
        (setf (aref hxy-table i) (list h x y))))
    (setf hxy-table (sort hxy-table #'> :key #'car))
    (when (zerop (car (aref hxy-table 0)))
      (error "Huh?"))
    (dotimes (cx 101)
      (dotimes (cy 101)
        (loop with cand-height = most-positive-fixnum
              for i below n
              for (h x y) of-type (uint32 uint32 uint32) = (aref hxy-table i)
              do (if (zerop h)
                     (unless (<= cand-height (+ (abs (- x cx)) (abs (- y cy))))
                       (return))
                     (let ((must-height (+ h (abs (- x cx)) (abs (- y cy)))))
                       (when (< must-height 1)
                         (return))
                       (if (= cand-height most-positive-fixnum)
                           (setf cand-height must-height)
                           (unless (= cand-height must-height)
                             (return)))))
              finally (format t "~A ~A ~A~%" cx cy cand-height)
                      (return-from main))))))

#-swank(main)


Measured memory_bytes: 16608
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#include<deque>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
vector<int>pa;
vector<int>na;
long long ans,L=-1e18,R=1e18,l,r,k,mid,MID,num,a[200005],n,x=1,y=2,t,g;;
int main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    while(L+1<R){
        MID=(L+R)/2;
        num=0;
        for(int i=1;i<=n;i++){
            if(a[i]<0){
                l=i;
                r=n+1;
                while(l+1<r){
                    mid=(l+r)/2;
                    if(a[i]*a[mid]<=MID)
                        r=mid;
                    else
                        l=mid;
                }
                num+=n-r+1;
            }
            else{
                l=i;
                r=n+1;
                while(l+1<r){
                    mid=(l+r)/2;
                    if(a[i]*a[mid]<=MID)
                        l=mid;
                    else
                        r=mid;
                }
                num+=l-i;
            }
        }
        if(num<k)
            L=MID;
        else
            R=MID;
        //printf("%lld %lld %lld %lld\n",L,R,MID,num);
    }
    printf("%lld",R);
}


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

int main() {

	int n;
	int i, r;

	int sum = 0;
	cin >> n;
  	for (int j = 0; j < n; j++) {
		cin >> i >> r;
    	sum += (r - i + 1);
	}
	cout << sum << endl;
}
	

Measured memory_bytes: 256
<?php

[$a, $b, $h, $m] = array_map(
    function (string $string): int {
        return (int)$string;
    },
    explode(' ', trim(fgets(STDIN)))
);

$α = 2 * M_PI * abs(60 * $h - 11 * $m) / 12 / 60;

echo sqrt($a ** 2 + $b ** 2 - 2 * $a * $b * cos($α));


Measured memory_bytes: 16528