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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const ll MOD = 1000000007;
const ll MX = 1000000000000000000;

vector<ll> fib; //87
vector<pair<ll,ll>> cand[100];

void gen() {
	for (int i = 1; i < (int)fib.size() - 1; ++i) {
		cand[i].eb(fib[i], fib[i+1]);

		for (int p = 1; p < i; ++p) {
			ll x = 1, y = 1;
			for (ll j = 1; j <= i; ++j) {
				ll nx, ny;
				if (j != p) {
					nx = y;
					ny = x + y;
				} else {
					nx = y;
					ny = x + y * 2;
				}
				x = nx; y = ny;
			}
			cand[i].eb(x, y);
		}
	}
}

int main() {
	fib.pb(1); fib.pb(1);
	for (int i = 2; ; ++i) {
		ll x = fib[i-2] + fib[i-1];
		fib.pb(x);
		if (x > MX) {
			break;
		}
	}

	gen();

	int Q; cin >> Q;
	while (Q--) {
		ll X, Y;
		cin >> X >> Y;
		if (X > Y) swap(X, Y);

		int maxi = 1;
		
		if (X != 1) {
			for (int i = 0; i < (int)fib.size()-1; ++i) {
				if (fib[i] <= X && fib[i + 1] <= Y) {
					maxi = i;
				}
			}
		}

		ll ans = 0;
		if (maxi == 1) {
			ans = X % MOD * Y % MOD;
		} else {
			for (auto p : cand[maxi]) {
				ll a = p.fi, b = p.se;
				ll cnt = 0;
				if (a <= X && b <= Y) {
					cnt += (Y - b) / a + 1;
				}
				if (b <= X && a <= Y) {
					cnt += (Y - a) / b + 1;
				}

				ans += cnt % MOD;
				if (ans >= MOD) ans -= MOD;
			}
		}

		cout << maxi << " " << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <tuple>
#include <stack>

using namespace std;

#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug

#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');

typedef double db;
typedef long long LL;
typedef pair<int, int> pii;

const int Max = 100010;

vector<int> edges[Max];
int res[Max];

int dfs(int x, int f) {
    auto r = 0;
    for (auto y : edges[x]) if (y != f) r ^= dfs(y, x) + 1;
    return r;
}

int main() {
#ifdef ZTDebug
    while (true) {
        for (auto i = 0; i < Max; ++i) edges[i].clear();
#endif // ZTDebug
        int n;
        cin >> n;
        for (auto i = 1; i < n; ++i) {
            InD2(x, y);
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        cout << (dfs(1, -1) > 0 ? "Alice" : "Bob") << endl;
#ifdef ZTDebug
    }
#endif // ZTDebug
    return 0;
}


Measured memory_bytes: 10368
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)
#define ps(x) cout << x << endl;
#define ps_end(x) ps(x); return;

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n, m;

void task() {
	cin >> n;
	vector<int> v(n);
	int x = 0;
	int ans = 0;
	while (1) {
		x = x * 10 + 7;
		x %= n;
		ans++;
		if (x == 0) {
			ps_end(ans);
		}
		if (v[x]) {
			ps_end(-1);
		}
		v[x] = 1;
	}
	
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


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

using namespace std;
long long a,b[10000],n,i,j,ok;

int main()
{
	cin>>n;
	ok=0;
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
		if(i*j==n)
		{
			//cout<<"Yes";
			ok=1;
		}
		if(ok==1)
			cout<<"Yes";
		else
			cout<<"No";


}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int n, T;
  cin >> n >> T;
  vi t(n);
  REP(i, n) cin >> t[i];
  ll ans = T;
  REP(i, n-1) {
    ans += min(T, t[i+1]-t[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#!/mnt/c/Users/moiki/bash/env/bin/python
N,M = list(map(int, input().split()))
P =[]
Y = []
yp = [(0,0,0)] * M
for i in range(M):
    P.append(0)
    Y.append(0)
    P[i], Y[i] = list(map(int, input().split()))
    yp[i] = (Y[i], P[i], i)

yp.sort()
dic = {}
# for i in range(M):
#     dic[P[i]] = [Y[i]] if not P[i] in dic else dic[P[i]] + [Y[i]]
#     dic[P[i]] = sorted(dic[P[i]])

# print(yp)
pre = [0] * (N+1)
ansnum = [0] * M
for (y,p,i) in yp:
    pre[p] += 1
    ansnum[i] = "{0:06d}{1:06d}".format(p, pre[p])

import numpy as np
for i in range(M):
    print(ansnum[i])
    # num = yp[]
    # num = dic[P[i]].index(Y[i]) + 1
    # print("{0:06d}{1:06d}".format(P[i], num))

Measured memory_bytes: 40584
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, m, i, j, k, t;
	cin >> n >> m;
	t = 1900 * m + 100 * (n - m);
	t = t << m;
	cout << t << "\n";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    rep(i, n) {
        int a;
        cin >> a;
        q.push(a);
    }
    vector<pair<int, int>> b(m);
    rep(i, m) cin >> b[i].first >> b[i].second;
    sort(b.begin(), b.end());
    rep(i, m){
        rep(j, b[b.size() - i - 1].first){
            if (q.top() >= b[b.size() - i - 1].second) {
                break;
            }
            q.pop();
            q.push(b[b.size() - i - 1].second);
        }
    }
    ll ans = 0;
    rep(i, n) {
        //cout << q.top() << ' ';
        ans += q.top();
        q.pop();
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4512
n = int(input())
a = list(map(int, input().split()))
a_cur = a[0]

m = 1000
s = 0

for i in range(1, n):
    a_next = a[i]
    if a_cur < a_next:
        # buy
        s += m // a_cur
        m -= m // a_cur * a_cur
    else:
        # sell
        m += s * a_cur
        s = 0
    a_cur = a_next
m += s * a_cur
print(m)


Measured memory_bytes: 9064
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
ps=sorted(p,reverse=True)
qs=sorted(q,reverse=True)
pn=ps[:x]
qn=qs[:y]
nl=sorted(pn+qn+r,reverse=True)
print(sum(nl[:x+y]))


Measured memory_bytes: 24240
import itertools
import numpy as np
N = int(input())
log_n = int(np.log10(N))

vals = []

for a,b in itertools.product(range(1,10), range(1,10)):
    res = 0
    if a == b and a <= N:
        res += 1
    for i in range(1, log_n + 1):
        mini = a * (10 ** i) + b
        if N - mini < 0:
            break
        if 10 * (10 ** (i - 1) - 1) <= N - mini:
            res += 1 + 10 * (10 ** (i - 1) - 1) // 10
        else:
            res += 1 + np.floor((N - mini) / 10)
    vals.append(((a, b), int(res)))
table = {k:v for k,v in vals}
res = 0
for x in list(itertools.combinations(range(1,10),2)):
    res += 2 * (table[x] * table[(x[1],x[0])])
for x in range(1,10):
    res += table[(x,x)] ** 2
print(res)

Measured memory_bytes: 12520
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> field(H);
    rep(i, H){
        cin >> field[i];
    }
    //1が赤で塗りつぶす行、列
    ll ans = 0;
    rep(bith, 1<<H){
        rep(bitw, 1<<W){
            ll tmp = 0;
            rep(i, H){
                if(bith & (1<<i)){
                    continue;
                }
                rep(j, W){
                    if(!(bitw & (1<<j))){
                        if(field[i][j] == '#'){
                            tmp++;
                        }
                    }
                }
            }
            if(tmp == K) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3612
#include<stdio.h>
#define M 1000000
int first[M], next[M], go[M], ans[M], visited[M], q[M];
int i, n, m, x, y, flag = 0, re, t, l = 0, r = 1;
int main(){
	scanf("%d %d",&n,&m);
	for(i = 1; i <= m; i++){
		scanf("%d %d",&x,&y);
		next[i] = first[x];
		first[x] = i;
		go[i] = y;
		next[i + m] = first[y];
		first[y] = i + m;
		go[i + m] = x;
	}
    q[1] = 1;
    visited[1] = 1;
    while(l < r){
    	l++;
    	re = q[l];
    	t = first[re];
    	while(t){
    		if(!visited[go[t]]){
    			visited[go[t]] = 1;
    			r++;
    			q[r] = go[t];
    			ans[go[t]] = re;
			}
    		t = next[t];
		}
	}
    for(i = 2; i <= n; i++)
      if(!visited[i])
        flag = 1;
	if(flag)
		puts("No");
	else{
    	puts("Yes");
        for (i = 2; i <= n; i++)
    	    printf("%d\n",ans[i]);
    }
} 

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    // test
    {
        int k;
        cin>>k;

        f0(i,0,k) cout<<"ACL";
    }
}

Measured memory_bytes: 3648
using System;
using System.Linq;
using System.Collections.Generic;

namespace D
{
  class Program
  {
    static Dictionary<int, LinkedList<int>> linkList = new Dictionary<int, LinkedList<int>>();
    static Dictionary<int, long> answer = null;
    static void Main(string[] args)
    {
      var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
      var N = input[0];
      var Q = input[1];

      answer = Enumerable.Range(1, N).ToDictionary(x => x, x => 0L);
      for (int i = 0; i < N - 1; i++)
      {
        input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var id = input[0];
        var childId = input[1];
        if (!linkList.Keys.Contains(id))
        {
          linkList[id] = new LinkedList<int>();
        }
        if (!linkList.Keys.Contains(childId))
        {
          linkList[childId] = new LinkedList<int>();
        }
        // 双方向
        linkList[id].AddLast(childId);
        linkList[childId].AddLast(id);
      }

      for (int i = 0; i < Q; i++)
      {
        input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var id = input[0];
        var value = input[1];
        if (!answer.Keys.Contains(id))
        {
          answer[id] = 0;
        }
        answer[id] += value;
      }

      PropagateValue(1, -1);

      Console.WriteLine(string.Join(" ", answer.OrderBy(x => x.Key).Select(n => n.Value.ToString())));
    }
    private static void PropagateValue(int child, int parent)
    {
      foreach (var gchild in linkList[child])
      {
        if (gchild != parent)
        {
          answer[gchild] += answer[child];
          PropagateValue(gchild, child);
        }
      }
    }
  }
}


Measured memory_bytes: 112204
#include<stdio.h>
#include<string.h>
int main(void){
	int i, s[6], n[6], n2[6];
	char c;
	for (i = 0; i<6; i++){
		scanf("%d", &s[i]);
		n[i] = i;
	}
	scanf("%c", &c);
	while (1){
		scanf("%c", &c);
		if (c == '\n'){ break; }
		if (c == 'N'){
			n2[0] = n[1]; n2[1] = n[5]; n2[3] = n[3]; n2[4] = n[0]; n2[2] = n[2]; n2[5] = n[4];
		}
		if (c == 'E'){
			n2[0] = n[3]; n2[1] = n[1]; n2[3] = n[5]; n2[4] = n[4]; n2[2] = n[0]; n2[5] = n[2];
		}
		if (c == 'S'){
			n2[0] = n[4]; n2[1] = n[0]; n2[3] = n[3]; n2[4] = n[5]; n2[2] = n[2]; n2[5] = n[1];
		}
		if (c == 'W'){
			n2[0] = n[2]; n2[1] = n[1]; n2[3] = n[0]; n2[4] = n[4]; n2[2] = n[5]; n2[5] = n[3];
		}
		for (i = 0; i < 6; i++){
			n[i] = n2[i];
		}
	}
	printf("%d\n", s[n[0]]);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
char c[2][4];
scanf("%s %s", c[0], c[1]);
if(c[0][0]==c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}

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

using namespace std;

int main() {
	int a, b;
	vector<int> hyou(1000001, 0);
	hyou[0] = hyou[1] = 1;
	for (int i = 2; i*i < 1000001; i++) {
		if (hyou[i] == 0) {
			for (int j = 2; j <= 1000000/i; j++) {
				hyou[i*j] = 1;
			}
		}
	}
	while(cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}
		long long int sum1, sum2;
		int pre1, pre2;
		sum1 = sum2 = 0;
		pre1 = pre2 = 0;
		for (int i = 2; i <= a; i++) {
			if (hyou[i] == 0) {
				if (a % i == 0) {
					sum1 += pre1;
					pre1 = i;
				}
			}
		}
		sum1 = pre1 - sum1;
		for (int i = 2; i <= b; i++) {
			if (hyou[i] == 0) {
				if (b % i == 0) {
					sum2 += pre2;
					pre2 = i;
				}
			}
		}
		sum2 = pre2 - sum2;
		if (sum1 > sum2) {
			cout << 'a' << endl;
		} else {
			cout << 'b' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4900
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int N, T;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> N >> T;
    int ans = inf;
    rep(i, 0, N) {
      int c, t;
      cin >> c >> t;
      if (t <= T) ans = min(ans, c);
    }
    if (ans == inf) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;



namespace	{
#define rep(i, N, M) for(int i=N, i##_len=(M); i<i##_len; ++i)
#define rep_skip(i, N, M, ...) for(int i=N, i##_len=(M); i<i##_len; i+=(skip))
#define rrep(i, N, M)  for(int i=(M)-1, i##_len=(N-1); i>i##_len; --i)
#define pb push_back


	typedef long long ll;
	typedef unsigned long long ull;
	typedef pair<ll, ll> pll;
	typedef tuple<ll, ll, ll> tll;
	typedef tuple<ll, ll, ll, ll> tll4;
	typedef vector<ll> vll;
	typedef vector<vll> vvll;
	typedef vector<pll> vpll;
	typedef vector<bool> vb;
	typedef vector<vb> vvb;
	typedef vector<string> vs;
	typedef priority_queue<ll> pqll;
	typedef priority_queue<pll, vector<pll>> pqpll;
	typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
	typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define perm(c) sort(all(c));for(bool c##perm=1;c##perm;c##perm=next_permutation(all(c)))


	template<class T, class S>
	T atbit(T n, S i) {
		return (n >> i) % i;
	}

	template<class T>
	T getbit(T i) {
		return 1LL << i;
	}
	template<class T>
	T POW(T n, T m) {
		T res = 1;
		rep(i, 0, m) {
			res *= n;
		}
		return res;
	}

	vll getDivisors(ll n) {
		vll res;
		ll i = 1;

		for (; i*i < n; i++) {
			if (n%i == 0) {
				res.push_back(i);
				res.push_back(n / i);
			}
		}
		if (i*i == n)res.push_back(i);
		sort(res.begin(), res.end());
		return res;
	}

	vll getDivisors(ll n, ll m) {
		if (n > m) swap(n, m);
		vll res;
		ll i = 1;

		for (; i*i < n; i++) {
			if (n%i == 0) {
				if (m%i == 0) res.push_back(i);
				if (m%(n/i) == 0) res.push_back(n / i);
			}
		}
		if (i*i == n) if (m%i == 0) res.push_back(i);
		sort(res.begin(), res.end());
		return res;
	}


	ll gcd(ll a, ll b) {
		if (a%b == 0) return b;
		else return gcd(b, a%b);
	}

	template<
		typename Inputs,
		typename Functor,
		typename T = typename Inputs::value_type>
		void sort_by(Inputs& inputs, Functor f) {
		std::sort(std::begin(inputs), std::end(inputs),
			[&f](const T& lhs, const T& rhs) { return f(lhs) < f(rhs); });
	}

	template<int I>
	vll proj(vpll v) {
		vll res(v.size());
		rep(i, 0, v.size()) {
			if (!I) res[i] = v[i].first;
			else res[i] = v[i].second;
		}
		return res;
	}


	template<int I, class T>
	vll proj(T v) {
		vll res(v.size());
		rep(i, 0, v.size()) {
			res[i] = get<I>(v[i]);
		}
		return res;
	}

	
}



int main() {

	ll N;
	cin >> N;
	vll A(N);
	rep(i, 0, N) cin >> A[i];
	sort(all(A));
	bool isFirst=true;
	ll h=0, l=0;
	rrep(i, 0, N - 1)
	{
		if (A[i] == A[i + 1]) {
			if (isFirst) {
				isFirst = false;
				h = A[i];
				i--;
			}
			else {
				l = A[i];
				break;
			}
		}
	}
	cout << h * l;
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, m := readI(), readI()
	a := readIs(m)

	sum := 0
	for _, v := range a {
		sum += v
	}
	if ans := n - sum; ans >= 0 {
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1948
// Author : Mohamed sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		if (a[i] >= a[i-1])continue;
		ans += a[i-1] - a[i];
		a[i] = a[i-1];
	}
	cout << ans << '\n';
	
}


Measured memory_bytes: 4052
n = int(input())
A = [int(i) for i in input().split()]
ans = [0 for i in range(n)]
ans[-1] = A[-1]
for i in range((n-1)//2):
    ans[-1] = ans[-1] - A[2*i] + A[2*i+1]
for i in range(n-2, -1, -1):
    ans[i] = 2*A[i] - ans[i+1]
for i in ans:
    print(i, end=" ")

Measured memory_bytes: 14024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int m;
  cin >> m;

  // 解答
  cout << 48 - m << endl;

  return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if(a >= 13)cout << b  << endl;
    else if(a >= 6)cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
const int MOD=1e9+7;
const int N=2e4+10;

inline LL read(){
	LL ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

LL n,k,a[N],b[N];
LL res,cnt,ans,tmp;
LL pre[N],num[N];

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	k=read();
	for(int i=1;i<=n;i++) a[i]=read(),b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++){
		if(i!=1){
			if(b[i]!=b[i-1]) ans+=i-1,tmp=i-1;
			else ans+=tmp;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			if(a[j]>a[i]) res++;
//	printf("%I64d\n",ans);
	ans=ans*((k*(k-1)/2)%MOD)%MOD;
//	printf("%I64d\n",ans);
	ans+=res*k;
	ans%=MOD;
	printf("%I64d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#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 int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, i, done = 0;
    cin>>n>>k;
    vector<ll> a(n);
    for(i = 0; i < n; i++) {
    	cin>>a[i];
    }
    while(done < k) {
    	bool flag = true;
    	vector<ll> cp(n, 0);
    	for(i = 0; i < n; i++) {
    		ll cur = a[i];
    		ll l = max(i - a[i], (ll) 0);
    		ll r = min(i + a[i], (ll) n - 1);
    		cp[l]++;
    		if(r != n-1) {
    			cp[r + 1]--;
    		}
    	}
    	for(i = 1; i < n; i++) {
    		cp[i] = cp[i-1] + cp[i];
    	}
    	for(i = 0; i < n; i++) {
    		a[i] = cp[i];
    		if(a[i] != n) {
    			flag = false;
    		}
    	}
    	done++;
    	if(flag) {
    		break;
    	}
    }
    for(i = 0; i < n; i++) {
    	cout<<a[i]<<" ";
    } cout<<"\n";
}

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

long long  n, cost[4], cnt[4],po[4] = {1,2,4,8};
long long ans=0;

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

    for(int i = 0; i < 4; i++)cin>>cost[i];
    cin>>n;
    n*=4;

    for(int i = 3; i >= 0; i--){
        cnt[i] = (int)(n/po[i]);
        n -= cnt[i] * po[i];
    }

    for(int i = 2; i >= 0; i--){
        for(int j = i+1; j < 4; j++){
            if(po[j-i]*cost[i] <= cost[j]){
                cnt[i] += po[j-i] * cnt[j];
                cnt[j] = 0;
            }
        }
    }
    for(int i = 0; i < 4; i++)ans+=cnt[i]*cost[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

if ((C1[1]-C1[0]) == (C2[1]-C2[0]) == (C3[1]-C3[0]) and
    (C1[2]-C1[1]) == (C2[2]-C2[1]) == (C3[2]-C3[1])):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility> 
#include <cmath>
#define N 20
using namespace std;

int T[N][N];
pair <bool,bool> S[N][N];

void init(){
	for(int i = 0; i < N; i++){
		for (int j = 0; j < N; ++j){
			T[i][j] = 0;
			S[i][j].first = true;
			S[i][j].second = true;
		}
	}
}

int func(int i,int j){
	if(i < 0 || j < 0) return 0;
	if(i == 0 && j == 0) return 1;
	if(i == 0) return ((S[i][j].first)? T[i][j-1]: 0);
	if(j == 0) return ((S[i][j].second)? T[i-1][j]: 0); 
	int ans = 0;
	if(S[i][j].first)  ans += T[i][j-1];
	if(S[i][j].second) ans += T[i-1][j];
	return ans;
}

void DispAns(int x,int y){
	if(T[x][y] == 0) cout << "Miserable Hokusai!" << endl;
	else cout << T[x][y] << endl;
	// for(int i = 0; i <= x; i++){
	// 	for (int j = 0; j <= y; ++j){
	// 		cout << T[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << endl;
}

void solve(){
	init();
	int x,y;
	cin >> x >> y;
	int p;
	cin >> p;
	for (int i = 0; i < p; ++i){
		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int p = max(x1,x2);
		int q = max(y1,y2);
		if(x1 == x2) S[p][q].first = false;
		if(y1 == y2) S[p][q].second = false;
	}
	for(int i = 0;i <= x; i++){
		for (int j = 0; j <= y; ++j){
			T[i][j] = func(i,j);
		}
	}
	DispAns(x,y);
}

int main(){
	int n;
	int x,y;
	cin >> n;
	for(int i = 0; i < n; i++) solve();
	return 0;
}

Measured memory_bytes: 1160
/* 
 * Project: AtCoder Beginners Contest 134 B - Golden Apple
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/15
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
using namespace std;

int32_t n;
int32_t d;

void solve() {

    int32_t cnt = (n+2*d)/(2*d+1);
    printf("%d\n", cnt);

}

int main() {

    scanf("%d", &n);
    scanf("%d", &d);

    solve();

}


Measured memory_bytes: 3188
#include <stdio.h>

int main() {
	double x, y;
	int a,b,c,d,e,f;
	while(scanf("%d %d %d %d %d %d",&a ,&b ,&c ,&d ,&e ,&f )!=EOF) {
		x = (double)(e*c-b*f) / (double)(a*e-b*d);
		y = (double)(a*f-c*d) / (double)(a*e-b*d);
		if (x == -0.000000) x = 0.000000;
		if (y == -0.000000) y = 0.000000;
		printf("%.3f %.3f\n",(double)x ,(double)y);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio> 
#include<iostream>
using namespace std;
int N,C,tmp; 
int s[100000],t[100000],c[100000]; 
int sm[200002]; int tt[200002]; 
int main() { 
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> tmp; s[i] = tmp; cin >> tmp; t[i] = tmp; cin >> tmp; c[i] = tmp;
	}
	for(int i=1;i<=C;i++) { 
		for(int j=0;j<200002;j++)tt[j]=0; 
		for(int j=0;j<N;j++)if(c[j]==i)tt[s[j]*2-1]++,tt[t[j]*2]--; 
		for(int j=1;j<200002;j++)tt[j]+=tt[j-1]; 
		for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++; }
	int mx=0; for(int j=0;j<200002;j++)if(mx<sm[j])mx=sm[j]; printf("%d\n",mx);

	//system("pause");
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using 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 (b<a) { a=b; return 1; } return 0; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
   if (N) os << " ";
   os << get<N>(t);
   out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
   os << "(";
   out<0,tuple<Ts...>,Ts...>(os, t);
   os << ")";
   return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
   os << "(" << e.to << ", " << e.cost << ")";
   return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n, x; cin >> n >> x;
   vector<int> l(n);
   for (int i = 0; i < n; ++i) {
      cin >> l[i];
   }

   int d = 0, ans = 1;
   for (int i = 0; i < n; ++i) {
      d += l[i];
      if (d > x) {
         break;
      }
      ++ans;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=30100;
const ll INF=2147483647;
const ll mod=998244353;
ll a,b,c,n,ia[maxn],ib[maxn],ic[maxn],sum;
int main()
{
	cin>>a>>b>>c>>n;
	for(int i=0;i<=n;i++)
	{
		if(i*a>n)break;
		ia[i*a]=1;
	}
	for(int i=0;i<=n;i++)
	{
		if(i*b>n)break;
		ib[i*b]=1;
	}
	for(int i=0;i<=n;i++)
	{
		if(i*c>n)break;
		ic[i*c]=1;
	}
	for(int i=0;i<=n;i++)
	{
		if(ia[i])
		{
			for(int j=0;j<=n;j++)
			{
				if(n-i-j<0)continue;
				if(ib[j]&&ic[n-i-j])
				{
					sum++;
					//cout<<i/a<<" "<<j/b<<" "<<(n-i-j)/c<<"\n";
				}
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	long long int a,s,d[1000],f[1000],g[1000],h[1000],z[1000],x[1000],c,v;
	int i,j;
	scanf("%lld %lld",&a,&s);
	for(i=0;i<a;i++){
		scanf("%lld %lld",&d[i],&f[i]);
		z[i]=2100000000;
	}
	for(i=0;i<s;i++)
		scanf("%lld %lld",&g[i],&h[i]);
	for(i=0;i<a;i++){
		for(j=0;j<s;j++){
			c=(d[i]-g[j]);
			v=(f[i]-h[j]);
			if(0>c)
				c=c*-1;
			if(0>v)
				v=v*-1;
			c=c+v;
			if(z[i]>c){
				z[i]=c;
				x[i]=j+1;
			//	printf("%d %lld\n",i,x[i]);
			}
		}
	}
	for(i=0;i<a;i++)
		printf("%lld\n",x[i]);
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
p_list = list(map(int,input().split()))
x_y_list = []
for i in range(m):
  x_y_list.append(list(map(int,input().split())))
  
class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[y] = x
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
U = UnionFindPathCompression(n)

for x_y in x_y_list:
  x = x_y[0] -1
  y = x_y[1] - 1
  U.union(x,y)
  
count = 0
for i in range(n):
  if U.same(i,p_list[i]-1) == True:
    count += 1
    
print(count)

Measured memory_bytes: 35224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll MOD = 1000000007LL;
ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

template<class T> struct Matrix {
    vector <vector<T>> val;
    Matrix(int n = 1, int m = 1) {
        val.clear();
        val.resize(n, vector<T>(m));
    }
    Matrix(int n, int m, T x) {
        val.clear();
        val.resize(n, vector<T>(m, x));
    }
    void init(int n, int m, T x = 0) {
        val.clear();
        val.resize(n, vector<T>(m, x));
    }
    void resize(int n, int m, T x = 0) {
        val.resize(n);
        for (int i = 0; i < n; ++i) val[i].resize(m, x);
    }
    int size() { return val.size(); }
    inline vector <T> &operator[](int i) { return val[i]; }
    friend ostream &operator<<(ostream &s, Matrix<T> M) {
        s << endl;
        for (int i = 0; i < M.val.size(); ++i) s << M[i] << endl;
        return s;
    }
};


template<class T> Matrix<T> operator * (Matrix<T> A, Matrix<T> B) {
    Matrix<T> R(A.size(), B[0].size());
    for (int i = 0; i < A.size(); ++i)
        for (int j = 0; j < B[0].size(); ++j)
            for (int k = 0; k < B.size(); ++k)
                R[i][j] = mod(R[i][j] + A[i][k] * B[k][j], MOD);
    return R;
}

template<class T> vector<T> operator * (Matrix<T> A, vector<T> B) {
    vector <T> v(A.size());
    for (int i = 0; i < A.size(); ++i)
        for (int k = 0; k < B.size(); ++k)
            v[i] = (v[i] + A[i][k] * B[k]) % MOD;
    return v;
}

template<class T> Matrix<T> pow(Matrix<T> A, ll n) {
    Matrix<T> R(A.size(), A.size());
    for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

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

    Matrix <ll> M(n, n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> M[i][j];
        }
    }

    vector <ll> vec(n, 1);
    Matrix <ll> P = pow(M, k);
    vector <ll> V = P * vec;

    ll ans = 0LL;
    for (int i = 0; i < n; i++) {
        ans += V[i];
    }

    cout << ans % MOD << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iterator>
#include <list>

int main(void) {
    int q;
    std::cin >> q;

    std::list<int> my_list{};
    auto cursor = my_list.end();
    int kind;
    for (int i = 0; i < q; ++i) {
        std::cin >> kind;
        switch (kind) {
            case 0:
                int x;
                std::cin >> x;
                cursor = my_list.insert(cursor, x);
                break;
            case 1:
                int d;
                std::cin >> d;
                advance(cursor, d);
                break;
            case 2:
                cursor = my_list.erase(cursor);
                break;
            default:
                std::cerr << "strange kind" << std::endl;
        }
    }

    for (auto iter = my_list.begin(); iter != my_list.end(); ++iter) {
        std::cout << *iter << std::endl;
    }
}


Measured memory_bytes: 18620
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
int getdistance(int i, int j, int N, int X, int Y) {
	int result=0;
	if (i <= X)
	{
		if (j < Y)
		{
			result= min(j - i, X - i + Y - j + 1);
		}
		else
		{
			result= X - i + j - Y + 1;
		}
	}
	else if (i <= Y) {
		if (j < Y)
		{
			result= min(j - i, i - X + (Y - j) + 1);
		}
		else {
			result= min(j - i, j - Y + (i - X) + 1);
		}
	}
	else {
		result= j - i;
	}
	if (result == 5) {
		//cout << endl;
	}
	return result;
}

int main()
{
	long N, X, Y;
	cin >> N >> X >> Y;
	vector<long> discount(N+1);
	for (int k = 0; k < N; k++)
	{
		for (int m = k+1; m < N; m++)
		{
			discount[getdistance(k+1, m+1, N, X, Y)]++;
		}
	}
	for (int i = 1;i < N ;i++) {
		cout << discount[i] << endl;
	}
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,a,b; cin>>x>>y>>a>>b;
    int dx = a-x, dy = b-y;
    cout<<string(dy, 'U')<<string(dx, 'R');
    cout<<string(dy, 'D')<<string(dx, 'L');
    cout<<'D';
    cout<<string(dx+1, 'R')<<string(dy+1, 'U')<<'L';
    cout<<'U'<<string(dx+1,'L')<<string(dy+1, 'D')<<'R';
    cout<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int cnt = 0;
    int bstu = 0;
    REP(i, n){
        if(s[i] == 'a'){
            if(cnt < a + b){
                cout << "Yes" << endl;
                cnt++;
            }else {
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(cnt < a + b && bstu < b){
                cout << "Yes" << endl;
                cnt++; bstu++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int nmax=50;
int n,m;
int a[nmax],b[nmax];
bool graph[nmax][nmax];
bool visited[nmax];
void dfs(int v){
  visited[v]=true;
  for(int v2=0;v2<n;v2++){
    if(graph[v][v2]==false){
      continue;
    }
    if(visited[v2]==true){
      continue;
    }
    dfs(v2);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  int ans=0;
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0;j<n;j++){
      visited[j]=false;
    }
    dfs(0);
    bool bridge=false;
    for(int j=0;j<n;j++){
      if(!visited[j]){
        bridge=true;
      }
    }
    if(bridge){
      ans++;
    }
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout << ans << endl;
}

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

int main()
{
	string s;
	
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]==',')
			cout<<' ';
		else
			cout<<s[i];
    }
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <set>
#include <vector>

#define INF (1000000000000000000L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N;
  vector<long> as;
  scanf("%ld", &N);
  for (int i = 0; i < 3 * N; i++) {
    long a;
    scanf("%ld", &a);
    as.push_back(a);
  }

  // calculate sum of n largest elements and sum of n smallest elements
  vector<long> snls(3 * N, 0), snss(3 * N, 0);
  multiset<long> nls, nss;
  // put the left most n elements in nls
  for (long i = 0; i < N; i++) {
    const long a = as[i];
    nls.insert(a);
    snls[N] += a;
  }
  // put the right most n elements in nss
  for (long i = 2 * N; i < 3 * N; i++) {
    const long a = as[i];
    nss.insert(a);
    snss[2 * N] += a;
  }
  // calculate sums of n largest elements
  // printf("i = %ld:  ", N);
  // for (long nl : nls) {
  //   printf("%ld ", nl);
  // }
  // printf("\n");
  for (long i = N + 1; i <= 2 * N; i++) {
    const long a = as[i - 1];
    if (nls.lower_bound(a) != nls.begin()) {
      const int a_prev = *nls.begin();
      nls.erase(nls.begin());
      nls.insert(a);
      snls[i] = snls[i - 1] + a - a_prev;
    } else {
      snls[i] = snls[i - 1];
    }
    // printf("i = %ld:  ", i);
    // for (long nl : nls) {
    //   printf("%ld ", nl);
    // }
    // printf("\n");
  }
  // calculate sums of n smallest elements
  // printf("i = %ld:  ", 2 * N);
  // for (long ns : nss) {
  //   printf("%ld ", ns);
  // }
  // printf("\n");
  for (long i = 2 * N - 1; i >= N; i--) {
    const long a = as[i];
    if (nss.upper_bound(a) != nss.end()) {
      const int a_prev = *nss.rbegin();
      nss.erase(--nss.end());
      nss.insert(a);
      snss[i] = snss[i + 1] + a - a_prev;
    } else {
      snss[i] = snss[i + 1];
    }
    // printf("i = %ld:  ", i);
    // for (long ns : nss) {
    //   printf("%ld ", ns);
    // }
    // printf("\n");
  }
  // calculate final answer
  long ans = -INF;
  for (long i = N; i <= 2 * N; i++) {
    if (snls[i] - snss[i] >= ans) {
      ans = snls[i] - snss[i];
    }
  }
  // for (long i = N; i <= 2 * N; i++) {
  //   printf("%ld ", snls[i]);
  // }
  // printf("\n");
  // for (long i = N; i <= 2 * N; i++) {
  //   printf("%ld ", snss[i]);
  // }
  // printf("\n");
  printf("%ld\n", ans);

  return 0;
}


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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	if(t.length() == s.length()+1 && s == t.substr(0, s.length()) )
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3580
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

t = Hash.new(0)

c = 0
ans = 0

A.each do |a|
  c = (c + a) % M
  ans += 1 if c == 0
  ans += t[c]
  t[c] += 1
end

puts ans

Measured memory_bytes: 12164
import functools as ft

n = int(input())


mp_ = [0]*100 

for i in range(1,n+1):

    t = i%10

    if t == 0:
        continue
    else:

        h = int(str(i)[0])
        
        mp_[h*10 + t] += 1


ans = 0
for i, v in enumerate(mp_):

    if v == 0:
        continue

    #if v != 0:
#    print(i,v)
    j = (i%10)*10 + i//10
    t = mp_[j] * v
    ans += t

print(ans)


Measured memory_bytes: 3572