akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意MOD = 10**9+7

h,w,k = [int(i) for i in readline().split()]
MOD = 10**9+7

num =[0]*(w-1)
total = 0
for i in range(1<<(w-1)):
    for j in range(w-2):
        if ((i>>j)&1) & ((i>>(j+1))&1): break
    else:
        total += 1
        for j in range(w-1):
            if ((i>>j)&1): num[j] += 1



#dp[i][j] iまで見て位置j
dp = [[0]*(w) for i in range(h+1)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        r=l=0
        if j < w-1: r = num[j]
        if j: l = num[j-1]

        if r:
            dp[i+1][j+1] += r*dp[i][j]
            dp[i+1][j+1] %= MOD
        dp[i+1][j  ] += (total-r-l)*dp[i][j]
        dp[i+1][j  ] %= MOD
        if l:
            dp[i+1][j-1] += l*dp[i][j]
            dp[i+1][j-1] %= MOD

#print(dp)
#print(total, num)
print(dp[-1][k-1])










Measured memory_bytes: 3064
from math import gcd
n = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(n):
    L.append(gcd(L[-1], A[i]))
R = [0]
for i in range(n):
    R.append(gcd(R[-1], A[-i-1]))
R = R[::-1]
ans = 0
for i in range(n):
    ans = max(ans, gcd(L[i],R[i+1]))
print(ans)

Measured memory_bytes: 21512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    ll H,N,sum=0;
    cin >> H >> N;
    vector<ll> a(N);
    rep(i,N){
        cin >> a.at(i);
        sum+=a.at(i);
    }
    
    if(sum >= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int n, a[100100], dp[100100];

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

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for (int i = 1; i <= n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(a[i]-a[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(a[i]-a[i+2]));
    }
    cout << dp[n];

}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy";
  if(s=="Cloudy")
    cout<<"Rainy";
  if(s=="Rainy")
    cout<<"Sunny";
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll A, B;
    cin >> A >> B;

    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3636
import kotlin.math.*
import java.util.*

const val mod = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun sqrt(x: Long) = sqrt(x.toDouble()).toLong()

data class Power(val base: Long, val exp: Int)

fun pfactor(n: Long): List<Power> {
  val factors = mutableListOf<Power>()
  var m = n
  var p = 2L
  var e = 0
  while (m % p == 0L) {
    m /= p
    e++
  }
  if (0 < e) factors += Power(p, e)
  p = 3
  var pmax = sqrt(m)
  while (m != 1L && p <= pmax) {
    e = 0
    while (m % p == 0L) {
      m /= p
      e++
    }
    if (0 < e) {
      factors += Power(p, e)
      pmax = sqrt(m)
    }
    p += 2
  }
  if (m != 1L) factors += Power(m, 1)
  return factors
}

fun main(args: Array<String>) {
  var n = readL()
  var ans = 0L
  for (pf in pfactor(n)) {
    var e = pf.exp
    var i = 0
    while (0 < e) {
      i++
      e -= i
    }
    ans += if (e < 0) i - 1 else i
  }
  println(ans)
}


Measured memory_bytes: 34600
#include <stdio.h>

int main(){
	int a,b[3],c,i,j,k,l;
	scanf("%d",&a);
	for(l=0;l<a;l++){
		scanf("%d %d %d",&b[0],&b[1],&b[2]);
		for(j=0;j<3;j++){
			for(k=0;k<2;k++){
				if(b[k]<=b[k+1]){
					c=b[k];
					b[k]=b[k+1];
					b[k+1]=c;
				}
			}
		}
		for(i=0;i<3;i++){
			b[i]=b[i]*b[i];
		}
		if(b[0]==b[1]+b[2]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;

typedef pair<int, int> P;

int sx, sy, tx, ty;
char dir[4] = {'U', 'D', 'L', 'R'};
bool flag = true;

int main() {
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  int dx, dy;
  dx = tx - sx; dy = ty - sy;
  int count = 0;

  while(count < 2) {
    for (int i = 0; i < dx; i++) {
      if (count == 0) {
        printf("R");
      } else {
        printf("L");
      }
    }
    for (int i = 0; i < dy; i++) {
      if (count == 0) {
        printf("U");
      } else {
        printf("D");
      }
    }
    count++;
  }

  count = 0;
  dx++; dy++;

  while (count < 2) {

    if (count == 0) {
      printf("D");
    } else {
      printf("U");
    }

    for (int i = 0; i < dx; i++) {
      if (count == 0) {
        printf("R");
      } else {
        printf("L");
      }
    }

    for (int i = 0; i < dy; i++) {
      if (count == 0) {
        printf("U");
      } else {
        printf("D");
      }
    }

    if (count == 0) {
      printf("L");
    } else {
      printf("R");
    }

    count++;
  }

  cout << endl;
}


Measured memory_bytes: 256
import sys
import bisect

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    r = []
    g = []
    b = []
    for i, s in enumerate(S):
        if s == "R":
            r.append(i)
        elif s == "G":
            g.append(i)
        else:
            b.append(i)
    setr = set(r)
    setg = set(g)
    setb = set(b)
    ans = len(r) * len(g) * len(b)

    for i in r:
        for j in range(N):
            if i + j in setg and i + j + j in setb:
                ans -= 1
            if i + j in setb and i + j + j in setg:
                ans -= 1
    for i in g:
        for j in range(N):
            if i + j in setr and i + j + j in setb:
                ans -= 1
            if i + j in setb and i + j + j in setr:
                ans -= 1
    for i in b:
        for j in range(N):
            if i + j in setr and i + j + j in setg:
                ans -= 1
            if i + j in setg and i + j + j in setr:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68744
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main(){
	int n, l[2000],ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++)cin >> l[i];
	for(int i = 0; i < n - 2; i++){
		//cout << l[i] << " ";
		
	for(int j = i+1; j < n - 1; j++){
		//cout << l[j] << " ";
		
	for(int k = j+1; k < n; k++){
		//cout << l[i] << " " << l[j] << " " << l[k] << endl;
		//cout << i << " " << j << " " << k << endl;
		
	if(l[i] < l[j] + l[k] && l[j] < l[i] + l[k] && l[k] < l[j] + l[i])ans++;
		}
		}
		}
	cout << ans << endl;
	}


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

int main(){
    int a,b,c,d;
    if(scanf("%d",&a)==1);
    if(scanf("%d",&b)==1);
    if(scanf("%d",&c)==1);
    if(scanf("%d",&d)==1);

    int flag=0;
    if(abs(a-c)<=d)flag=1;
    if(abs(a-b)<=d && abs(c-b)<=d) flag=1;

    if(flag==1)printf("Yes\n");
    else printf("No\n");

}

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

int main()
{
	string s[100];
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
	{
		cin >> s[i];
	}
	for (int i = -1; i < h + 1; ++i)
	{
		for (int j = -1; j < w+1; ++j)
		{
			if (i == -1 || i == h || j == -1 || j == w)
			{
				cout << "#";
			}
			else
			{
				cout << s[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

using namespace std;
//using bint = boost::multiprecision::cpp_int;
typedef uint64_t ulint;
typedef int64_t lint;

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);


bool flagdebug = false;


int main(){
//////////////////////////////////////////////////////

    flagdebug = true; ///本番時削除！！！！！

    //入力

    lint h, w, a, b;
    cin >> h >> w >> a >> b;

    //vector<lint> s(n);
    if(w >= a * 2 && h >= b * 2)
    {
        rep1(i, h)
        {
            rep1(j, w)
            {
                if(j <= a && i <= b || j > a && i > b)
                {
                    cout << "1";
                }
                else
                {
                    cout << "0";
                }
            }
            cout << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }





    //2次元配列
    //vector<vector<lint>> mat(row, vector<lint>(column, 初期値));
    //ペア
    //pair<lint,lint> p = make_pair(1,2);
    //vector<pair<lint,lint>> c(100010, pair<lint,lint>(0,0));
    //タプル
    //tuple<lint,lint,lint> t  = make_tuple(1,2,3);


    //昇順ソート
    //sort(all(a));
    //降順ソート
    //sort(all(a),greater<lint>());
    //特殊なソート（ラムダ式）
    //sort(all(mat), [&i](const vector<lint> &a, const vector<lint> &b){return a[i] < b[i];});
    // //[&i]は参照する変数，いらなければからの大括弧でよし．
    
    //////////////////////////////////////////////////////
    //キュー
    //queue<lint> que;
    //que.push(value);
    //que.front(); //先頭を参照
    //que.top(); //トップを参照（消されないので消したい場合は直後にpop()を使う）
    //que.pop(); //追い出す
    //que.empty(); //空なら1，あれば0
    //優先度付きキュー
    //priority_queue<lint> que;
    //キューにque.push()で入れると最大値順に並べられる．que.pop()で取り出すときは常に最大値が前にくる．
    //最小値から取り出したい時はpriority_queue< lint, std::vector<lint>, std::greater<lint> >
    //////////////////////////////////////////////////////
    //スタック
    //stack<lint> stk;
    //stk.push(value);
    //stk.top(); //先頭を参照（消されないので消したい場合は直後にpop()を使う）
    //stk.pop(); //トップを削除
    //stk.empty(); //空なら1,あれば0
    //stk.size(); //数
    //
    // sort(input.begin() , input.end());
    // uint64_t max = numeric_limits<uint64_t>::max();

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int n;
	cin >> n;
	string s;
	double res;
	double ans = 0;
	cu(i,0,n){
		cin >> res;
		cin >> s;
		if(s == "JPY"){
			ans += res;
		}
		else{
			ans += 380000.0 * res;
		}
	}
	cout.precision(19);
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string str[105];
int w,h;

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++)cin >> str[i];

    for(int i=0;i<h;i++)cout << str[i] << endl << str[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<", ";cout<<a.back()<<']'<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

int comb(int n, int r){  //  nCr (MOD環境下)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}

int f(int h,int w){
  return comb(h+w,h);
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  int ans = 0;
  
  int st1=f(H-A-1,B),st2=f(A-1,W-1-B);
  int qw=B+(H-A-1)+1,er=qw-(H-A-1),ty=(A-1)+(W-B-1),ui=ty-(A-1);
  //cout<<qw<<' '<<er<<' '<<ty<<' '<<ui<<' '<<endl;
  //cout << st1 << ' '<< st2<<endl;
  
  rep(i,0,W-B){
    ans += st1 * st2;
    ans %= MOD;
    
    st1 = st1*qw%MOD;
    st1 = st1*mypow(er,MOD-2,MOD)%MOD;
    st2 = st2*ui%MOD;
    st2 = st2*mypow(ty,MOD-2,MOD)%MOD;
    qw++,er++,ty--,ui--;
  }
  
  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 repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n;
    cin >> n;
    cout << pow(n,3) << "\n";
}




Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

// ?????????????´????????????§???
ll MAX_ELEM = 2000000;

void CountingSort(int* A, int n, int* Ans)
{
	vector<int> C(MAX_ELEM,0);
	REP(i,n)
	{
		C[A[i]]++;

	}
	
	FOR(i,1,MAX_ELEM)
	{
		C[i] = C[i-1] + C[i];
	}

	FORR(i, n-1, 0)
	{
		Ans[C[A[i]]-1] = A[i];
		C[A[i]]--;
	}
}

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int *A = new int[2000001];
	REP(i,n) 
	{
		cin >> A[i];
	}
	int *Ans = new int[2000001];
	CountingSort(A, n, Ans);
	
	REP(i,n-1) cout << Ans[i] << " ";
	cout << Ans[n-1] << endl;
	delete[] A;
	delete[] Ans;
	return 0;
}

Measured memory_bytes: 26168
T = int(input())

while(T > 0):
    N, A, B, C, D = map(int, input().split())
    dp = {}

    def d(n):
        if n == 0:
            return 0
        if n == 1:
            return D

        if n in dp:
            return dp[n]

        ret = min(
            D * n,
            D * abs(n - (n // 2) * 2) + A + d(n // 2),
            D * abs(n - ((n+1) // 2) * 2) + A + d((n+1) // 2),
            D * abs(n - (n // 3) * 3) + B + d(n // 3),
            D * abs(n - ((n + 2) // 3) * 3) + B + d((n + 2) // 3),
            D * abs(n - (n // 5) * 5) + C + d(n // 5),
            D * abs(n - ((n + 4) // 5) * 5) + C + d((n + 4) // 5),
        )

        dp[n] = ret
        return ret

    print(d(N))
    T -= 1

Measured memory_bytes: 11000
#include<algorithm>
#include<iostream>

using namespace std;
const int N = 1000;
const int M = 10e4;
int a[N];
int divisor[M];

int cal_divisor(int n){
  int i = 1;
  int num_divisor = 0;
  while(i * i <= n){
    if(n % i == 0){
      divisor[num_divisor] = i;
      divisor[num_divisor + 1] = n / i;
      num_divisor += 2;
    }
    i++;
  }

  return num_divisor;
}

bool constraint_check(int d, int n, int k){
  int up[N], down[N];
  int change = 0;
  int sumup = 0;
  int sumdown = 0;
  for (int i = 1; i <=n; ++i ){
    if(a[i] % d != 0){
      up[change] = a[i] % d;
      down[change] = d - up[change];
      sumup += up[change];
      sumdown += down[change];
      change++;
    }
  }

  int numup = sumup / d;
  int numdown = sumdown / d;
  sort(up, up + change);
  sort(down, down + change);

  int totalup = 0;
  int totaldown = 0;
  for (int i = 0; i < change - numup; ++ i){
    totalup += up[i];
  }

  for (int i = 0; i < change - numdown; ++i){
    totaldown += down[i];
  }

  //cout << totalup << " " << totaldown << endl;
  if (totalup <= k){
    return true;
  }
  return false;
}

int main(){
  int n,k;
  int sum = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i){
    cin >> a[i];
    sum += a[i];
  }

  int result = 1;
  int num_divisor = cal_divisor(sum);
  for (int i = 0; i < num_divisor; ++ i){
    //cout << divisor[i] << endl;
    if(constraint_check(divisor[i],n,k)){
      result = max(result, divisor[i]);
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	map<string,long long int>m;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}
	for (auto i : m) {
		K += (i.second*(i.second - 1)) / 2;
	}
	cout << K << endl;
}



Measured memory_bytes: 11264
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  int ans = 0;
  map<int, int> m;
  m[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i) a[i] += a[i - 1];
    ans += m[a[i]];
    m[a[i]]++;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int a, b;

void init()
{
	cin >> a >> b;
}

void solve()
{
	int res = b;
	rep(i, a-1) res *= b-1;
	cout << res << endl;
}



Measured memory_bytes: 256
from itertools import *

def mlist(n, *args, **keys):
    if args:
        return [mlist(*args, **keys) for i in range(n)]
    else:
        return [keys.get('default')] * n

for h in count(1):
    w = int(raw_input())
    if w == 0: break
    n = int(raw_input())
    a, b = zip(*[map(int, raw_input().split(',')) for i in range(n)])
    c = mlist(1010, 1010)
    c[0][0] = 0
    for i in range(n):
        for j in range(w + 1):
            if c[i][j] is None: continue
            c[i + 1][j] = max(c[i + 1][j], c[i][j])
            if j + b[i] <= w:
                c[i + 1][j + b[i]] = max(c[i + 1][j + b[i]], c[i][j] + a[i])
    mx = max(c[n])
    print 'Case {}:'.format(h)
    print mx
    print c[n].index(mx)

Measured memory_bytes: 20860
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int a,b;cin>>a>>b;
    cout<<(a+b)/2<<endl;
    return 0;
}


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

int main() {
  
  string N;
  cin >> N;
  
  bool a = true;
  for(int i = 0; i < N.size(); i++){
    if(N.at(i) == '9'){
      cout << "Yes" << endl;
      a = false;
      break;
    }
  }
    
  if(a){
    cout << "No" << endl;
  }
    
    
    
}


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

int lcs(string &X, string &Y)
{
	static int Z[1001][1001];
	int m = X.size();
	int n = Y.size();
	int i, j;

	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++) {
			if (X[i - 1] == Y[j - 1])
				Z[i][j] = Z[i - 1][j - 1] + 1;
			else
				Z[i][j] = max(Z[i - 1][j], Z[i][j - 1]);
		}
	}
	return Z[m][n];
}

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

	string X, Y;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> X >> Y;
		cout << lcs(X, Y) << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        _n: usize,
        s: Chars,
    }
    let res = 1_000_000_007;
    let mut ans = 1;
    let mut count = vec![0; 26];
    for &c in &s {
        count[c as usize - 'a' as usize] += 1;
    }
    for i in 0..26 {
        if count[i] != 0 {
            ans = ans * (count[i] + 1) % res as u64;
        }
    }
    ans -= 1;
    println!("{}", ans);
}


Measured memory_bytes: 2496
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
'''
a = [0] * (10 ** 5)
for i in range(m):
    a[int(input())] = 1
'''

MOD = 10 ** 9 + 7
# ---------------------------
dp = [0] * (n + 1)
dp[0] = 1
if (1 in a):
    # if (a[1] == 1):
    dp[1] = 0
else:
    dp[1] = 1
# dp approach

for i in range(2, n + 1):
    if (i in a):
        # if (a[i] == 1):
        # (x in list)で探索すると、時間がかかるっぽい
        #dp[i] = 0
        continue
    elif (dp[i - 1] == 0 and dp[i - 2] == 0):
        print(0)
        exit()
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD


#print(dp[n] % MOD)
print(dp[n])


Measured memory_bytes: 13192
N,X = map(int,input().split())
L = list(map(int,input().split()))
L.insert(0,0)
D = [0 for _ in range(N+2)]
cnt = 1
for i in range(2,N+2):
    D[i] = D[i-1]+L[i-1]
    if D[i]<=X:
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int N = int.Parse(str);
        int[] a = new int[N];
        string[] stra = Console.ReadLine().Split(' ');

        for(int i = 0; i < N; i++){
            a[i] = int.Parse(stra[i]);
        }

        Array.Sort(a);
        Console.WriteLine(a[N - 1] - a[0]);
    }
}



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

ll f(ll x){
	if(x%2)return x%4==1;
	return x+(x%4)/2;
}

int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(f(a-1)^f(b))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
	ios;
	ll n,ans;
	cin>>n;
	if(n%2==0) {
		ans=n/2;
		ans*=(n-1);
	}
	else {
		ans=(n-1)/2;
		ans*=n;
	}
	cout<<ans;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	int count5=0,count7=0;
	if(A==5)
	{
		count5++;
	}
	else if(A==7)
	{
		count7++;
	}
	if(B==5)
	{
		count5++;
	}
	else if(B==7)
	{
		count7++;
	}
	if(C==5)
	{
		count5++;
	}
	else if(C==7)
	{
		count7++;
	}
	if(count5==2&&count7==1)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int num=0;
    char ch=getchar();
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)) num*=10,num+=ch-48,ch=getchar();
    return num;
}
int main()
{
	int n=read();
	for(int i=1; i<=n; i++) printf("ACL");
	
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
#include<algorithm>
#include<math.h>

using namespace std;

int x[10], y[10];
int order[10];

int main() {
  int n;
  
  scanf("%d", &n);
  
  for(int i=0; i<n; i++) scanf("%d%d", &x[i],&y[i]);
  for(int i=0; i<n; i++) order[i] = i;
  
  double allSum = 0.0;
  int count = 0;
  
  do {
    double curSum = 0.0;
    for(int i=1; i<n; i++) {
      int curX = x[order[i]] - x[order[i-1]];
      int curY = y[order[i]] - y[order[i-1]];
      double dist = sqrt( curX*curX + curY*curY);
      curSum += dist;
    }
    allSum += curSum;
    count++;
  } while(next_permutation(order,order+n));
  printf("%.10lf\n", allSum / (double)count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

lli get(lli x,lli p){
    lli ans=0;
    while(x){
        ans+=x/p;
        x/=p;
    }
    return ans;
}

void solve(){
    lli n;cin>>n;
    if(n%2){
        cout<<0<<endl;
    }else{
        cout<<get(n/2,5)<<endl;
    }
}   

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
#include<climits>
#include<queue>
using namespace std;
#define MAXN 100000
int A,ans;
int main()
{
    scanf("%d",&A);
    int ans=A;
    for(int i=0;i<=A;i++)
    {
        int cont=0;
        int t=i;
        while(t>0)cont+=t%6,t/=6;
        t=A-i;
        while(t>0)cont+=t%9,t/=9;
        ans=min(ans,cont);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MaxN = 1000;
struct Point {
	int x, y;
}a[MaxN + 5], b[MaxN + 5];
bool vis[MaxN + 5];

bool cmp(Point A, Point B) {return A.x < B.x;}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i].x, &a[i].y);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &b[i].x, &b[i].y);
	}
	memset(vis, 0, sizeof(vis));
	int ans = 0;
	sort(a + 1, a + n + 1, cmp);
	for (int i = n; i >= 1; i--) {
		pair <int, int> MiN = make_pair(1 << 30, -1);
		for (int j = 1; j <= n; j++)
			if (!vis[j] && b[j].x > a[i].x && b[j].y > a[i].y) {
				if (b[j].y < MiN.first) {
					MiN.first = b[j].y;
					MiN.second = j;
				}
			}
		if (MiN.second != -1) ans++, vis[MiN.second] = true;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int h,w;
    int n;
    std::cin >> h>>w>>n;
    VEC(int,a,n);
    int counter=0,k=0;
    vvector(aa,int,w,h,0);
    rep(j,h){
        if(j%2==0){
            rep(i,w){
            
            if(a[k]<=counter){
                k++;
                counter=0;
            }
            aa[i][j]=k+1;
            counter++;  
            //std::cout << a[k]<<" " ;//<< std::endl;
            }
            
            std::cout  << std::endl;
        }else{
            rep(i,w){
           // counter++;
            if(a[k]<=counter){
                k++;
                counter=0;
            }
            //std::cout << a[k]<<" " ;//<< std::endl;
            aa[w-i-1][j]=k+1;
            counter++;    
            }
        //    std::cout  << std::endl;
        }
        
        
    }
    rep(j,h){
        rep(i,w){
            std::cout << aa[i][j]   <<" ";       
        }
        std::cout  << std::endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N;
  string S;
  cin >> N >> S;
  ll ans = 0;
  for(ll i=0; i<N-2; i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (!(x % 3)) {
            cout << ' ' << i;
        } else {
            while (x) {
                if ((x % 10) == 3) {
                    cout << ' ' << i;
                    break;
                } else {
                    x /= 10;
                }
            }
        }
        if (i == n) cout << endl;
    }
}


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

int main() {
    string s;
    char t[20];
    cin >> s;
    stack<char> stk;

    int j = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0' or s[i] == '1') t[j++] = s[i];
        else {
            if (j > 0) j--;
        }
    }
    for (int i = 0; i < j; i++) cout << t[i];
    cout << endl;
}

Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

char c;

int main() {

	cin >> c;


	if (c >= 'a' && c <= 'z')
		cout << 'a' << endl;
	else
		cout << 'A' << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<N;i++){
    if(s[i]!='.')continue;
    bool l=false,r=false;
    for(int j=i-1;j>=0;j--){
      if(s[j]=='B')l=true;
      if(s[j]=='.')break;
    }
    for(int j=i+1;j<N;j++){
      if(s[j]=='B')r=true;
      if(s[j]=='.')break;
    }
    if(l&&r)continue;
    int lcnt=0,rcnt=0;
    for(int j=i-1;j>=0;j--){
      if(s[j]=='B')lcnt++;
      if(s[j]=='W'){lcnt*=1000;break;}
      if(s[j]=='.'){lcnt=0;break;}
    }
    for(int j=i+1;j<N;j++){
      if(s[j]=='B')rcnt++;
      if(s[j]=='W'){rcnt*=1000;break;}
      if(s[j]=='.'){rcnt=0;break;}
    }
    ans=max(ans,lcnt/1000+rcnt/1000);
  }
  fin(ans);
}



Measured memory_bytes: 3184
n,m = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
abSorted = sorted(ab)
sum = 0
sumMoney = 0
i = 0
while sum + abSorted[i][1] < m:
    sum += abSorted[i][1]
    sumMoney += abSorted[i][0] * abSorted[i][1]
    i += 1
sumMoney += abSorted[i][0] * (m - sum)
print(sumMoney)

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

int main() {

  ll A, B;
  cin >> A >> B;
  ll ans = 1;
  ll x = A;
  while(x<=B) {
    x *= 2;
    ans++;
  }
  ans--;
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,i1,len,len1,check,max1,memo1,max2,memo2;
	max1 = 0;
	max2 = 0;
	memo1 = 0;
	memo2 = 0;
	string t;
	vector<string> s;
	vector<int> a,u;
	for (int h = 0; h < 500; h++) {
		u.push_back(0);
	}
	while (cin >> t) {
		check = 0;
		len = s.size();
		for (i = 0; i < len; i++) {
			if (t == s[i]) {
				u[i] += 1;
				check = 1;
			}
		}
		if (check == 0) {
			s.push_back(t);
			len1 = t.size();
			a.push_back(len1);
		}
	}
	len = s.size();
	for (i1 = 0; i1 < len; i1++) {
		while (max1 < u[i1]) {
			max1 = u[i1];
			memo1 = i1;
		}
	    while (max2 < a[i1]) {
			max2 = a[i1];
			memo2 = i1;
		}
	}
	cout << s[memo1] << " " << s[memo2] << endl;
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <string.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const double pi=acos(-1.0);
int main()
{
  fio;
  int n;
  cin>>n;
  int a=0,b=0,c=0,d=0;
  string s;

  for (int i=0 ; i<n ; i++)
  {
    cin>>s;
    if (s=="AC")
    {
      a++;
    }
    else if(s=="WA")
    {
      b++;
    }
    else if(s=="TLE")
    {
      c++;
    }
    else if(s=="RE")
    {
      d++;
    }
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
  return 0;
}

Measured memory_bytes: 3656
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

A, B, C, D = list(map(int, input().split()))
lcm = int(C * D / gcd(C, D))

num_lesser_than_A_non_dividable_by_C = (A - 1) - (A - 1) // C
num_lesser_than_A_non_dividable_by_D = (A - 1) - (A - 1) // D
num_lesser_than_A_non_dividable_by_C_or_D = (A - 1) - (A - 1) // lcm
num_lesser_than_A_dividable_by_C_nor_D = num_lesser_than_A_non_dividable_by_C + num_lesser_than_A_non_dividable_by_D - num_lesser_than_A_non_dividable_by_C_or_D
num_not_larger_than_than_B_non_dividable_by_C = B - B // C
num_not_larger_than_than_B_non_dividable_by_D = B - B // D
num_not_larger_than_than_B_non_dividable_by_C_or_D = B - B // lcm
num_not_larger_than_than_B_dividable_by_C_nor_D = num_not_larger_than_than_B_non_dividable_by_C + num_not_larger_than_than_B_non_dividable_by_D - num_not_larger_than_than_B_non_dividable_by_C_or_D
print(num_not_larger_than_than_B_dividable_by_C_nor_D - num_lesser_than_A_dividable_by_C_nor_D)

Measured memory_bytes: 3064
n = int(input())
ar = list(map(int,input().split()))
su = [0]*n
su[0]=ar[0]
for i in range(1,n):
    su[i] = ar[i] + su[i-1]

# +
ans1,off = 0,0
for i in range(0,n):
    if i%2 == 0:
        if su[i] + off <= 0:
            ans1 += 1-(su[i]+off)
            off += 1-(su[i]+off)
    else:
        if su[i] + off >= 0:
            ans1 += (su[i]+off+1)
            off -= (su[i]+off+1)

# -
ans2,off = 0,0
for i in range(0,n):
    if i%2 != 0:
        if su[i] + off <= 0:
            ans2 += 1-(su[i]+off)
            off += 1-(su[i]+off)
    else:
        if su[i] + off >= 0:
            ans2 += (su[i]+off+1)
            off -= (su[i]+off+1)
print(min(ans1,ans2))


Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
 
  int N;
in(N);
  int ans =0;
vl v(N),c(N);
  rep(i,N)in(v[i]);
  rep(i,N)in(c[i]);
  rep(i,N){
	if(v[i] > c[i]) ans += (v[i] - c[i]);
    
  }
  out(ans);
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll r,ans;
  cin >> r;
  ans = r*r*3;
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main(void)
{
    string s;
    cin >>s;

    for(int i = 0; i < s.size(); i++){
        printf("x");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
/*
2020-04-25
atcoder ABC
C - Fennec vs Monster
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, K;
    ll ans = 0;
    cin >> N >> K;
    vector<ll> hps(N);
    for(int i = 0; i < N; i++) {
        cin >> hps[i];
    }
    sort(hps.begin(), hps.end());

    for(int i = 0; i < N - min(N, K); i++) {
        ans += hps[i];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*101;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()


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

	int n, p;
	cin >> n >> p;
	vi s(n);
	for(int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		s[i] = ch - '0';
	}
	vi cum_mod(n);
	cum_mod[n - 1] = s[n - 1] % p;
	int power = 1;
	for(int i = n - 2; i >= 0; i--) {
		power = power * 10 % p;
		cum_mod[i] = (cum_mod[i + 1] + s[i] * power) % p;
	}
	ll ans = 0;
	if(p == 2 || p == 5) {
		for(int i = 0; i < n; i++) {
			if(s[i] % p == 0) {
				ans += i + 1;
			}
		} 
	}
	else {
		vi mod_cnt(p);
		mod_cnt[cum_mod[n - 1]] = 1;
		for(int i = n - 2; i >= 0; i--) {
			ll temp = (mod_cnt[cum_mod[i]])++;
			ans += temp;
		}
		// debugtwo(mod_cnt);
		// trace1(ans);
		ans += mod_cnt[0];
	} 
	cout << ans << endl;
	return 0;
}		


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	size_t N;
    cin >> N;

    vector<ll> P(N);

    rep(i, N) {
        cin >> P[i];
    }

    ll ans{};

    ll mini = P[0];

    rep(i, N) {
        if (mini >= P[i]) {
            ++ans;
            mini = P[i];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 1792