akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a, b;
	cin >> a >> b;

	if (abs(a - b) % 2==0)
	{
		cout << min(a, b) + abs(a - b) / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
S, T = input().split()
ans = ''
for i in range(N):
    ans += S[i]
    ans += T[i]

print(ans)

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    ll K; cin >> K;
    string T1 = S + S;
    string T2 = S + S + S;
    ll res1 = 0, res2 = 0, res3 = 0;
    bool allsame = true;
    for(int i = 1; i < S.length(); i++){
        if(S[i-1] != S[i]) allsame = false;
    }
    for(int i = 1; i < S.length(); i++){
        if(S[i-1] == S[i]){S[i] = 0; res1++;}
    }
    for(int i = 1; i < T1.length(); i++){
        if(T1[i-1] == T1[i]){T1[i] = 0; res2++;}
    }
    for(int i = 1; i < T2.length(); i++){
        if(T2[i-1] == T2[i]){T2[i] = 0; res3++;}
    }

    if(S.length() == 1){
        cout << K/2 << endl;
    }
    else if(allsame){
        cout << K*S.length()/2 << endl;
    }
    else if(K == 1) cout << res1 << endl;
    else if(K == 2) cout << res2 << endl;
    else{
        ll diff = res3-res2;
        cout << res2 + diff*(K-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Measured memory_bytes: 36384
#include <iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0) break;
        else{
            for(int i=0;i<w;i++){
                cout << "#";
            }
            for(int j=0;j<h-2;j++){
                cout << "\n#";
                for(int k=0;k<w-2;k++){
                    cout << ".";
                }
                cout << "#";
            }
            cout << "\n";
            for(int l=0;l<w;l++){
                cout << "#";
            }
            cout << "\n\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1120
N = int( input())
X = list( map( int, input().split()))
 
v_min = 10 ** 18
m = min( X )
M = max( X )
for i in range( m, M + 1):
  v = 0
  for x in X:
    v += ( i - x ) ** 2
  v_min = min( v, v_min )
print( v_min )


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

typedef const char *Pos;
long long number(Pos &p) {
	int i;
	long long x;
	sscanf(p, "%lld%n", &x, &i);
	p += i;
	return x;
};

long long factor(Pos &p) {
	long long x = number(p);
	while(*p == '*') {
		++ p;
		long long y = number(p);
		if(x * 1. * y > 1e10) x = INFL;
		else x *= y;
	}
	return x;
};

long long expr(Pos &p) {
	long long x = factor(p);
	while(*p == '+') {
		++ p;
		long long y = factor(p);
		if(x + y > 1e10) x = INFL;
		else x += y;
	}
	return x;
}

long long expr2(Pos &p) {
	long long x = number(p);
	while(*p == '+' || *p == '*') {
		char op = *p;
		++ p;
		long long y = number(p);
		if(op == '*') {
			if(x * 1. * y > 1e10) x = INFL;
			else x *= y;
		}else {
			if(x + y > 1e10) x = INFL;
			else x += y;
		}
	}
	return x;
}


int main() {
	char *s = new char[20];
	scanf("%s", s);
	long long t;
	cin >> t;
	long long x1, x2;
	{	const char *p = s;
		x1 = expr(p);
	}
	{	const char *p = s;
		x2 = expr2(p);
	}
//	cerr << x1 << ", " << x2 << endl;
	if(t == x1 && t != x2)
		puts("M");
	else if(t != x1 && t == x2)
		puts("L");
	else if(t == x1 && t == x2)
		puts("U");
	else
		puts("I");
	return 0;
}

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

int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N, 0), v(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    int total = accumulate(v.begin(), v.end(), 0);
    vector<vector<ll>> dp(N + 1, vector<ll>(total + 1, 1000000001));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= total; j++)
        {
            if (v[i - 1] <= j)
            {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= total; i++)
    {
        if (dp[N][i] <= W)
        {
            ans = max(ans, i);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll imos[100005][35]={0};
int main(){
  ll n,c;
  cin>>n>>c;
  for(int i=1;i<=n;i++){
    ll s,t,u;
    cin>>s>>t>>u;
    imos[s-1][u]++;
    imos[t][u]--;
  }
  for(int i=0;i<100004;i++){
    for(int j=0;j<=c;j++) imos[i+1][j]+=imos[i][j];
  }
  ll ans=1;
  for(int i=0;i<100005;i++){
    ll kans=0;
    for(int j=0;j<=c;j++) kans+=(imos[i][j]>=1?1:0);
    ans=max(ans,kans);
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    vector<vector<int>> S(11,vector<int>(11));
    S[0]={1,1,1,2,2,3,4,4,5,5,5};
    S[1]={0,1,2,2,3,3,3,4,4,4,5};
    S[2]={1,1,1,2,2,2,3,3,4,5,5};
    S[3]={0,0,1,1,2,3,3,4,4,4,5};
    S[4]={1,2,2,3,3,3,4,4,4,5,5};
    S[5]={0,0,1,1,1,2,2,3,4,4,5};
    S[6]={0,1,1,2,3,3,4,4,4,5,5};
    S[7]={1,1,2,2,2,3,3,3,4,4,5};
    S[8]={0,1,1,1,2,2,3,4,4,5,5};
    S[9]={1,1,2,3,3,4,4,4,5,5,5};
    S[10]={0,1,1,1,2,2,2,3,3,4,5};
    
    int N,K;cin>>N>>K;
    N-=3;
    cout<<5*(N/11)+S[K][N%11]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int D;
            cin >> D;
                if(D == 25){
                    cout << "Christmas" << endl;
                }else if(D == 24){
                    cout << "Christmas Eve" << endl;
                }else if(D == 23){
                    cout << "Christmas Eve Eve" << endl;
                }else if(D == 22){
                    cout << "Christmas Eve Eve Eve" << endl;
                }else{}
    return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v) sort(v.begin(),v.end(),[](P a, P b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int n,t;
int dp[3005][3005];
vector<pair<int,int>> AB;

int main() {
  cin >> n >> t;
  rep(i,n) {
    int a, b; cin >> a >> b;
    AB.push_back(make_pair(a,b));
  }
  sort(ALL(AB));

  int ans = 0;
  dp[0][0] = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= t-1; j++) {
      ans = max(ans, dp[i-1][j]+AB[i-1].second);
      if(j-AB[i-1].first >= 0) {
        dp[i][j] = max(dp[i][j], dp[i-1][j-AB[i-1].first]+AB[i-1].second);
      }
      chmax(dp[i][j],dp[i-1][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int P,Q,R;
int a,b,c;
int ans;
int main(){
    cin >> P >> Q >> R;
    vector<int> ve;
    a = P+Q;
    b = P+R;
    c = Q+R;
    ve.push_back(a);
    ve.push_back(b);
    ve.push_back(c);
    int min = *std::min_element(ve.begin(), ve.end());
    cout << min;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

int f(int x){
  int res = 0;
  for(int i=1;i*i<x;++i){
    for(int j=i;j*j<x;++j){
      for(int k=j;k*k<x;++k){
        if(i*i+j*j+k*k+i*j+j*k+k*i==x){
          if(i!=j&&j!=k) res += 6;
          else if(i==j&&j==k) ++res;
          else res += 3;
        }
      }
    }
  }
  return res;
}

void m1(){
  int n; cin >> n;
  REP(i,n){
    println(f(i+1));
  }
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();

    int gcd;
	if (n == 1) {
      gcd = scanner.nextInt();
    } else {
      gcd = scanner.nextInt();
      for (int i = 2; i <= n; i++) {
        gcd = gcd(gcd, scanner.nextInt());
      }
    }

    System.out.println(gcd);
  }
  private static int gcd(final int a, final int b) {
    if (a == 0) {
      if (b == 0) {
        throw new ArithmeticException("greatest common divisor of 0 and 0 is undefined.");
      }
      return b;
    }
    if (b == 0) {
      return a;
    }
    int p = Math.abs(a);
    int q = Math.abs(b);
    int sign = (a < 0 && b < 0) ? -1 : 1;
	if (p < q) {
      p = Math.abs(b);
      q = Math.abs(a);
    }
    int r = p % q;
    while (r > 0) {
      p = q;
      q = r;
      r = p % q;
    }
    return sign * q;
  }
}

Measured memory_bytes: 48496
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))


L1 = T1 * (A1- B1)
L2 = L1 + T2 * (A2- B2)

if L1 * L2 > 0:
    print(0)
elif L2 == 0:
    print("infinity")
else:
    M = (-L1) / L2
    ans = 2 * int(M) + 1
    if float(int(M)) == M:
        ans -= 1
    print(ans)



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

using namespace std;

typedef long long ll;
int main() {

int n;
cin >> n;
vector<int> v;
v.resize(n);
for(int i = 0 ; i < n ; i++)
    cin >> v[i];

ll ans = 1e9 + 5;

for(int X = 1 ; X <= 100 ; ++X)
{
    ll tmp = 0;
    for(auto &P : v)
    {
        tmp+=(X - P) * (X - P);
    }
    ans = min(ans , tmp);
}

cout << ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
const int maxn = 200200;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a + 3);
    if (a[0] == a[1] && a[1] != a[2] || a[2] == a[1] && a[1] != a[0])
        puts("Yes");
    else
        puts("No");
    return 0;
}





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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> magic(10, vector<int>(10));
  for(int i=0;i<10;i++) {
    for(int j=0;j<10;j++) {
      cin >> magic[i][j];
    }
  }

  for(int k=0;k<10;k++) {
    for(int i=0;i<10;i++) {
      for(int j=0;j<10;j++) {
        if(magic[i][j] > magic[i][k] + magic[k][j]) magic[i][j] = magic[i][k] + magic[k][j];
      }
    }
  }

  int ans = 0;

  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      int a;
      cin >> a;
      if(a == -1) continue;
      else ans += magic[a][1];
    }
  }

  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int>a(n);
  rep(i, n) a[i] = i+1;
  map<vector<int>, int> mp;
  do {
    mp[a]=mp.size();
  } while(next_permutation(a.begin(), a.end()));

  cout << abs(mp[p] - mp[q]) << endl;
  return 0;
}

Measured memory_bytes: 8652
#include <cstdio>
int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009];
bool dfs(int pos) {
	bool ret = true; cnt++;
	for (int i = c[pos]; i < c[pos + 1]; i++) {
		if (col[e[i]] == col[pos]) ret = false;
		if (col[e[i]] == 0) {
			col[e[i]] = 3 - col[pos];
			if (!dfs(e[i])) ret = false;
		}
	}
	return ret;
}
void reader(int *x) {
	for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48;
}
int main() {
	reader(&n); reader(&m);
	for (int i = 0; i < m; i++) {
		reader(&a[i]); reader(&b[i]);
		c[--a[i]]++; c[--b[i]]++;
	}
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + c[i]; c[0] = 0;
	for (int i = 0; i < n; i++) c[i + 1] = s[i + 1];
	for (int i = 0; i < m; i++) e[s[a[i]]++] = b[i], e[s[b[i]]++] = a[i];
	int c0 = 0, c1 = 0, c2 = 0;
	for (int i = 0; i < n; i++) {
		if (col[i] == 0) {
			col[i] = 1; cnt = 0;
			bool res = dfs(i);
			if (cnt == 1) c0++;
			else if (!res) c1++;
			else c2++;
		}
	}
	printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0));
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int inf= 1<<30;
const int maxn = 1000005;
void solve(){
	int n;
	cin >> n;
	vector<lli> a(n);
	for(int i=0; i < n; i++) cin >> a[i];
	lli ans = 0ll;
	for(int i=1;i < n; i++){
		if(a[i] >= a[i-1]) continue;
		lli dif = a[i-1] - a[i];
		ans+=dif;
		a[i] = a[i-1];
	}

	cout << ans << endl;
}

int main(){
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>

using namespace std;

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

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

    REP(i, N) {
        string s;
        cin >> s;
        if (s[0] == 'Y') {
            cout << "Four" << "\n";
            return 0;
        }
    }
    cout << "Three" << "\n";
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (51)

vector<int> d1[N][N];
int d2[N][N];


void Warshall_Floyd(void){
	f(k, N){
		f(i, N){
			f(j, N){
				if ((d2[i][j] > d2[i][k]) &&(d2[i][j]> d2[k][j]) ){
					d2[i][j] = max(d2[i][k] , d2[k][j]);
				}
			}
		}
	}
	return;
}


int main(void){
	int x, y, z;
	for (int i = 1; i <= 50;i++){
		for (int j = 1; j <= 50; j++){
			x = j;
			y = j%i;
			z = i;
			d1[x][y].push_back(z);
		}
	}
	f(i, 51){
		f(j, 51){
			if (i == j)d2[i][j] = 0;
			else if (d1[i][j].size() == 0)d2[i][j] = MOD;
			else{
				d2[i][j] = MOD;
				f(ii, d1[i][j].size()){
					if (d1[i][j][ii] < d2[i][j])d2[i][j] = d1[i][j][ii];
				}
			}
		}
	}
	Warshall_Floyd();


	int n;
	int a[51];
	int b[51];
	long long c[51];
	int m;
	long long ans = 0;
	c[0] = 1;
	f(i, 50)c[i + 1] = c[i] * 2;
	scanf("%d", &n);
	f(i, n){
		scanf("%d", &a[i]);
	}
	f(i, n){
		scanf("%d", &b[i]);
	}
	f(i, n){
		if (d2[a[i]][b[i]] == MOD){
			printf("-1\n");
			return 0;
		}
	}
	while (true){
		m = -1;
		f(i, n){
			if (d2[a[i]][b[i]] > m)m = d2[a[i]][b[i]];
		}
		if (m == 0)break;
		else{
			f(i, 51){
				f(j, 51){
					f(ii, d1[i][j].size()){
						if (d1[i][j][ii] == m)d1[i][j][ii] = 0;
					}
				}
			}
			f(i, 51){
				f(j, 51){
					if (i == j)d2[i][j] = 0;
					else{
						d2[i][j] = MOD;
						f(ii, d1[i][j].size()){
							if (d1[i][j][ii] < d2[i][j])d2[i][j] = d1[i][j][ii];
						}
					}
				}
			}
			Warshall_Floyd();
			ans += c[m];
		}
	}
	printf("%lld\n", ans);

	return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    ld sum = 0;
    vector<ll> a(n);
    ll r = 1;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i]==0){
            std::cout << 0 << std::endl;
            return 0;
        }
        sum += log10l(a[i]*1.0);
        r *= a[i];
    }
    if(sum<=18){
        if(r<=1000000000000000000){
            std::cout << r << std::endl;    
        }else{
            std::cout << -1 << std::endl;
        }
    }else{
        std::cout << -1 << std::endl;
    }
    
}


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

int main()
{
    char a,b,c;
    cin >> a>>b>>c;
    int count=0;
    if(a=='1'){
        count++;
    }
    if(b=='1'){
        count++;
    }
    if(c=='1'){
        count++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = res*x;
  
        // n must be even now
        y = y>>1; // y = y/2
        x = x*x;  // Change x to x^2
    }
    return res;
}
int main()
{
int d,n;
cin>>d>>n;
ll y = pow(100,d)*n;
if(n==100) y = pow(100,d)*101;
cout<<y;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
    public static Scanner sc;
    public static Pattern pt;
    public static void main(String[] args) throws Exception {
        pt = Pattern.compile("^.+$");
        sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            System.out.println(s.replace("Hoshino", "Hoshina"));
        }
    }
}

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

const int INF = 1001001001;
vector<int> to[100005];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i,n) {
        if (i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10648
N = int(input())
A = list(map(int,input().split()))

cnt_0, cnt_2, cnt_4 = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    cnt_4 += 1
  elif A[i] % 2 == 0:
    cnt_2 += 1
  else:
    cnt_0 += 1

if cnt_2 == 0:
  if cnt_4 >= cnt_0 - 1:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4 >= cnt_0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define F first
#define S second
#define inf (long long) 1e18
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)

const int MOD = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    long long int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    sort(arr,arr+n);
    ll sum=arr[n-1];int k=1,i=n-2;
    while(k!=n-1){
        sum+=arr[i];
        k++;
        if(k%2==1)
            i--;
    }
    cout << sum;
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 5212
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        ws: [[isize; 3]; n],
    }

    for cx in 0..101isize {
        for cy in 0..101isize {
            let mut last_hh = -1;
            let mut ok = true;

            for i in 0..ws.len() {
                let x = ws[i][0];
                let y = ws[i][1];
                let h = ws[i][2];

                if h != 0 {
                    let hh = h + (x - cx).abs() + (y - cy).abs();
                    if last_hh == -1 {
                        last_hh = hh;
                    }
                    if hh != last_hh {
                        ok = false;
                        break;
                    }
                }
            }

            for i in 0..ws.len() {
                let x = ws[i][0];
                let y = ws[i][1];
                let h = ws[i][2];

                if h == 0 {
                    let hh = last_hh - (x - cx).abs() - (y - cy).abs();
                    if hh > 0 {
                        ok = false;
                        break;
                    }
                }
            }

            if ok {
                println!("{} {} {}", cx, cy, last_hh);
            }
        }
    }
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> vec;
    for (int i = 0; i < n; ++i) {
        pair<int, int> pa;
        cin >> pa.first >> pa.second;
        vec.push_back(pa);
    }

    // 報酬がもられる日数が短い順にソート
    sort(vec.begin(), vec.end());

    int res = 0;
    int ptr = 0;
    priority_queue<int> pr;
    for (int i = m - 1; i >= 0; i--) {
        int cur = m - i;
        while (ptr < n && vec[ptr].first <= cur) {
            pair<int, int> pa = vec[ptr];
            pr.push(pa.second);
            ptr++;
        }

        if (!pr.empty()) {
            res += pr.top(); pr.pop();
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1908
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]
count = 0
for y in range(h):
    for x in range(w):
        if a[y][x]=="#":
            count += 1
            
visited = [[0]*w for _ in range(h)]
q = [(0,0)]
visited[0][0] = 1
while q:
    cy,cx = q.pop()
    for dy,dx in ((1,0),(0,1)):
        ny,nx = cy+dy,cx+dx
        if (0<=ny<h and 0<=nx<w and a[ny][nx]=="#" and visited[ny][nx]==0):
            visited[ny][nx] = visited[cy][cx]+1
            q.append((ny,nx))
            
if visited[h-1][w-1]==count:
    print('Possible')
else:
    print('Impossible')

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, H, D; cin >> N >> H >> D;
  c_fac();
  ll facsum = 0; repr(i,1,N+1) facsum = (facsum+fac[i]) % MOD;

  ll dp[H+1] = {}; dp[0] = 1;
  rep(i,H) {
    if (i<D) dp[i+1] = ((dp[i]-dp[0])*facsum+fac[N]) % MOD;
    else dp[i+1] = (dp[i]-dp[i-D]+MOD) * facsum % MOD;
    dp[i+1] = (dp[i] + dp[i+1]) % MOD;
  }
  // debug(dp,dp+(H+1));

  ll result = (dp[H] - dp[H-1] + MOD) % MOD;
  cout << result << endl;
  return 0;
}

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

