akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
	ll x; cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << endl;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define mod 1000000007
#define maxn 100005

ll n, m, q, t, k;
ll a[maxn];



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

	ll m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if(m2 > m1)
		cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
int x,y;
cin>>x>>y;
cout<<(x<y?0:10)<<endl;
  return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])


Measured memory_bytes: 19720
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) ;
#define cerr if(0)cout
#endif

const int N = 100000;
int n;
vector<int> nei[N + 1];
bool visited[N + 1];

ll dfs(int v){
    visited[v] = true;
    ll res = 0;
    for(auto& w : nei[v]){
        if(!visited[w]){
            res ^= dfs(w);
        }
    }
    return res + (v != 1);
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    cin >> n;
    rep(_, 0, n - 1){
        int t1, t2; cin >> t1 >> t2;
        nei[t1].pb(t2); nei[t2].pb(t1);
    }
    if(dfs(1)){
        cout << "Alice\n";
    } else {
        cout << "Bob\n";
    }
    return 0;
}

Measured memory_bytes: 10496
N = int(input())
S = list(map(int, input().split()))
flg = 1
for i in range(N - 1, 0, -1):
    if S[i] - S[i -1] <= -2:
        flg = 0
        break
    elif S[i] - S[i -1] == -1:
        S[i - 1] -= 1
    else:
        continue


if flg:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 15020
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN( a )
    LIN( b )

    bool is_0 = false;
    bool is_negative = false;

    if( (a < 0 && b > 0 ) ) is_0 = true;
    else if( (a < 0 && b < 0 && abs( b - a ) % 2 == 0 ) ) is_negative = true;

    if( is_0 ){
      cout << "Zero" << endl;
      return 0;
    }
    else if( is_negative ){
      cout << "Negative" << endl;
      return 0;
    }
    else{
      cout << "Positive" << endl;
      return 0;
    }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    }
    if (a == b) {
        cout << "a == b" << endl;
    }
    if (a > b) {
        cout << "a > b" << endl;
    }
} 


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

int main(void){
    int N;
    cin>>N;
    vector<int> a(N);
    for (int i=0;i<N;i++) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[N-1]-a[0]<<endl;
    return 0;   
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int cnt = Integer.parseInt(sn.next());
        int y = Integer.parseInt(sn.next());
        int[] list = new int[cnt];
        int sum = 0;
        for ( int i = 0; i < cnt ; i++){
            list[i] = Integer.parseInt(sn.next());
        }
        Arrays.sort(list);
        for ( int l = 0; l < y ; l++){
            sum = sum + list[l];
        }
        System.out.println(sum);
	}
}



Measured memory_bytes: 38576
n, k = map(int, input().split())
V = list(map(int, input().split()))

ans = - 10 ** 19
# i: Dから取り出す宝石の個数
for i in range(min(k + 1, n + 1)):
  # j: 左からとる個数(i-jが右からとる個数)
  for j in range(i + 1):
    inhands = V[:j] + V[n - i + j:]
    inhands.sort()
    remnum = k - i
    val = 0
    for h in inhands:
      if h < 0 and remnum > 0:
        remnum -= 1
      else:
        val += h
    ans = max(ans, val)
print(ans)

Measured memory_bytes: 9208
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
prev = -1
for i in a :
    ans += b[i - 1]
    if prev + 1 == i :
        ans += c[i - 2]
    prev = i
print(ans)

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

