akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long, long> pl;
typedef vector<long, long> vll;
typedef map<int, int> mi;
typedef map<long, long> ml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef tuple<double, int, int> dii;
typedef tuple<int, int, int> iii;
typedef priority_queue<int, vi, greater<int>> min_pq;
 
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, b) for(int i = 0; i < b; ++i)
#define ROF(i, b, a) for(int i = b; i >= a; --i)
#define PER(i, b) for (int i = b; i >= 0; --i)
#define trav(x, a) for(auto x: a)
#define TC(test_case) while(test_case--)
 
#define mp make_pair
#define mtp make_tuple
#define pb push_back
#define eb emplace_back
#define rsz resize
#define pf push_front
#define F first
#define S second

#define ar array
#define LSOne(S) ((S) & -(S))
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define MxN 1005
#define INF 1e9
#define EPS 1e-9
enum {UNVISITED = -1, VISITED = -2};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int x; cin >> x;
    cout << (x == 1? 0 : 1) << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
using namespace std;
const int N = 2e5+10;
int n,k,a[N];

bool check(int mid)
{
		int cnt = 0;
		for (int i = 0 ;i < n; i++)
		{

			cnt += a[i]/mid;
			if (a[i] % mid == 0) cnt--;
		}

		if (cnt <= k) return true;
	return false;
}

int main()
{

	int mx = 0;
	cin>>n>>k;
	for (int i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
		mx = max(mx,a[i]);
	}

	int up = mx, down = 1;
	while(up-down > 1)
	{
		int mid = (up+down)/2;
		if (check(mid)) up = mid;
		else			down = mid;
		
	}

	if (check(down)) cout<<down<<endl;
	else			 cout<<up<<endl;


return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e6+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

const int N = 25;

int n, m;
char a[N][N];
int vis[N][N], dist[N][N];
int dx[]={-1, +1, 0, 0};
int dy[]={0, 0, +1, -1};

int bfs(int i, int j)
{
    memset(vis, 0, sizeof vis);
    queue<pi>q;
    vis[i][j] = 1;
    dist[i][j] = 0;
    q.push({i, j});
    int cost = 0;
    while(!q.empty()){
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            for(int c=0 ; c<4 ; c++){
                int nx = x + dx[c];
                int ny = y + dy[c];
                if(nx < 0 or nx >= n or ny < 0 or ny >= m or a[nx][ny] == '#' ) continue;
                if(!vis[nx][ny]){
                    vis[nx][ny] = 1;
                    dist[nx][ny] = dist[x][y] + 1;
                    cost = max(dist[nx][ny], cost);
                    q.push({nx, ny});
                }
            }
    }
    return cost;
}


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

	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(a[i][j] == '.'){
				ans = max(ans, bfs(i, j));
			}
		}
    }

	cout << ans <<endl ;

	return 0;
}