main() {
    int A,B; cin >> A >> B;
    if(A==B)cout << "Draw" << endl;
    else if(A==1 || A>B && B!=1) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const int maxn=200001;
struct node{
	int x,y;
	friend bool operator<(node a,node b)
	{
		return a.x==b.x?a.y<b.y:a.x<b.x;
	}
}p[maxn];
int n,sx,sy,tx,ty,_x,_y,top=0,tot=0,s[maxn];
double ans;
bool ok1=false,ok2=false;
int main()
{
	cin>>sx>>sy>>tx>>ty>>n;
	if(sx>tx)
	{
		sx=-sx;
		tx=-tx;
		ok1=true;
	}
	if(sy>ty)
	{
		sy=-sy;
		ty=-ty;
		ok2=true;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>_x>>_y;
		_x*=ok1?-1:1;
		_y*=ok2?-1:1;
		if(_x>=sx&&_x<=tx&&_y>=sy&&_y<=ty)
		{
			p[++top].x=_x;
			p[top].y=_y;
		}
	}
	sort(p+1,p+top+1);
	for(int i=1;i<=top;i++)
	{
		if(!tot||p[i].y>s[tot])
		{
			s[++tot]=p[i].y;
		}
		else
		{
			int nw=lower_bound(s+1,s+tot+1,p[i].y)-s;
			s[nw]=p[i].y;
		}
	}
	ans=(double)(tx-sx+ty-sy)*100.0-(double)tot*(20.0-PI*5.0)+((tot==min(tx-sx+1,ty-sy+1))?PI*5.0:0);
	printf("%.15lf",ans);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#define int long long

using namespace std;

int N, K;
int A[202020];
int Ks[202020];

signed main()
{
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
    }

    int sum = 0;
    for (int i = 1; i <= K; i++)
    {
        sum += A[i];
    }

    for (int i = K + 1; i <= N; i++)
    {
        int presum = sum;
        int postsum = presum - A[i - K] + A[i];
        if (postsum > presum)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        sum = postsum;
    }
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

char g[1005][1005];

int main() {
  int h, w, a, b;
  scanf("%d%d%d%d", &h, &w, &a, &b);
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      if (i <= b && j <= a || i > b && j > a) g[i][j] = '0';
      else g[i][j] = '1';
    }
    printf("%s\n", g[i] + 1);
  } 
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    string s; cin>>s;
    int cnt=0;

    if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cnt++;
    if(s[0] == 'R' && s[1] == 'R') cnt=2;
    if(s[0]== 'R' && s[1] == 'R' && s[2] == 'R') cnt=3;
    if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R') cnt=2;
    cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

map<ll,ll> M;

int main(){
    ll N,sum=0,A[200007],S[200007],C=0;
    cin >> N ;
    M[0]++;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
        M[sum]++;
    }
    for(auto P : M){
        if(P.second>=2){
            C+=P.second*(P.second-1)/2;
        }
    }
    cout  << C << endl;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;

    vector<int> L(N);
    rep(i,N) cin >> L[i];
    sort(L.begin(),L.end());

    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(L[j]>L[i]){
                for(int k=j+1; k<N; k++){
                    if(L[i]+L[j] > L[k] && L[k]>L[j]){
                        ans ++;
                    }
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3624
s = input()
t = input()
m = len(t)
for i in range(len(s) - len(t) + 1):
    x = s[i:i+len(t)]
    count = 0
    for a, b in zip(list(t), list(x)):
        if a != b:
            count += 1
    if m > count:
        m = count
print(m)


Measured memory_bytes: 9008
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  if(n==1){
    cout<<"YES"<<endl;
    return 0;
  }
  vl a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  ll one=n*(n+1)/2;
  if(sum%one!=0){
    cout<<"NO"<<endl;
    return 0;
  }
  ll num=sum/one;
  ll count=0;
  vl kaisa(n);
  rep(i,n-1)kaisa[i]=a[i+1]-a[i];
  kaisa[n-1]=a[0]-a[n-1];
  rep(i,n){
    ll d=num-kaisa[i];
    if(d%n!=0||d/n<0){
      cout<<"NO"<<endl;
      return 0;
    }
    count+=d/n;
  }
  if(count==num){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[MN+5],rk[MN+5],ans=0;
bool cmp(int x,int y){return a[x]<a[y];}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read(),rk[i]=i;
    sort(rk+1,rk+n+1,cmp);
    for(int i=1;i<=n;++i) a[rk[i]]=i;
    for(int i=1;i<=n;++i) if((a[i]^i)&1) ++ans;
    printf("%d\n",ans>>1);
    return 0;
}


Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
    }
    let ans = if a%2==0 || b%2==0 || c%2==0 {
        0
    }else{
        std::cmp::min(a*b, std::cmp::min(b*c, c*a))
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
S = input()

cum_sum_w = [0] * (N + 1)
cum_sum_e = [0] * (N + 1)


for i in range(N):

    if (S[i] == "W"):
        cum_sum_w[i+1] = cum_sum_w[i] + 1
        cum_sum_e[i+1] = cum_sum_e[i] + 0
    else:
        cum_sum_w[i+1] = cum_sum_w[i] + 0
        cum_sum_e[i+1] = cum_sum_e[i] + 1

ans = 10**100  

for i in range(N):
    tmp_ans = cum_sum_w[i] + (cum_sum_e[N] - cum_sum_e[i + 1])
    ans = min(ans,tmp_ans)
    
print(ans)

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;

    long long all = a*b*c;
    if (all % 2LL == 0) cout << 0 << endl;
    else {
        long long ans = min({a*b, b*c, c*a});
        cout << ans << endl;
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  int ans = 0;
  
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      ans+=d[i]*d[j];
    }
  }
  
  cout << ans << endl;
  
    


}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int left, int mid, int right) {
  int i, j, k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i] <= R[j] )
      A[k] = L[i++];
    else {
      A[k] = R[j++];
      cnt += n1 - i;  // = mid + j - k - 1
    }
  }
  return cnt;
}

