akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
using namespace std;
typedef long long int ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{for(T&x:v)i>>x;return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;for(T&x:v)s<<' '<<x;return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vl d;
void dfs(ll n, ll x) {
  if (x > n) return;
  if (x && n%x == 0) d.pb(x);
  x = x*10+2;
  dfs(n,x);
  x += 6;
  dfs(n,x);
}
map<P,int> mp;
int sol(ll x, int i) {
  if (x == 1) return 0;
  P p(x,i);
  if (mp.count(p)) return mp[p];
  int res = -INF;
  for (; i < sz(d) && x >= d[i]; ++i) {
    if (x%d[i] == 0) maxs(res, sol(x/d[i],i)+1);
  }
  return mp[p] = res;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout<<-1<<endl;
    return 0;
  }
  dfs(n,0);
  sort(rng(d));
  int ans = sol(n,0);
  if (ans < 0) ans = -1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll ans = 0;

    string s;

    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (i == 0) continue;
        if (s[i-1] == s[i]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;

    
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = min(n,k)*(x)
n -= k
if n>0:
    ans += n*y
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W;
int N;
int a[10010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  } 
  int y = 0, x = 0, d = 1; 
  int b[110][110];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < a[i]; j++) {
      b[y][x] = i + 1;
      if ((d > 0 && x + d == W) || (d < 0 && x + d < 0)) {
        y++;
        d *= -1;
      } else {
        x += d;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << b[i][j] << " \n"[j + 1 == W];
    }
  }

  return 0;
}

Measured memory_bytes: 384
using System;
class SS
{
  static void Main()
  {
    var num=int.Parse(Console.ReadLine());
    int x=num%10;
    if(x==3)
      Console.WriteLine("bon");
    else if(x==0||x==1||x==6||x==8)
      Console.WriteLine("pon");
    else
      Console.WriteLine("hon");
  }
}

