akhauriyash/Code-Regression huggingface dataset:
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Monday July 27, 2020
 */

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

#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define X  first
#define Y  second

#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(const pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

// add templates here

template <typename T>
string to_string(const vector<T> &v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}

template<class T>
void println(const T &data) {
#ifndef ONLINE_JUDGE
    cout << to_string((T)data) << endl;
#endif
}

const int MOD = int(1e9+7);
const ll oo  = (ll)(1e9+20);
const ll lloo  = (ll)(1e18)+40;

template<class T>
vector<T> divisors(T number) {
    vector<T> solutions;
    for (T i = 1; i <= sqrt(number); ++i) {
        if (number % i == 0) {
            if (number/i == i) {
                solutions.push_back(i);
            } else {
                solutions.push_back(i);
                solutions.push_back(number/i);
            }
        }
    }
    return solutions;
}

class Task {
public:
    ll N;

    ll solve(istream &in, ostream &out) {
        in >> N;
        if(sqrt(N) == ((ll)sqrt(N))) return (ll)sqrt(N)*2 -2;
        vector<ll> divs = divisors<ll>(N);
        sort(rall(divs));
        ll ans = lloo;
        for(ll i = 0; i < divs.size(); ++i) {
            if(ans > (N/divs[i] + divs[i])) {
                ans = (N/divs[i] + divs[i]) - 2;
            }
        }
        return ans;
    }
    
    void run(istream &in, ostream &out) {
        int t;
        in >> t;
        while(t--) {
            out << solve(in, out) << endl;
        }
    }
};
    
auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    cout << solver.solve(in, out) << endl;
    //solver.run(in, out);
    return 0;
}


Measured memory_bytes: 3700
n = int(input())
l = []
s = 0
for i in range(n):
  a, b = map(int, input().split())
  s += a
  l.append((a, b))
  
l = sorted(l, key=lambda x: x[1])
for i in range(n):
  if s > l[-i-1][1]:
    print("No")
    exit()
  else:
    s -= l[-i-1][0]
    
print("Yes")

Measured memory_bytes: 76524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
// using ll = long long;


int main(){
    ll n;
    ll m;
    cin >> n >> m;
    ll aX[n], aY[n];
    ll bX[m], bY[m];
    rep(i, n){
        cin >> aX[i] >> aY[i];
    }

    rep(i, m){
        cin >> bX[i] >> bY[i];
    }

    ll res[n];

    rep(i, n){
        ll minD = INF;
        rep(j, m){
            ll dist = abs(aX[i] - bX[j]) + abs(aY[i] - bY[j]);
            if(dist < minD){
                minD = dist;
                res[i] = j + 1;
            }
        }
    }

    rep(i, n){
        cout << res[i] << endl;
    }

}