llong mergeSort(int A[], int left, int right) {
  int mid;
  llong v1, v2, v3;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    v1 = mergeSort(A, left, mid);
    v2 = mergeSort(A, mid, right);
    v3 = merge(A, left, mid, right);
    return v1 + v2 + v3;
  } else return 0;
}

int main() {
  int A[MAX], n, i;

  cin >> n;
  for ( i = 0; i < n; i++ )
    cin >> A[i];

  llong ans = mergeSort(A, 0, n);
  cout << ans << endl;

  return 0;
}


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

struct BIT{
  int t[5000];
  void init(){
    for(int i=0;i<5000;i++){
      t[i]=0;
    }
  }
  void add(int i,int x){
    i+=10;
    
    while( i<5000 ){
      t[i]+=x;
      i+=(i&-i);
    }
  }
  int sum(int i){
    i+=10;
    
    int res=0;
    while(i>0){
      res+=t[i];
      i-=(i&-i);
    }
    return res;
  }
};

BIT T;
int H,W,L,P;
short t[4000][4000];

short A[4000][4000];
short B[4000][4000];
short C[4000][4000];
short D[4000][4000];

vector< short > G[5000];

ll solve(int y,int x){
  for(int i=0;i<5000;i++)G[i].clear();
  T.init();
  
  ll res=0;
  
  for(int i=0;i<5000;i++){
    int py=y+i;
    int px=x+i;
    if(py>=H || px>=W)break;
    if(i-L+1>=0){
      int ay=py-L+1;
      int ax=px-L+1;

      int len = min( C[ay][ax], D[ay][ax]) - 1;
      
      if(i-L+1+len>=i){
        T.add( i-L+1 , 1 );
        G[ i-L+1 + len  ].push_back( i-L+1 );
      }
      
    }

    int fr=min(A[py][px],B[py][px]);
    
    if(fr>=3){
      ll v = T.sum(4500) - T.sum(i-fr);
      res+=v;
    }
    
    for(int j=0;j<(int)G[i].size();j++){
      T.add( G[i][j], -1 );
    }
  }

  return res;
}

