akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#define LL long long
#define INF 2000000000
#define maxn 1010
using namespace std;
int n,m;
int k[][2]={{-1,0},{1,0},{0,-1},{0,1}};//L,R,U,D
int border[maxn][maxn][4];//边界
int vis[maxn][maxn],qx[maxn*maxn],qy[maxn*maxn];
LL ans;
struct node{
	int a,b,c;
}f[maxn],g[maxn];
int X[maxn],Y[maxn],XN,YN;//值到脚标，离散化
int findX(int v){
	return lower_bound(X,X+XN,v)-X;//功能：查找非递减序列[first,last) 内第一个大于或等于某个元素的位置。
}
int findY(int v){
	return lower_bound(Y,Y+YN,v)-Y;
}
void bfs(int xx,int yy){
	int i,h,t,nx,ny,x,y;
	h=t=0;
	qx[t]=xx,qy[t]=yy,t++,vis[xx][yy]=1;
	while(h<t){
		x=qx[h],y=qy[h],h++;
		ans+=(LL)(X[x+1]-X[x])*(Y[y+1]-Y[y]);//根据此句编写The point (0,0) does not lie on any of the given segments.
		for(i=0;i<4;i++){//四个方向
			if(border[x][y][i])continue;
			nx=x+k[i][0],ny=y+k[i][1];
			if(nx==0||nx==XN-1||ny==0||ny==YN-1){//到达-INF,INF表示无线延伸
				ans=-1;
				return;
			}
			if(vis[nx][ny])continue;//该点已经访问过
			vis[nx][ny]=1,qx[t]=nx,qy[t]=ny,t++;
		}
	}
}
void init(){
	int i,x,y,r,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].c),X[XN++]=f[i].c;
	X[XN++]=-INF,X[XN++]=INF;//设定值的范围
	sort(X,X+XN);//自小到大排序
	XN=unique(X,X+XN)-X;//去重
	for(i=0;i<m;i++)scanf("%d%d%d",&g[i].a,&g[i].b,&g[i].c),Y[YN++]=g[i].a;
	Y[YN++]=-INF,Y[YN++]=INF;
	sort(Y,Y+YN);//自小到大排序
	YN=unique(Y,Y+YN)-Y;
	for(i=0;i<n;i++){
		x=findX(f[i].c);
		r=findY(f[i].b);
		if(Y[r]!=f[i].b)r--;//找不到的情况，需要--
		for(j=findY(f[i].a);j<r;j++)
			border[x-1][j][1]=border[x][j][0]=1;//边界设定:1表示,向右不能到达;0表示,向左不能到达
	}
	for(i=0;i<m;i++){
		y=findY(g[i].a);
		r=findX(g[i].c);
		if(X[r]!=g[i].c)r--;
		for(j=findX(g[i].b);j<r;j++)
			border[j][y-1][3]=border[j][y][2]=1;//边界设定:3表示,向下不能到达;2表示,向上不能到达
	}
}
int main(){
	init();
	bfs(findX(0)-1,findY(0)-1);//根据此句编写The point (0,0) does not lie on any of the given segments.
	if(ans==-1)printf("INF\n");
	else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 29212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;

void solve()
{
    int n; cin >> n;
	cout << (n+1)/2 << endl;
	return;
}

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


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
while True:
    n = int(input())
    if n == 0:
        break
    c = input().split()
    cnt = Counter()

    for i, x in enumerate(c):
        cnt[x] += 1
        m1 = ('', 0)
        m2 = ('', 0)
        for k, v in cnt.items():
            if m1[1] < v:
                m1 = (k, v)
        for k, v in cnt.items():
            if k != m1[0] and m2[1] < v:
                m2 = (k, v)
        if m1[1] - m2[1] >= n - i:
            print(m1[0], i + 1)
            break
    else:
        print('TIE')



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

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n)
    {
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = m.size();
    int cnt = 0;
    for (auto mm: m)
    {
        if (mm.second % 2 == 0)
            cnt ++;
    }

    if (cnt % 2 == 1)
        ans --;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
arr = input()
l = len(arr)

ans_arr = [0] * (l+1)
for i in range(l):
    if arr[i] == '<':
        ans_arr[i+1] = ans_arr[i] + 1

for i in range(l-1, -1, -1):
    if arr[i] == '>':
        ans_arr[i] = max(ans_arr[i], ans_arr[i+1] + 1)

# print(ans_arr)
print(sum(ans_arr))


Measured memory_bytes: 23336
#include<stdio.h>

int main()
{
	int num;
	int t;
	int i, j;
	int min;
	int max_profit;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++)
	{
		scanf("%d", &t);
		
		if(i == 0) min = t;
		
		else if(i == 1)
		{
			max_profit = t - min;
			if(t < min) min = t;
		}  
		else
		{
			if(max_profit < t - min)
			max_profit = t - min;
			if(t < min) min = t;
		}
	}
	printf("%d\n", max_profit);
	
	return 0;
}