Measured memory_bytes: 27544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(b<=a)cout<<"delicious"<<endl;
  else if(b<=a+x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
  return 0;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
cn = [list(map(int, input().split())) for _ in range(n)]
cn.sort(key=lambda x: x[0])
m = 10e9
for c in cn:
    if c[1] <= t:
        m = min(m, c[0])

print('TLE' if m == 10e9 else m)


Measured memory_bytes: 3060
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0
A = []
X = []


def set_inputs():
    global N, A
    N = get_int()
    A = get_li()
    return


def f(n):
    return sum(abs(x-n) for x in X)


def main():
    global X
    setrecursionlimit(100000)
    set_inputs()
    X = [a - (i + 1) for i, a in enumerate(A)]
    X.sort()
    b = X[0]
    i = 1
    passed = 0
    same = 1
    coming = N - 1
    ans = f(b)
    tmp = ans
    while i < N:
        if X[i] == b:
            same += 1
            coming -= 1
            i += 1
            continue
        diff = X[i] - b
        tmp = tmp + (passed + same - coming) * diff
        ans = min(ans, tmp)
        b = X[i]
        passed += same
        same = 1
        coming -= 1
        i += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


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

int main() {
  int n,d,ans = 0;
  cin >> n >> d;
  vector<vector<int>>data(n,vector<int>(d));
  for(int i = 0;i < n;i++){
    for(int j = 0;j < d;j++){
      cin >> data.at(i).at(j);
    }
  }
  for(int i = 1;i < n;i++){
    for(int j = 0;j < i;j++){
      int sum = 0;
      for(int k = 0;k < d;k++){
        sum += (data[i][k]-data[j][k])*(data[i][k]-data[j][k]);
      }
      for(int k = 1;k <= sum;k++){
        if(k*k == sum) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 MOD = 1000000007;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;


int main() {
    i64 n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
 }

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

using namespace std ;

const int MAX = 2e3 + 10 ;

int arr[MAX] , ans[MAX] , dist[MAX] ;
int n , x , y ;

vector< vector<int> >adj(MAX) ;

void bfs(int node)
{
	for(int i = 1 ; i <= n ; ++i)
		dist[i] = -1 ;
	queue<int>q ;
	dist[node] = 0 ;
	q.push(node) ;
	while(!q.empty())
	{
		int x = q.front() ;
		q.pop() ;
		for(auto &child : adj[x])
		{
			if(dist[child] != -1)
				continue ;
			dist[child] = dist[x] + 1 ;
			q.push(child) ;
		}
	}
	for(int i = node+1 ; i <= n ; ++i)
		ans[dist[i]]++ ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>x>>y ;
	for(int i = 1 ; i <= n-1 ; ++i)
	{
		adj[i].push_back(i+1) ;
		adj[i+1].push_back(i) ; 
	}
	adj[x].push_back(y) ;
	adj[y].push_back(x) ;
	for(int i = 1 ; i <= n ; ++i)
		bfs(i) ;
	for(int i = 1 ; i <= n-1 ; ++i)
		cout<<ans[i]<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define N 200005
int dis1[N],dis2[N];
int n;
vector<int>g[N];
void dfs(int cur, int pre, int len, int dist[])
{
	int now;
	dist[cur]=len;
	for(int i=0;i<g[cur].size();++i)  
	{
		now=g[cur][i];
		if(now!=pre)
			dfs(now,cur,len+1,dist);
	}
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(i=0;i<n-1;++i)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,-1,0,dis1);
	dfs(n,-1,0,dis2);
	int ans=0;
	for(i=2;i<n;++i)
	{
		if(dis1[i]<=dis2[i])
		ans++;
		else
		ans--;
	}
	if(ans>0)
	cout<<"Fennec";
	else
	cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 17280
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, k, ans;
string s[10];

void fun(int a, int b)
{
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if ((1 << i) & a) continue;
			if ((1 << j) & b) continue;
			if (s[i][j] == '#') cnt++;
		}
	}
	if (cnt == k) ans++;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << m); j++) {
			fun(i, j);
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    int N,b,ans;
    cin >>N;
    vector<int>B;
    for(int i=0;i<N-1;i++){
        cin >> b;
        B.push_back(b);
    }
    ans=B[0];
    for(int i=0;i<N-2;i++){
        ans+=min(B[i],B[i+1]);
    }
    ans+=B[N-2];
    cout << ans;
    
    return 0;

}


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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***スニペット***
ifelse, isprime, torad, todeg, lcm, bfs
****************/

//隣接リスト
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    int count=0;
    rep(i,0,3){
        if(s[i]==t[i]) count++;
    }
    cout << count ENDL;
    return 0;
}

Measured memory_bytes: 6000
#include <iostream>

using namespace std;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  for (int i = sy; i < ty; ++i) cout << 'U';
  for (int i = sx; i < tx; ++i) cout << 'R';

  for (int i = ty; i > sy; --i) cout << 'D';
  for (int i = tx; i > sx; --i) cout << 'L';

  cout << 'L';
  for (int i = sy; i <= ty; ++i) cout << 'U';
  for (int i = sx; i <= tx; ++i) cout << 'R';
  cout << 'D';

  cout << 'R';
  for (int i = ty; i >= sy; --i) cout << 'D';
  for (int i = tx; i >= sx; --i) cout << 'L';
  cout << 'U';
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include<queue>
#include <string>
#include<algorithm>
#define N 250000
#define MOD 1000000007
using namespace std;
int cas;
int n,m;
struct ds{int x,y,i;}d[N];
bool cmpx(ds d1,ds d2){return d1.x<d2.x;}
bool cmpy(ds d1,ds d2){return d1.y<d2.y;}
struct es{int i,j,c;}e[N];
bool cmp(es d1,es d2){return d1.c<d2.c;}
int p[N];
int getf(int x)
{
    int i=x,j;
    while(p[i]!=i)i=p[i];
    while(p[x]!=i){j=p[x];p[x]=i;x=j;}
    return i;
}
void merge(int a,int b)
{
    a=getf(a);b=getf(b);
    p[a]=b;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        d[i].i=i;
        p[i]=i;
        scanf("%d%d",&d[i].x,&d[i].y);
    }
    sort(d+1,d+n+1,cmpx);
    for(int i=1;i<n;i++)
    {
        e[i].i=d[i].i;
        e[i].j=d[i+1].i;
        e[i].c=d[i+1].x-d[i].x;
    }
    sort(d+1,d+n+1,cmpy);
    for(int i=1;i<n;i++)
    {
        e[i+n-1].i=d[i].i;
        e[i+n-1].j=d[i+1].i;
        e[i+n-1].c=d[i+1].y-d[i].y;
    }
    sort(e+1,e+2*n-1,cmp);
    long long ans=0,cnt=0;
    for(int i=1;i<=2*n-2;i++)
    {
        if(getf(e[i].i)!=getf(e[i].j))
        {
            merge(e[i].i,e[i].j);
            ans+=e[i].c;
            cnt++;
            if(cnt==n-1){cout<<ans;return 0;}
        }
    }
}




Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s,t;
	cin >> s >> t;
	sort(t.rbegin(), t.rend());
	sort(s.begin(), s.end());
	for(int i = 0; i < max(s.length(), t.length()); i++) {
		if(s[i] < t[i]) {
			cout << "Yes" << endl;
			return 0;
		}
		if(s[i] > t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	if(s.length() < t.length()) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200005
using namespace std;
typedef long long ll;
const int mod=1e9+7;
struct edge{
	int k,next;
}e[N<<2];
int n,home[N],cnt=-1,a[N],tot,sum=0,s[N],top,to[N],H[N];
ll fac[N],inv[N];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll C(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
bool vis[N];
ll ans=1;
void add(int *home,int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void dfs(int k){
	vis[k]=1;a[++tot]=k;
	for(int i=home[k];~i;i=e[i].next,sum++) if(!vis[e[i].k])
		dfs(e[i].k);
}
int used[N],cir[N],cc;
int fa[N];
void dfs(int k,int F){
	used[k]=++cc;fa[k]=F;
	for(int i=home[k];~i;i=e[i].next) if(i!=F){
		if(used[e[i].k]){
			if(used[e[i].k]>used[k]) continue;
			int x=k;
			cir[e[i].k]=1;
			while(x!=e[i].k){
				s[++top]=x;
				cir[x]=1;
				x=e[fa[x]].k;
			}
			s[++top]=e[i].k;
			continue;
		}
		else dfs(e[i].k,i^1);
	}
}
void dfs1(int k,int F){
	used[k]=1;
	if(!cir[k]) to[k]=e[F].k;
	for(int i=home[k];~i;i=e[i].next) if(i!=F&&!used[e[i].k]){
		dfs1(e[i].k,i^1);
	}
}
int vec,now,siz[N],IN[N];
ll f[N];
void dp(int k){
	f[k]=1;now++;siz[k]=0;
	for(int i=H[k];~i;i=e[i].next){
		dp(e[i].k);
		siz[k]+=siz[e[i].k];
		f[k]=f[k]*C(siz[k],siz[e[i].k])%mod*f[e[i].k]%mod;
	}
	siz[k]++;
}
void solve(){
	top=cc=0;
	dfs(a[1],-1);
	for(int i=1;i<=tot;i++) used[a[i]]=0;
	dfs1(s[1],-1);
	for(int i=1;i<=tot;i++) used[a[i]]=0;
	ll ret=0;
	int vv=vec,CNT=cnt;
	for(int w=-1;w<=1;w+=2){
		cnt=CNT;
		for(int i=1;i<=tot;i++) H[a[i]]=-1,IN[a[i]]=0;
		for(int i=1;i<=top;i++){
			int x=i+w;
			if(x==top+1) x=1;
			if(x==0) x=top;
			to[s[i]]=s[x];
		}
		for(int i=1;i<=tot;i++){
			for(int p=home[a[i]];~p;p=e[p].next)if(e[p].k<to[a[i]]){
				add(H,a[i],e[p].k);
				IN[e[p].k]++;
			}
		}
		ll o=1;vec=vv;
		for(int i=1;i<=tot;i++) if(!IN[a[i]]){
			now=0;
			dp(a[i]);
			o=o*C(vec,now)%mod*f[a[i]]%mod;
			vec-=now;
		}
		ret=(ret+o)%mod;
	}
	ans=ans*ret%mod;
}
int main(){
	memset(home,-1,sizeof(home));
	memset(H,-1,sizeof(H));
	scanf("%d",&n);
	vec=n+n;
	fac[0]=inv[0]=1;
	for(int i=1;i<=200002;i++) fac[i]=fac[i-1]*i%mod,inv[i]=quick_pow(fac[i],mod-2);
	for(int i=1,x,y;i<=n+n;i++){
		scanf("%d%d",&x,&y);
		add(home,x,y+n);add(home,y+n,x);
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		tot=sum=0;
		dfs(i);
		if(sum!=tot+tot) return puts("0"),0;
		solve();
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 21248
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,M,Q,l,r,p,q,ans[501][501],tmp;

int main(){
    cin>>N>>M>>Q;
    rep(i,501){
        rep(j,501){
            ans[i][j]=0;
        }
    }
    rep(i,M){
        cin>>l>>r;
        ans[l][r]++;
    }
    rep(i,N+1){
        rep(j,N){
            ans[i][j+1]+=ans[i][j];
        }
    }
    rep(i,Q){
        cin>>p>>q;
        tmp=0;
        repi(i,p,q+1){
            tmp+=ans[i][q]-ans[i][p-1];
        }
        out(tmp);

    }
}


Measured memory_bytes: 1920
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

#define VMAX 10010

struct edge
{
	int to, cap, cost, rev;
	edge(int to, int cap, int cost, int rev) :to(to), cap(cap), cost(cost), rev(rev) {}
	edge() :to(-1), cap(-1), cost(-1), rev(-1) {}
};

vector<edge> G[VMAX];
int h[VMAX], dist[VMAX], prevv[VMAX], preve[VMAX];
int V, E, F;

void add_edge(int from, int to, int cap, int cost)
{
	G[from].push_back(edge(to, cap, cost, SZ(G[to])));
	G[to].push_back(edge(from, 0, -cost, SZ(G[from]) - 1));
}

int min_cost_flow(int s, int t, int f)
{
	int res = 0;
	fill(h, h + V, 0);
	while (f > 0)
	{
		priority_queue<pii, vector<pii>, greater<pii>> q;
		fill(dist, dist + V, INF);
		dist[s] = 0;
		q.push(pii(0, s));
		while (!q.empty())
		{
			pii p = q.top(); q.pop();
			int v = p.second;
			if (dist[v] < p.first)continue;
			rep(i, 0, SZ(G[v]))
			{
				edge& e = G[v][i];
				if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to])
				{
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					q.push(pii(dist[e.to], e.to));
				}
			}
		}
		if (dist[t] == INF)
		{
			return -1;
		}
		rep(v, 0, V)h[v] += dist[v];

		int d = f;
		for (int v = t; v != s; v = prevv[v])
		{
			chmin(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d*h[t];
		for (int v = t; v != s; v = prevv[v])
		{
			edge& e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

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

	cin >> V >> E >> F;
	int s, t, c, d;
	rep(i, 0, E)
	{
		cin >> s >> t >> c >> d;
		add_edge(s, t, c, d);
	}

	cout << min_cost_flow(0, V - 1, F) << endl;

	return 0;
}


Measured memory_bytes: 3444
//not answered

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define LIMIT 10000

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#include <cmath>

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,m;
  cin >> n >> m;
  
  ll ans = 0;
  if(n <= LIMIT){
  for(ll i = m/n; i >= 1; i--){
    if(m%i == 0){
      ans = i;
      break;
    }
  }
  }
  else{
  for(ll i = 1; i <= m/n; i++){
    if(m%i == 0)
      ans = i;
  }
  }
  
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
int main(void) {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

s = int(input())

res = 0
dp = [0] * 3 + [1] * (s - 2)
for i in range(700):
    res += dp[-1]

    new_dp = [0] * 3
    for j in range(3, len(dp)):
        new_dp.append(new_dp[j - 1] + dp[j - 3])

    dp = new_dp

print(res % MOD)


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

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

  if(d==0) cout << n+n/100 << endl;
  else if(d==1) cout << n*(100+n/100) << endl;
  else cout << n*10000+(n/100)*10000 << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

func main() {
	N := nextInt()
	var count int
	for a := 1; a < N; a++ {
		for b := 1; b < N; b++ {
			if a*b < N {
				count++
			} else {
				break
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1820
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int distance( const PII &a, const PII &b )
{
	return abs( a.fst - b.fst ) + abs( a.snd - b.snd );
}

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

	while ( true )
	{
		int w, h;
		cin >> w >> h;
		
		if ( !( w | h ) )
		{
			break;
		}

		vector<VS> board( h, VS( w ) );
		FOR( line, board )
		{
			FOR( word, line )
			{
				cin >> word;
			}
		}

		int n = 0, maxsize = 1;
		PII s, g;
		map< int, vector< PII > > index;
		REP( i, 0, h )
		{
			REP( j, 0, w )
			{
				if ( board[i][j] == "." )
				{
					continue;
				}
				else if ( board[i][j] == "S" )
				{
					s = MP( i, j );
				}
				else if ( board[i][j] == "G" )
				{
					g = MP( i, j );
				}
				else
				{
					ISS iss( board[i][j] );
					int num;
					iss >> num;

					index[ num ].PB( MP( i, j ) );
					n = max( n, num );
					maxsize = max( maxsize, (int)index[ num ].size() );
				}
			}
		}
		index[0].PB( s );
		index[ n + 1 ].PB( g );

		VVI dp( n + 2, VI( maxsize, INT_MAX ) );
		dp[0][0] = 0;

		REP( i, 0, n + 1 )
		{
			REP( f, 0, index[i].size() )
			{
				REP( t, 0, index[ i + 1 ].size() )
				{
					dp[ i + 1 ][t] = min( dp[ i + 1 ][t], dp[i][f] + distance( index[i][f], index[ i + 1 ][t] ) );
				}
			}
		}

		cout << dp[ n + 1 ][0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
MOD = 10**9 + 7
mod13 = [[0] * 10 for _ in range(6)]
for i in range(6):
    mod13[i] = [(10**i * item) % 13 for item in range(10)]

s = input().rstrip()
dp = [[0] * (len(s)+1) for _ in range(13)]
dp[0][0] = 1

for i, item in enumerate(s[::-1]):
    if item == "?":
        for j in range(13):
            for modval in mod13[i%6]:
                dp[(j+modval)%13][i+1] += dp[j][i]
            dp[j][i+1] %= MOD
    else:
        modval = mod13[i%6][int(item)]
        for j in range(13):
            dp[(j+modval) % 13][i+1] += dp[j][i]
            dp[j][i+1] %= MOD

print(dp[5][-1] % MOD)

Measured memory_bytes: 53484
// Problem : C - Bugged
// Contest : AtCoder - AtCoder Beginner Contest 063
// URL : https://atcoder.jp/contests/abc063/tasks/arc075_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
vi v(n);cin>>v;
int sum=0;
int non=INT_MAX;
for(int i:v)
{
	sum+=i;
	if(i%10!=0)
	non=min2(non,i);
}
if(sum%10!=0)
cout<<sum;
else
{
if(non==INT_MAX)
cout<<0;
else
cout<<sum-non;
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            total = 500 * i + 100 * j + 50 * k
            if total == X:
                count += 1

print(count)

Measured memory_bytes: 9184
D = int(input())
C = list(map(int, input().split()))
#  S = [[1st day], [2nd day],  ..., [D-th day]]
S = []
for i in range(D):
    Si = list(map(int, input().split()))
    S.append(Si)
I = 26

last = [0]*I

score = S[1]
contest = score.index(max(score))

last = [x+1 for x in last]
last[contest] = 0

print(contest + 1)

for day in range(1, D):
    score = [(last[i]*C[i])**3*S[day][i] for i in range(I)]
    contest = score.index(max(score))

    last = [x+1 for x in last]
    last[contest] = 0

    print(contest + 1)

Measured memory_bytes: 9396
// Vicfred
// https://atcoder.jp/contests/abc148/tasks/abc148_c
// math
import std.stdio;

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

void main() {
    long a, b;
    readf("%s %s", &a, &b);
    readln;
    writefln("%d", a*b/gcd(a,b));
}


Measured memory_bytes: 2884
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int f(int n)
{
    int ret = 0;

    while(n)
    {
        ret++;

        n/=10;
    }

    return ret;
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n;

    int ans = 0;
    For(i,1,n)
    {
        m = f(i);

        if(m%2)
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            price = 500 * i + 100 * j + 50 * k
            if price == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 9104
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, al = 0, bo = 0;
    cin >> n;
    int  a[105];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a, a+n);
    reverse(a, a+n);

    for(int j = 0; j < n; j++){
        if(j% 2 == 0){
            al += a[j];
        }else{
            bo += a[j];
        }
    }
    cout << al - bo << endl;
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    a[i]=0;
  }
  for(int i=0;i<n-1;i++){
    int l;
    cin>>l;
    a[l-1]++;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<endl;
  }
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int ans = 0;
    if(a+b>=2*c) {
        ans += 2 * c * min(x, y); 
    }
    else ans += (a+b) * min(x, y);

    if(x>y) {
        if(a>=2*c) ans += 2*c*(x-y);
        else ans += a*(x-y);
    }
    else if(x<y) {
        if(b>=2*c) ans += 2*c*(y-x);
        else ans += b*(y-x);
    }
    else ;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for((i)=1;(i)<=(n);(i)++) 
using namespace std;
int n,m,i,j,dp[105][105];
char mp[105][105];
int main(){
	scanf("%d%d",&n,&m);
	rep(i,n){
		scanf(" ");
		rep(j,m)scanf("%c",&mp[i][j]);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[1][1]=(mp[1][1]=='#');
	rep(i,n){
		rep(j,m)if(i*j!=1){
			dp[i][j]=min(dp[i-1][j]+(mp[i][j]=='#'&&mp[i-1][j]=='.'),dp[i][j-1]+(mp[i][j]=='#'&&mp[i][j-1]=='.'));
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,i;
	int k,min,max,mid;
	cin>>n>>k;
	vector<int>L(n);
	for(i=0;i<n;i++){
	    cin>>L[i];
	}
	sort(L.begin(),L.end());
	min=-1;
	max=n;
	while(max-min>1){
	    mid=(max+min)/2;
	    if(L[mid]<k){
	        min=mid;
	    }
	    else{
	        max=mid;
	    }
	}
	cout<<n-max<<endl;
    return 0;
}


Measured memory_bytes: 640
function main(input){
    var args = input.split("\n");
    var d = [];
    for (var i=1; i<Number(args[0]) + 1; i++) {
        dd = Number(args[i]);
        if (d.indexOf(dd) < 0) d.push(dd);
    }
    console.log(d.length);
}
main(require('fs').readFileSync('/dev/stdin', {encoding:'utf8'}))


Measured memory_bytes: 7500
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


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

    int A, B, C;
    cin >> A >> B >> C;
    REP(i, 1, 10000) {
        if((A * i) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  vector<pair<int,int>> pr(n);
  rep(i,n){
    int a;cin>>a;
    pr[i]=make_pair(a,i+1);
  }
  sort(all(pr));
  rep(i,n)cout<<pr[i].second<<" ";
  cout<<endl;
}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout<<s<<endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}


int main()
{
    int a,b,k,cnt=0;
    cin>>a>>b>>k;
    for(int i=100; i>=1; i--){
        if(a%i==0 && b%i==0){
            cnt++;
            if(cnt==k){
                cout<<i<<endl;
            }
        }
    }
}

Measured memory_bytes: 256
<?php
    list($num,$limit) = explode(" ",trim(fgets(STDIN)));
    $box = explode(" ",trim(fgets(STDIN)));
    $work = 0;
    if($box[0] > $limit){
        $work = $box[0] - $limit;
        $box[0] = $limit;
    }

    for($i = 1; $i < $num; $i++){
        if($box[$i-1] + $box[$i] > $limit){
            $work += $box[$i] - ($limit - $box[$i-1]);
            $box[$i] = $limit - $box[$i-1];
        }
    }

    echo $work;
?>  

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

#define MaxN 100005
#define INF 2140000000

using namespace std;

int N,Max1=0,x,Max2=0,v[MaxN],Size=0;
map<int,int>Hash;
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>x;
        Hash[x]++;
        if(Hash[x]>1&&Hash[x]%2==0)
            v[++Size]=x;
    }
    sort(v+1,v+1+Size);
    if(Size<2)
    {
        cout<<'0';
    }
    else
    {
        cout<<1LL*v[Size]*v[Size-1];
    }
    return 0;
}


Measured memory_bytes: 4992
import sys
N = int(input())
ans = [['.']*N for _ in range(N)]
def make4(a):
    for j in range(4):
        ans[a][a] = ans[a+1][a] = 'a'
        ans[a][a+1] = ans[a+1][a+1] = 'b'
        ans[a][a+2] = ans[a][a+3] = 'c'
        ans[a+1][a+2] = ans[a+1][a+3] = 'd'

        ans[a+2][a] = ans[a+2][a+1] = 'e'
        ans[a+3][a] = ans[a+3][a+1] = 'f'
        ans[a+2][a+2] = ans[a+3][a+2] = 'g'
        ans[a+2][a+3] = ans[a+3][a+3] = 'h'
def make6(a):
    ans[a+3][a] = ans[a+4][a] = 'a'
    ans[a][a+3] = ans[a][a+4] = 'a'
    ans[a+5][a+1] = ans[a+5][a+2] = 'b'
    ans[a+1][a+5] = ans[a+2][a+5] = 'b'

    ans[a][a] = ans[a+1][a] = 'c'
    ans[a][a+1] = ans[a][a+2] = 'd'
    ans[a+1][a+2] = ans[a+2][a+2] ='e'
    ans[a+2][a] = ans[a+2][a+1]  = 'f'

    ans[a+3][a+3] = ans[a+4][a+3] = 'c'
    ans[a+3][a+4] = ans[a+3][a+5] = 'd'
    ans[a+4][a+5] = ans[a+5][a+5] ='e'
    ans[a+5][a+3] = ans[a+5][a+4]  = 'f'
def make5(a):
    ans[a+2][a+1] = ans[a+3][a+1] = 'a'
    ans[a+1][a+2] = ans[a+1][a+3] = 'a'

    ans[a][a] = ans[a+1][a] = 'b'
    ans[a+2][a] = ans[a+3][a] = 'c'

    ans[a+4][a] = ans[a+4][a+1] = 'd'
    ans[a+4][a+2] = ans[a+4][a+3] = 'e'

    ans[a+4][a+4] = ans[a+3][a+4] = 'f'
    ans[a+2][a+4] = ans[a+1][a+4] = 'g'

    ans[a][a+1] = ans[a][a+2] = 'h'
    ans[a][a+3] = ans[a][a+4] = 'i'




def answer():
    for i in range(N):
        print(*ans[i], sep = '')      

if N == 1 or N == 2:
    print(-1)
elif N == 3:
    a = 0
    ans[a][a] = ans[a+1][a] = 'c'
    ans[a][a+1] = ans[a][a+2] = 'd'
    ans[a+1][a+2] = ans[a+2][a+2] ='e'
    ans[a+2][a] = ans[a+2][a+1]  = 'f'
    answer()
elif N ==7:
    print(".aabbcc",
"e.hhii.",
"ek....p",
"fk....p",
"fl....q",
"gl....q",
"g.mmnn.", sep = '\n')


elif N%2 == 0:
    if N%4 == 0:
        for i in range(0, N, 4):
            make4(i)
        answer()
    else:
        make6(0)
        for i in range(6, N, 4):
            make4(i)
        answer()
else:
    make5(0)
    if (N-5)%4 == 0:
        for i in range(5, N, 4):
            make4(i)
    else:
        make6(5)
        for i in range(5+6, N, 4):
            make4(i)
    answer()

    
        


Measured memory_bytes: 73180
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(abs, A))
    minus = 0
    for i in range(N):
        if A[i]<0:
            minus += 1
    if minus%2==0:
        ans = sum(B)
    else:
        ans = sum(B) - min(B)*2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 12496
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = begin; i <= end; i++)

double calc(int start, int end, int max, int time) {
    if (max < start || max < end) {
        return -1.0;
    }
    if (time < abs(start-end)) {
        return -1.0;
    }

    if (start < end) {
        double tmp = (end - start) * start + double((end - start) * (end - start)) / 2;
        return tmp + calc(end, end, max, time - (end - start));
    }

    if (end < start) {
        double tmp = (start - end) * end + double((start - end) * (start - end)) / 2;
        return tmp + calc(start, start, max, time - (start - end));
    }

    assert(start == end);

    if (start*2 + time <= max * 2) {
        return double(time * time) / 4.0 + start * time; 
    } else {
        return (max - start) * (max - start) + (max - start) * 2 * start + (time - (max - start) * 2) * max;
    }

}

const int MAX_N = 110;
int N;
int t[MAX_N], v[MAX_N];

double dp[MAX_N][MAX_N];

int main(int argc, char **argv){
    std::cin >> N;
    rep (i, 1, N) {
        std::cin >> t[i];
    }
    rep (i, 1, N) {
        std::cin >> v[i];
    }
    v[0] = 0; v[N+1] = 0;

    rep (i, 0, N) {
        rep (j, 0, MAX_N-1) {
            dp[i][j] = -1.0;
        }
    }
    dp[0][0] = 0.0;

    rep (i, 1, N) {
        rep (j, 0, v[i]) {
            rep (k, 0, v[i-1]) {
                if (dp[i-1][k] < 0) {
                    continue;
                }
                double tmp = calc(k, j, v[i], t[i]);
                if (0 <= tmp) {
                    dp[i][j] = std::max(dp[i][j], dp[i-1][k] + tmp);
                }
            }
        }
    }

    std::cout << std::setprecision(12) << dp[N][0] << std::endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main(){
	float n;
	float pi = 3.1415926;
	float ans;
	string str;

	cin >> n;

	ans = n * 2 * pi;

	cout << ans;

	return 0;
}

/*

for(int i=0;i< ;i++);

*/

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  ll n,t;
  cin>>n>>t;
  vector<ll> a(n);
  ll sum=t;

  r(i,n){
    cin>>a.at(i);
  }


  r(i,n-1){
    sum+=t;
    //cout<<sum<<endl;
    if(a.at(i+1)-a.at(i)<t){
      //if(t-a.at(i+1)+a.at(i))<0){};
      sum-=t-a.at(i+1)+a.at(i);
    }

  }

cout<<sum<<endl;





  return 0;
}


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

int a, b, c, x, ta = 0;

int main(){
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) {
					ta++;
				}
			}
		}
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main(){
  int a, b, c;
  int ans[4] = {};
  while(cin>>a>>b>>c){
    if(!(c > b - a)) break;
    if(!(c > a - b)) break;
    if(!(c < a + b)) break;
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    int D = a * a + b * b  - c * c;
    ans[0]++;
    if(D > 0) ans[1]++;
    if(D == 0) ans[2]++;
    if(D < 0) ans[3]++;
  }
  printf("%d %d %d %d\n", ans[0], ans[2], ans[1], ans[3]);
  return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int hour = scan.nextInt();
		int minute = scan.nextInt();

		double rad = Math.PI*2*((double)hour/12.0 + ((double)minute/60.0)/12.0 - (double)minute/60.0);
		double len = (double)(b*b + a*a) - (double)(2*b*a)*Math.cos(rad);

		System.out.printf("%.20f",Math.sqrt(len));
		scan.close();

	}

}


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

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

    int g = __gcd(x, 360);
    int lcm = x * 360 / g;

    cout << lcm / x << '\n';

    return 0;
}


Measured memory_bytes: 3648