int main(){

  scanf("%d %d %d %d",&H,&W,&L,&P);
  for(int i=0;i<P;i++){
    int y,x;
    scanf("%d %d",&y,&x);
    y--,x--;
    
    t[y][x]=1;
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]==1){
        A[i][j]=0;
        continue;
      }
      A[i][j]=1;
      if(j>0){
        A[i][j]+=A[i][j-1];
      }
    }
  }
  
  for(int j=0;j<W;j++){  
    for(int i=0;i<H;i++){
      if(t[i][j]==1){
        B[i][j]=0;
        continue;
      }
      B[i][j]=1;
      if(i>0){
        B[i][j]+=B[i-1][j];
      }
    }
  }

  
  for(int i=0;i<H;i++){
    for(int j=W-1;j>=0;j--){
      if(t[i][j]==1){
        C[i][j]=0;
        continue;
      }
      C[i][j]=1;
      if(j+1<W){
        C[i][j]+=C[i][j+1];
      }
    }
  }
  
  for(int j=0;j<W;j++){  
    for(int i=H-1;i>=0;i--){
      if(t[i][j]==1){
        D[i][j]=0;
        continue;
      }
      D[i][j]=1;
      if(i+1<H){
        D[i][j]+=D[i+1][j];
      }
    }
  }

  ll ans=0;
  for(int i=0;i<H;i++){
    ans+= solve(i,0);
  }
  for(int i=1;i<W;i++){
    ans+= solve(0,i);
  }
  
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 157496
(function(input) {
    var a = input.split('\n');
    var n = Number(a.shift());
    var i = 0;
    var t = h = 0;
    while (i++ < n) {
        var l = a.shift().split(' ');
        var tc = l[0];
        var hc = l[1];
        if (tc > hc) {
            t += 3;
        } else if (tc < hc) {
            h += 3;
        } else {
            t++;h++;
        }
    }
    console.log('%s %s', t, h);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n,ans=0;
    int p[15]={};
    cin>>n;
    rep(i,n){
        cin>>p[i];
    }
    sort(p,p+n);
    rep(i,n-1){
        ans += p[i];
    }
    cout<< ans + p[n-1]/2 <<endl;

}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<long long> h(n);
    vector<int> a(m), b(m);
    for(int i=0; i<n; i++){
        cin>>h.at(i);
    }
    for(int i=0; i<m; i++){
        cin>>a.at(i)>>b.at(i);
    }
    map<int, vector<int>> mp;
    for(int i=0; i<m; i++){
        mp[a.at(i)].push_back(b.at(i));
        mp[b.at(i)].push_back(a.at(i));
    }
    int count = n;
    for(auto iter=mp.begin(); iter != mp.end(); ++iter){
        vector<int> tmp = iter->second;
        for(int j=0; j<tmp.size(); j++){
            if(h.at((iter->first)-1) <= h.at(tmp.at(j)-1)){
                count--;
                break;
            }
        }
    }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 14348
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int kosuu = sc.nextInt();
        List<String> syouhin = new ArrayList();
        for(int i = 0;i < kosuu;i++){
            String k = sc.next();
            syouhin.add(k);
        }
        List<String> listB = new ArrayList<String>(new HashSet<>(syouhin));
        System.out.println(listB.size());
    }
}


Measured memory_bytes: 73100
import math

N, K = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


w = 10**9+7

for i in range(1, K+1):
    if N-K+1-i >= 0:
        ans1 = combinations_count(N-K+1, i)
        ans2 = combinations_count(K-1, i-1)
        ans = ans1 % w * ans2 % w
        print(ans)
    else:
        print(0)


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

typedef long long ll;

int main(int argc, char* argv[])
{
  ll x, y;
  std::cin >> x >> y;
  std::vector< ll > vd;

  ll dd = x;
  while (dd <= y) {
    vd.push_back(dd);
    dd *= 2;
  }

  std::cout << vd.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n,i,A[44];

  A[0]=1;
  A[1]=1;

  scanf("%d",&n);

  for(i=2;i<=n;i++){

    A[i]=A[i-1]+A[i-2];

  }

  printf("%d\n",A[n]);

  return 0;
  
}



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

int main() {
	int w, h;
	do {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i % 2 == 1 && j % 2 == 1) || (i % 2 == 0 && j % 2 == 0))
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	} while (true);
	return 0;
}


Measured memory_bytes: 3116
// Power Socket

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    int cnt = 1;
    int i = 0;
    for (; cnt < B; i++) {
        cnt += (A - 1);
    }
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256