Measured memory_bytes: 3488
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr ll mod = 1e9 + 7;
int n, a[10010], p[1000010];
ll power(ll n, ll e) {
	ll r = 1;
	while (e) {
		if (e & 1)
			r = r * n % mod;
		n = n * n % mod;
		e /= 2;
	}
	return r;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	for (int i = 0; i < n; i++) {
		int d = a[i];
		for (int m = 2; m * m <= a[i]; m++) {
			int count = 0;
			while (d % m == 0)
				count++, d /= m;
			p[m] = max(p[m], count);
		}
		p[d] = max(p[d], 1);
	}
	ll mul = 1;
	for (int i = 1; i <= 1000000; i++)
		mul = mul * power(i, p[i]) % mod;
	ll s = 0;
	for (int i = 0; i < n; i++)
		s += mul * power(a[i], mod - 2) % mod;
	printf("%lld\n", s % mod);
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 2147483647
#define Max 100000
#define NTL -1
#define min(a,b) ((a>b)?b:a)

int main(){
  int a,b,c,i;
  int cos,x=0,y=0,z=0;
for(i=0;;i++){
  scanf("%d%d%d",&a,&b,&c);
  int tmp;
  if(a<b){
    tmp=b;b=a;a=tmp;
  }
  if(a<c){
    tmp=c;c=a;a=tmp;
  }
  if(b+c<=a)break;
  cos=b*b+c*c-a*a;
  if(cos>0){
    y++;
  }else if(cos<0){
    z++;
  }else{
    x++;
  }
}
printf("%d %d %d %d\n",i,x,y,z);
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int sum(int n) {
    int ret = 0;
    while(n > 0){
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, a, b;cin >> n >> a >> b;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int s = sum(i);
        if(a <= s && s <= b){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String aStr[] = br.readLine().split(" ");
            ArrayList<Integer> aList = new ArrayList<Integer>();
            for (int i = 0; i < aStr.length; i++) {
                aList.add(Integer.parseInt(aStr[i]));
            }
            boolean noFlag = false;
            while (aList.size() > 1) {
                if (aList.size() == 2) {
                    int tmp1 = aList.get(0);
                    int tmp2 = aList.get(1);
                    if (tmp1 % 2 == 0 && tmp2 % 2 == 0) {
                        int sum = tmp1 + tmp2;
                        aList.remove(1);
                        aList.remove(0);
                        aList.add(sum);
                    } else if (tmp1 % 2 != 0 && tmp2 % 2 != 0) {
                        int sum = tmp1 + tmp2;
                        aList.remove(1);
                        aList.remove(0);
                        aList.add(sum);
                    } else {
                        System.out.println("NO");
                        noFlag = true;
                        break;
                    }
                } else {
                    int tmp1 = aList.get(0);
                    int tmp2 = aList.get(1);
                    int tmp3 = aList.get(2);
                    if ((tmp1 % 2 == 0 && tmp2 % 2 == 0) || (tmp1 % 2 != 0 && tmp2 % 2 != 0)) {
                        int sum = tmp1 + tmp2;
                        aList.remove(1);
                        aList.remove(0);
                        aList.add(sum);
                    } else if ((tmp1 % 2 == 0 && tmp3 % 2 == 0) || (tmp1 % 2 != 0 && tmp3 % 2 != 0)) {
                        int sum = tmp1 + tmp3;
                        aList.remove(2);
                        aList.remove(0);
                        aList.add(sum);
                    } else if ((tmp2 % 2 == 0 && tmp3 % 2 == 0) || (tmp2 % 2 != 0 && tmp3 % 2 != 0)) {
                        int sum = tmp2 + tmp3;
                        aList.remove(2);
                        aList.remove(1);
                        aList.add(sum);
                    }
                }
            }
            if (!noFlag) {
                System.out.println("YES");
            }
           } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

using namespace std;

const int maxn=105;

int n,s[maxn],ans;

void selectionsort()
{
	int minn;
	for(int i=0;i<n-1;i++){
		minn=i;
		for(int j=i+1;j<n;j++){
			if(s[j]<s[minn]){
				minn=j;
			}
		}
		swap(s[minn],s[i]);
		if(i!=minn){
			ans++;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	selectionsort();
	for(int i=0;i<n;i++){
		if(i!=0){
			printf(" ");
		}
		printf("%d",s[i]);
	}
	printf("\n%d\n",ans);
	return 0;
}
/*
6
5 6 4 2 1 3
*/


Measured memory_bytes: 3184
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    vector<int> a;
    int p,q,r;
    cin>>p>>q>>r;
    a.push_back(p);
    a.push_back(q);
    a.push_back(r);

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

    cout<<a[0]+a[1]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

int dp[3][100005];

int main() {
  int N;
  cin >> N;
  vector<vector<int>> vv(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    cin >> vv.at(i).at(0) >> vv.at(i).at(1) >> vv.at(i).at(2);
  }
  dp[0][0] = vv.at(0).at(0);
  dp[1][0] = vv.at(0).at(1);
  dp[2][0] = vv.at(0).at(2);
  for (int i = 1; i < N; i++) {
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + vv.at(i).at(0);
    dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + vv.at(i).at(1);
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + vv.at(i).at(2);
  }
  int ans = max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]);
  cout << ans << endl;
}

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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    int n,l;
    cin >> n >> l;
    vector <string> v;
    string s;
    while(n--)
    {
        cin >> s;
        v.pb(s);
    }
    srt(v);
    for(auto i : v) cout << i ;
    cout << '\n';

    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

ll power(int a, int n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    int x, y, z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}



Measured memory_bytes: 256
from itertools import combinations

N = int(input())
li = []
cnt = 1
calc = 0

def nCr(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

for i in range(N):
    s = list(input())
    s.sort()
    li.append(s)

li.sort()
li.append('XXXX')

for i in range(0, N):
    if li[i] == li[i+1]:
        cnt += 1
    else:
        if cnt == 1:
            continue
        calc += nCr(cnt, 2)
        cnt = 1

print(calc)

Measured memory_bytes: 24776
n,m=map(int,input().split())
h=list(map(int,input().split()))
connect={}
for i in range(0,m):
  a,b=map(int,input().split())
  if a not in connect.keys():
    connect[a]=set()
    connect[a].add(b)
  else:
    connect[a].add(b)
  if b not in connect.keys():
    connect[b]=set()
    connect[b].add(a)
  else:
    connect[b].add(a)
count=0
final=0
for i in connect.keys():
    count+=1
    connect[i]=list(connect[i])
    for j in range(0,len(connect[i])):
        if h[i-1]<=h[connect[i][j]-1]:
            break
    else:
        final+=1
print(final+n-count)

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

using namespace std;
#define ll long long

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    vector<int> p(Q), q(Q);
    for(int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    for(int i = 0; i < Q; i++) {
        cin >> p[i] >> q[i];
        p[i]--;
        q[i]--;
    }
    vector<vector<int>> a(N, vector<int>(N, 0));
    for(int i = 0; i < M; i++) {
        a[L[i]][R[i]] += 1;
    }
    vector<vector<int>> csum(N + 1, vector<int>(N + 1, 0));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            csum[i + 1][j + 1] = csum[i][j + 1] + csum[i + 1][j] - csum[i][j] + a[i][j];
        }
    }
    for(int i = 0; i < Q; i++) {
        q[i]++;
        cout << csum[q[i]][q[i]] - csum[q[i]][p[i]] - csum[p[i]][q[i]] + csum[p[i]][p[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 7688
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;

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

cin >> a >> b >> c >> d;

if(a+b == c+d){

cout << "Balanced"<<endl;

}else if(a+b > c+d){

cout << "Left"<<endl;

}else{
cout << "Right" << endl;

}
 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll k; cin>>k;
	ll ans=0;
	for(ll i=1;i<=1e7;i++)
	{
		ans=(ans*10+7)%k;
		if(ans==0)
		{
			cout<<i; return;
		} 
	} 
	cout<<-1;
}

int main()
{
	solve();
}
/*




*/


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

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)

const int N = 2e5+5;

int n, a, b, c, d;
char s[N];

int main () {
	scanf ("%d%d%d%d%d%s", &n, &a, &b, &c, &d, s+1);
	Rep(i,a,max (c, d)-1) if (s[i]=='#' && s[i+1]=='#') {puts ("No"); return 0;}
	if (c<b || c<d) {puts ("Yes"); return 0;}
	int fl = 0;
	Rep(i,b,d) if (s[i]=='.' && s[i-1]=='.' && s[i+1]=='.') fl = 1;
	puts (fl? "Yes": "No");
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<fstream>
#include<time.h>
#include<cmath>

using namespace std;

int main(void)
{
    int a,p;
    cin>>a>>p;
    p+=a*3;    
    cout<<p/2<<endl;
}


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

const long long MOD = 1000000007;

long long LDP(long long N) {
	long long COUNT = 0, BIT[64] = {}, DP[65][3] = {};
	for (int i = 0; i < 64; i++) {
		BIT[i] = N % 2;
		N /= 2;
	}
	long long Cur = 1, END = 0;
	for (int i = 0; i < 64; i++) {
		if (BIT[i] == 1) {
			END = Cur;
			Cur *= 1;
			Cur %= MOD;
		}
		else {
			Cur *= 2;
			Cur %= MOD;
		}
	}
	COUNT = END;
	bool flag = true;
	for (int i = 63; i >= 0; i--) {
		if (BIT[i] == 0) continue;
		Cur = 1, END = 0;
		if (flag) {
			for (int j = 0; j < i; j++) {
				COUNT += Cur;
				COUNT %= MOD;
				Cur *= 3;
				Cur %= MOD;
			}
			flag = false;
			continue;
		}
		for (int j = 0; j < 65; j++) DP[j][0] = DP[j][1] = DP[j][2] = 0;
		DP[0][0] = 1;
		for (int j = 0; j < 64; j++) {
			long long SUM = DP[j][0] + DP[j][1] + DP[j][2];
			SUM %= MOD;
			if (j < i) {
				DP[j + 1][0] = SUM;
				DP[j + 1][1] = SUM;
				DP[j + 1][2] = SUM;
				END = DP[j + 1][0];
			}
			else if (BIT[j] == 1 && i != j) {
				DP[j + 1][0] = SUM;
				DP[j + 1][1] = 0;
				DP[j + 1][2] = 0;
				END = DP[j + 1][0];
			}
			else {
				DP[j + 1][0] = 0;
				DP[j + 1][1] = SUM;
				DP[j + 1][2] = SUM;
			}
		}
		COUNT += END;
		COUNT %= MOD;
	}
	return COUNT;
}

long long RDP(long long N) {
	long long COUNT = 0, BIT[64] = {}, DP[65][3] = {};
	for (int i = 0; i < 64; i++) {
		BIT[i] = N % 2;
		N /= 2;
	}
	long long Cur = 1, END = 0;
	for (int i = 0; i < 64; i++) {
		if (BIT[i] == 1) {
			END = Cur;
			Cur *= 2;
			Cur %= MOD;
		}
		else {
			Cur *= 1;
			Cur %= MOD;
		}
	}
	COUNT = END;
	bool flag = true;
	for (int i = 63; i >= 0; i--) {
		if (BIT[i] == 0) continue;
		Cur = 1, END = 0;
		if (flag) {
			for (int j = 0; j < i; j++) {
				COUNT += Cur;
				COUNT %= MOD;
				Cur *= 3;
				Cur %= MOD;
			}
			flag = false;
			continue;
		}
		for (int j = 0; j < 65; j++) DP[j][0] = DP[j][1] = DP[j][2] = 0;
		DP[0][0] = 1;
		for (int j = 0; j < 64; j++) {
			long long SUM = DP[j][0] + DP[j][1] + DP[j][2];
			SUM %= MOD;
			if (j < i) {
				DP[j + 1][0] = SUM;
				DP[j + 1][1] = SUM;
				DP[j + 1][2] = SUM;
				END = DP[j + 1][0];
			}
			else if (BIT[j] == 1 && i != j) {
				DP[j + 1][0] = SUM;
				DP[j + 1][1] = SUM;
				DP[j + 1][2] = 0;
				END = DP[j + 1][0];
			}
			else {
				DP[j + 1][0] = 0;
				DP[j + 1][1] = 0;
				DP[j + 1][2] = SUM;
			}
		}
		COUNT += END;
		COUNT %= MOD;
	}
	return COUNT;
}

int main() {
	long long L, R;
	cin >> L >> R;
	if (L == R) {
		cout << 1 << endl;
		return 0;
	}
	while (1) {
		long long LMBS = 1, RMBS = 1;
		while (L > LMBS * 2) LMBS *= 2;
		while (R > RMBS * 2) RMBS *= 2;
		if (LMBS != RMBS) break;
		if (L == LMBS || R == RMBS) break;
		L -= LMBS;
		R -= RMBS;
	}
	cout << (RDP(R) - LDP(L - 1) + MOD) % MOD << endl;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static String[] a = new String[] {"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"};
	static String[] b = new String[] {"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] w = new int[10];
		int[] k = new int[10];
		for(int i = 0; i < 10; i++) {
			w[i] = stdIn.nextInt();
		}
		for(int i = 0; i < 10; i++) {
			k[i] = stdIn.nextInt();
		}
		
		Arrays.sort(w);
		Arrays.sort(k);
		
		System.out.println((w[9] + w[8] + w[7]) + " " + (k[9] + k[8] + k[7]));
	}
	
}

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

using namespace std;

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

typedef long long int ll;

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

	int n;
	cin >> n;
	int arr[50];

	rep(i , n)
		cin >> arr[i];

    int count = 0;
	rep(i , n)
	{
		if(arr[i] != i+1)
			count++;
	}
	if(count <= 2)	cout << "YES";
	else
		cout << "NO";
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
int main(){
  int N; cin>>N;
  int ans = 0;
  for(int i=1;i<=N;++i){
    int a; cin >> a;
    if(i%2==1 && a%2==1){ ++ans;}
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3596
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func main() {
	var l, r, ans int
	fmt.Scan(&l, &r)
	if r-l <= 2018 {
		ans = 2020
		for i := l; i <= r-1; i++ {
			for j := i + 1; j <= r; j++ {
				ans = min(ans, (i*j)%2019)
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  bool ok=1;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];}
  for(int i = 0;i<n;i++){
    if(a[i]%2==0){if(a[i]%5!=0&&a[i]%3!=0){ok=0;break;
  }}
}
if(ok==0){
  cout << "DENIED";
}
else{cout << "APPROVED";}
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#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++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N,P;

int main(){
    cin>>N>>P;
    out((N*3+P)/2);
    
    
}


Measured memory_bytes: 764
N, M=map(int, input().split())
xyz=[list(map(int, input().split())) for _ in range(N)]
cand=[]

#+++
wxyz=[tmp[0]+tmp[1]+tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#++-
wxyz=[tmp[0]+tmp[1]-tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#+-+
wxyz=[tmp[0]-tmp[1]+tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#+--
wxyz=[tmp[0]-tmp[1]-tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#-++
wxyz=[-tmp[0]+tmp[1]+tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#-+-
wxyz=[-tmp[0]+tmp[1]-tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#--+
wxyz=[-tmp[0]-tmp[1]+tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

#---
wxyz=[-tmp[0]-tmp[1]-tmp[2] for tmp in xyz]
wxyz.sort(reverse=True)
cand.append(sum(wxyz[:M]))

print(max(cand))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=4010 ;
const LL MOD = 998244353;
char s[N];
LL f[N][N];
int pre[N],n;

int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%s", s+1); n=strlen(s+1);
	pre[0] =0;
	for (int i=1; i<=n; ++i) pre[i]=pre[i-1] + s[i]-'0';
	for (int i=n+1; i<=n+n; ++i) pre[i]=pre[i-1];
	memset(f, 0 ,sizeof(f));
	f[0][0] =1;
	for (int i=1; i<=2*n; ++i){
		int avail=min(n,i)*2,preR,preB;
		for (int j=0; j<= i; ++j){
			preR = j;preB = i-j;
			if ( preR > avail-pre[i] || preB>pre[i]) continue;
			f[i][j] =f[i-1][j];
			if ( j) f[i][j]=(f[i][j]+f[i-1][j-1])%MOD;
			#ifdef che
//			debug("f[%d][%d] = %lld\n", i,j,f[i][j]);
			#endif	
		}
	}
	printf("%lld\n", f[n+n][n+n-pre[n]]);	
	return 0;
}

Measured memory_bytes: 125952
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int x, y;
    cin >> x >> y;
    if (x%y==0)cout << -1 << endl;
    else cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static int M = (int) Math.pow(4, 12);

	static class Hash {
		static int[] T = new int[M];

		public Hash() {
			Arrays.fill(T, -1);
		}

		static int h1(int key) {
			return key % M;
		}

		static int h2(int key) {
			return 1 + key % (M - 1);
		}

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

		static void insert(int key) {
			int i = 0;
			while (true) {
				int j = h(key, i);
				if (T[j] == -1) {
					T[j] = key;
					return;
				} else {
					i++;
				}
			}
		}
		
		static String find(int key) {
			int i = 0;
			while (true) {
				int j = h(key, i);
				if (T[j] == key) {
					return "yes";
				}else if (i >= M || T[j] == -1) {
					return "no";
				} else {
					i++;
				} 
			}
		}
		
	}
	
	public static int keyToInt(String key){
		String s = "";
		for (int i = 0; i < key.length(); i++) {
			char c = key.charAt(i);
			if (c == 'A') {
				s += "1";
			}else if (c == 'C') {
				s += "2";
			}else if (c == 'G') {
				s += 3;
			}else if (c == 'T') {
				s += 4;
			}
		}
		return Integer.parseInt(s);
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String[][] input = new String[N][2];
		Hash hash = new Hash();

//		for (int i = 0; i < N; i++) {
//			input[i][0] = scan.next();
//			input[i][1]= scan.next();
//		}
//		for (int i = 0; i < N; i++) {
//			if (input[i][0].equals("insert")) {
//				hash.insert(keyToInt(input[i][1]));
//			}else if (input[i][0].equals("find")) {
//				System.out.println(hash.find(keyToInt(input[i][1])));
//			}
//		}
		HashSet<String> hashSet = new HashSet<>();
		for (int i = 0; i < N; i++) {
			String command = scan.next();
			String key = scan.next();
			if (command.equals("insert")) {
				hashSet.add(key);
			}else if (command.equals("find")) {
				if (hashSet.contains(key)) {
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}
		}
		
		
		scan.close();
	}

	public static void insert(int[] T, int data) {

	}

}

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

int main()
{
  int W, H;
  while (cin >> W >> H && W != 0) {
    vector<vector<int> > grid(2*H+1, vector<int>(2*W+1, 0));
    for (int i = 0; i < 2*H+1; i++) {
      grid[i][0] = grid[i][2*W] = 1;
    }
    for (int j = 0; j < 2*W+1; j++) {
      grid[0][j] = grid[2*H][j] = 1;
    }
    grid[0][1] = 0;
    grid[2*H][2*W-1] = 0;

    for (int j = 1; j < W; j++) {
      cin >> grid[1][2*j];
      if (grid[1][2*j]) {
        grid[2][2*j] = 1;
      }
    }
    for (int i = 1; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> grid[2*i][2*j+1];
        if (grid[2*i][2*j+1]) {
          grid[2*i][2*j] = grid[2*i][2*j+2] = 1;
        }
      }
      for (int j = 1; j < W; j++) {
        cin >> grid[2*i+1][2*j];
        if (grid[2*i+1][2*j]) {
          grid[2*i][2*j] = grid[2*i+2][2*j] = 1;
        }
      }
    }

    queue<pair<int,int> > q;
    q.push(make_pair(0, 1));
    vector<vector<int> > dist(2*H+1, vector<int>(2*W+1, 1000000));
    dist[0][1] = 0;
    const pair<int,int> goal(2*H, 2*W-1);
    while (!q.empty()) {
      const pair<int,int> p = q.front();
      q.pop();
      const int c = dist[p.first][p.second];
      if (p == goal) {
        cout << c/2 << endl;
        goto NEXT;
      }
      for (int d = 0; d < 4; d++) {
        static const int di[] = {-1, 1, 0, 0};
        static const int dj[] = {0, 0, -1, 1};
        const int i = p.first + di[d];
        const int j = p.second + dj[d];
        if (i >= 0 && j >= 0 && !grid[i][j] && c+1 < dist[i][j]) {
          dist[i][j] = c+1;
          q.push(make_pair(i, j));
        }
      }
    }
    cout << 0 << endl;
NEXT:
    ;
  }
  return 0;
}

Measured memory_bytes: 940
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct edge { int to, cost; };

signed main() {
	int a, b, n; cin >>n>> a >> b;
	cout << min(a, b) << ' ' << max(0ll, a + b - n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>

#define SIZE 100

int data[SIZE];
char line[SIZE];

int A,B,C,X,Y,Z;
int bill1,bill2,bill3;
int bill;
int min;
int max;
int main(){
#ifdef DEBUG
	printf("DEBUGGING ON\n");
#endif
	fgets(line,sizeof(line),stdin);
	sscanf(line,"%d %d %d %d %d",&A,&B,&C,&X,&Y);
	min = X;
	max = Y;
	if (min > Y){ min = Y;max = X;}
	/* bill = A*(X-Z/2)+B*(Y-Z/2)+C*Z */
	bill1 = A*(X-0/2)+B*(Y-0/2)+C*0;
	bill2 = A*(X-min)+B*(Y-min)+2*C*min;
	bill3 = A*(X-X)+B*(Y-Y)+2*C*max;
	bill = bill1;
	if (bill>bill2) bill=bill2;
	if (bill > bill3) bill = bill3;
	printf("%d\n",bill);
	return 0;
}

Measured memory_bytes: 128
import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


alf = ['z','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']


N = int(input()) # 1行, 単数
M = N
ans = []

while True:
  ans.append(alf[M % 26])
  if M % 26 == 0:
    M = M - 1
  if M <= 26:
    break
  M = math.floor(M / 26)

ans.reverse()
print(''.join(ans))

Measured memory_bytes: 62024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=5*1e5;
const int INF=1<<30;
int main(){
	LL N,C;
	cin >> N;
	REP(i,N+1){
		if(i*(i+1)/2>=N) {
			C=i;
			break;
		}
	}
	REP(i,C){
		LL p=C-i;
		if(N>=p){
			N-=p;
			cout << p << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

using namespace std;

int main(){

    int a,b;
    double a_d,b_d;
    int d,r;
    double f;
    

    scanf("%d %d",&a,&b);
    a_d=static_cast<double>(a);
    b_d=static_cast<double>(b);
    d=(a/b);
    r= (a%b);
    f= (a_d / b_d);
    printf("%d %d %.5f\n",d,r,f);
    //printf("%d %d\n",d,r);

    return 0;
    
}


Measured memory_bytes: 2696
n, k = map(int, input().split())
s, segment, ans, now = input(), 0, 0, '#'
for i in s:
    if i!=now:
        segment, now = segment+1, i
    else:
        ans+=1
for i in range(k):
    t = (segment>=2) + (segment>2)
    segment, ans = segment-t, ans+t
print(ans)


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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int n,m; cin >> n >> m;
    int sum=0;
    vector<int> a(m);
    rep(i,m){ cin >> a[i]; sum+=a[i];}
    if(sum<=n) cout << n-sum << endl;
    else cout << -1 << endl;
    


    }

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

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	scc_graph g(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		g.add_edge(a, b);
	}
	vector<vector<int>> scc = g.scc();
	cout << scc.size() << "\n";
	for (vector<int> l : scc) {
		cout << l.size();
		for (int v : l) {
			cout << " " << v;
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 40100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    ll A,B,AB,X,Y;
    cin >> A >> B >> AB >> X >> Y;
    
    if(A+B<2*AB){
        cout << A*X + B*Y << endl;
    } else if(X>=Y){
        ll pat1 = max(X,Y)*AB*2;
        ll pat2 = min(X,Y)*AB*2 + (X-Y)*A;
        cout << min(pat1,pat2) << endl;
    } else {
        ll pat1 = max(X,Y)*AB*2;
        ll pat2 = min(X,Y)*AB*2 + (Y-X)*B;
        cout << min(pat1,pat2) << endl;
    }
}


Measured memory_bytes: 256
/************************************************************/
//
//3????????´??°a,b,c??????????????????a??????b?????§?????´??°?????????c????´???°??????????????????????±???????????????°??????
//
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D&lang=jp
/************************************************************/

#include<stdio.h>

#define MAX 10000
#define MIN 1

int main()
{
	int a,b,c;
	int count=0;
	
	if( scanf("%d %d %d", &a, &b, &c)==3 )
	{
		if((a>=MIN) && (a<=MAX) &&
			(b>=MIN) && (b<=MAX) &&
			(c>=MIN) && (c<=MAX) && (a<=b))
		{
			for(int i=a; i<=b; i++)
			{
				if(c%i==0)
				{
					count++;
				}
			}
			printf("%d\n", count);
		}
		else
		{
			/* ERROR */
			return -1;
		}
	}
	else
	{
		/* ERROR */
		return -1;
	}
	
	return 0;
}

Measured memory_bytes: 1844
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
const long MOD = 1000000007;

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  // single A
  int num_single = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (A[i] > A[j]) {
        num_single += 1;
      }
    }
  }
  // doulbe A
  vector<int> dA(2 * N);
  for (int i = 0; i < 2 * N; ++i) {
    dA[i] = A[i % N];
  }
  int num_double = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = N; j < 2 * N; ++j) {
      if (dA[i] > dA[j]) {
        num_double += 1;
      }
    }
  }

  num_single = num_single % MOD;
  long long comb = (K * (K - 1) / 2) % MOD;
  cout << ((num_single * K) % MOD + (num_double * comb) % MOD) % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void insertionsort(int A[], int N);

int main(void){
  int i,N;
  int A[100];
  
  scanf("%d",&N);
  
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
    if(i != N-1)printf(" ");
  }
  /*  for(i = 0;i < N; i++){
    printf("%d",A[i]);
    if(i =! N-1) printf(" ");
    }*/
  printf("\n");


  insertionsort(A,N);
  
  return 0;
}

void insertionsort(int A[], int N){
  int i ,a, j,v;
  
  for(i = 1; i < N; i++){
    
    v = A[i];
    j = i -1;
    while((j >= 0) && A[j]> v){
      A[j + 1] = A[j];
      j--;
      A[j + 1] = v;
    }
    for(a = 0; a < N;a++){
      printf("%d",A[a]);
      if(a != N-1) printf(" ");
    }
    printf("\n");
  }
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <regex>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

bool match(string s1, string s2){
    for(int i=0; i<s1.length(); i++)if (s1[i] != '?' && s1[i] != s2[i])return false;
    return true;
}

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    auto M=T.length();
    auto N=S.length();

    if(N >= M){
        for(long long i=N-M; i>=0; i--){
            if(match(S.substr(i, M), T)){
                for(auto j=0; j<N; j++){
                    if(j>=i && j<i+M)cout << T[j-i];
                    else if(S[j]=='?')cout << "a";
                    else cout << S[j];
                }
                cout << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static int Num;
    public static int[] List;
    public static int Count=0;
    public static int min_j;
    public static int tmp;

    public static void main(String[] args)
    {
        Scanner scan=new Scanner(System.in);

        Num=scan.nextInt();

        List=new int[Num];

        for(int i=0;i<Num;i++)
        {
            List[i]=scan.nextInt();
        }

        SelectionSort();

        if(Num==1) System.out.println(List[0]);
        else
        {
            for (int i = 0; i < Num; i++)
            {
                if(i==Num-1) System.out.println(List[Num-1]);
                else System.out.print(List[i] + " ");
            }
        }
        System.out.println(Count);

    }

    public static void SelectionSort()
    {
        for(int i=0;i<Num;i++)
        {
            min_j=i;
            for(int j=i;j<Num;j++)
            {
                if(List[j]<List[min_j])
                {
                    min_j=j;
                }
            }
            if(min_j!=i){
                tmp=List[i];
                List[i]=List[min_j];
                List[min_j]=tmp;
                Count++;
            }
        }
    }
}

Measured memory_bytes: 26304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	
	int n; cin >> n;
	map<int, int> data = {};
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		data[a]++;
		if (data[a] >= 2) { cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 9600
import collections


points = []

for i in range(0, 3):
    p1, p2 = map(int, input().split(' '))
    points.extend([p1, p2])

counter = collections.Counter(points)
num_mode = counter.most_common(1)[0][1]
# print(num_mode)

if num_mode >= 3:
    print("NO")
else:
    print("YES")

exit(0)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){

  int N;
  cin >> N;
  vector<int> t_vector(N);
  vector<int> x_vector(N);
  vector<int> y_vector(N);

  for(int i=0;i<N;++i){
    cin >> t_vector[i] >> x_vector[i] >> y_vector[i];
  }

  int t_now;
  int t_next;
  int x_now;
  int y_now;
  int x_next;
  int y_next;
  bool flag = true;

  t_next = 0;
  x_next = 0;
  y_next = 0;

  for(int i=0; i<N; ++i){
    t_now = t_next;
    x_now = x_next;
    y_now = y_next;

    t_next = t_vector[i];
    x_next = x_vector[i];
    y_next = y_vector[i];

    int x_sa = abs(x_next - x_now);
    int y_sa = abs(y_next - y_now);
    int t_sa = t_next - t_now;

    if (((x_sa + y_sa) % 2) != (t_sa % 2)){
      flag = false;
      cout << "No" << endl;
      break;
    } else if((x_sa + y_sa) > t_sa){
      flag = false;
      cout << "No" << endl;
      break;
    }
  }

  if (flag){
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
int cnt[2][maxn], M[2], Q[2], m[2], q[2];
int n;
int main() {
	cin >> n; 
	for (int i = 1; i <= n; i++) {
                int x, p;
		cin >> x;
 p = i % 2;
		cnt[p][x]++;
		if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;
	}
	if (Q[0] != Q[1]) {
		printf("%d\n", n - M[0] - M[1]);
		return 0;
	}
	for (int i = 1; i <= 100000; i++) {
		if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;
		if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;
	}
	if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);
	else printf("%d\n", n - m[0] - M[1]);
	return 0;
}

Measured memory_bytes: 4484
n = int(input())

f = [-1 for i in range(n//2+5)]

for i in range(2,n//2+5):
    if f[i]==-1:
        f[i]=True
        for j in range(i+i,n//2+5,i):
            f[j] = False

f[0]=False
f[1]=False

lis = []
for i in range(n//2+5):
    if f[i]:
        lis.append(i)

div = []

for i in lis:
    num=n
    s=0
    while num>=1:
        num//=i
        s+=num
    div.append(s)

lis2 = [0 for i in range(5)]
for i in div:
    if i>=74:
        lis2[4]+=1
    if i>=24:
        lis2[3]+=1
    if i>=14:
        lis2[2]+=1
    if i>=4:
        lis2[1]+=1
    if i>=2:
        lis2[0]+=1
ans = 0

ans += lis2[1]*(lis2[1]-1)/2*(lis2[0]-2)
ans += lis2[2]*(lis2[1]-1)
ans += lis2[3]*(lis2[0]-1)
ans += lis2[4]

print(int(ans))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout << ((a+b < a+c)?((a+b < b+c)? a+b:b+c ):(a+c < b+c)?a+c:b+c) << endl;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1

s = input()

if c < d:
    for i in range(a,d-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    print('Yes')
else:
    flag = False
    for i in range(a,c-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    for i in range(b-1,d):
        if s[i]==s[i+1]==s[i+2]=='.':
            flag = True
            break
    if not flag:
        print('No')
        exit()
    print('Yes')



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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> st;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        st.PB(x);
    }
    sort(st.begin(), st.end());

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) continue;
            int a = st[i];
            int b = st[j];
            if(lower_bound(st.begin(), st.end(), a+b) == st.begin()) continue;

            int qtdMenor = (int) ((--lower_bound(st.begin(), st.end(), a+b)) - st.begin());
            int qtdMaior = (int) (upper_bound(st.begin(), st.end(), max(a-b, b-a)) - st.begin());
            int resp = qtdMenor - qtdMaior + 1;
            if((i >= qtdMaior && i <= qtdMenor)) resp--;
            if((j >= qtdMaior && j <= qtdMenor)) resp--;
            if(resp <= 0) continue;
            if(resp <= 0) continue;
            ans += resp;
        }
    }
    cout << ans/6 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,n,s,b,a[100];
	while(~scanf("%d",&n))
	{
		s=0;
		int a[n];
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=0;i<n-1;i++)
		{
			for(j=i+1;j<n;j++)
			{
				b=a[i]*a[j];
				s+=b;
			}
		}
		printf("%d",s);
	} 
	return 0;
} 

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w, n;
	cin>>h>>w>>n;
	vector<int> v[200001];
	for(int i=0; i<n; i++){
		int x, y;
		cin>>x>>y;
		v[x].push_back(y);
	}
	for(int x=2; x<=h; x++) sort(v[x].begin(), v[x].end());
	int sy=1;
	for(int x=2; x<=h; x++){
		for(auto y:v[x]){
			if(y<=x-2+sy){
				cout<<x-1<<endl;
				return 0;
			}
			if(x-1==y-sy) sy--;
		}
	}
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
int main(){

  int h,w,a,i,j,k;
  char cloud[100];

  scanf("%d %d",&h,&w);

  for(i = 0; i < h; i++){

    scanf("%s",cloud);

    for(j = 0; j < w; j++){

      a=0;

      for(k = j; k != -1; k--){

	if(cloud[k] == 'c'){

          printf("%d",j-k);
          a=1;
          break;

	}

      }

      if(a == 0) printf("-1");

      if(j != w-1) printf(" ");
      else printf("\n");

    }

  }

  return 0;

}

Measured memory_bytes: 604
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N;
ll D[100000];
ll cnt[100001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) cin >> D[i];
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,N) cnt[D[i]]++;
    if (cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for (int i = 1; i <= N; i++) {
        rep(j,cnt[i]) {
            ans = ans * cnt[i-1] % MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//227
	string a,b;
	cin>>a>>b;
	for(int i = (int)a.length()-(int)b.length();i>=0;i--) {
		bool h = true;
		REP(j,0,(int)b.length()-1) {
			if(b[j]!=a[i+j]&&a[i+j]!='?') {
				h=0;
				break;
			}
		}
		if(h) {
			REP(j,0,(int)b.length()-1) {
				a[i+j]=b[j];
			}
			REP(j,0,(int)a.length()-1){
				if(a[j]=='?')a[j]='a';
			}
			cout<<a;
			return;
		}
	}
	cout<<"UNRESTORABLE";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644