akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

// ll g[200000], ig[200000];




void solve()
{	

    ll n;
    cin>>n;

    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    ll sum = a[0];

    ll ans = 0;

    for(ll i=1;i<n;i++){
        ans += sum*a[i];
        ans %= MOD;
        sum+= a[i];
        sum %= MOD;
    }

    cout<<ans;


}

int main() {


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

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


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  double L; 
  cin >> L;

  L /= 3.0;
  cout << L*L*L << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 44
int f[N];
int fibonacci(int n){
  int i;
  f[0]=1;
  f[1]=1;
  for(i=2;i<=n;i++){
    f[i]=f[i-2]+f[i-1];
  }
  return f[n];
}

int main(){
  int n;
  
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

Measured memory_bytes: 596
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;


int main() {
	FASTIO
	string s, t;
	cin >> s >> t;
	int n = s.size();
	if(s == t.substr(0, n))
	cout << "Yes";
	else
	cout << "No";
	return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 50
int N, M;
string A[MAX_N], B[MAX_N];

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

	cin >> N >> M;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, M) cin >> B[i];

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			bool flag = true;
			for(int k = 0; k < M; k++) {
				for(int l = 0; l < M; l++) {
					if(i + k > N || j + l > N) {
						flag = false;
						break;
					}
					if(A[i + k][j + l] != B[k][l]) {
						flag = false;
						break;
					}
				}
				if(!flag) break;
			}

			if(flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
res = []
3.times {|i| res << gets.split(' ').map(&:to_i)}
n = gets.to_i
nums = []
n.times {|i| nums << gets.to_i}
nums.each {|n| 3.times {|i| res[i].map!{|r| r==n ? 0 : r}}}
new_res = res.transpose
if res[0].all? {|r| r == 0} || res[1].all? {|r| r == 0} || res[2].all? {|r| r == 0}
  puts "Yes"
elsif new_res[0].all? {|r| r == 0} || new_res[1].all? {|r| r == 0} || new_res[2].all? {|r| r == 0}
  puts "Yes"
elsif (res[0][0] == 0 && res[1][1] == 0 && res[2][2] == 0) || (res[0][2] == 0 && res[1][1] == 0 && res[2][0] == 0)
  puts "Yes"
else
  puts "No"
end

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    string a,b; cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else{
        if(a > b) cout << "GREATER" << endl;
        if(a < b) cout << "LESS" << endl;
        if(a == b) cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
int lcm(int a, int b) {return a / gcd(a, b) * b;}
signed main() {
    INCANT;
    int n, m, res = 0, l = 1, a, cnt = 0, cntt;
    cin>>n>>m;
    rep(i, n) {
        cin>>a;
        a /= 2;
        l = lcm(l, a);
        if(i) {
            cntt = 0;
            while(a % 2 == 0) {
                cntt++;
                a /= 2;
            }
            if(cnt != cntt) {
                cout<<0<<endl;
                return 0;
            }
        } else {
            while(a % 2 == 0) {
                cnt++;
                a /= 2;
            }
        }
    }
    cout<<(m / l + 1) / 2<<endl;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int f = 1;
    int s = 1;
    do {
        f = a[f];
        s = a[a[s]];
    } while (f != s);

    s = 1;
    while (s != f) {
        s = a[s];
        f = a[f];
        k--;
        if (k == 0) {
            cout << s;
            return 0;
        }
    }

    int size = 0;
    do {
        s = a[s];
        size++;
    } while (f != s);
    s = 1;
    k %= size;
    while (k--) {
        f = a[f];
    }
    cout << f;
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int X;
  cin>>X;
  vi A;
  A.push_back(1);
  REP(i,2,31){
    int Q=i;
    while(Q<=1000){
      Q*=i;
      A.push_back(Q);
      }
    }
  sort(ALL(A));
  int R=disup(A,X)-1;
  cout<<A[R];
  }


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    x = int(input())

    num_500 = x // 500

    amari_500 = x % 500

    num_5 = amari_500 // 5

    ans = num_500 * 1000 + num_5 * 5

    print(ans)


if __name__ == "__main__":
    resolve()



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

int main() {
  int N,i,x;
  x = 0;
  cin >> N;
  vector<int> a(N);
  for(i=0;i<N;i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  if(N == 1) cout << 1 << endl;
  else{
   for(i=0;i<N-1;i++){
    if(a.at(i) == a.at(i+1)) x = x + 1;
   }
   cout << N-x << endl;
  }
}






Measured memory_bytes: 3488
if __name__ == "__main__":
  N = int(input())
  min = 1000000000000
  for i in range(1, N):
    A = i
    A_sum = sum([int(x) for x in list(str(A))])
    B = N - i
    B_sum = sum([int(x) for x in list(str(B))])
    buf = A_sum + B_sum
    if buf < min:
      min = buf
  print(min)

Measured memory_bytes: 3316
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter

n = int(readline())
ppp = list(map(int,readline().split()))

def BIT_add(i,x):
    while i <= n:
        tree[i] += x
        i += i&(-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

def BIT_search(x):
    # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
      i = 0
      s = 0
      step = 1<<(n.bit_length()-1)
      while step:
          if i+step <= n and s + tree[i+step] < x:
              i += step
              s += tree[i]
          step >>= 1
      return i+1

q = sorted(enumerate(ppp,1),key=itemgetter(1),reverse=True)
tree = [0]*(n+1)

ans = 0
for i, p in q:
    L = BIT_sum(i) # 左にある既に書き込んだ数の個数
    BIT_add(i,1)
    R = n-p-L # 右にある既に書き込んだ数の個数
    LL = BIT_search(L-1) if L >= 2 else 0
    LR = BIT_search(L) if L >= 1 else 0
    RL = BIT_search(L+2) if R >= 1 else n+1
    RR = BIT_search(L+3) if R >= 2 else n+1
    ans += p*((LR-LL)*(RL-i)+(RR-RL)*(i-LR))
print(ans)

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 2e5 + 10;

int n;
int p[N], fa[N];

int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int rt, ban;
int val[N];
vector<int> G[N];

bool vis[N];

void DFS(int o){
	if(o == ban) return;
	if(!G[o].size()) return;
	for(int v : G[o]) DFS(v);
	for(int v : G[o]) vis[val[v]] = true;
	For(i, 0, n) if(!vis[i]){
		val[o] = i; 
		break;
	} 
	for(int v : G[o]) vis[val[v]] = false;
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) fa[i] = i;
	For(i, 1, n){
		scanf("%d", &p[i]);
		if(find(i) == find(p[i])) rt = i;
		else fa[find(i)] = find(p[i]), G[p[i]].pb(i);
	}
	DFS(rt);
	if(val[rt] == val[p[rt]]){
		ban = p[rt];
		val[p[rt]]++;
		DFS(rt);
		if(val[rt] != val[p[rt]] - 1){
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 20352
#include<stdio.h>
int main(void)
{
	int x,a,b;	
	int sum;

	scanf("%d",&x);
	scanf("%d",&a);
	scanf("%d",&b);
	
	sum = x - a;
	
	while(sum >= b){
		sum = sum - b;
	}

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

	return 0;
}

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


int main() {
    int n, a, b; cin >> n;

    vector<pair<int, int>> v;

    for ( int i = 0; i < n; i++){
        cin >> a >> b;
        v.emplace_back(b, a);
    }

    sort(v.begin(), v.end());

    int sum = 0;

    bool isYes = true;

    for (auto t : v){
        sum += t.second;

        if (sum > t.first){
            isYes = false;
            break;
        }
    }

    cout << (isYes ? "Yes" : "No") << endl;
}

Measured memory_bytes: 2420
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            long N = in.nextLong();

            long sum = 0;
            ArrayList<Long> divisors = divisor(N);
            for (Long divisor : divisors) {
                if (divisor.longValue() == 1) {
                    continue;
                }
                long m = divisor.longValue() - 1;
                if (N / m == N % m) {
                    sum += m;
                }
            }

            System.out.println(sum);
        }
    }

    public static final ArrayList<Long> divisor(long n) {
        ArrayList<Long> res = new ArrayList<>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.add(i);
                if (n / i != i) {
                    res.add(n / i);
                }
            }
        }
        return res;
    }
}


Measured memory_bytes: 23764
#入力した文字を変数に格納する
input_number=input()

array=input_number.split()

#整数型に変換を行う
W=int(array[0])
H=int(array[1])
x=int(array[2])
y=int(array[3])
r=int(array[4])

#条件式
if x+r<=W and y+r<=H and x-r>=0 and y-r>=0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:13/03/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
const ll inf=0x3f3f3f3f;

vector<int>primeFactorization(int n)
{
    vector<int>prime_fact;
    for(int i=2;i<=sqrt(n);++i)
    {
        while(n%i==0)
        {
            prime_fact.push_back(i);
            n/=i;
        }
    }
    if(n!=1)
    prime_fact.push_back(n);
    return prime_fact;
}

vector<int>sieve(int n)
{
    bool primes[n+5];
    memset(primes,true,sizeof(primes));
    vector<int>res;//res vector all the prime no between 1 to n
    for(int i=2;i<=sqrt(n);++i)
    {
        if(primes[i]==true)
        {
            res.push_back(i);
            for(int j=i*2;j<=n;j+=i)
            primes[j]=false;
        }
    }
    return res;
}








ll const Mxn=100000;
bool test=0;
void solve()
{
    ll n,f=0,q,c,ans=0,i,W;
    cin>>n>>W;
    ll dp[2][100005];
    memset(dp,false,sizeof(dp));
    vector<ll>w(n),p(n);
    fab(i,0,n)
      cin>>w[i]>>p[i];
    fab(j,0,n)
    {
        fab(i,1,W+1)
        {
            if(i>=w[j])
            dp[1][i]=max(dp[0][i],p[j]+dp[0][i-w[j]]);
            else
            dp[1][i]=dp[0][i];
        }
        fab(i,1,W+1)
        dp[0][i]=dp[1][i];
    }
    cout<<dp[0][W];
    
}





























int main()
{
    fio;
    ll t=1,s;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,x = li()
a = li()

mins = [ai for ai in a]
a2 = a+a

ans = sum(mins)
for k in range(n):
    for i in range(n):
        mins[i] = min(mins[i],a2[i+k])
    
    temp = sum(mins)    
    ans = min(ans, temp + k*x)
    
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
 
char str[15];
char a[10000000];
 
int find(void);
void insert(void);
int getChar(char);
int getkey(void);
 
int main(){
    int i,j,n;
    char b[7];
 
    scanf("%d",&n);
 
    for(i=0;i<n;i++){
        scanf("%s %s",b,str);
        if(b[0]=='i'){
            insert();
        }
        else if(b[0]=='f'){
            if(find())printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}
 
int find(){
    int key = getkey();
     
    if(a[key]) return 1;
    else return 0;
}

int getkey(){
    int sum=0, p=1,i;
    for(i=0;i<strlen(str);i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

void insert(){
    a[getkey()] = 1;
}

int getChar(char c){
    if(c == 'A')return 1;
    else if(c == 'C')return 2;
    else if(c == 'G')return 3;
    else if(c == 'T')return 4;
}

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

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a,0,sizeof(a))
#define sqr(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;

const int mn=1e5+5;

int n,m;

char a[mn];
int aa[mn];
char b[mn];
int ab[mn];

ll c=0;

map<int,char> h;

int main() {
	//cin.sync_with_stdio(0);
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	clock_t cc=clock();
#endif
	scanf("%d%d",&n,&m);
	scanf("%s%s",a+1,b+1);

	ll ans=1ll*n*m/__gcd(n,m);

	for(int i=1;i<=n;i++){
		aa[i]=1+(i-1)*ans/n;
		h[aa[i]]=a[i];
	}
	bool flag=1;
	for(int i=1;i<=m;i++){
		ab[i]=1+(i-1)*ans/m;
		if (h.count(ab[i])&&h[ab[i]]!=b[i]) {
			flag=0;break;
		}
	}
	if (flag) printf("%lld\n",ans);
	else puts("-1");


#ifdef LOCAL
	cout<<"time:"<<(double)(clock()-cc)/CLOCKS_PER_SEC;
#endif
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string s, t;
    int cnt = 0;

    cin >> s >> t;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
march = {'m': 0, 'a': 0, 'r': 0, 'c': 0, 'h': 0}
for i in range(n):
  s = input()[0].lower()
  try:
    march[s] += 1
  except:
    pass
ans = 0

for key1 in march.keys():
  for key2 in march.keys():
    if key1 != key2:
      for key3 in march.keys():
        if key3 != key1 and key3 != key2:
          ans += march[key1] * march[key2] * march[key3]
print(ans//6)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Point {
    int x;
    int y;

    Point(int a, int b) {
      x = a;
      y = b;

    }

    int[][] ofs = new int[][] { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

    Point(Point p, int d) {
      x = p.x + ofs[ d ][ 0 ];
      y = p.y + ofs[ d ][ 1 ];
    }
  }

  int INF = 1 << 28;

  void run() {
    for ( ;; ) {
      int N = ni();
      if ( N == 0 ) {
        break;
      }

      HashMap<Integer, Point> map = new HashMap<Integer, Point>();

      map.put( 0, new Point( 0, 0 ) );

      for ( int i = 1; i < N; ++i ) {
        int n = ni();
        int d = ni();

        Point p = map.get( n );
        map.put( i, new Point( p, d ) );
      }

      int minx = 1 << 28;
      int maxx = -( 1 << 28 );
      int miny = INF;
      int maxy = -INF;
      for ( Integer k : map.keySet() ) {
        Point p = map.get( k );
        minx = Math.min( p.x, minx );
        maxx = Math.max( p.x, maxx );
        miny = Math.min( p.y, miny );
        maxy = Math.max( p.y, maxy );
      }

      int w = maxx - minx + 1;
      int h = maxy - miny + 1;
      System.out.println( w + " " + h );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 35408
#include<stdio.h>

int main(){
	int n;
	int i,j;
	int a;
	
	while(scanf("%d",&n),n!=0){
		int m[2]={n,n},card[200]={0},t=1,ba=0;
		for(i=0;i<n;i++) scanf("%d",&a),card[a-1]=1;
		
		while(m[0]!=0 && m[1]!=0){
			for(i=0;i<2*n;i++){
				if(t==1 && card[i]==1 && i>=ba){
					card[i]=2;m[0]--;t=0;ba=i;
					//break;
				}
				if(t==0 && card[i]==0 && i>=ba){
					card[i]=2;m[1]--;t=1;ba=i;
					//break:
				}
			}
			ba=0;
			t=!t;
//			if(p=0) t=!t,ba=0;
//			else p=0;
		}
		printf("%d\n%d\n",m[1],m[0]);
	}
	return 0;
}



Measured memory_bytes: 1924
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

int N, M;
map<int, int> mp;

int main(void) {
  cin >> N >> M;
  REP(i, N) {
    int t; cin >> t;
    mp[t]++;
  }
  vector<int> pcnt(M + 1), cnt(M + 1);
  for (auto p : mp) {
    cnt[p.first % M] += p.second;
    pcnt[p.first % M] += p.second / 2;
  }
  int res = 0;
  for (int i = 0; i < M; i++) {
    int j = (M - i + M) % M;
    if (i > j) continue;
    if (i == j) {
      res += cnt[i] / 2;
      //cout << i << " " << cnt[i] / 2 << endl;
    }
    else {
      if (cnt[i] < cnt[j]) {
	int rest = cnt[j] - cnt[i];
	res += cnt[i] + min(pcnt[j], rest / 2);
	//cout << i << " " << cnt[i] + min(pcnt[j], rest / 2) << endl;
      } else {
	int rest = cnt[i] - cnt[j];
	res += cnt[j] + min(pcnt[i], rest / 2);
	//cout << i << " " << cnt[j] + min(pcnt[i], rest / 2) << endl;
      }
    };
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
         
using namespace std;
         
int main() {
long a,b;
cin >> a >> b;
long d = a/b;
long r = a%b;

cout << d << " " << r << " " << d << ".";
for(int i=0; i<5; ++i) {
int k=-1;
while(r!=0 && r < b){r *= 10; ++k;}
long rr = r/b;
r%=b;
for(int j=0; j<k; ++j)
cout << 0;
cout << rr;
}
cout << endl;
}


Measured memory_bytes: 3088
# Kが奇数の時はa,b,cが全てKの倍数
# Kが偶数の時はa,b,cが全てmod(K)=0 となるか mod(K)=K/2となる
# なのでそれらを数え上げて3乗するだけ
N, K = list(map(int, input().split()))

if K % 2 == 0:
    l1 = 0
    l2 = 0
    for i in range(1, N+1):
        if i % K == 0:
            l1 += 1
        if i % K == (K / 2):
            l2 += 1
    print(l1 ** 3 + l2 ** 3)
else:
    l1 = 0
    for i in range(1, N+1):
        if i % K == 0:
            l1 += 1
    print(l1 ** 3)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int sumOfDigits(ll n) {
  int ret = 0;
  while (n > 0) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

void solve() {
  int n; cin >> n;
  if (n % sumOfDigits(n) == 0) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

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

LL cnt(LL x, LL y, LL z) {
	return (y / z) - ((x - 1) / z);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	LL a, b, c, d; cin >> a >> b >> c >> d;
	cout << cnt(a, b, 1) - (cnt(a, b, c) + cnt(a, b, d) - cnt(a, b, c * (d / __gcd(c, d)))) << '\n';
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
s = 0
count = Hash.new{0}
A.each{|a|
    count[a] += 1
    s += a
}
Q = gets.to_i
Q.times{
    b, c = gets.split.map(&:to_i)
    s += (c - b) * count[b]
    count[c] += count[b]
    count.delete(b)
    puts s
}


Measured memory_bytes: 25812
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC052 B - Increment Decrement
// 2020. 06.13

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  int res = 0;
  REP(i, N){
    if(S[i] == 'I') res++;
    if(S[i] == 'D') res--;
    ans = max(ans, res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
array=list(map(int,input().split()))
array1=sorted(array)
import itertools
list1=list(itertools.combinations(array1,3))
ans=0
for n in range(len(list1)):
  if list1[n][0]!=list1[n][1] and list1[n][1]!=list1[n][2]:
    if list1[n][0]+list1[n][1]>list1[n][2]:
      ans=ans+1
print(ans)

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

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

  int n,k; cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  if(n > k) rep(i,k) h.pop_back();
  else{
    cout << 0 << '\n';
    return 0;
  }

  long long ans = 0;
  rep(i,h.size()) ans += h[i];
  cout << ans << '\n';

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
vector<int> g[100010];
ll d[100010];
bool f[100010];

void dfs(int v,int pre,int dep){
  d[v]=dep;
  for(int nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v,dep+1);
  }
}

int main(){
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0,-1,0);
  int s=0;
  rep(i,n)if(d[i]>d[s])s=i;
  dfs(s,-1,0);
  int t=0;
  rep(i,n)if(d[i]>d[t])t=i;

  vector<int> vs;
  {
    int v=t;
    vs.push_back(t);
    f[v]=true;
    while(v!=s){
      for(int nv : g[v]){
        if(d[nv]+1==d[v]){
          v=nv;
          break;
        }
      }
      f[v]=true;
      vs.push_back(v);
    }
  }

  vector<int> c(vs.size(),0),rc;

  repl(i,1,vs.size()-1){
    int v=vs[i];
    for(int nv : g[v]){
      if(f[nv])continue;
      if(g[nv].size()>=2){
        cout<<-1<<endl;
        return 0;
      }
      c[i]++;
    }
  }
  rc=c;
  reverse(all(rc));
  minch(c,rc);

  int v=1;
  rep(i,vs.size()){
    int sav=v;
    v++;
    rep(j,c[i])cout<<v++<<" ";
    cout<<sav<<" ";
  }
  cout<<endl;

  return 0;
}


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

using namespace std;
long long int N;

#define INF 1LL<<60

int main(){
	long long int N, K;
	cin >> N >> K;
	long long int ans = 1;
	N -= K;
	if( N > 0 ){
		ans += ( N + K - 2 ) / ( K - 1 );
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
x, y = map(int, input().split())

cnt = 0
t = x
while True:
    if t > 0:
        if y >= 0:
            if t < y:
                cnt += y - t
                break
            elif t == y:
                break
            else:
                #t > y
                cnt += 1
                t *= (-1)               
        else:
            #y < 0
            #t > y
            if abs(t) >= abs(y):
                t *= (-1)
                cnt += 1
            else:
                #abs(t) < abs(y)
                cnt += (-1) * y - t
                t = (-1) * y
    elif t == 0:
        if y > 0:
            #t < y
            cnt += y - t
            break
        elif y == 0:
            #t == y
            break
        else:
            #y < 0
            #y < t
            #abs(t) < abs(y)
            cnt += (-1) * y - t
            t = (-1) * y
    else:
        #t < 0
        if y >= 0:
            #t < y
            if abs(t) <= abs(y):
                t *= (-1)
                cnt += 1
            else:
                #abs(t) > abs(y)
                cnt += (-1) * y - t
                t = (-1) * y
        else:
            #y < 0
            if t < y:
                cnt += y - t
                break
            elif t == y:
                break
            else:
                #t > y
                cnt += 1
                t *= (-1)
print(cnt)    



Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main{
 
    // a～zの文字数を記録する配列
    static int[] CharCount = new int[26];
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // Ctrl+Zが押されるまで繰り返す
        while (sc.hasNext()) {
            // 入力と文字カウント
            CountingCharacters(sc.next());
        }
        // 表示
        Print();
 
    }
 
    // 文字列からa~zの文字をカウントする（大小文字区別なし）
    static void CountingCharacters(String str) {
 
        char[] c = str.toCharArray();
        for (int i = 0; i < c.length; i++) {
            for (int a = (int) 'A'; a < 1 + (int) 'Z'; a++) {
                if (Character.toUpperCase(c[i]) == (char) a) {
                    CharCount[a - (int) 'A']++;
                    break;
                }
            }
        }
    }
 
    // 表示処理
    static void Print() {
        for (int i = 0; i < CharCount.length; i++) {
            System.out.println((char) (i + (int) 'a') + " : " + CharCount[i]);
        }
    }
 
}



Measured memory_bytes: 26672
// Main.java
import java.io.*;
public class Main
{
        public static void main(String args[])
        {
                int K, X;
                InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(isr);
                String line;
                try{
                    while((line = br.readLine()) != null){
                        String buf[] = line.trim().split(" +");//空白が一回以上で区切る
                        K = Integer.parseInt(buf[0]);
                        X = Integer.parseInt(buf[1]);
                        int sum = 500*K;
                        if(sum >= X) System.out.println("Yes");
                        else System.out.println("No");
                    }
                }catch(Exception e){
                    e.getStackTrace();
                }
        }
}

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

string s;
int n;

int solve(vector<char> &ans){
    for(int i = 1; i < n-1; i++){
        if(ans[i] == 'S'){
            if(s[i] == 'o'){
                if(ans[i-1] == 'S'){
                    ans[i+1] = 'S';
                }else{
                    ans[i+1] = 'W';
                }
            }else{
                if(ans[i-1] == 'S'){
                    ans[i+1] = 'W';
                }else{
                    ans[i+1] = 'S';
                }
            }
        }else{
            if(s[i] == 'o'){
                if(ans[i-1] == 'S'){
                    ans[i+1] = 'W';
                }else{
                    ans[i+1] = 'S';
                }
            }else{
                if(ans[i-1] == 'S'){
                    ans[i+1] = 'S';
                }else{ 
                    ans[i+1] = 'W';
                }
            }
        }
    }
    if(ans[n-1] == 'S'){
        if(s[n-1] == 'o'){
            if(ans[n-2] != ans[0]){
                return -1;
            }
        }else{
            if(ans[n-2] == ans[0]){
                return -1;
            }
        }
    }else{
        if(s[n-1] == 'x'){
            if(ans[n-2] != ans[0]){
                return -1;
            }
        }else{
            if(ans[n-2] == ans[0]){
                return -1;
            }
        }
    }
    if(ans[0] == 'S'){
        if(s[0] == 'o'){
            if(ans[1] != ans[n-1]){
                return -1;
            }
        }else{
            if(ans[1] == ans[n-1]){
                return -1;
            }
        }
    }else{
        if(s[0] == 'x'){
            if(ans[1] != ans[n-1]){
                return -1;
            }
        }else{
            if(ans[1] == ans[n-1]){
                return -1;
            }
        }
    }
    return 1;
}

int main(){
    cin >> n >> s;
    vector<char> ans1(n), ans2(n), ans3(n), ans4(n);
    ans1[0] = 'S';ans1[1] = 'S';
    ans2[0] = 'W';ans2[1] = 'W';
    ans3[0] = 'S';ans3[1] = 'W';
    ans4[0] = 'W';ans4[1] = 'S';
    if(solve(ans1) == 1){
        for(int i = 0; i < n; i++){
            cout << ans1[i];
        }
    }else if(solve(ans2) == 1){
        for(int i = 0; i < n; i++){
            cout << ans2[i]; 
        }
    }else if(solve(ans3) == 1){
        for(int i = 0; i < n; i++){
            cout << ans3[i];
        }
    }else if(solve(ans4) == 1){
        for(int i = 0; i < n; i++){
            cout << ans4[i];
        }
    }else{
        cout << -1;
    }
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[100000];
int u[100000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>s;
  s[0]+=1;
  cout <<s[0]<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	int mx=(n-1)*(n-2)/2;

	if(mx<k)
	{
		cout << -1 << endl;
		return 0;
	}

	int m=(n-1)+(mx-k);

	cout << m << endl;

	for(int i=2;i<=n;i++)
		cout << 1 << " " << i << endl;

	int cnt=0;
	for(int i=2;i<=n;i++)
	{
		if(cnt>=mx-k)
			break;
		for(int j=i+1;j<=n;j++)
		{
			if(i==j)continue;
			else
			{
				cout << i << " " << j << endl;
				cnt++;
			}
			if(cnt>=mx-k)
				break;
		}
		if(cnt>=mx-k)
			break;
	}
}

Measured memory_bytes: 256
A,B = map(int,input().split())
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
gcd = gcd(max(A,B),min(A,B))
divisors = sorted(make_divisors(gcd))
divisors.pop(0)
ans = [1]
while divisors:
    i = divisors.pop(0)
    for j in range(len(divisors)-1,-1,-1):
        if divisors[j]%i == 0:
            divisors.pop(j)
    ans.append(i)
print(len(ans))

Measured memory_bytes: 3316
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(m - 2)
elif n > 1 and m == 1:
    print(n - 2)
elif n == 2 and m > 1:
    print(0)
elif n > 1 and m == 2:
    print(0)
else:
    print((n - 2) * (m - 2))

Measured memory_bytes: 3060
n = int(input())
li = list(map(int, input().split()))
i = 0

flag = True
while flag:
    flag = False
    for j in range(1, n)[::-1]:
        if li[j] < li[j-1]:
            tmp = li[j]
            li[j] = li[j-1]
            li[j-1] = tmp
            i += 1
            flag = True
            

print(str(li).replace(',', '')[1:-1])
print(i)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[101];
    for (int i = 0; i < n; i++) {
      int d = sc.nextInt();
      arr[d] = 1;
    }
    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (arr[i] == 1) {
        cnt += 1;
      }
    }
    System.out.println(cnt);
  }
}


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

using namespace std;
int sum(int arr[],int n)
{
    int i, sum=0;
   for (i=0;i<n;i++)
   {
       sum=sum+arr[i];

    }
    return sum;
}
int main()
{
  int n,i;
  float d,m;
  cin>>n;
  cin>>m;
  int arr[n];
  for(i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  sort(arr,arr+n);
  d=sum(arr,n)/(4*m);
  int count=0;
  for(i=0;i<m;i++)
  {
      if(arr[n-1-i]>=d)
      {
          count=count+1;
      }
  }
  if(count>=m)
  {
      cout<<"Yes";

  }
  else
    cout<<"No";
}


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

typedef long long ll;
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<int> lp(n);
  vector<int> ord(n);
  for (int i = 0; i < n; ++i) { 
    cin >> lp[i];
    ord[i] = i;
  }
  sort(ord.begin(), ord.end(), [&](int x, int y){
    return lp[x] > lp[y];
  });
  multiset<int> st;
  st.insert(n);
  st.insert(n);
  st.insert(-1);
  st.insert(-1);
  ll ans = 0;
  for (int i : ord) { 
    int m1, m2, m3, m4;
    auto itr = st.lower_bound(i);
    m3 = *itr;
    ++itr;
    m4 = *itr;
    --itr;
    --itr;
    m2 = *itr;
    --itr;
    m1 = *itr;
    // cerr << m1 << " " << m2 << " " << i << " " << m3 << " " << m4 << endl;
    ans += lp[i]*((ll)(i-m2)*(ll)(m4-m3)+(ll)(m3-i)*(ll)(m2-m1));
    st.insert(i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 5760
n = int(input())
a, b = 0, 0
for i in range(n):
    s1, s2 = input().split()
    if s1 < s2:
        b += 3
    elif s1 > s2:
        a += 3
    else:
        a += 1
        b += 1
print(a, b)


Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray()[0];
            var am = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var sum = am.Sum();
            Console.WriteLine(N-sum<0?-1: N - sum);
        }
    }
}

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

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

    int rec1 = a * b;
    int rec2 = c * d;

    cout << (rec1 >= rec2 ? rec1 : rec2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	float a,b,c;
	cin>>a>>b>>c;
	
	for(int i=1;i<10000;i++){
		for(int j=0;j<10000;j++){
			if(a*i==b*j+c){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;

long long n,k;

void solve(){
    int i,j;
    string str;
    cin >> n >> k;
    vector<int> a(n);
    for(i = 0;i < n;i++) cin >> a[i];
    vector<int> tj(n);
    vector<int> ta(200001,-1);
    for(i = 0;i < n;i++){
        ta[a[i]] = i;
    }
    for(i = 0;i < n;i++){
        if(ta[a[i]] < i) tj[ta[a[i]]] = i;
        else tj[ta[a[i]]] = n+i;
        ta[a[i]] = i;
    }
    //for(i = 0;i < n;i++) cout << tj[i] << endl;
    vector<int> tn(n);
    for(i = n-1;i >= 0;i--){
        if(tj[i] >= n-1) tn[i] = tj[i];
        else tn[i] = tn[tj[i]+1];
    }
    //for(i = 0;i < n;i++) cout << tn[i] << endl;
    vector<int> tk;
    i = 0;
    tk.push_back(0);
    do{
        if(i == n) i = 0;
        else{
            i = tn[i]+1;
            if(i>=n) i -= n;
        }
        tk.push_back(i);
        //cout << i << endl;
    }while(i != 0);
    //for(i = 0;i < tk.size();i++) cout << tk[i] << endl;
    long long k2 = k%(tk.size()-1);
    vector<int> ans;
    if(k2 != 0){
        for(i = tk[k2-1];i < n;i++){
            //cout << tj[i] << endl;
            if(tj[i] < n){
                i = tj[i];
            }
            else{
                ans.push_back(a[i]);
            }
        }
    }
    for(i = 0;i < ans.size();i++) cout << ans[i] << ' ';
    cout << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m];
	int sum=0;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	if(n>=sum)
	{
		cout<<(long long)n-sum;
	}
	else
	cout<<-1;
	return 0;
}

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

using ll=long long;



void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(a*10+b+c,max(a+b*10+c,a+b+c*10))<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);

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

    ll sum = 0;

    for(int i=0;i<n;i++){
        sum += min(a[i],b[i]);
        if(b[i] > a[i]){
            b[i] -= a[i];
            sum += min(b[i],a[i+1]);
            a[i+1] -= min(b[i],a[i+1]);
        }
    }

    cout << sum << endl;
    return 0;
}

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

const int MAX_N = 100;
const int MAX_W = 10000;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_W+1];

int main(void) {
    int N, W; cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];

    int ans = 0;
    fill(dp, dp+W+1, -1);
    dp[0] = 0;
    for (int i = 0; i <= W; i++) {
        for (int j = 0; j < N; j++) {
            if (i-w[j] < 0) continue;
            dp[i] = max(dp[i], dp[i-w[j]]+v[j]);
            ans = max(ans, dp[i]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3144
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))


Measured memory_bytes: 5604
use std::io;
use std::mem;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn mod_add(a:&u64, b:&u64, m:&u64) -> u64 {
    (*a%*m + *b%*m)%*m
}

fn mod_sub(a:&u64, b:&u64, m:&u64) -> u64 {
    let mut ret = (*a%*m) as i64 - (*b%*m) as i64;
    if ret < 0 {
        ret += *m as i64;
    }
    ret as u64
}

fn mod_mul(a:&u64, b:&u64, m:&u64) -> u64 {
    ((*a%*m)*(*b%*m))%m
}

fn mod_pow(a:&u64, b:&u64, m:&u64) -> u64 {
    let mut ret:u64 = 1;
    let mut aa = *a%*m;
    let mut bb = *b;
    while bb != 0 {
        if bb&(1_u64) == 1 {
            ret = (ret*aa)%*m;
        }
        aa = (aa*aa)%*m;
        bb >>= 1;
    }
    ret
}

fn mod_inv(a:&u64, p:&u64) -> u64 {
    // aのmod p における逆元を求める
    let mut aa = *a;
    let mut b = *p;
    let mut u:i64 = 1;
    let mut v:i64 = 0;
    while b != 0 {
        let t = aa/b;
        aa = aa - t*b;
        mem::swap(&mut aa, &mut b);
        u = u - (t as i64) * v;
        mem::swap(&mut u, &mut v);
    }
    u = u % (*p as i64);
    if u < 0 {
        u += (*p as i64);
    }
    u as u64
}

fn mod_div(a:&u64, b:&u64, m:&u64) -> u64 {
    let mut ret = *a%*m;
    let inv = *b%*m;
    ret = (ret * mod_inv(&inv, m))%*m;
    ret
}

fn COMinit(fac:&mut Vec<u64>, finv:&mut Vec<u64>, inv:&mut Vec<u64>, memMax:u64, m:&u64){
    fac.push(1); fac.push(1); 
    finv.push(1); finv.push(1); 
    for i in 2..memMax as usize {
        fac.push((fac[i-1]*(i as u64))%*m);
        inv.push(*m - ((inv[(*m as usize)%i] * (*m/(i as u64)) )%*m) );
        finv.push( (finv[i-1]*(inv[i]) ) % *m );
    }
}

fn comb(n:&u64, k:&u64, m:&u64, fac:&Vec<u64>, finv:&Vec<u64>) -> u64 {
    if *n < *k {
        return 0
    }
    fac[*n as usize] * ((finv[*k as usize]*finv[(*n - *k) as usize] )%*m) % *m
}

fn main() {
    let n:u64 = procon_read()[0];
    let m:u64 = 1000000007;// 10⁹ +7
    let mut ans = mod_pow(&10_u64, &n, &m);
    ans = mod_sub(&ans, &mod_pow(&9_u64, &n, &m), &m);
    ans = mod_sub(&ans, &mod_pow(&9_u64, &n, &m), &m);
    ans = mod_add(&ans, &mod_pow(&8_u64, &n, &m), &m);
    println!("{}", ans);
}

Measured memory_bytes: 2120