Measured memory_bytes: 71936
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m; string s;
char maze[60][60];
int dis[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	int a, b;
	cin >> a >> b;
	int res = 0;
	res = max(a + b, a + a - 1);
	chmax(res, b + b - 1);
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string X;
ll modByPlus[200010];
ll modByMinus[200010];
ll wholePlus,wholeMinus;
int main(){
    cin>>N>>X;
    ll cnt=0;
    for(ll i=0;i<N;i++)cnt+=(X[i]=='1');
    
    modByPlus[0]=1%(cnt+1);
    if(cnt!=1)modByMinus[0]=1%(cnt-1);
    ll tmp=1;
    for(ll i=1;i<N;i++){
        tmp=tmp*2%(cnt+1);
        modByPlus[i]=tmp;
    }
    tmp=1;
    for(ll i=1;i<N;i++){
        if(cnt==1)break;
        tmp=tmp*2%(cnt-1);
        modByMinus[i]=tmp%(cnt-1);
    }
    for(ll i=0;i<N;i++){
        if(X[N-1-i]=='1'){
            wholePlus=(wholePlus+modByPlus[i])%(cnt+1);
            if(cnt==1)continue;
            wholeMinus=(wholeMinus+modByMinus[i])%(cnt-1);
        }
    }
    for(ll i=0;i<N;i++){
        ll now;
        if(X[i]=='1'){
            if(cnt==1){
                cout<<0<<endl;
                continue;
            }
            now = (wholeMinus-modByMinus[N-1-i]+(cnt-1))%(cnt-1);

        }else{
            now= (wholePlus+modByPlus[N-1-i])%(cnt+1);
        }
        ll ans=0;
        while(now!=0){
            ll cnt=0;
            for(ll bit=0;(1<<bit)<=now;bit++){
                if(now & (1<<bit))cnt++;
            }
            now%=cnt;
            ans++;
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> v(n);
	for( auto &i : v ){
		cin >> i;
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	for( int i = 0; i < n; ++i ){
		sum += v.at(i);
		if( sum > x ){
			cout << i << endl;
			return 0;
		} 
	}
	cout << ( ( sum == x ) ? n : n-1 ) << endl;
	return 0;
}

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

int main()
{
int N,M,X,under=0,up=0;scanf("%d %d %d",&N,&M,&X);
vector<int> A(M);
for(int i=0;i<M;i++){scanf("%d ",&A[i]);if(A[i]>X)up++;else if(A[i]<X)under++;}
printf("%d\n",min(up,under));
}

Measured memory_bytes: 256
from collections import deque
rand = False
verbose = False

if rand:
    import random
    N, K = 200000, 10000
    A = random.choices(range(-10**9, 10**9), k=N)
else:
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

MOD = 10**9 + 7

def mul(A):
    ret = 1
    for i in range(len(A)):
        ret = (ret * A[i]) % MOD
#        print (ret)
    return ret

if K==N:
    print(mul(A))
    exit()

POS, NEG = list(), list()
for i in range(len(A)):
    if A[i] < 0:
        NEG.append(A[i])
    else:
        POS.append(A[i])

POS.sort(reverse=True)
NEG.sort()

if len(POS)==0 and K%2==1: # must go negative
    print(mul(NEG[-K:]))
    exit()

POS = deque(POS)
NEG = deque(NEG)

ans = list()
while len(ans)<K:
    if len(NEG) <= 1:
        if verbose: print('no more neg numbers')
        ans.append(POS.popleft()) # no negative numbers to add
    elif len(POS) <= 1:
        if verbose: print('no more pos numbers')
        if K-len(ans)>=2:
            ans.append(NEG.popleft())
            ans.append(NEG.popleft())
        else:
            ans.append(POS.popleft())
    elif POS[0]*POS[1] > NEG[0]*NEG[1] or K-len(ans)==1:
        if verbose: print('pos bigger')
        ans.append(POS.popleft())
    else:
        if verbose: print('neg biger')
        ans.append(NEG.popleft())
        ans.append(NEG.popleft())

print(mul(ans))



Measured memory_bytes: 108964
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        Solver s = new Solver();
        int test = 1;
        for (int i = 1; i <= test; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

    static class Solver {
        void solve(int test_case, InputReader in, PrintWriter out) {
            long[] l = new long[100];
            l[0] = 2;
            l[1] = 1;
            for (int i = 2; i < l.length; i++) {
                l[i] = l[i - 1] + l[i - 2];
            }
            int n = in.nextInt();
            out.println(l[n]);
        }
    }

    static class InputReader {

        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

vector<int> topological_sort(const Graph &graph) {
    int N = graph.size();
    vector<int> in_cnt(N, 0);
    for (int i = 0; i < N; ++i) {
        for (int v : graph[i]) {
            in_cnt[v]++;
        }
    }
    queue<int> S;
    for (int i = 0; i < N; ++i) {
        if (in_cnt[i] == 0) S.push(i);
    }

    vector<int> res(N, -1);
    res[S.front()] = 0;
    while (!S.empty()) {
        int u = S.front(); S.pop();
        for (int v : graph[u]) {
            in_cnt[v]--;
            if (in_cnt[v] == 0) {
                S.push(v);
                res[v] = u + 1;
            }
        }
    }
    return res;
}


void Main() {
    int N, M;
    cin >> N >> M;
    Graph graph(N);
    rep(i, N + M - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
    }

    auto sorted = topological_sort(graph);
    rep(i, N) {
        cout << sorted[i] << endl;
    }


}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
const int W = 1e9;
#define maxn 20100
PII t[maxn];
int skladowa[maxn], x[maxn], n, m, a, b, c;
bool odw[maxn];
inline bool odl(int p, int q) {
	return abs(p - q);
}
set <PII> q;
vector <int> top;
int Key;

inline void topdfs(int u) {
	odw[u] = 1;
	while (1)
	{
		set <PII> :: iterator it = q.lower_bound(mp(x[u] - Key + 1, -inf));
		while (it != q.end() && (it->e2 == u || abs(((*it).e2 - u) == n)))++it;
		if (it == q.end()) break;
		if (abs(x[u] - x[it -> e2]) >= Key) break;
		PII tmp = *it;
		q.erase(it);
		//cout << "Znalazlem krawedz: " << u << ' ' << tmp.e2 << endl;
		if (tmp.e2 > n && !odw[tmp.e2 - n]) topdfs(tmp.e2 - n);
		else if (tmp.e2 <= n && !odw[tmp.e2 + n]) topdfs(tmp.e2 + n);
	}	
	top.pb(u);
}
 
inline void ccdfs(int u, int skl) {
	odw[u] = 1;
	skladowa[u] = skl;
	int para = (u <= n)?u+n:u-n;
	while (1)
	{
		set <PII> :: iterator it = q.lower_bound(mp(x[para] - Key + 1, -inf));
		while (it != q.end() && (it->e2 == u || it->e2 == para)) ++it;
		if (it == q.end()) break;
		if (abs(x[para] - x[it -> e2]) >= Key) break;
		PII tmp = *it;
		q.erase(it);
		//cout << "Znalazlem na odwrot: " << para << ' ' << tmp.e2 << endl;
		if (!odw[tmp.e2]) ccdfs(tmp.e2, skl);
	}
}

inline bool check(int k)
{
	Key = k;
	int N = 2 * n;
	FOR(i, 1, N) odw[i] = 0;
	q.clear();
	FOR(i, 1, n)
	{
		q.insert(mp(t[i].e1, i));
		q.insert(mp(t[i].e2, i + n));
	}
	top.clear();
	
	int SKL = 0;
	FOR(i, 1, N)
		if (!odw[i]) topdfs(i);
		
	assert((int)top.size() == N);
	
	FOR(i, 1, N) skladowa[i] = 0, odw[i] = 0;
	q.clear();
	FOR(i, 1, n)
	{
		q.insert(mp(t[i].e1, i));
		q.insert(mp(t[i].e2, i + n));
	}
	
	for (int i=(int)top.size()-1; i>=0; --i)
		if (!odw[top[i]])
		{
			++SKL;
			ccdfs(top[i], SKL);
		}
	
	FOR(i, 1, n)
		if (skladowa[i] == skladowa[i + n]) return 0;
	
	return 1;
}
 
int main()
{
	boost;
	cin >> n;
	FOR(i, 1, n) 
	{
		cin >> t[i].e1 >> t[i].e2;
		x[i + n] = t[i].e2;
		x[i] = t[i].e1;
	}
	
	int fx = 0, fy = inf;
	while (fx < fy) 
	{
		int sr = (fx + fy)/2+1;
		if (!check(sr)) fy = --sr;
		else fx = sr;
	}
	
	cout << fx;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
/* #include <atcoder/all> */
#include <iostream>
using namespace std;
/* using namespace atcoder; */
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n;
    cin >> n;
    vint a(n);
    cin >> a;
    vint cnts(3, 0);
    ll ans = 1;
    REP(i, n) {
        int now = a[i], cnt = 0, add_j = 0;
        REP(j, 3) {
            if (cnts[j] == now) {
                ++cnt;
                add_j = j;
            }
        }
        ans = (ans * cnt) % MOD;
        cnts[add_j]++;
    }
    cout << ans << endl;
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3788
local t={}
t[0],t[1],t[2]=0,0,0
for i=3,10^5,2 do
    local check=true
    for j=2,math.sqrt(i) do
        if i%j==0 then
            check=false
            break
        end
    end
    if check then
        for j=2,math.sqrt((i+1)//2) do
            if ((i+1)//2)%j==0 then
                check=false
                break
            end
        end
    end
    t[i]=t[i-1]+(check and 1 or 0)
    t[i+1]=t[i]
end

local q=io.read("n")
for i=1,q do
    local l,r=io.read("n","n")
    print(t[r]-t[l-1])
end

Measured memory_bytes: 4216
n = int(input())
a = list(map(int, input().split()))
b = list(reversed(a))
c = [0] * (n + 1)
d = [0] * (n + 1)
s = [(0, 10 ** 30)]
res = 0
for i in range(1, n):
    if a[i - 1] < a[i] * 4:
        t = a[i - 1]
        cnt = 0
        while t < a[i]:
            cnt += 1
            t *= 4
        while cnt > 0:
            idx, p = s.pop()
            if cnt >= p:
                res += p * (i - idx)
                cnt -= p
            else:
                res += cnt * (i - idx)
                s.append((idx, p - cnt))
                cnt = 0
    else:
        t = a[i]
        cnt = 0
        while a[i - 1] >= t * 4:
            t *= 4
            cnt += 1
        s.append((i, cnt))
    c[i + 1] = res
s = [(0, 10 ** 30)]
res = 0
for i in range(1, n):
    if b[i - 1] < b[i] * 4:
        t = b[i - 1]
        cnt = 0
        while t < b[i]:
            cnt += 1
            t *= 4
        while cnt > 0:
            idx, p = s.pop()
            if cnt >= p:
                res += p * (i - idx)
                cnt -= p
            else:
                res += cnt * (i - idx)
                s.append((idx, p - cnt))
                cnt = 0
    else:
        t = b[i]
        cnt = 0
        while b[i - 1] >= t * 4:
            t *= 4
            cnt += 1
        s.append((i, cnt))
    d[i + 1] = res
ans = float('inf')
for i in range(n + 1):
    ans = min(ans, (c[i] + d[n - i]) * 2 + i)
print(ans)


Measured memory_bytes: 100176
import collections
import copy
n = int(input())
a = list(map(int,input().split()))
suma = sum(a)
numcount = [0] * ((10 ** 5) + 1)
for i in range(n):
         numcount[a[i]] += 1
q = int(input())
for i in range(q):
         b,c = map(int,input().split())
         if numcount[b] != 0:
                  tmpb = numcount[b]
                  numcount[c] += numcount[b]
                  numcount[b] = 0
                  suma += tmpb*(c - b)
         print(suma)


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


int main(){
    int M_one,M_two;
    int D_one,D_two;
    cin >> M_one >> D_one >> M_two >> D_two;

    if(M_one != M_two){
        cout << 1;
    }else{
        cout << 0;
    }

    return 0;
}


Measured memory_bytes: 256
import math

n = input()
for i in xrange(n):
    x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    p = ((y1-y3)*(y1**2 - y2**2 + x1**2 - x2**2) - \
         (y1-y2)*(y1**2 - y3**2 + x1**2 - x3**2)) / \
         (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))

    q = ((x1-x3)*(x1**2 - x2**2 + y1**2 - y2**2) - \
         (x1-x2)*(x1**2 - x3**2 + y1**2 - y3**2)) / \
         (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))

    print '%.3f %.3f %.3f'%(round(p,3), round(q,3), round(math.sqrt((x1-p)**2+(y1-q)**2), 3))

Measured memory_bytes: 6520
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
int  n,i,j,k,z,m,q,r,timer,v,tot,x,y,xx, yy,INF, sz;
int a[100500], cnt[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++) {
        if (a[i - 1] + a[i] >= k) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; j++)
                cout << j << endl;
            for (int j = n-1; j > i; j--)
                cout << j << endl;
            cout << i << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

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

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

ll it = 0, ans = 0;

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

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


void check()
{
	ll a,b,c,d, neg = 0;
	cin >> a >> b >> c >> d;
	cout << max(a*c,max(b*c,max(b*d,d*a))) << endl;
    return ;
}

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


Measured memory_bytes: 3648
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


class Combination:
    def __init__(self,N):
        self.fac = [1]*(N+1)
        for i in range(1,N+1):
            self.fac[i] = (self.fac[i-1]*i)%mod
        self.invmod = [1]*(N+1)
        self.invmod[N] = pow(self.fac[N],mod-2,mod)
        for i in range(N,0,-1):
            self.invmod[i-1] = (self.invmod[i]*i)%mod

    def calc(self,n,k):#nCk
        if n <= 0:
            return 0
        elif n < k:
            return 0
        else:
            return self.fac[n]*self.invmod[k]%mod *self.invmod[n-k] %mod


N,K = inpl()
C = Combination(N)
aa = sorted(inpl())

ans = 0
for i,a in enumerate(aa):
    ans += a * (C.calc(i,K-1) - C.calc(N-i-1,K-1)) %mod
    ans %= mod

print(ans)


Measured memory_bytes: 63596
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <list>
#include <climits>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    rep(i, n){
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    int mid = a[n / 2];
    ll ans = LLONG_MAX;
    if(n < 1000){
        for(int i = mid - n; i < mid + n; i++){
            ll sum = 0;
            rep(j, n){
                sum += abs(a[j] - i);
            }
            ans = min(ans, sum);
        }
    }else{
        for(int i = mid - n / 100; i < mid + n / 100; i++){
            ll sum = 0;
            rep(j, n){
                sum += abs(a[j] - i);
            }
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
ll gcd(ll x, ll y){ return y==0? x: gcd(y, x%y); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w;
	cin >>h >>w;
	
	vector<VI> a(h,VI(w)), ans;
	rep(i,h) rep(j,w) cin >> a[i][j];
	
	rep(i,h) repr(j,w-1,1){
		if(a[i][j] %2){
			a[i][j]--; a[i][j-1]++;
			ans.push_back(VI{i,j,i,j-1});
		}
	}
	rep(i,h-1){
		if(a[i][0] %2){
			a[i][0]--; a[i+1][0]++;
			ans.push_back(VI{i,0,i+1,0});
		}
	}
	
	printf("%d\n", sz(ans));
	for(auto x: ans) printf("%d %d %d %d\n", x[0]+1,x[1]+1,x[2]+1,x[3]+1);
	return 0;
}


Measured memory_bytes: 10032
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
  return;
}


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

#define ul unsigned long long
#define ll long long

int main()
{
  ul n,a,b;
  cin>>n>>a>>b;

  ul di=n/(a+b),am=n%(a+b);
  ul res=di*a+min(am,a);

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
def cmb(n, r, p):
    if r<0 or n<r:
        return 0
    r=min(r, n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

mod=10**9+7
MAXN=2*10**6+10
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]

for i in range(2, MAXN+1):
    fact.append((fact[-1]*i)%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)

x,y=map(int, input().split())
res=0
if (x+y)%3==0:
    m=(2*x-y)//3
    n=(2*y-x)//3
    res=cmb(m+n,m,mod)
print(res)

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


int main() {
    int n;
    int sn;
    cin >> n;
    int k = n;
    while (k > 0) {
        sn += k % 10;
        k /= 10;
    }

    if (n % sn == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n1 = readLine()!!.toInt()
    solve(n1)
}

fun solve(n1: Int){
    // (ans / 1.08).floor() = n1
    val moto = (n1 / 1.08).toInt()

    val kouho = Math.floor(moto * 1.08)
    val kouho2 = Math.floor((moto + 1) * 1.08)

    var ans = ""
    if( kouho.toInt() == n1 ) {
        ans = moto.toString()
    } else if(kouho2.toInt() == n1) {
        ans = (moto + 1).toString()
    }else{
        ans = ":("
    }
    println(ans)
}

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

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

    vector<int> d(n);
    rep (i, n)
        cin >> d[i];

    int ans = 0;
    rep (i, n)
        rep (j, n)
            if (i != j)
                ans += d[i] * d[j];

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A = input().rstrip()
dp = [chr(c) for c in range(ord('a'), ord('z')+1)]
for c in A[::-1]:
    s = min(dp, key=lambda x: len(x))
    dp[ord(c) - ord('a')] = c + s
print(min(dp, key=lambda x: len(x)))

Measured memory_bytes: 79968
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,k,ans;
    cin>>a>>b>>c>>k;
    if(a+b>=k)
        ans=min(a,k);
    else 
    {
        ans=a-(k-(a+b));
    }
    cout<<ans;
    
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N;
ll C[200100];

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

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

  std::cin >> N;

  for(int i=1;i<=N;++i){
      std::cin >> C[i];
  }

  std::sort(C + 1, C + 1 + N);

  ll res = 0;

  for(int i=1;i<=N;++i){
      int n = N - i;

      res = (res + C[i] * (n + 2)) % MOD;
  }

  res = res * mod_expt<ll>(2ll, 2 * (N - 1), MOD) % MOD;

  std::cout << res << std::endl;
}


Measured memory_bytes: 1792
// ITP1_7_A Grading
import java.io.*;

public class Main {

   public static void main(String[] args) {
      int m = 0, f = 0, r = 0;
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         while (true){
            String[] strAry = br.readLine().split(" ");
            m = Integer.parseInt(strAry[0]);
            f = Integer.parseInt(strAry[1]);
            r = Integer.parseInt(strAry[2]);

            if (m == -1 && f == -1 && r == -1)  break;

            System.out.println(judge(m, f, r));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static String judge(int m, int f, int r) {
      if ((m == -1 || f == -1) || m + f < 30)
         return "F";
      else if (m + f < 50) {
         if (r >= 50)
            return "C";
         else
            return "D";
      }
      else if (m + f < 65)
         return "C";
      else if (m + f < 80)
         return "B";
      else
         return "A";
   }
}

Measured memory_bytes: 16936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define _overload1(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload1(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _overload2(_1, _2, _3, name, ...) name
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (ll i = (ll)(a - 1); i >= (ll)(b); --i)
#define rrep(...) _overload2(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
#define all(x) (x).begin(), (x).end()

const double EPS = 1e-15, PI = acos(-1);
const ll INF = 1'010'000'000'000'000'017LL;

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

void Main() {
  ll n, m;
  cin >> n >> m;
  if (n >= 10) {
    cout << m << endl;
  } else {
    cout << m + 100 * (10 - n) << endl;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int main()
{
  stack<int> S;
  char s[100];
  while (scanf("%s", s) != EOF)
  {
    if (s[0] == '+')
    {
      int b = S.top();
      S.pop();
      int a = S.top();
      S.pop();
      S.push(a + b);
    }
    else if (s[0] == '-')
    {
      int b = S.top();
      S.pop();
      int a = S.top();
      S.pop();
      S.push(a - b);
    }
    else if (s[0] == '*')
    {
      int b = S.top();
      S.pop();
      int a = S.top();
      S.pop();
      S.push(a * b);
    }
    else
    {
      S.push(atoi(s));
    }
  }
  cout << S.top() << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
using namespace std;
class Processes
{
public:
  string sName;
  int iProcessTime;

};



int main(int argc, char *argv[])
{
  int iProcessNum;  		// プロセスの個数
  int iProcessTime;		// プロセスに書けることのできる時間
  int time = 0;

  queue<Processes> qu;
  cin >> iProcessNum >> iProcessTime;

  for (int i = 0; i < iProcessNum ; i++) {
    Processes ps;
    cin >> ps.sName >> ps.iProcessTime;
    qu.push(ps);
  }

  while (true) {
    if (qu.size() == 0) {
      break;
    }
    // for (int i = 0; i < qu.size() ; i++) {
    //   Processes ps = qu.front();
    //   qu.pop();
    //   cout << ps.sName << " "<< ps.iProcessTime  << "\n";
    //   qu.push(ps);

    // }
    // cout << "" << "\n";
    
    Processes ps = qu.front();
    qu.pop();

    
    if (ps.iProcessTime <= iProcessTime) {
      time = time + ps.iProcessTime;
      cout <<ps.sName << " " << time << "\n";
    }else {
      ps.iProcessTime = ps.iProcessTime - iProcessTime;
      time = time + iProcessTime;
      qu.push(ps);
    }
    
  }
  // cout << iProcessNum << " " << iProcessTime << "\n";

  return 0;
}



Measured memory_bytes: 6332
/* ex3_5
   hangan2020*/ 

#include <stdio.h>
#include <string.h>

int main(void){
    char str[11],  *p; 
    int len, max;

    //文字列入力
    scanf("%s", &str[0]);
    //文字列先頭のアドレス
    p = str;
    len = 0;
    max = 0; 

    //null文字ではない間に
    while(*p){
        
        //長さリセット
        len = 0;

        //ACGT列を見つけたら長さをカウントする。
        //カウントが終わるとポインタは最後の文字の次の文字にある
        while(*p == 'A'||*p == 'C'||*p == 'G'||*p == 'T'){
            len++;
            p++;
        }
        
        //もしカウントしている文字列が前の文字列より長かったらmaxにする
        if(len > max){
            max = len;
        }

        //次の文字へ
        p++;

    }

    printf("%d", max);

    return 0;

}


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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			
			int[] L = new int[N];
			
			
			int trycnt = 0;
			int firstLine = 0;
			int secondLine =0;
			int thirdLine =0;
			for(int i=0;i<N;i++) {
				L[i]=sc.nextInt();
			}
			
			
			
			Arrays.sort(L);
			

			for(int j=0;j<N-2;j++) {
		//		 System.out.println("start jroop"+j);
				 firstLine = L[j];
				
				for(int k=j+1;k<N-1;k++) {
					
					secondLine = L[k];
					if(firstLine==secondLine) {
//						System.out.println(j+":"+k+":"+L[j]);
					}else {
					
						for(int m=k+1;m<N;m++) {
							thirdLine = L[m];
							if(thirdLine==secondLine||thirdLine==firstLine) {
	
							}else{
				//				System.out.println("("+firstLine+","+secondLine+","+thirdLine+")");
								if(firstLine+secondLine>thirdLine) {
									trycnt=trycnt + 1;
				//					System.out.println("OK");
									
								}else {
				//					System.out.println("NG");
								}
							}
						}
					}
				}
				
			}
			
			
			
			System.out.println(trycnt);
	}	
}

Measured memory_bytes: 36300
import heapq
from collections import deque
N, Q = map( int, input().split())
H = [(0,0,0) for _ in range(N)]
for i in range(N):
    s, t, x = map( int, input().split())
    H[i] = (x-t+1, x-s, x)
D = [ ( -int( input()), i) for i in range(Q)]
D.sort()
H.sort()
d = deque(H)
q = []
ANS = [0]*Q
for i in range(Q):
    t, j = D[i]
    while d:
        if d[0][0] <= t:
            _, s, x = d.popleft()
            heapq.heappush(q,(x,s))
        else:
            break
    while q:
        if q[0][1] >= t:
            break
        heapq.heappop(q)
    if not q:
        ANS[j] = -1
    else:
        ANS[j] = q[0][0]
for ans in ANS:
    print( ans)


Measured memory_bytes: 83840
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
        Arrays.sort(in);
		String s = "YES";
        for(int i=0;i<a-1;i++){if(in[i]==in[i+1]){s = "NO";
                                                 break;}
                            }
      
		System.out.println(s);
	}
}


Measured memory_bytes: 63768
#include <bits/stdc++.h>
using namespace std;
/*
string s,s1,s2;
int a,b;
int main(){
	cin>>s>>s1;
	cin>>a>>b;
	cin>>s2;
	if(s2==s) a--;
	if(s2==s1) b--;
	cout<<a<<" "<<b<<endl;
	return 0;
}
///////////////
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++) cout<<"x";
	return 0;
}
*/

bool areDistinct(vector<int> arr){
    int n=arr.size();
    set<int> s;
    for(int i=0;i<n;i++) s.insert(arr[i]);
    return (s.size()==arr.size());
}

int n,x;
vector<int> v;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		v.push_back(x);
	}
	if(areDistinct(v)) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

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

MAX = 41

k = [0 for _ in range(MAX)]
c = [0 for _ in range(MAX)]
b = [0 for _ in range(MAX)]
v = [[0 for _ in range(MAX)] for _ in range(2)]

K = input_k + 1
d = 0
while K > 0:
    if K % 2 == 1:
        k[d] = 1
    d += 1
    K //= 2

for p in a:
    counter = 0
    while p > 0:
        if p % 2 == 1:
            c[counter] += 1
        counter += 1
        p //= 2

temp = 1
for i in range(MAX):
    if c[i] > n - c[i]:
        b[i] = 0
    else:
        b[i] = 1
    v[0][i] = temp * c[i]
    v[1][i] = temp * (n - c[i])
    temp *= 2

if input_k == 0:
    print(sum(v[0]))
    exit()

ans = 0
for i in range(MAX - 1, -1, -1):
    if k[i] == 0:
        continue

    temp_ans = 0
    for j in range(i+1, MAX):
        temp_ans += v[k[j]][j]

    temp_ans += v[0][i]

    for j in range(i):
        temp_ans += v[b[j]][j]

    #print(i, temp_ans)
    ans = max(ans, temp_ans)

print(ans)


Measured memory_bytes: 14620
// AOJ ITP1_11_D Dice IV
// 2018.5.2 bal4u
 
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
 
int  a[102][7];
char f[102];
 
int identical(int *a, int *b)
{
    int i, j;
    memset(f, 0, sizeof(f));
    for (i = 1; i <= 6; i++) f[a[i]]++;
    for (i = 1; i <= 6; i++) f[b[i]]--;
    for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;
 
    for (j = 0; j < 24; j++) {
        if (b[1] == a[rot[j][1]]) {
            for (i = 2; ; i++) {
                if (i > 6) return 1;
                if (b[i] != a[rot[j][i]]) break;
            }
        }
    }
    return 0;
}
 
int main()
{
    int n, i, j, f;
 
    n = in();
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 6; j++) a[i][j] = in();
    }
    f = 1;
    for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
        if (identical(a[i], a[j])) { f = 0; goto done; }
    }
done:
    puts(f? "Yes": "No");
    return 0;
}


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

#define PI acos(-1)

int main(){
  int a, b, c = 90, xx, yy;
  double x = 0, y= 0;

  while(1){
    scanf("%d,%d",&a,&b);
    if(a == 0 && b == 0) break;
    x += a * cos(c * PI / 180);
    y += a * sin(c * PI / 180);
    c -= b;
    xx = (int)x;
    yy = (int)y;
  }
  printf("%d\n%d\n",xx,yy);
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int a,ans;
int main(){
	while(cin>>a){
		for(int i=0;i<600/a;i++){
		ans+=i*i*a*a*a;}
	cout<<ans<<endl;
	ans=0;}
	return 0;}


Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define eb emplace_back
typedef long long ll;
#define int ll
auto const inf = numeric_limits<int>::max()/4;
 
using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
 
pair<vector<Weight>, bool> spfa(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    const int n = g.size(); priority_queue<int> q;
    vector<Weight> dist(n, inf); vector<int> inQ(n);
    vector<int> count(n);
    dist[s] = 0; q.emplace(s); inQ[s] = true; ++count[s];
    bool negCycle = false;
    for(int i = 0; q.size(); i++){
        int v = q.top(); q.pop(); inQ[v] = false;
        for(auto &e : g[v]){
            if(dist[v] != inf && dist[e.dst] > dist[v] + e.weight){
                dist[e.dst] = dist[v] + e.weight;
                if(!inQ[e.dst]){
                    q.emplace(e.dst); inQ[e.dst] = true; ++count[e.dst];
                    if(count[e.dst] >= n){ negCycle = true; goto END; }
                }
            }
        }
    }
 END:;
    return make_pair(dist, !negCycle);
}
 
signed main(){
    int V,E,r;
    while(cin >> V >> E >> r){
        Graph g(V);
        rep(i,E){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
        }
        bool ok;
        vector<Weight> dist;
        tie(dist, ok) = spfa(g,r);
        if(ok){
            for(int i = 0; i < (int)dist.size(); i++){
                if(dist[i] == inf) cout << "INF";
                else cout << dist[i];
                cout << endl;
            }
        } else {
            cout << "NEGATIVE CYCLE" << endl;
        }
    }
}

Measured memory_bytes: 24948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
//ll n = 3;
//vector<ll> vec(9),vec_init(9);
//vector<ll> move_vec[9];
//bool can = false;
//
//void init(){
//  rep(i,9){
//    vec[i] = vec_init[i];
//  }
//}
//
//void dfs(ll piv,ll pre, ll depth,ll maxi){
//  if(depth > maxi){
//    //cout << depth << endl;
//    return;
//  }
//  bool eq = true;
//  rep(i,9){
//    if(vec[i] != (i+1) % 9){
//      eq = false;
//      break;
//    }
//  }
//  if(eq){
//    can = true;
//    return;
//  }
//  for(auto itr:move_vec[piv]){
//    if(itr != pre){
//      swap(vec[piv],vec[itr]);
//      dfs(itr,piv,depth+1,maxi);
//      swap(vec[piv],vec[itr]);
//    }
//  }
//}
//
//int main(){
//  ll piv = 0;
//  rep(i,n*n){
//    cin >> vec_init[i];
//    if(vec_init[i] == 0){
//      piv = i;
//    }
//  }
//  rep(i,n*n){
//    if(i % 3 != 2){
//      move_vec[i].push_back(i+1);
//    }
//    if(i % 3 != 0){
//      move_vec[i].push_back(i-1);
//    }
//    if(i / 3 != 0){
//      move_vec[i].push_back(i-3);
//    }
//    if(i / 3 != 2){
//      move_vec[i].push_back(i+3);
//    }
//  }
//
//  ll ans = 0;
//  rep(i,100){
//    init();
//    dfs(piv,-1,0,i);
//    if(can){
//      ans = i;
//      break;
//    }
//  }
//  cout << ans << endl;
//}

#define N 3
#define N2 9

struct Puzzle{
    ll f[N2];
    ll space;
    string path;

    bool operator < (const Puzzle &p) const {
      rep(i,N2){
        if(f[i] == p.f[i])continue;
        return f[i] > p.f[i];
      }
      return false;
    }
};

static const ll dx[4] = {-1,0,1,0};
static const ll dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  rep(i,N2){
    if(p.f[i] != (i+1) ) return false;
  }
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u = Q.front();
    Q.pop();
    if(isTarget(u)) return u.path;
    ll sx = u.space / N;
    ll sy = u.space % N;
    rep(r,4){
      ll tx = sx + dx[r];
      ll ty = sy + dy[r];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N){
        continue;
      }
      v = u;
      swap(v.f[u.space],v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main(){
  Puzzle in;

  rep(i,N2){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2; // set space
      in.space = i;
    }
  }

  string ans = bfs(in);
  cout << ans.size() << endl;
}


Measured memory_bytes: 39416
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	int a[4],b[4];
	int hit,blow;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		hit = 0;
		blow = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] ==  b[i]){
				hit++;
			}
			for(int j = 0; j < 4; j++){
				if(i != j && a[i] == b[j]){
					blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}

	return 0;
}

Measured memory_bytes: 1160