akhauriyash/Code-Regression huggingface dataset:
a = list(map(int, input().split()))

is_even = []
max_num = 0
max_num_idx = 0
for i, a_i in enumerate(a):
    if a_i % 2 == 0:
        is_even.append(i)
    if max_num < a_i:
        max_num = a_i
        max_num_idx = i

count = 0
offset = 0
if len(is_even) == 0 or len(is_even) == 3:
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)
elif len(is_even) == 1:
    if max_num_idx not in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)
else:
    if max_num_idx in is_even:
        max_num += 1
        count += 1
        offset -= 1
    for i, a_i in enumerate(a):
        if i == max_num_idx:
            continue
        offset += (max_num - a_i)
    count += offset // 2
    print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

long n,m,v,p;

long func(long mid,long step,vector<long> &a){
    long A = a.at(mid) + m;
    if(A < step){
      return 10000000;
    }
    if(v <= mid + 1){
      return mid;
    }
    long V = v - mid - p;
    if(V <= 0){
      return mid;
    }
    
    long point = V*m;
    for(int i=mid+1;i<n-p+1;i++){
      point -= (A - a.at(i));
    }
    if(point <= 0) return mid;
    else return 10000000;
}

int main(){
  cin >> n >> m >> v >> p;
  vector<long> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  long N = lower_bound(a.begin(),a.end(),a.at(n-p)) - a.begin();
  if(N == 0){
    cout << n << endl;
    return 0;
  }
  long P = p;
  long SP = n - P - N;
  long step = a.at(N);
  //cout << N << P << SP << endl;
  long mini = 0;
  long maxi = N-1;
  long mid;
  while(maxi - mini > 1){
    mid = (maxi + mini)/2;
    long A = a.at(mid) + m;
    //cout << mid << " " << A << endl;
    if(A < step){
      mini = mid;
      //cout << mid;
      continue;
    }
    if(v <= mid + 1){
      maxi = mid;
      //cout << mid;
      continue;
    }
    long V = v - mid - p;
    if(V <= 0){
      maxi = mid;
      //cout << mid;
      continue;
    }
    
    long point = V*m;
    //cout << point << endl;
    for(int i=mid+1;i<n-p+1;i++){
      point -= (A - a.at(i));
      //cout << point << endl;
    }
    if(point <= 0) maxi = mid;
    else mini = mid;
  }
  //cout << mini << " " << maxi << endl;
  long tmp = N;
  tmp = min(tmp,func(maxi,step,a));
  tmp = min(tmp,func(mini,step,a));
  //cout << func(2,step,a);
  cout << n - tmp << endl;
}