Measured memory_bytes: 1024
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] s = io.r<string>(' ');
            if (s[1] == "?") { break; }
            else if (s[1] == "+") { io.w(util.parse<int>(s[0]) + util.parse<int>(s[2])); }
            else if (s[1] == "-") { io.w(util.parse<int>(s[0]) - util.parse<int>(s[2])); }
            else if (s[1] == "*") { io.w(util.parse<int>(s[0]) * util.parse<int>(s[2])); }
            else if (s[1] == "/") { io.w(util.parse<int>(s[0]) / util.parse<int>(s[2])); }
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<functional>
#include<algorithm>
#include<math.h>
#include<unordered_map>
#include<string.h>
#include<limits.h>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<unordered_set>
#include<deque>
using namespace std;

bool b[26];
signed main() {
	string a; cin >> a;
	for (char c : a) {
		b[c - 'a']++;
	}
	int ans = 1000;
	for (int I = 0; I < 26; I++) {
		if (!b[I])continue;
		string c = a;
		int sum = 0;
		while (1) {
			set<char>S;
			for (char d : c) {
				S.insert(d);
			}
			if (S.size() == 1 && *S.begin() != ' ')break;	string f;
			char N=0;
			for (int i = 0; i < c.length() - 1; i++) {
				if (c[i] == I + 'a' || c[i + 1] == I + 'a') {
					f += I + 'a';
				}
				else {
					f += " ";
				}
			}
			c = f;
			sum++;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

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

int N,M;
map<int,int>S,T;

int main(){
	cin>>N;
	S.clear();
	T.clear();
	for(int i=1;i<=N;i++){
		int d;
		cin>>d;
		S[d]++;
	}
	cin>>M;
	bool ans=true;
	for(int i=1;i<=M;i++){
		int d;
		cin>>d;
		T[d]++;
		if(T[d]>S[d]) ans=false;
	}
	if(ans)cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 18944
#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 N;
  cin >> N;
  string S;
  cin >> S;
  LL cR = 0, cG = 0, cB = 0;
  REP(i, N) {
    if(S[i] == 'R') cR++;
    if(S[i] == 'G') cG++;
    if(S[i] == 'B') cB++;
  }
  LL ret = cR * cG * cB;
  for(int i=1; i<N-1; ++i) {
    for(int j=i-1; j>=0 && i*2-j < N; --j) {
      if(S[i] != S[j]  && S[i] != S[i*2-j] && S[j] != S[i*2-j]) ret--;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3640
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
 
#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 fast_cin ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back
#define all(con) (con).begin(), (con).end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define ff(i,a,b) for(int i=a;i<=b;i++)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
 
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
 
int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
		res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}
 
const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
 
const int N = 1e5 + 10 ;
 
void solve() {
	int n;
	cin >> n ;
	map<string, int> m; 
	rp(i,n) {
		string s;
		cin >> s;
		m[s]++;  
	}
	int mx=0; 
	for(auto t:m) {
		mx=max(mx,t.second); 
	}
	vector<string> v;
	for(auto t:m) {
		if(t.second==mx) {
			v.pb(t.first); 
		}
	}
	sort(all(v)); 
	for(auto t:v) {
		cout << t << endl;
	}
}
 
signed main() {
        fast_cin;
	
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    	#endif
	
	int tests=1;
	// cin>>tests;
	while(tests--) {
		solve();
	}
 
return 0 ;
}
 

Measured memory_bytes: 25584
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
    int n;  cin >> n;
    double *p = new double[n];
    for (int i = 0; i < n; i++)
        cin >> p[i];

    vector<vector<double> > dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i+1][j] += dp[i][j] * (1-p[i]);
            if (j > 0)
                dp[i+1][j] += dp[i][j-1] * p[i];
        }
    }

    double ans = 0;
    for (int i = n/2+1; i <= n; i++) {
        ans += dp[n][i];
    }

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 73716
#include<iostream>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
struct Status{
        int a[3][3];
        int c,i,j;
        bool isTarget(){
                for(int i=0;i<8;i++){
                        if(a[i/3][i%3]!=i+1) return false;
                }
                return true;
        }
};

bool operator< (const Status &s, const Status &t){
        for(int i=0;i<9;i++){
                if(s.a[i/3][i%3]==t.a[i/3][i%3]) continue;
                return s.a[i/3][i%3] < t.a[i/3][i%3];
        }
        return false;
}

queue<Status> que;
set<Status> visited;


int solve(){
        while(1){
                Status s = que.front();que.pop();
                if(visited.find(s)!=visited.end()) continue;
                if(s.isTarget()) return s.c;
                visited.insert(s);
                s.c++;
                if(s.i!=0) {
                        swap(s.a[s.i][s.j], s.a[s.i-1][s.j]);
                        s.i = s.i-1;
                        que.push(s);
                        s.i = s.i+1;
                        swap(s.a[s.i][s.j], s.a[s.i-1][s.j]);
                }
                if(s.j!=0) {
                        swap(s.a[s.i][s.j], s.a[s.i][s.j-1]);
                        s.j = s.j-1;
                        que.push(s);
                        s.j = s.j+1;
                        swap(s.a[s.i][s.j], s.a[s.i][s.j-1]);
                }
                if(s.i!=2) {
                        swap(s.a[s.i][s.j], s.a[s.i+1][s.j]);
                        s.i = s.i+1;
                        que.push(s);
                        s.i = s.i-1;
                        swap(s.a[s.i][s.j], s.a[s.i+1][s.j]);
                }
                if(s.j!=2) {
                        swap(s.a[s.i][s.j], s.a[s.i][s.j+1]);
                        s.j = s.j+1;
                        que.push(s);
                        s.j = s.j-1;
                        swap(s.a[s.i][s.j], s.a[s.i][s.j+1]);
                }
        }
}
int main(){
        Status s;
        s.c=0;
        for(int i=0;i<9;i++) {
                cin>>s.a[i/3][i%3];
                if(s.a[i/3][i%3]==0){
                        s.i=i/3;
                        s.j=i%3;
                }
        }
        que.push(s);

        cout<<solve()<<endl;
}


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

int op(int a, int b){return max(a, b);}
int e(){return INT32_MIN;}

int n, q, t, x, y;
bool f(int v){return v < y;}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cin >> n >> q;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	segtree<int, op, e> d(a);
	while(q--){
		cin >> t >> x >> y;
		if(t == 1) d.set(x-1, y);
		else if(t == 2) cout << d.prod(x-1, y) << "\n";
		else cout << d.max_right<f>(x-1) + 1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 6116
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;

int gcd(int a,int b) {
	if(a == 0 || b == 0) {
		return max(a,b);
	}
	else {
		if(a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		int r = a % b;
		while(r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}
}

signed main() {
    int A,B;
    cin >> A >> B;
    cout << A * B / gcd(A, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>=(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
//#define DEBUG
using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef priority_queue<long,vector<long>,greater<long>> minp;
typedef priority_queue<long> maxp;

int main(void){
	long N,a;
	cin >> N;
	minp af;
	maxp ab;
	VI a_mid(N);
	long sum_f = 0;
	long sum_b = 0;

	REP(i,N) {
		cin >> a;
		af.push(a);
		sum_f += a;
	}
	REP(i,N) {
		cin >> a;
		a_mid[i] = a;
	}
	REP(i,N) {
		cin >> a;
		ab.push(a);
		sum_b += a;
	}

	VI dp_f(N+1,0);
	VI dp_b(N+1,0);
	dp_f[0] = sum_f;
	dp_b[N] = sum_b;

	// 0 ~ 2Nの中で最大を決める dp_l[i]:=左からN+iこ使って最大。
	REP(i,N) {
		long minv = af.top();
		if (minv < a_mid[i]) {
			af.pop();
			af.push(a_mid[i]);
			dp_f[i+1] = dp_f[i] + (a_mid[i] - minv);
		}
		else dp_f[i+1] = dp_f[i];
	}

	RFOR(i,N,1) {
		long maxv = ab.top();
		if (maxv > a_mid[i-1]) {
			ab.pop();
			ab.push(a_mid[i-1]);
			dp_b[i-1] = dp_b[i] + a_mid[i-1] - maxv	;	
		}
		else dp_b[i-1] = dp_b[i];
	}

	#ifdef DEBUG
		dump1d_arr(dp_f);
		dump1d_arr(dp_b);
	#endif

	REP(i,N+1) dp_f[i] -= dp_b[i];
	cout << *max_element(dp_f.begin(),dp_f.end()) << endl;
	return 0;


}

Measured memory_bytes: 4340
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	int a, b, x;
	cin >> a >> b >> x;

	if (a <= x && a+b >= x) {
		cout << "YES" << endl;
		
	}
	else {
		cout << "NO" << endl;
		
	}
	

	return 0;
}



Measured memory_bytes: 256
from collections import Counter

N, K = map(int, input().split())
A = list(map(lambda s: int(s) % K, input().split()))

cumAm1 = [1] + A
for i in range(1, N + 1):
    cumAm1[i] = (-1 + cumAm1[i - 1] + cumAm1[i]) % K

counts = Counter()
ans = 0
for i in range(N + 1):

    if i >= K:
        counts[cumAm1[i - K]] -= 1

    cur = cumAm1[i]
    ans += counts[cur]

    counts[cur] += 1

print(ans)


Measured memory_bytes: 41064
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    fastio;
    // fact[0]=1;
    // f(i,1,2000009)fact[i]=(fact[i-1]*i)%mod;
    int t;
    // cin>>t;
    t=1;
    while(t--){
       int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;cin>>k;cout<<a[k]<<"\n";
    }
    return 0; 	
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <queue>
#include <ctime>
#define int long long
#define double long double
using namespace std;
double INF = 1e9;
int MOD = 998244353;
int32_t main(){
    int n, x, y;
    vector<pair<int, int> > pr;
    cin >> n;
    for (int i=0; i < n; i++){
        cin >> x >> y;
        pr.push_back(make_pair(x, y));
    }
    map<pair<double, double>, set<int> > mm;
    int ans = 2;
    for (int i=0; i < n-1; i++){
        ans *= 2;
        ans %= MOD;
    }
    ans--;
    ans %= MOD;
    for (int i=0; i < n; i++){
        for (int j=i+1; j < n; j++){
            if (i == j) continue;
            double k, b;
            if (pr[i].first == pr[j].first){
                k = INF;
                b = pr[i].first;
            }
            else{
                k = (double) (pr[i].second - pr[j].second) / (double) (pr[i].first - pr[j].first);
                b = (double) pr[i].second - k * (double) pr[i].first;
            }
            k *= 1e9;
            k = round(k);
            b *= 1e9;
            b = round(b);
            if (mm.count(make_pair(k, b))){
                mm[make_pair(k, b)].insert(i);
                mm[make_pair(k, b)].insert(j);
            }
            else{
                set<int> ms;
                ms.insert(j);
                ms.insert(i);
                mm[make_pair(k, b)] = ms;
            }
        }
    }
    while (!mm.empty()){
        pair<double, double> p = (*mm.begin()).first;
        int sz = mm[p].size();
        mm.erase(p);
        int mins = 2;
        for (int i=0; i < sz-1; i++){
            mins *= 2;
            mins %= MOD;
        }
        mins -= sz+1;
        mins %= MOD;
        ans -= mins;
        ans %= MOD;
    }
    ans -= n;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
//VALUES : A1 A2 A3 A4... AN
//A2^A3....AN = a1
//A1^A3....^AN = a2
//A1^A2^A4....AN = a3

//A1^A2 = a1^a2
//A1^A3 = a1^a3

//A2^A3 = a2^a3
//We know xor of every pair of array

// I know XOR of whole array : A1 ^ A2...AN = T = a1 ^ a2... an
// NOW T^A1 = a1 => A1 = a1 ^ T
//restore : A1 A2 A3... AN
void testCase() {
    int n;
    cin >> n;
    ll arr[n+1];
    ll T = 0;
    for (int i=1; i<=n; i++) {
        cin >> arr[i];
        T = T ^ arr[i];
    }
    for (int i=1; i<=n; i++) {
        arr[i] = arr[i] ^ T;
        cout << arr[i] << " ";
    }
    cout << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 5084
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define rep(n, i) for(int i = 0; i < n; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

void cango(int m, int p, int*a, int*b, int*flags){
    flags[p] = 1;
    rep(m, i) {
        if (a[i] == p && !flags[b[i]]) cango(m, b[i], a, b, flags);
        else if (b[i] == p && !flags[a[i]]) cango(m, a[i], a, b, flags);
    }
}

void solve(void){
    int n, m;
    scanf("%d %d\n", &n, &m);
    int a[m], b[m];
    rep(m, i) {
        scanf("%d %d\n", &a[i], &b[i]);
        a[i]--; b[i]--;
    }

    int ans = 0;
    rep(m, j){
        int al[m-1], bl[m-1];       //橋を落とす
        int c = 0;                  //index管理
        for(int k = 0; k < m-1; k++) {
            if (k == j) c = 1;
            al[k] = a[k+c];
            bl[k] = b[k+c];
        }
        int flag = 0;
        int flags[n];
        rep(n, i) flags[i] = 0;

        cango(m-1, 0, al, bl, flags);
        rep(n, i) if (!flags[i]) flag = 1;
        if (!flag) ans++;
    }
  printf("%d\n", m-ans);
}

int main(void){
  solve();
  return 0;
}


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

using namespace std;
const int N = 100100;
vector<int> g[N];
vector<int> order;
int dp[N];
bool vis[N];

void dfs(int u) {
  vis[u] = true;
  for (int v : g[u]) {
    if (!vis[v]) dfs(v);
  }
  order.push_back(u);
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      dfs(i);
    }
  }

  reverse(order.begin(), order.end());

  for (int u : order) {
    for (int v : g[u]) {
      dp[v] = max(dp[v], dp[u] + 1);
    }
  }
  
  int best = 0;
  for (int i = 1; i <= n; ++i) best = max(dp[i], best);
  cout << best << endl;
}


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

const int MAX = 510000;
const int mod = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

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

//a^n (mod m)
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    COMinit();
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans = 0;
    ll cnt = n;
    for(int i=0;i<n;i++){
        cnt--;
        ll ret = modpow(2,2*i+2*cnt); 
        ret *= cnt+2;
        ret %= mod;
        ret *= a[i];
        ret %= mod;
        ans+=ret;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13824
x, y = map(int, input().split())
flag = True
for animal in range(1, x + 1):
    if y == animal * 4 + (x - animal) * 2 or y == animal * 2 + (x - animal) * 4:
        print ("Yes")
        flag = False
        break
if flag:
    print("No")


Measured memory_bytes: 9028
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e7 + 555;
const double PI = acos(-1.0);


void solve()
{
	int n;
	cin >> n;
	bool ok = 0;
	for(int i = 1; i <= 9; ++i) for(int j = 1; j <= 9; ++j) if(i * j == n) ok = 1;
	cout << (ok ? "Yes" : "No");
}
 
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char s[1000];
  int  i, cnt = 0;

  scanf("%s", s);
  i = 0;
  while(s[i++])
    cnt++;
  if (s[cnt - 1] == 's')
    printf("%ses\n", s);
  else if(s[cnt - 1] != 's')
    printf("%ss\n", s);
}

Measured memory_bytes: 1736
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            int d = sc.nextInt();
            System.out.println(100 * (600 - d) * (1200 - d));
        }
    }
}

Measured memory_bytes: 26056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
    if (i==N-1) {
      cout << "Three" << endl;
    }
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc")
    {
        Yes
    }
    else
    {
        No
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    cin >> a;
    cin >> b;
    if(a > b){
        cout << ">" << endl;
    }else if(a < b){
        cout << "<" << endl;
    }else if(a == b){
        cout << "=" << endl;
    }

}


Measured memory_bytes: 256
Imports System.Console
Module Module1
    Dim w As Int64
    Dim ii, iii As Int64
    Dim ans As Int64
    Dim md As Int64 = (10 ^ 9) + 7
    Dim max, min As Int64
    Dim n, k, x, t, d, m As Int64
    Sub Add(ByRef arr() As Integer, ByVal num As Integer)
        If arr Is Nothing Then
            ReDim arr(0)
            arr(0) = num
        Else
            ReDim Preserve arr(arr.Length)
            arr(arr.Length - 1) = num
        End If
    End Sub
    Sub Main()
        n = ReadLine()
        For i = 1 To n - 1
            ans += (n - 1) \ i
        Next
        WriteLine(ans)
        ReadLine()
    End Sub
End Module


Measured memory_bytes: 28392
vec = []

loop do
  a, op, b = gets.split
  break if op == '?'

  a = a.to_i
  b = b.to_i

  vec << if op == '+'
           a + b
         elsif op == '-'
           a - b
         elsif op == '*'
           a * b
         else
           a / b
         end
end

vec.each do |v|
  p v
end



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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  string S, T;
  cin >> S >> T;
  int ans = INF;

  int SN = S.size(), TN=T.size();
  REP(i, SN){
    if(i+TN > SN) break;
    int cnt = 0;
    REP(j, TN){
      if(S[i+j] != T[j]){
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> ans;
int main(){
  string s,sk;
  cin>>sk;
  s='0'+sk;
  ll n=sk.length();
  if(s[1]=='0'||s[n]=='1'){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(s[i]!=s[n-i]){
      cout<<-1<<endl;
      return 0;
    }
  }

  ll k=1;
  for(int i=1;i<=n/2;i++){
    if(s[i]=='0'){
      ans.push_back(P(k,i+1));
    }
    else{
      ans.push_back(P(k,i+1));
      k=i+1;
    }
  }
  for(int i=n/2+2;i<=n;i++) ans.push_back(P(k,i));
  for(int i=0;i<ans.size();i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
}


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

typedef long long ll;

template <typename T>
T gcd(T x,T y)
{
	while(y)swap(x%=y,y);
	return x;
}

#define rep(i,l,r) for(int i=l;i<=r;++i)

const int N=200+5,U=2e4+5,D=998244353;
int mi_2[N];
struct point
{
	int x,y;
};
point operator -(const point &a)
{
	return (point){-a.x,-a.y};
}
point operator -(const point &a,const point &b)
{
	return (point){a.x-b.x,a.y-b.y};
}
point operator /(const point &a,int k)
{
	return (point){a.x/k,a.y/k};
}
point standard(point p)
{
	if(p.x==0)return (point){0,1};
	if(p.x<0)p=-p;
	return p/gcd(p.x,abs(p.y));
}
int dy(const point &p)
{
	return p.x*U+p.y;
}
point p[N];
int F2(int n)
{
	return mi_2[n]-1-n;
}

int main()
{
	int n;
	cin>>n;
	rep(i,1,n)cin>>p[i].x>>p[i].y;
	mi_2[0]=1;
	rep(i,1,n)mi_2[i]=mi_2[i-1]*2%D;
	ll ans=mi_2[n]-1-n-n*(n-1)/2;
	rep(i,1,n)
	{
		unordered_map<int,int>mp;
		rep(j,i+1,n)++mp[dy(standard(p[j]-p[i]))];
		for(auto pr:mp)ans-=F2(pr.second);
	}
	cout<<(ans%D+D)%D<<endl;
}

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

#define MOD 1000000007
#define MAX 1000000

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

//http://drken1215.hatenablog.com/entry/2018/06/08/210000

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

long long int comb(int n, int k) {
    initComb();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(void) {
    int x, y;
    scanf("%d %d", &x, &y);
    int m, n;
    long long int ans;

    m = (2*y - x)/3;
    n = (2*x - y)/3;

    if ((x+y)%3 != 0) {
        ans = 0;
    } else if (m < 0 || n < 0) {
        ans = 0;
    } else {
        //ans = (m+n)C(m)
        ans = comb(m+n, m);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 23552
#!/usr/bin/env python3

n, m = map(int, input().split())

flag = 0
ans = [None for i in range(n)]
# print(ans)
for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        flag = 1
        break

# print(flag)
if n == 1:
    if ans[0] is None:
        ans[0] = 0
    print("".join(map(str, ans)) if flag == 0 else -1)
else:
    if ans[0] == 0:
        flag = 1
    if ans[0] is None:
        ans[0] = 1
    for i in range(1, len(ans)):
        if ans[i] is None:
            ans[i] = 0

    print("".join(map(str, ans)) if flag == 0 else -1)


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    double R;
    cin >> R;
    const double pi = 3.141592653589793;
    printf("%.5f\n", 2*R*pi);
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000000007, true>;

int main(void)
{
  ll n,k;
  cin >> n >> k;
  REP(i,k) {
    ll bbox = i+1;
    ll freeb = k - bbox;
    ll freer = n - k - i;
    Mod answer = Mod::comb(freeb + i, i) * Mod::comb(freer + bbox,bbox);
    cout << (ll)answer << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
//#define MOD 1000000007
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> m;
    rep(i, N) {
        ll a;
        cin >> a;
        m[a]++;
    }
    vector<ll> v;
    for(P p : m) {
        while(p.second >= 2) {
            v.push_back(p.first);
            p.second -= 2;
        }
    }
    sort(all(v));
    if (v.size() >= 2) {
        print(v[v.size()-1] * v[v.size()-2]);
    } else {
        print(0);
    }
    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<long long> l(n+1), v(n+1);
    for(auto &i:l)cin>>i;
    v[0]=1; v[n]=0;

    for(int i=n-1;i>0;i--){
        v[i]=l[i+1]+v[i+1];
    }
    for(int i=1;i<n;i++){
        if(v[i] > 2*v[i-1]-l[i])v[i]=2*v[i-1]-l[i];
        else break;
    }

    long long ans=0;
    for(auto i:v)ans+=i;
    for(auto i:l)ans+=i;

    // valid check
    for(auto i:v)if(i<0)ans=-1;
    for(int i=0;i<n;i++){
        if(2*v[i] < l[i+1]+v[i+1])ans=-1;
        if(v[i] > l[i+1]+v[i+1])ans=-1;
    }

    if(n!=0 && l[0]!=0)ans=-1;

    if(n==1 && l[1]>2)ans=-1;

    if(n==0 && l[0]!=1)ans=-1;

    cout<<ans<<endl;
}


Measured memory_bytes: 4788
import sys
n = int(input())
l = list(map(int,input().split()))
counter = 0
if n < 3:
    print(0)
    sys.exit(0)
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            data0 = l[i]
            data1 = l[j]
            data2 = l[k]
            if (data0 != data1) and (data0 != data2) and (data1 != data2):
                if (data0 + data1 + data2 - max(data0,data1,data2)*2) > 0:
                    counter += 1    
print(counter)

Measured memory_bytes: 9112
n, m = map(int, raw_input().split(" "))
a = [[0 for j in range(m)] for i in range(n)]
b = [0 for j in range(m)]
for i in range(n):
    a[i] = map(int, raw_input().split(" "))
for j in range(m):
    b[j] = input()

for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)

Measured memory_bytes: 6520
n = int(input())
s = []
for i in range(n):
  si = sorted(input())
  s.append(si)

s.sort()

ans = 0
cnt = 0
for i in range(1, n):
  if s[i] == s[i-1]:
    cnt += 1
  else:
    ans += cnt * (cnt + 1) // 2
    cnt = 0

ans += cnt * (cnt + 1) // 2
print(ans)

Measured memory_bytes: 97552
package main

import "fmt"

func trinum(x int) int {
	if x <= 0 {
		return 0
	}
	if x > 1 {
		return x + trinum(x-1)
	}
	return x
}

func main() {
	var n, m int

	fmt.Scan(&n)
	fmt.Scan(&m)

	fmt.Print(trinum(n-1) + trinum(m-1))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
//300iq
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
vector<pair<ll,int> > e;
map<ll,int> ret;
int n;
inline void die(){
    puts("-1");
    exit(0);
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        ret[x]=i;
        e.pb(mp(x,i));
    }
    sort(e.begin(),e.end());
    reverse(e.begin(),e.end());
    ll x=e.back().first;
    vector<int> siz(n,1);
    vector<ll> dp(n,0);
    vector<pii> ans;
    for(int i=0;i<e.size();i++){
        pair<ll,ll> c=e[i];
        if(c.first==x) continue;
        if(siz[c.se]*2>=n)
            die();
        ll need=c.first+2*siz[c.se]-n;
        if(!ret.count(need))
            die();
        int par=ret[need];
        dp[par]+=dp[c.se]+siz[c.se];
        siz[par]+=siz[c.se];
        ans.pb(mp(c.se+1,par+1));
    }
    if(dp[e.back().se]!=x)
        die();
    for(int i=0;i<ans.size();i++)
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    return 0;
}

Measured memory_bytes: 12144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,p,q,m,c1,c2,c3;
    string s;
    cin>>s;
    m=p=0;
    for(ll i=0; i<s.size(); i++)
    {
        q=s[i]-'0';
        m+=q;
        p=p*10+q;
    }
    if(p%m==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}





Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	sum := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				sum += gcd(gcd(a, b), c)
			}
		}
	}

	fmt.Println(sum)
}

func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}


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

int main()
{
	int N;
    int l;
    int r;
    int total;
    
    total = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
    	cin >> l >> r;
        total += r - l + 1;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	int n;
	scanf("%d", &n);
	int x, y;
	x = 800*n;
	y = n/15*200;
	printf("%d\n", x-y);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){
    ll N,M;
    ll res;


    cin >> N >> M;

    vector <ll> sa(M+1); 
    vector <ll> X(M); 


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

    REP(i,M)
    {
        cin >> X[i];
    }
    sort(X.begin(),X.end());

    REP(i,M - 1)
    {
        sa[i] = X[i+1] - X[i];
    }

    sort(sa.begin(),sa.end(),greater<ll>());

    //+N?
    res = 0;
    for (std::vector<ll>::iterator it = sa.begin() + N - 1; it != sa.end(); ++it) {
        res += *it;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

typedef long long LL;
using namespace std;

LL gcd(LL x, LL y){
  if (y>x) return gcd(y,x);
  if (y==0) return x;
  return gcd(y, x%y);
}
int main(void){
  int n;
  LL ans,tmp;
  
  cin >> n;
  cin >> ans;
  for (int i=0; i<n-1; i++){
    cin >> tmp;
    ans = tmp/gcd(ans,tmp)*ans;
  }
  cout << ans << endl;
  return 0;
}
  

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

int main(void) {

    int n, k;
    cin >> n >> k;
    long long int ans = k;
    for(int i=1; i<n; i++) ans *= k-1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

struct dice {
    int top, bottom, west, east, north, south;

    // no need naming these... just for clarity

    void roll_east() {
        int t = top;
        top = west;
        west = bottom;
        bottom = east;
        east = t;
    };

    void roll_west() {
        int t = top;
        top = east;
        east = bottom;
        bottom = west;
        west = t;
    };

    void roll_north() {
        int t = top;
        top = south;
        south = bottom;
        bottom = north;
        north = t;
    };

    void roll_south() {
        int t = top;
        top = north;
        north = bottom;
        bottom = south;
        south = t;
    };

    void show_dice() {
        std::cout << " " << north << std::endl;
        std::cout << west << bottom << east << top << std::endl;
        std::cout << " " << south << std::endl;
        std::cout << std::endl;
    };
};

int main() {
    dice d1;
    std::cin >> d1.top >> d1.south >> d1.east >> d1.west >> d1.north >> d1.bottom;
    dice d2;
    std::cin >> d2.top >> d2.south >> d2.east >> d2.west >> d2.north >> d2.bottom;
    bool b = false;
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            if( d1.south == d2.south)
                break;
            d2.roll_north();
        }
        if( d1.south == d2.south)
                break;
        d2.roll_east();
    }
    for(int i = 0; i < 4; i++){
        if( d1.top == d2.top)
            break;
        d2.roll_east();
    }
    for(int i = 0; i < 4; i++){
        if( d1.east == d2.east)
            break;
        d2.roll_east();
    }

    
    if(d1.top == d2.top && d1.south == d2.south && d1.east == d2.east)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>

using namespace std;

typedef int64_t ll;

int main() {
    ll L, R;
    cin >> L >> R;

    if (R - L >= 2018 || L == 0) {
        cout << 0 << endl;
        return 0;
    }

    L %= 2019;
    R %= 2019;

    if (L >= R) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1e9;
    for (ll i = L; i <= R - 1; ++i) {
        for (ll j = i + 1; j <= R; ++j) {
            ll hoge = i * j;
            hoge %= 2019;
            if (ans > hoge) {
                ans = hoge;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256