int main(){
    int M,D;
    cin >> M >> D;
    int ans = 0;
    for(int i = 1; i <= M; i++) {
        for(int j = 1; j <= D; j++) {
            int X = j%10;
            int Y = j/10;
            if(X >= 2 && Y >= 2) {
                if(X*Y == i) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat May  5 20:55:26 2018
ABC096-3
@author: maezawa
"""

dxy = [[-1,0],[0,1],[1,0],[0,-1]]

def is_connect(i,j):
    global dxy
    global s
    for d in dxy:
        #print(i+d[0], j+d[1])
        if s[i+d[0]][j+d[1]] == '#':
            return True
    return False

h, w = list(map(int, input().split()))
s = ['-'*(w+2)]
for i in range(h):
    s_in = input()
    s_temp = '-'+s_in+'-'
    s.append(s_temp)
s.append('-'*(w+2))

#for i in range(h+2):
#    print(s[i])
is_paint = 'Yes'
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == '#':
            if is_connect(i,j):
                continue
            else:
                is_paint = 'No'
                break

print(is_paint)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int n,x;
		Scanner scan = new Scanner(System.in);
		while(true){
			n=scan.nextInt();
			x=scan.nextInt();
			int ways=0;
			if((n==0)&&(x==0))
				break;
			for(int i=3;i<=n;i++){
				for(int j=2;j<i;j++){
					for(int k=1;k<j;k++){
						if((i+j+k)==x)
							ways++;
					}
				}
			}
			System.out.println(ways);
		}
	}
}


Measured memory_bytes: 26684
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

string S;
ll dp[100001][4] = {{1}};

int main() {
    cin >> S;
    REP(i, S.length()) {
        if (S[i] == '?') {
            dp[i + 1][0] = 3 * dp[i][0] % MOD;
            FOR(j, 1, 4)
                dp[i + 1][j] = (3 * dp[i][j] + dp[i][j - 1]) % MOD;
        }
        else {
            REP(j, 4) dp[i + 1][j] = dp[i][j];
            dp[i + 1][S[i] - 'A' + 1] += dp[i][S[i] - 'A'];
            dp[i + 1][S[i] - 'A' + 1] %= MOD;
        }
    }
    cout << dp[S.length()][3] << endl;
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        const int mod = 1001;
        int[] f = new int[1000];
        f[0] = 2;
        f[1] = 3;
        for (int i = 2; i < 1000; i++)
            f[i] = (f[i - 1] + f[i - 2]) % mod;
        for (;;)
        {
            try
            {
                string[] s = Console.ReadLine().Split(' ');
                int v, d;
                v = int.Parse(s[0]);
                d = int.Parse(s[1]);
                Tree t = new Tree(v);
                for (int i = 0; i < v; i++)
                    for (int j = 0; j < v; j++)
                        if (Math.Abs(f[i] - f[j]) < d)
                            t.unite(i + 1, j + 1);
                List<int> l = new List<int>();
                for (int i = 1; i <= v; i++)
                {
                    if (l.Contains(t.root(i)))
                        continue;
                    l.Add(t.root(i));
                }
                Console.WriteLine(l.Count);
            }
            catch { Environment.Exit(0); }
        }
    }
}
class Tree
{
    private int[] p; //頂点iの親がp[i-1]
    public Tree(int n) //コンストラクタ
    {
        p = new int[n];
        for (int i = 0; i < n; i++) p[i] = i + 1;
    }
    public int GetParent(int a) //aの親を返す
    {
        return p[a - 1];
    }
    public void SetParent(int a, int b) //aの親をbに設定
    {
        p[a - 1] = b;
    }
    public int root(int a) //aのrootを求め、aの親にする
    {
        if (p[a - 1] == a) return a;
        return (p[a - 1] = root(p[a - 1]));
    }
    public bool IsSameSet(int a, int b) //aとbが同一グループに属するか
    {
        return root(a) == root(b);
    }
    public void unite(int a, int b) //aとbを同一グループにまとめる
    {
        p[root(a) - 1] = root(b);
    }
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

string n, m;
ll N, M;
ll dp[3030][3030];

void traceBack(ll i, ll j) {
  if(i==-1||j==-1) return;
  
  if(n[i]==m[j]) {
    traceBack(i-1, j-1);
    cout << n[i];
  }else if(dp[i][j+1]>dp[i+1][j]){
    traceBack(i-1, j);
  }else {
    traceBack(i, j-1);
  }
}

int main(void) {
  cin >> n;
  cin >> m;
  N=n.size();
  M=m.size();
  ll i, j;
  
  for(i=0; i<N; i++) {
    for(j=0; j<M; j++) {
      if(n[i]==m[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
    }
  }
  
  traceBack(N-1, M-1);
  pt("");
}
  










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

int main(){
  string s;
  int a, b;
  for(int i = 0; i < 9; i++){
    cin >> s >> a >> b;
    cout << s << " " << a + b << " " << a * 200 + b * 300 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	char ch;
	string s;
	int box[4];
	int i;
	for(i=0;i<4;i++)	box[i]=0;
	while(cin>>n>>ch>>s){
		if     (s=="A")	box[0]++;
		else if(s=="B")	box[1]++;
		else if(s=="AB")box[2]++;
		else			box[3]++;
		
	}
	for(i=0;i<4;i++)	cout<<box[i]<<endl;
	return 0;
}


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

long long int sum_left[100005]={0};
long long int sum_right[100005]={0};

int main(){
    int n;
    cin >> n;
    vector<long long int> v;
    for(int i=0;i<3*n;++i){
        long long int a;
        cin >> a;
        v.push_back(a);
    }

    priority_queue<long long int, vector<long long int>, greater<long long int>> que_left;
    priority_queue<long long int> que_right;
    for(int i=0;i<n;++i){
        sum_left[0] += v[i];
        sum_right[0] += v[v.size()-i-1];
        que_left.push(v[i]);
        que_right.push(v[v.size()-i-1]);
    }

    for(int i=0;i<n;++i){
        sum_left[i+1] = sum_left[i] + v[n+i];
        que_left.push(v[n+i]);
        sum_left[i+1] -= que_left.top();
        que_left.pop();

        sum_right[i+1] = sum_right[i] + v[2*n-i-1];
        que_right.push(v[2*n-i-1]);
        sum_right[i+1] -= que_right.top();
        que_right.pop();
    }

    long long int ans = sum_left[0] - sum_right[n];
    for(int i=1;i<=n;++i){
        ans = max(ans, sum_left[i] - sum_right[n-i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8428
import std.stdio; // readln
import std.array; // split
import std.conv; // to

int[] dx = [1,1,1,0,-1,-1,-1,0];
int[] dy = [1,0,-1,-1,-1,0,1,1];

void main(){
	string[] s = split(readln());
	int h = to!int(s[0]);
	int w = to!int(s[1]);

	char[][] m = new char[][](h + 2,w + 2);
	for(int i = 1; i < m.length - 1; i++){
		string str = readln();
		for(int j = 1; j < m[0].length - 1; j++){
			m[i][j] = str[j - 1];
		}
	}

	char[][] ans = new char[][](h + 2,w + 2);
	for(int i = 0; i < m.length; i++){
		ans[i][0] = '.';
		ans[i][w + 1] = '.';
	}
	for(int i = 0; i < m[0].length; i++){
		ans[0][i] = '.';
		ans[h + 1][i] = '.';
	}
	for(int i = 1; i < m.length - 1; i++){
		for(int j = 1; j < m[0].length - 1; j++){
			if(m[i][j] == '#'){
				ans[i][j] = '#';
			}else{
				int cnt = 0;
				for(int k = 0; k < 8; k++){
					if(m[i + dy[k]][j + dx[k]] == '#') cnt++;
				}
				ans[i][j] = to!char(cnt + 48);
			}
		}
	}

	for(int i = 1; i < m.length - 1; i++){
		for(int j = 1; j < m[0].length - 1; j++){
			write(ans[i][j]);
		}
		writeln("");
	}
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)



char S[505050], T[505050];
ll TZ[505050];
ll mt[505050], mk2[505050];
bool mk[60][505050];
ll i,j,k,ans;

void ZA(char *st){
    ll len=strlen(st);
    TZ[0] = len;
    ll i = 1, l = 0,r=1;
    //printf("%lld ",TZ[0]);
    fornum(i,1,len){
        if(i+TZ[i-l]<r){
            TZ[i] = TZ[i - l];
        }else{
            //printf("%lld:%lld ", i, r);
            l = i;
            while (r< len && st[r - l] == st[r])
                r++;
            TZ[i] = r - l;
            if(r==i){
                r++;
            }
        }
        //printf("%lld:%lld ", TZ[i],r);
    }
}

int main(){
    scanf("%s%s", S,T);
    ZA(T);
    ll Slen = strlen(S);
    ll Tlen = strlen(T);
    
    ll l=0,r=0;
    
    fornum(i,0,Slen){
        if(i+TZ[i-l]<r){
            mt[i] = TZ[i - l];
        }else{
            l = i;
            while(r-l<Tlen&&T[r-l]==S[r%Slen])
                r++;
            mt[i] = r - l;
            if(i==r){
                r++;
            }
        }
    }
    
    
    queue<ll> q;
    fornum(i,0,Slen){
        if(mt[i]==Tlen){
            mk[0][i] = true;
            mk2[i] = 1;
            q.push(i);
        }
    }
    if(q.size()==Slen){
        printf("-1");
        return 0;
    }
    
    fornum(i,0,20){
        ll a = q.size();
        fornum(j,0,a){
            ll qa = q.front();
            q.pop();
            if(mk[i][qa]&&mk[i][(qa+(1ll<<i)*Tlen)%Slen]){
                mk[i + 1][qa] = true;
                mk2[qa] *= 2;
                q.push(qa);
            }
        }
    }

    fornum(i,0,Slen){
        if(mk2[i]==(1ll<<20)){
            printf("-1");
            return 0;
        }
        ll a = mk2[i];
        ll b = (i+mk2[i] * Tlen) % Slen;
        while(mk2[b]){
            //printf("%lld ", b);
            a += mk2[b];
            b = (b + mk2[b] * Tlen) % Slen;
        }
        if(ans<a)
            ans = a;
        //printf(":%lld,%lld\n", i, ans);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

bool dp[30][2020];

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;

  int q;
  cin >> q;
  for (int k = 0; k < q; ++k)
  {
    int m;
    cin >> m;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = true;
    for (int i = 0; i < n; ++i)
    {
      for (int j = 0; j <= 2000; ++j)
      {
        if (j - a[i] >= 0)
          dp[i + 1][j] = dp[i][j] || dp[i][j - a[i]];
        else
          dp[i + 1][j] = dp[i][j];
      }
    }
    if (dp[n][m])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }

  return 0;
}


Measured memory_bytes: 3160
package main

import(
	"os"
	"io"
	"bufio"
	"bytes"
	"fmt"

	"sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

func max(lhs, rhs int) int {
	if lhs < rhs {
		return rhs
	} else {
		return lhs
	}
}
type Pair struct {
	key rune
	value int
}
type Node struct {
	id rune
	frequency int
	parent *Node
	leftChild *Node
	rightChild *Node
}

func dfs(list *map[rune]int, current *Node, cost int) {
	(*list)[current.id] = cost
	if current.leftChild == nil && current.rightChild == nil {
		return
	}
	dfs(list, current.leftChild, cost + 1)
	dfs(list, current.rightChild, cost + 1)
}
// huffman
func solve(s *string) int {
	// create frequecy
	frequency := make(map[rune]int)
	for _, v := range (*s) {
		frequency[v] += 1
	}
	// init tree
	nodeList := make([]Node, 0) // とりあえず二倍確保
	for k, v := range frequency {
		node := Node{ k , v, nil, nil, nil }
		nodeList = append(nodeList, node)
	}
	// sort
	sort.Slice(nodeList, func(lhs, rhs int) bool {
		return nodeList[lhs].frequency < nodeList[rhs].frequency
	})

	// make huffman tree
	MAX := 100000
	var root *Node = &nodeList[0]
	for {
		// dummy
		var min1 *Node = &Node{ 0, MAX, nil, nil, nil }
		var min2 *Node = &Node{ 0, MAX, nil, nil, nil}
		for i := range nodeList {
			if nodeList[i].parent != nil {
				continue
			}
			if nodeList[i].frequency < min1.frequency {
				min1 = &nodeList[i]
			} else if nodeList[i].frequency < min2.frequency {
			// if nodeList[i].frequency < min2.frequency && (nodeList[i].id != min1.id || min1.id == 0) {
				min2 = &nodeList[i]
			}
		}
		if min2.frequency == MAX {
			break
		}
		// fmt.Printf("min1: %c, min2: %c\n", min1.id, min2.id)
		parent := Node{ 0 , min1.frequency + min2.frequency, nil, min1, min2 }
		min1.parent = &parent
		min2.parent = &parent
		nodeList = append(nodeList, parent)
		root = &parent
	}
	// fmt.Println(*root)
	// for i := range nodeList {
	// 	fmt.Printf("%p: %v\n",&nodeList[i], nodeList[i])
	// }
	costs := make(map[rune]int)
	if root.id != 0 {
		dfs(&costs, root, 1)
	} else {
		dfs(&costs, root, 0)
	}
	// fmt.Println(costs)
	result := 0
	for _, r := range *s {
		result += costs[r]
	}
	return result
}



func main() {
	inputs, err := ReadLongLines(1)
	if err != nil {
		fmt.Println(err)
		return
	}
	result := solve(&inputs[0])
	fmt.Printf("%d\n", result)
}


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

bool isTooBig(unsigned long long a, unsigned long long b) {
  unsigned long long result = a * b;
  unsigned long long max = pow(10, 18);

  if ((result > max) || (result / a != b)) {
    return true;
  }
  return false;
}

void multiply(vector<unsigned long long> input, int length) {
  unsigned long long product = 1;

  for (int i = 0; i < length; i++) {
    if (input[i] == 0) {
      cout << 0 << endl;
      return;
    } else if (isTooBig(product, input[i])) {
      cout << -1 << endl;
      return;
    }
    product *= input[i];
  }
  cout << product << endl;
}

int main() {
  vector<unsigned long long> input;
  string length;

  getline(cin, length);

  string line;
  getline(cin, line);
  istringstream iss(line);
  string n;

  while (iss >> n) {
    if (n == "0") {
      cout << 0 << endl;
      exit(0);
    }
    input.push_back(stoull(n));
  }

  multiply(input, stoi(length));
}

Measured memory_bytes: 8724
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int x,a,b;
  std::cin >> x >> a >>b;
  if(abs(x-a)<abs(x-b)) printf("A\n");
  else printf("B\n");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T,bool directed>
struct Dinic{
  struct edge {
    int to;
    T cap;
    int rev;
    edge(){}
    edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
  };

  vector<vector<edge> > G;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int n):G(n),level(n),iter(n){}

  int add_edge(int from,int to,T cap){
    G[from].emplace_back(to,cap,G[to].size());
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
    return G[to].back().rev;
  }

  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.emplace(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.emplace(e.to);
        }
      }
    }
  }

  T dfs(int v,int t,T f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        T d=dfs(e.to,t,min(f,e.cap));
        if(d==0) continue;
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
    return 0;
  }

  T flow(int s,int t,T lim){
    T fl=0;
    while(1){
      bfs(s);
      if(level[t]<0||lim==0) break;
      fill(iter.begin(),iter.end(),0);

      while(1){
        T f=dfs(s,t,lim);
        if(f==0) break;
        fl+=f;
        lim-=f;
      }
    }
    return fl;
  }

  T flow(int s,int t){
    return flow(s,t,numeric_limits<T>::max()/2);
  }

  T cut(int s,int t,int x,int a){
    static_assert(directed, "must be directed");
    auto &e=G[x][a];
    int y=e.to;
    T cr=G[y][e.rev].cap;
    if(cr==0) return e.cap=0;
    e.cap=G[y][e.rev].cap=0;
    T cap=cr-flow(x,y,cr);
    if(x!=s&&cap!=0) flow(x,s,cap);
    if(t!=y&&cap!=0) flow(t,y,cap);
    return cap;
  }

  T link(int s,int t,int x,int a,T f){
    auto &e=G[x][a];
    e.cap+=f;
    return flow(s,t,f);
  }
};

//INSERT ABOVE HERE


signed main(){
  int n,e,q;
  cin>>n>>e>>q;
  Dinic<int, true> G(n);
  vector< map<int, int> > I(n);
  for(int i=0;i<e;i++){
    int f,t;
    cin>>f>>t;
    f--;t--;
    I[f][t]=G.add_edge(f,t,1);
    I[t][f]=G.add_edge(t,f,1);
  }

  vector<int> ms(q),as(q),bs(q);
  for(int i=0;i<q;i++){
    cin>>ms[i]>>as[i]>>bs[i];
    as[i]--;bs[i]--;
    if(I[as[i]].count(bs[i])) continue;
    I[as[i]][bs[i]]=G.add_edge(as[i],bs[i],0);
    I[bs[i]][as[i]]=G.add_edge(bs[i],as[i],0);
  }

  int res=G.flow(0,n-1);
  for(int i=0;i<q;i++){
    if(ms[i]==1){
      res+=G.link(0,n-1,as[i],I[as[i]][bs[i]],1);
      res+=G.link(0,n-1,bs[i],I[bs[i]][as[i]],1);
    }
    if(ms[i]==2){
      res-=G.cut(0,n-1,as[i],I[as[i]][bs[i]]);
      res-=G.cut(0,n-1,bs[i],I[bs[i]][as[i]]);
    }
    cout<<res<<"\n";
  }
  return 0;
}



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

int s[5];

int main()
{
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        s[a]++;
        s[b]++;
    }
    string ans = "YES";
    repl(i, 1, 5) {
        if(s[i] == 3) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;


ll f(ll x){
    if (x!=1){
        return (2*f(floor(x/2))+1);
    }
    else return 1;
}
int main(){
    ll h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
    

    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back 
#define ll long long
using namespace std;

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n,i;
	cin>>n;
	ll a[n], f=0;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    a[i] *= 2;
	    if(i%2 == 0) f = f + a[i];
	    else f = f - a[i];
	}
	f = f/2;
	cout<<f<<" ";
	for(i=0;i<n-1;i++){
	    f = a[i] - f;
	    cout<<f<<" "; 
	}
  	cout<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
const long long MAX = 100007;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    //rep(i,n) cout << a[i];
    ll ans = 0ll;
    COMinit();
    for(int i=(k-1);i<n;i++){
        ans = (ans+COM(i,k-1)*(a[i]-a[n-i-1]))%mod;
        //ans = (ans-i*a[index])%mod;
    }
    cout << ans%mod <<endl;
}


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

long long n, p, ans = 1;
vector<pair<long long, int> > v;

void f(long long t){
	for (int i = 2; i <= sqrt(t); i++){
		if(t % i != 0)
			continue;
		int cnt = 0;	
		while(t % i == 0){
			t /= i;
			cnt++;
		}
		v.push_back({i, cnt});
	}
	if(t != 1)
		v.push_back({t, 1});
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> p;
	f(p);
	for (auto i : v)
		if(i.second >= n)
			ans = 1LL * ans * (long long)pow(i.first, (i.second / n));
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    vector<int> q;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        q.emplace_back(a);
    }
    if(n==1){
        if(q[0]==1){
            cout << 0 << endl;
            return 0;
        }
        else {
            cout << 1 << endl;
            return 0;
        }
    }
    map<int,int> mp;
    for(int i=0;i<n;i++){
        mp[q[i]]++;
    }
    int ans=0;
    for(auto e : mp){
        if(e.second>e.first) {
            ans += e.second - e.first;
        }
        else if(e.second<e.first){
            ans+=e.second;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5112
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [a//2 for a in A]

base = B[0]

is_break = False
for b in B:
  if base % b == 0:
    if (base // b) % 2 == 0:
      is_break = True
      break
    
    continue
  
  new_base = lcm(base, b)
  if (new_base // base) % 2 == 0:
    is_break = True
    break
  
  base = new_base

if is_break:
  ans = 0
else:
  ans = M // base
  if ans%2 == 0:
    ans = ans // 2
  else:
    ans = (ans + 1) // 2


print(ans)

Measured memory_bytes: 64228
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i],y[i] = map(int,input().split() )
d=dict()

maxi=0
for i in range(N-1):
  for j in range(i+1,N):
    if (x[j]-x[i],y[j]-y[i]) not in d:
      d[ (x[j]-x[i],y[j]-y[i]) ] =1
      d[ (x[i]-x[j],y[i]-y[j]) ] =1
    else:
      d[ (x[j]-x[i],y[j]-y[i]) ] +=1
      d[ (x[i]-x[j],y[i]-y[j]) ] +=1
#print(d)      

for p in d:
  maxi=max(maxi,d[p])
ans= (N-1-maxi)+1
print(ans)


Measured memory_bytes: 3440
#include <bits/stdc++.h>
int main()
{
    int n(0);
    using namespace std;
    int N, L, sum(0);
    cin >> N >> L;
    vector<int> Apple(N);
    for (int i = 0; i < N; i++)
    {
        Apple[i] = L + i;
        sum += Apple[i];
    }
    int x = Apple[0] > 0 ? Apple[0] : Apple[N - 1] > 0 ? 0 : Apple[N - 1];
    cout << sum - x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::set<std::pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        v.emplace(a, i + 1);
    }

    for (auto &e : v) std::cout << e.second << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <map>
#include <sstream>
#include <string>

using namespace std;

map<char, string> dict1{
    {' ', "101"},      {'\'', "000000"},  {',', "000011"},   {'-', "10010001"},
    {'.', "010001"},   {'?', "000001"},   {'A', "100101"},   {'B', "10011010"},
    {'C', "0101"},     {'D', "0001"},     {'E', "110"},      {'F', "01001"},
    {'G', "10011011"}, {'H', "010000"},   {'I', "0111"},     {'J', "10011000"},
    {'K', "0110"},     {'L', "00100"},    {'M', "10011001"}, {'N', "10011110"},
    {'O', "00101"},    {'P', "111"},      {'Q', "10011111"}, {'R', "1000"},
    {'S', "00110"},    {'T', "00111"},    {'U', "10011100"}, {'V', "10011101"},
    {'W', "000010"},   {'X', "10010010"}, {'Y', "10010011"}, {'Z', "10010000"},
};

map<string, char> dict2{
    {"00000", 'A'}, {"00001", 'B'}, {"00010", 'C'},  {"00011", 'D'},
    {"00100", 'E'}, {"00101", 'F'}, {"00110", 'G'},  {"00111", 'H'},
    {"01000", 'I'}, {"01001", 'J'}, {"01010", 'K'},  {"01011", 'L'},
    {"01100", 'M'}, {"01101", 'N'}, {"01110", 'O'},  {"01111", 'P'},
    {"10000", 'Q'}, {"10001", 'R'}, {"10010", 'S'},  {"10011", 'T'},
    {"10100", 'U'}, {"10101", 'V'}, {"10110", 'W'},  {"10111", 'X'},
    {"11000", 'Y'}, {"11001", 'Z'}, {"11010", ' '},  {"11011", '.'},
    {"11100", ','}, {"11101", '-'}, {"11110", '\''}, {"11111", '?'},
};

int main() {

  string str;
  while (getline(cin, str)) {
    string str2 = "";
    for (char c : str)
      str2 += dict1[c];

    str2 += "0000";
    str2.erase(str2.begin() + int(str2.length() / 5) * 5, str2.end());

    for (int i = 0; i < str2.length(); i += 5)
      cout << dict2[str2.substr(i, 5)];
    cout << endl;
  }
}


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

int main(){
  int m, mi, ma;
  while(cin >> m >> mi >> ma, m){
    vector<int> P(m);
    for(int i = 0; i < m; ++i) cin >> P[i];
    int g = -1, ans = -1;
    for(int i = mi; i <= ma; ++i){
      if(P[i-1] - P[i] < g) continue;
      g = P[i-1] - P[i];
      ans = i;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3064
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main():
    for line in stdin:
        line = line.rstrip()
        first, line = line.split('+')
        second, answer = line.split('=')

        if len(first) > 1 and first[0] == 'X':
            candidate = '123456789'
        elif len(second) > 1 and second[0] == 'X':
            candidate = '123456789'
        elif len(answer) > 1 and answer[0] == 'X':
            candidate = '123456789'
        else:
            candidate = '0123456789'

        for c in candidate:
            f = int(first.replace('X', c))
            s = int(second.replace('X', c))
            a = int(answer.replace('X', c))
            if f + s == a:
                print(c)
                break
        else:
            print('NA')
    exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 4292
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
  int A1,A2,A3;
  scanf("%d %d %d",&A1,&A2,&A3);
  if(A1+A2+A3>=22) printf("bust\n");
  else printf("win\n");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 3534567;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    int cnt = 0;
    double ans = n;

    rep(i , 1 , n) {
        if(i % 2 != 0) {
            cnt++;
        }
    }

    cout << (ld)cnt / ans << endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;

  rep(i, h){
    string str;
    cin >> str;
    cout << str << endl << str << endl;
  }
}

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

using ll = long long;
using ld = long double;

int main()
{
    int n;
    cin >> n;
    set<int> s;
    
    
    for(int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        s.emplace(d);
    }
    
    cout << s.size() << endl;
    
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  auto begin = find_if(s.cbegin(), s.cend(), [](const auto & c){return 'A' == c;});
  auto end = find_if(s.crbegin(), s.crend(), [](const auto & c){return 'Z' == c;});
  cout << distance(begin, end.base());
  return 0;
}


Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = (0..N)
        .map(|_| {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse().unwrap()
        })
        .collect();

    // 先頭から順に可能な限り売却する
    // 最後に売却する際は所持金が1になるように売る
    let (ans, _) = A.iter()
        .fold(
            (0, 1),
            |(res, h), &a| (
                res + (a - 1) / h,
                if h == a || h == 1{
                    h + 1
                } else {
                    h
                }
            )
        );

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    double sum = 0;
    for(int i = 0; i < n; i++){
        double x;
        string c;
        cin >> x >> c;
        if(c[0] == 'J'){
            sum += x;
        }else{
            sum += (x*380000.0);
        }
    }

    printf("%f", sum);
    
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <list>
#include <ctime>
#include <random>
using namespace::std;

int main(){
	int n; cin >> n;
	long int ans=0;
	for(int i = 0; i < n; i++){
		long int a; cin >> a;
		while(1){
			if(a%2==0){
				a=a/2;
				ans++;
			} else{
				break;
			}
		}
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;
typedef tuple<int,int,int,int> Tile;
map<Tile,int> M;
vector<Tile> V;

int self_dub(Tile t){
    int i=1;
    if(t==Tile(get<1>(t),get<2>(t),get<3>(t),get<0>(t)))i++;
    if(t==Tile(get<2>(t),get<3>(t),get<0>(t),get<1>(t)))i++;
    if(t==Tile(get<3>(t),get<0>(t),get<1>(t),get<2>(t)))i++;
    return i;
}

bool equal(Tile a, Tile b){
    int A[4],B[4];
    A[0]=get<0>(a);A[1]=get<1>(a);A[2]=get<2>(a);A[3]=get<3>(a);
    B[0]=get<0>(b);B[1]=get<1>(b);B[2]=get<2>(b);B[3]=get<3>(b);
    if(A[0]==B[0]&&A[1]==B[1]&&A[2]==B[2]&&A[3]==B[3]) return true;
    if(A[0]==B[1]&&A[1]==B[2]&&A[2]==B[3]&&A[3]==B[0]) return true;
    if(A[0]==B[2]&&A[1]==B[3]&&A[2]==B[0]&&A[3]==B[1]) return true;
    if(A[0]==B[3]&&A[1]==B[0]&&A[2]==B[1]&&A[3]==B[2]) return true;
    return false;
}

int64_t cnt(int i, int j, int d){
    Tile T[6];
    T[0]=V[i];
    int Bo[4];
    Bo[(0+d)%4]=get<0>(V[j]);
    Bo[(1+d)%4]=get<1>(V[j]);
    Bo[(2+d)%4]=get<2>(V[j]);
    Bo[(3+d)%4]=get<3>(V[j]);    
    T[1]=Tile(Bo[0],Bo[1],Bo[2],Bo[3]);
    T[2]=Tile(get<1>(T[0]),get<0>(T[0]),get<1>(T[1]),get<0>(T[1]));
    T[3]=Tile(get<2>(T[0]),get<1>(T[0]),get<0>(T[1]),get<3>(T[1]));
    T[4]=Tile(get<3>(T[0]),get<2>(T[0]),get<3>(T[1]),get<2>(T[1]));
    T[5]=Tile(get<0>(T[0]),get<3>(T[0]),get<2>(T[1]),get<1>(T[1]));
    int Dub[6]={};
    for(int a=0;a<6;a++){
        for(int b=a+1;b<6;b++){
            if(equal(T[a],T[b])){
                Dub[b]+=self_dub(T[b]);
            }
        }
    }
    int64_t ret=1;
    for(int i=2;i<6;i++){
        int64_t p=0;
        if(M.find(T[i])!=M.end()){
            p=M[T[i]]-Dub[i];
        }
        ret*=p;
    }
    return ret;
}

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int c0,c1,c2,c3;
        cin>>c0>>c1>>c2>>c3;
        V.emplace_back(c0,c1,c2,c3);
        M[Tile(c0,c1,c2,c3)]++;
        M[Tile(c1,c2,c3,c0)]++;
        M[Tile(c2,c3,c0,c1)]++;
        M[Tile(c3,c0,c1,c2)]++;
    }
    int64_t ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int d=0;d<4;d++){
                ans+=cnt(i,j,d);
                // if(cnt(i,j,d))cout<<i<<' '<<j<<' '<<d<<' '<<cnt(i,j,d)<<endl;
            }
        }
    }
    cout<<ans/3<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Arrays;
import java.util.Stack;

public class Main {
		static  Scanner scn=new Scanner(System.in);
		static int count=0;
		public static void main(String[] args) {
			
			int n=scn.nextInt();
			int arr[]=new int[n];
			for(int i=0;i<n;i++)
			{
				arr[i]=scn.nextInt();
			}
			long sum=0;
			for(int i=0;i<n;i++)
			{
				for(int j=i+1;j<n;j++)
				{
					if(arr[i]==0)
						break;
					else if(arr[i]>0)
					{
						sum+=arr[i]*arr[j];
					}
				}
			}
			System.out.println(sum);
		}
		public static int gcd(int a,int b)
		{
			if(a==0)return b;
			int l= gcd(b%a,a);
			return l;
		}

		
}


Measured memory_bytes: 21332
#include<iostream>
#include<bitset>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int rain_count=0;
  if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR")
  {
    rain_count=1;
  }
  else if(s=="RRS"||s=="SRR")
  {
    rain_count=2;
  }
  else if(s=="RRR")
  {
    rain_count=3;
  }
  cout <<rain_count<<endl;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

string a[575];

int main(void){
	int h,w,i,j;
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> a[i];
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			cout << ((((i)%2 || (!j))&&(j!=w-1))?'#':a[i][j]);
		}
		cout << endl;
	}
	cout << endl;
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			cout << ((((i+1)%2 || j==(w-1))&&j)?'#':a[i][j]);
		}
		cout << endl;
	}
	return 0;
}


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

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  a[n] = a[0] + k;
  int A = 0;
  for (int i = 0; i < n; i++)
  {
    if (a[i + 1] - a[i] > A)
    {
      A = a[i + 1] - a[i];
    }
  }
  
  int ans = k - A;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

long long ans, a[maxn], b[maxn];
int n;

bool mycmp(int i, int j) {
	return a[i] + b[i] > a[j] + b[j];
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	vector<int> d;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i] >> b[i];
		d.push_back(i);
	}

	sort(d.begin(), d.end(), mycmp);
	
	for (int i = 0; i < n; ++i) {
		// printf("i:%d d[i]:%d\n", i,d[i]);
		if (i&1)
			ans -= b[d[i]];
		else
			ans += a[d[i]];
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2296
#include<iostream>
#include<stack>
#include<utility>
#include<cctype>

using namespace std;

typedef pair<long long,long long> PLL;

const int M=1000000007;
stack<PLL> num;
stack<char> op;

bool do2(){
  bool flag=false;
  while(!op.empty()){
    if(op.top()=='&'){
      auto r=num.top();
      num.pop();
      auto l=num.top();
      num.pop();
      auto t=(r.first*l.first)%M;
      num.push(PLL(t,((l.first+l.second)*(r.first+r.second)-t)%M));
    }else if(op.top()=='~'){
      auto r=num.top();
      num.pop();
      num.push(PLL(r.second,r.first));
    }else{
      break;
    }
    flag=true;
    op.pop();
  }
  return flag;
}

void do3(){
  while(!op.empty()){
    if(do2()){
    }else if(op.top()=='|'){
      auto r=num.top();
      num.pop();
      auto l=num.top();
      num.pop();
      auto f=(r.second*l.second)%M;
      num.push(PLL(((l.first+l.second)*(r.first+r.second)-f)%M,f));
      op.pop();
    }else{
      break;
    }
  }
}

int main(){
  char str[1000001];
  cin>>str;
  for(char *p=str;*p;){
    if(*p=='x'){
      num.push(PLL(1,1));
      p++;
      while(isdigit(*p)){
	p++;
      }
    }else{
      if(*p==')'){
	do3();
	op.pop();
      }else{
	if(*p=='|'){
	  do3();
	}else if(*p=='&'){
	  do2();
	}
	op.push(*p);
      }
      p++;
    }
  }
  do3();
  cout<<num.top().first<<endl;
}

Measured memory_bytes: 2584
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
d = LIST()
d.sort()
mid = n // 2
print(d[mid] - d[mid - 1])


Measured memory_bytes: 74252
N, M = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.sort()
err_list = [X_list[i+1] - X_list[i] for i in range(len(X_list)-1)]
err_list.sort()

if N == 1:
    print(sum(err_list))
else:
    print(sum(err_list[:-(N-1)]))

Measured memory_bytes: 13960