Measured memory_bytes: 1152
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int A, B;
    cin >> A >> B;
    cout << A * B - A -B + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int main()
{
	int num, sum = 0;
	
	REP(10)
	{
		cin >> num;
		sum += num;
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define N 1000

int main(){
    char a,b,c;
    cin>>a>>b>>c;
    if (a==b && b==c) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

vl divisor(ll n){
	vl ret;
	for (ll i = 1; i*i <= n; ++i){
		if (n%i == 0){
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}

	//これ入れたらオーダーちょい上がる
	sort(ret.begin(), ret.end());

	return ret;
}

int main(){
	ll n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i += 2){
		if (divisor(i).size() == 8) ans++;
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if(abs(x-y)<=1){
        cout << "Brown" << endl;
        return 0;
    }else{
        cout << "Alice" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  pll p[n];
  rep(i,n)cin >> p[i].first >> p[i].second;
  ll x=p[0].first,y=p[0].second;
  rep(i,n){
    ll k=max((x+p[i].first-1)/p[i].first,(y+p[i].second-1)/p[i].second);
    x=k*p[i].first;
    y=k*p[i].second;
  }
  cout << x+y << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  
  int ans=0;
  int count;
  for(int i=1;i<N+1;i+=2){
    count=0;
    for(int j=1;j<i+1;j++){
      if(i%j==0)
        count++;
    }
    if(count==8)
        ans++;
  }
  cout<<ans<<endl;
}
 
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
#include <array>

using namespace std;
int N;


int main(){
	
	cin >> N ;


	cout << N * 800 - (N / 15) * 200 << endl;

	return 0;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
		Scanner in = new Scanner(System.in);
		int x[]=new int[10];
		for(int i=0;i<10;i++){
			x[i]=in.nextInt();
		}
		for(int j=0;j<3;j++){
			
			int max=0;
			int k=0;
			for(int i=0;i<10;i++)
			{
				if(x[i]>max){
					k=i;
					max=x[i];
				}
				
			}
			System.out.println(x[k]);
			x[k]=0;
			
		}
	}
}

Measured memory_bytes: 26060
#include<stdio.h>


int main(){

  int a,b,c,d;

  scanf("%d %d %d", &a,&b,&c);

  if(a > b){
    d = a;
    a = b;
    b = d;
  }
  if(b > c){
    d = b;
    b = c;
    c = d;
  }
  if(a > b){
    d = b;
    b = a;
    a = d;
  }
  printf("%d %d %d\n", a, b, c);

  
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
struct edge{
    int to, cost;
};
typedef vector<vector<edge> > AdjList;
typedef pair<int, int> P;

int gnum[200005];
int gnum2[200005];

AdjList graph;
AdjList graph2;

bool used[200005];
bool used2[200005];

void dfs(int s, int par, int group){
    used[s] = false;
    gnum[s] = group;
    for(int i=0; i<graph[s].size(); i++){
        edge e = graph[s][i];
        if(e.to == par || used[e.to] == false){
            continue;
        }
        dfs(e.to, s, group);   
    }
    
}

void dfs2(int s, int par, int group){
    used2[s] = false;
    gnum2[s] = group;
    for(int i=0; i<graph2[s].size(); i++){
        edge e = graph2[s][i];
        if(e.to == par || used2[e.to] == false){
            continue;
        }
        dfs2(e.to, s, group);
    }
    
}
int main(void){
    int n, k, l;
    cin >> n >> k >> l;
    graph = AdjList(2*n);
    graph2 = AdjList(2*n);
    for(int i=0; i<k; i++){
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        graph[p].push_back((edge){q,1});
        graph[q].push_back((edge){p,1});
    }

    for(int i=0; i<l; i++){
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        graph2[r].push_back((edge){s,1});
        graph2[s].push_back((edge){r,1});
    }

    fill(used, used+n, true);
    for(int i=0; i<n; i++){
        if(used[i] != false){
            dfs(i, -1, i);
        }
    }
    fill(used2, used2+n, true);
    for(int i=0; i<n; i++){
        if(used2[i] != false){
            dfs2(i, -1, i);
        }
    }
    map<P,int> map;
    for(int i=0; i<n; i++){
        map[P(gnum[i], gnum2[i])]++;
    }
    for(int i=0; i<n; i++){
        cout << map[P(gnum[i], gnum2[i])];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 38400
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

s = ns()
n = len(s)

for i in range(n):
    print("x", end="")
print()

Measured memory_bytes: 38760
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    vector<vector<int>> A(3, vector<int>(3));
    REP(i, 3){
        REP(j, 3){
            cin >> A[i][j];
        }
    }
    int N; cin >> N;
    vector<vector<int>> C(3, vector<int>(3));
    REP(i, N){
        int b; cin >> b;
        REP(j, 3){
            REP(k, 3){
                if(A[j][k]==b) C[j][k] = 1;
            }
        }
    }
    bool res = false;
    REP(i, 3){
        int x = 1;
        REP(j, 3){
            x *= C[i][j];
        }
        res |= x;
    }
    REP(i, 3){
        int x = 1;
        REP(j, 3){
            x *= C[j][i];
        }
        res |= x;
    }
    bool ok = true;
    REP(i, 3){
        if(C[i][i]==0){
            ok = false;
        }
    } 
        if(ok) {
            res = true;
        }
    ok = true;
    REP(i, 3){
        if(C[i][2-i]==0) ok = false;
    } 
        if(ok) {
            res = true;
        }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    h, w, m = map(int, input().split())
    A = [0] * h
    B = [0] * w
    Bomb = set()
    for _ in range(m):
        hi, wi = map(lambda x: int(x) - 1, input().split())
        A[hi] += 1
        B[wi] += 1
        Bomb.add((hi, wi))
    ma, mb = max(A), max(B)
    A = [i for i, a in enumerate(A) if a == ma]
    B = [i for i, b in enumerate(B)if b == mb]
    if len(A) * len(B) > m:
        print(ma + mb)
    else:
        f = False
        for i in A:
            for j in B:
                if (i, j) not in Bomb:
                    f = True
                    break
        print(ma + mb) if f else print(ma + mb - 1)



if __name__ == '__main__':
    main()


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

int main(){
  vector<int> ant(5);
  for(int i = 0;i < 5;i++){
  cin >> ant.at(i);
  }
  int k,ans;
  cin >> k;
  for(int i = 0;i < 4;i++){
    for(int j = i + 1;j < 5;j++){
      if(k >= ant.at(j) - ant.at(i)){
        continue;
      }else{
        ans++;
        break;
      }
    }
  }
    if(ans > 0){
      cout << ":(" << endl;
    }else{
      cout << "Yay!" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
# class Map(dict):
#     def __missing__(self, key):
#         # この割当てなしのほうが速い。
#         # self[key] = 0
#         return 0


def main():
    int(input())

    d = {}
    ans = 0
    for i, height in enumerate(input().split()):
        height = int(height)
        # 引き算のほうの i は足し算のよりも大きい。
        # 従って，このように順番に見ていく必要がある。
        got = d.get(i + height) or 0
        d[i + height] = got + 1
        ans += d.get(i - height) or 0

    return ans


if __name__ == '__main__':
    print(main())

# 大いに参考にした。
# https://kmjp.hatenablog.jp/entry/2020/05/03/1030


Measured memory_bytes: 46308
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N,M;
    cin>>N>>M;

    priority_queue<int> Q;
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        Q.push(a);
    }

    for(int i = 0;i < M;i++) {
        int x = Q.top();Q.pop();
        x /= 2;
        Q.push(x);
    }

    Int ans = 0;
    while(!Q.empty()) {
        Int x = Q.top();Q.pop();
        ans += x;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 892
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b)%2==0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, m, c, count = 0;
	cin >> n >> m >> c;
	vector<int> B(m);
	vector<vector<int>> A(n);
	FOR(i, m)cin >> B[i];
	FOR(i, n) {
		FOR(j, m) {
			int o;
			cin >> o;
			A[i].push_back(o);
		}
		int ans = c;
		FOR(j, m)ans += A[i][j] * B[j];
		if (ans > 0)count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}

	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		g[a] = append(g[a], b)
	}

	for i := 0; i < n; i++ {
		visited := make([]int, n, n)
		from := make([]int, n, n)
		from[i] = i
		dfs(i, g, visited, from)
		if from[i] != i {
			cycle := make([]int, 0)
			s := i
			for from[s] != i {
				cycle = append(cycle, from[s])
				s = from[s]
			}
			cycle = append(cycle, i)
			l := len(cycle)
			for ii := 0; ii < l>>1; ii++ {
				cycle[ii], cycle[l-1-ii] = cycle[l-1-ii], cycle[ii]
			}
			index := IntMap{}
			for ii := 0; ii < l; ii++ {
				index[cycle[ii]] = ii
			}

			start := 0
			end := l

			for ii := 0; ii < l && start == 0; ii++ {
				max := 0
				for _, to := range g[cycle[ii]] {
					if index.get(to) >= 0 && index.get(to) < index.get(cycle[ii]) {
						if max < index.get(to) {
							max = index.get(to)
							start = max
							end = index.get(cycle[ii]) + 1
						}
					}
				}
			}
			ans := make([]int, 0)
			index = IntMap{}
			for ii := start; ii < end; ii++ {
				index[cycle[ii]] = ii
			}

			for ii := start; ii < end; ii++ {
				ans = append(ans, cycle[ii]+1)
				max := ii + 1
				for _, to := range g[cycle[ii]] {
					if index.get(to) >= 0 && index.get(to) > max {
						max = index.get(to)
					}
				}
				ii = max - 1
			}

			fmt.Fprintln(writer, len(ans))
			for ii := 0; ii < len(ans); ii++ {
				fmt.Fprintln(writer, ans[ii])
			}
			writer.Flush()
			return
		}
	}

	fmt.Fprintln(writer, -1)
	writer.Flush()
}

func dfs(i int, g [][]int, visited, from []int) {
	for _, to := range g[i] {
		if visited[to] > 0 {
			continue
		}
		from[to] = i
		visited[to]++
		dfs(to, g, visited, from)
	}
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return -1
}

func (m IntMap) increment(key int) {
	m[key] = m.get(key) + 1
}


Measured memory_bytes: 6400
#!/usr/bin/env python
# encoding: utf-8

import copy


class Solution:
    def stable_sort(self):
        # write your code here
        array_length = int(input())
        b_array = [str(x) for x in input().split()]
        s_array = copy.deepcopy(b_array)

        bubble_result = self.bubble_sort(b_array=b_array, array_length=array_length)
        selection_result = self.selection_sort(s_array=s_array, array_length=array_length)

        # check whether selection sort is stable
        if bubble_result == selection_result:
            print("Stable")
        else:
            print("Not stable")

    @staticmethod
    def selection_sort(s_array, array_length):
        # selection sort
        selection_count = 0
        for i in range(array_length):
            min_j = i
            for j in range(i, array_length):
                if s_array[j][1] < s_array[min_j][1]:
                    min_j = j
            s_array[i], s_array[min_j] = s_array[min_j], s_array[i]
            if i != min_j:
                selection_count += 1

        result = " ".join(map(str, s_array))
        print(result)
        return result

    @staticmethod
    def bubble_sort(b_array, array_length):
        flag, bubble_count, cursor = 1, 0, 0
        while flag:
            flag = 0
            for j in range(array_length - 1, cursor, -1):
                if b_array[j][1] < b_array[j - 1][1]:
                    b_array[j], b_array[j - 1] = b_array[j - 1], b_array[j]
                    flag = 1
                    bubble_count += 1
        cursor += 1
        result = " ".join(map(str, b_array))
        print(result)
        print("Stable")
        return result


if __name__ == '__main__':
    solution = Solution()
    solution.stable_sort()

Measured memory_bytes: 8152
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long a,b,M=2019,n,i,j,ans=M+1;
  scanf("%lld %lld",&a,&b);
  n=MIN(M,b-a);
  a%=M;
  for(i=a;i<a+n;i++){
    for(j=i+1;j<=a+n;j++)ans=MIN(((i%M)*(j%M))%M,ans);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
// yo3.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int h, w;
	char field[52][52];

	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> field[i][j];
		}
	}

	int ans = 2500;
	for (int a = 1; a <= h - 2; ++a) {
		for (int b = 1; a + b <= h - 1; ++b) {
			int cnt = 0;
			for (int i = 1; i <= h; ++i) {
				for (int j = 1; j <= w; ++j) {
					if (i <= a) {
						if (field[i][j] != 'W') {
							cnt++;
						}
					}
					else if (i <= a + b) {
						if (field[i][j] != 'B') {
							cnt++;
						}
					}
					else {
						if (field[i][j] != 'R') {
							cnt++;
						}
					}
				}
			}
			ans = min(ans, cnt);
		}
	}

	cout << ans << endl;

    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(a[0]-'a'+'A') << char(b[0]-'a'+'A') << char(c[0]-'a'+'A') << endl;
    return 0;
}


Measured memory_bytes: 256
s=str(input())
ans=int(0)
if s=="SUN":
    ans=7
elif s=="MON":
    ans=6
elif s=="TUE":
    ans=5
elif s=="WED":
    ans=4
elif s=="THU":
    ans=3
elif s=="FRI":
    ans=2
elif s=="SAT":
    ans=1

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
  char a[2];
  scanf("%s", a);
  
  if (!strcmp(a, "A")){
    printf("T");
  }
  if (!strcmp(a, "T")){
    printf("A");
  }
  
  if (!strcmp(a, "C")){
    printf("G");
  }
  if (!strcmp(a, "G")){
    printf("C");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX / 40 - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
int ddx[] = {-1,0,1,-1,1,-1,0,1}, ddy[] = {1,1,1,0,0,-1,-1,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n + 1,0);
        inv = vector<int>(n + 1,0);
        fac[0] = 1; for (int i = 1; i < n + 1; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n + 1;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {if (n<r) return 0; return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return (a / GCD(a,b)) * b;}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

long long mul(long long a, long long b, long long mod) {
    long long keta[20] = {};
    long long c = b;
    long long now = 0;
    while (c != 0ll) {
        keta[now] = c % 10; c /= 10; now++;
    }
    long long res = 0;
    for (int i = 19; i >= 0; --i) {
        res *= 10; res %= mod;
        res += keta[i] * a % mod;
    }
    return res % mod;
}

void solve() {
    int n; cin >> n;
    if (n % 2) {
        cout << n / 2 << endl;
    } else {
        cout << n / 2 - 1 << endl;
    }
    return;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}



Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 998244353

N, S = map(int, input().split())
A = list(map(int, input().split()))


dp = [np.zeros(S + 10, dtype=np.int64) for _ in range(N+1)]
#dp[0][0] = 1

# print(dp[0])
ans = 0
for i in range(N):
    a = A[i]

    dp[i][0] += 1
    dp[i + 1] += dp[i]
    dp[i + 1] %= MOD

    # a足す
    dp[i + 1][a:] += dp[i][:-a]
    dp[i + 1] %= MOD

    #print(dp[i + 1])
    ans += dp[i + 1][S]
    ans %= MOD

print(ans)


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

int main() {
	map<int, long long>mp;
	int n; cin >> n;
	long long k; cin >> k;
	while (n--) {
		int num, cop; cin >> num >> cop;
		mp[num] += cop;
	}
	for (auto it : mp) {
		if (k <= it.second) return cout << it.first, 0;
		k -= it.second;
	}
	return 0;
}

Measured memory_bytes: 7436
N=int(input())
A=[]
XY=[[] for _ in range(N)]
t=0
for i in range(N):
    A.append(int(input()))
    for j in range(A[-1]):
        XY[t].append(list(map(int,input().split())))
    t+=1

import itertools
PRD=list(itertools.product([0,1], repeat=N))

def counter(status):
    f=1
    l=[-1]*N
    for i in range(N):
        if status[i]==0:
            continue
        else:
            for j in range(A[i]):
                if (l[XY[i][j][0]-1]!=-1 and l[XY[i][j][0]-1]!=XY[i][j][1]) or (status[XY[i][j][0]-1]!=XY[i][j][1]):
                    f=0
                    break
                else:
                    l[XY[i][j][0]-1]=XY[i][j][1]
    return([0,status.count(1)][f])

ans=0                
for i in range(2**N):
    ans=max(ans,counter(PRD[i]))
print(ans)

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
//約数の列挙
vector<int> divisor(int n){
    vector<int> res;//約数を格納する列
    for(int i= 1;i*i <= n;i++){
        if(n % i == 0){
           res.push_back(i);
           if(i != n/i) res.push_back(n/i);
         }
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1;i<=N;i++){
      vector<int> res = divisor(i);
      if(i%2 != 0 && res.size() == 8) ans++;
    }
    cout << ans << endl;
  
  }

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

int main(){
    string S1,S2;
    cin >> S1;
    cin >> S2;

    if ((S1[0] == S2[2]) && (S1[1] == S2[1]) && (S1[2] == S2[0])){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
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(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int n;
double memo[301][301][301];
double f(int i, int j, int k) {
    if(i + j + k == 0) return 0;
    if(memo[i][j][k] != 0) return memo[i][j][k];
    int s = i + j + k;
    double ret = n;
    if(i) ret += f(i - 1, j, k) * i;
    if(j) ret += f(i + 1, j - 1, k) * j;
    if(k) ret += f(i, j + 1, k - 1) * k;
    memo[i][j][k] = ret/s;
    return ret/s;
}



int main(){
    int r, a = 0, b = 0, c = 0;
    setp(12);
    cin >> n;
    rep(i, n) {
        cin >> r;
        if (r == 1) a ++;
        else if (r == 2) b ++;
        else c ++;
    }
    co(f(a, b, c));
}



Measured memory_bytes: 111136
#include <stdio.h>
int main(void){
  int n,m,i,j,a[100]={0};
  scanf("%d %d",&n,&m);
  int A[n][m],b[m];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf(" %d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf(" %d",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      a[i]+=A[i][j]*b[j];
    }
  }
  for(i=0;i<n;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

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

int main() {
  int a,b;cin>>a>>b;
  if (a+b>=10) {
    cout << "error" << endl;
  } else {
    cout << a+b << endl;
  }
  // cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n;

int tmp[MAXN];

void merge(int *a, int *b, int *c) {
	for (int i = 0; i < n; ++i)
		c[i] = a[b[i]];
}

void rev(int *a, int *b) {
	for (int i = 0; i < n; ++i)
		b[a[i]] = i;
}

void revin(int *a) {
	rev(a, tmp);
	for (int i = 0; i < n; ++i)
		a[i] = tmp[i];
}

void mergein(int *a, int *b) {
	merge(a, b, tmp);
	for (int i = 0; i < n; ++i)
		a[i] = tmp[i];
}


void init(int *a) {
	for (int i = 0; i < n; ++i)
		a[i] = i;
}

int tmp2[MAXN];

void pw(int *a, int b) {
	init(tmp2);
	while (b) {
		while (!(b & 1))
			mergein(a, a), b >>= 1;
		--b;
		mergein(tmp2, a);
	}
	for (int i = 0; i < n; ++i)
		a[i] = tmp2[i];
}

int a[MAXN];
int b[MAXN];

int go[MAXN];
int ar[MAXN];
int br[MAXN];

int go2[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int k;
	cin >> n >> k;
	--k;
	for (int i = 0; i < n; ++i)
		cin >> a[i], --a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i], --b[i];
	rev(a, ar);
	rev(b, br);
	if (k == 0) {
		for (int i = 0; i < n; ++i)
			cout << a[i] + 1 << " ";
		cout << "\n";
		return 0;
	}
	int c = (k - 1) / 3;
	init(go);
	int c2 = c / 2;
	mergein(go, b);
	mergein(go, ar);
	mergein(go, br);
	mergein(go, a);
	pw(go, c2);
	if (c % 2 == 1) {
		mergein(go, b);
		mergein(go, ar);
	}
	rev(go, go2);
	int lf = (k - 1) % 3;
	if (c % 2 == 0) {
		mergein(go, b);
		if (lf >= 1)
			mergein(go, ar);
		if (lf >= 2)
			mergein(go, br);
	}
	else {
		mergein(go, br);
		if (lf >= 1)
			mergein(go, a);
		if (lf >= 2)
			mergein(go, b);
	}
	mergein(go, go2);
	for (int i = 0; i < n; ++i)
		cout << go[i] + 1 << " ";
	cout << "\n";
	return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    string s; int i, c=0;
    cin>>s; vi v;
    for(i=0;i<s.sz;i++){
        if(s[i]=='R')c++;
        else{
            v.pb(c); c=0;
        }
    }
    if(c>0)v.pb(c);
    sort(v.begin(), v.end());
    if(v.sz==0)cout<<0<<endl;
    else cout<<v.back()<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/


Measured memory_bytes: 3624
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		long n = sc.nextLong();
		String s = "";
		long ac = 0, wa = 0, tle = 0, re = 0;
		for(long i=0; i<n; i++){
			s = sc.next();
			if(s.equals("AC")){
				ac++;
			}else if(s.equals("WA")){
				wa++;
			}else if(s.equals("TLE")){
				tle++;
			}else{
				re++;
			}
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}
}


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

int main(){

  string s1;
  cin >> s1;

  string s2;
  cin >> s2;

  string s3;
  cin >> s3;

  cout << s1[0];
  cout << s2[0];
  cout << s3[0];

return 0;
}

Measured memory_bytes: 256
N, *d = map(int, open(0).read().split())
#print(N, d)

tako = []
for i in range(N):
    for j in range(i+1,N):
        #print(i,j, "(", d[i], d[j], ")")
        tako.append([d[i],d[j]])
#print(tako)
#print(len(tako))

sum = 0
for k in tako:
    sum += k[0]*k[1]
print(sum)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}


int main() {
	int a = 0,b=0;
	cin >> a>>b;
	if (a % (b * 2 + 1) != 0) {
		cout << a / (b * 2 + 1) + 1 << endl;
		return 0;
	}
	else {
		cout << a / (b * 2 + 1) << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		String next = "a";
		while(true) {
			if(next.equals("a") && a.length()>0) {
				next = a.substring(0, 1);
				a = a.substring(1);
			} else if(next.equals("b") && b.length()>0) {
				next = b.substring(0, 1);
				b = b.substring(1);
			} else if(c.length()>0){
				next = c.substring(0, 1);
				c = c.substring(1);
			} else {
				break;
			}
		}
		System.out.println(next.toUpperCase());
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << "\n"; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(string, s);
    For(i, (int)s.size()){
        if(i < 0) continue;
        while(true){
            if(s[i] == 'B'){
                s.erase(s.begin() + i);
                continue;
            }
            if(i < (int)s.size()-1 && s[i+1] == 'B'){
                s.erase(s.begin() + i, s.begin() + i + 2);
                i -= 2;
                continue;
            }
            break;
        }
    }
    Cout(s);
}


Measured memory_bytes: 256
open Printf
open Scanf

let rec read f n =
  if n <= 0 then []
  else
    let x = f () in
    x :: read f (n - 1)

let () =
  let n, k = sscanf (read_line ())"%d %d" (fun x y -> (x, y)) in
  let ws = read read_int n in
  let rec allocatable c w xs p =
    if c + 1 > k then false
    else match xs with
           [] -> true
         | y :: ys -> let w' = w + y in
                      if w' > p then allocatable (c+1) 0 xs p
                      else allocatable c w' ys p in
  let rec loop fp tp =
    if tp - fp = 1 then tp
    else let p' = (fp + tp) / 2 in
         if allocatable 0 0 ws p' then loop fp p'
         else loop p' tp in
  loop 0 1000000000 |> string_of_int |> print_endline

Measured memory_bytes: 9620
#include <stdio.h>
#include <stdlib.h>

int comp(const void* x,const void* y) {
	if(*((int*)x)<*((int*)y))return -1;
	if(*((int*)x)>*((int*)y))return 1;
	return 0;
}

int main(void) {
	int i;
	int klength;
	int tenpokazu;
	int chuumonkazu;
	int tenpoiti[100001];
	int nowchuumon;
	int left,right,center;
	int kyorisum;
	while(1) {
		scanf("%d",&klength);
		if(klength==0)break;
		scanf("%d",&tenpokazu);
		scanf("%d",&chuumonkazu);
		tenpoiti[0]=0;
		for(i=1;i<tenpokazu;i++) {
			scanf("%d",&tenpoiti[i]);
		}
		tenpoiti[tenpokazu]=klength;
		qsort(tenpoiti,tenpokazu+1,sizeof(int),comp);
		kyorisum=0;
		for(i=0;i<chuumonkazu;i++) {
			scanf("%d",&nowchuumon);
			left=0;right=tenpokazu;
			while(right-left>1) {
				center=(right+left)/2;
				if(tenpoiti[center]>nowchuumon)right=center;
				else left=center;
			}
			kyorisum+=(nowchuumon-tenpoiti[left]<tenpoiti[right]-nowchuumon)?
				(nowchuumon-tenpoiti[left]):(tenpoiti[right]-nowchuumon);
		}
		printf("%d\n",kyorisum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
	int n;
	double sum = 0;
	cin >> n;
	vector <double> l(n) ;
	vector<double> x(n);
	vector<double> y(n);
	rep(i, n)
		cin >> x[i] >> y[i];
	rep(i, n) {
		for (int j = 0; j < n; j++) {
				l[i] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
				sum += l[i];
		}
		}
		double ans;
		ans = sum;
			for (int i = 1; i <= n - 1; i++) {
				ans = ans * i;
			}
		for (int i = 2; i <= n; i++)
			ans = ans / i;
		std::cout << std::fixed;
		cout << ans <<std::setprecision(6)<< endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(void){
    int N;
    long ans=0;
    cin >> N;
    map<int, int> Li;
    rep(i,N){
        int Ai;
        cin >> Ai;
        Li[i+1+Ai]++;
        ans+=Li[i+1-Ai];
    }
    
    cout  << ans <<endl;
    return 0;
}

Measured memory_bytes: 20568
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;
ll a, b;
ll c[55];
ll d[55][55];
ll ans, ans2;
ll cnt, cnt2;

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%lld%lld%lld", &n, &a, &b);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &c[i]);
    }
    sort(c, c + n, greater<ll>());
    d[0][0] = 1;
    for(ll i = 1; i <= 50; i++)
    {
        d[i][0] = 1;
        for(ll j = 1; j <= i; j++) d[i][j] = d[i - 1][j - 1] + d[i - 1][j];
    }
    for(ll i = 0; i < a; i++)
    {
        ans += c[i];
    }
    printf("%.9f\n", (double)ans / a);
    for(ll i = a - 1; i >= 0; i--)
    {
        if(c[i] == c[a - 1]) cnt++;
    }
    cnt2 = cnt;
    for(ll i = a; i < n; i++)
    {
        if(c[i] == c[a - 1]) cnt2++;
    }
    if(c[0] != c[a - 1])
    {
        printf("%lld", d[cnt2][cnt]);
    }
    else
    {
        for(ll i = a; i <= b; i++) ans2 += d[cnt2][i];
        printf("%lld", ans2);
    }
    return 0;
}


Measured memory_bytes: 256
int2=tuple(map(int,input().split()))
t=0
for a in range(0,int2[0]+1):
  for b in range(0,int2[0]+1):
    if a+b==int2[0] and 2*a+4*b==int2[1]:
      t+=1
      break
if t==0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9192
#include<stdio.h>
int main(){
  int a1,a2,a3,a4,a5,A;
  scanf("%d \n",&a1);
  scanf("%d \n",&a2);
  scanf("%d \n",&a3);
  scanf("%d \n",&a4);
  scanf("%d",&a5);

  if (a1<40)a1=40;
 if (a2<40) a2=40;
 if (a3<40) a3=40;
 if (a4<40) a4=40;
 if (a5<40) a5=40;

A=(a1+a2+a3+a4+a5)/5;

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

 return 0;
}

Measured memory_bytes: 600