akhauriyash/Code-Regression huggingface dataset:
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val A, B, C, X, Y = sc.nextInt()

    def cost(i: Int) = {
      2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B
    }

    val ans = min(min(cost(0), cost(X)), cost(Y))
    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    (0 until n) foreach f
  }

  private def map[@specialized(Int, Long) A](n: Int)(f: Int => A): Seq[A] = {
    (0 until n) map f
  }
}


Measured memory_bytes: 25536
import numpy as np
N = int(input())
M = 10**9 + 7

P = np.empty((4,4,4),dtype=np.int64)
Q = np.ones((4,4,4),dtype=np.int64)
Q[0,2,1] = Q[2,0,1] = Q[0,1,2] = 0
for n in range(3,N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if (i,j,k) in [(0,2,1), (2,0,1), (0,1,2)]:
                    P[i,j,k] = 0
                elif (j,k) == (2,1) or (i,k) == (2,1):
                    P[i,j,k] = Q[1:,i,j].sum() % M 
                else:
                    P[i,j,k] = Q[:,i,j].sum() % M
    (P, Q) = (Q, P)

print(Q.sum() % M)

Measured memory_bytes: 12424
#include<stdio.h>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
struct edge{
	int from;
	int to;
	string name;
};
edge e[400];
char str[7];
string p[40];
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a){
		for(int i=0;i<b;i++){
			scanf("%d%d%s",&(e[i].from),&(e[i].to),str);
			e[i].name=str;
		}
		for(int i=0;i<a;i++)p[i]="|";
		p[d]="";
		bool ok=false;
		for(int i=0;i<10*a;i++){
			
			//ok=false;
			for(int j=0;j<b;j++)if((p[e[j].to].size()==0||p[e[j].to][0]!='|')&&e[j].name+p[e[j].to]<p[e[j].from]){
				if(i>7*a&&e[j].from==c)ok=true;
				p[e[j].from]=e[j].name+p[e[j].to];
			}
		}
		if(ok||p[c]=="|")printf("NO\n");
		else printf("%s\n",p[c].c_str());
	}
}

Measured memory_bytes: 1976
package main

import "fmt"

func main() {
	var r, d, x int
	fmt.Scan(&r, &d, &x)
	initial := r*x - d
	fmt.Println(initial)
	for i := 1; i < 10; i++ {
		initial = r*initial - d
		fmt.Println(initial)
	}
}


Measured memory_bytes: 512
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define max(x,y)			(x>y)?x:y
#define min(x,y)			(x<y)?x:y
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	string s,t;

	cin>>n>>s>>t;
	
	for(int i=0; i<n; i++)	cout<<s[i]<<t[i];
	cout<<endl;

	return 0;
}



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

using namespace std;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;
}

Measured memory_bytes: 3676
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>

#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;
const int MAX = 10000000;
bool isPrime[MAX];
int main(){
  cin.sync_with_stdio(false);
  fill(isPrime,isPrime+MAX,true);
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i < MAX; ++i){
    if(isPrime[i]){
      for(int j = i*2;j < MAX;j+=i){
	isPrime[j] = false;
      }
    }
  }
  int n;
  while(cin >> n){
    int ans = 0;
    for(int i = 2;i <= n;i++){
      if(isPrime[i])ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
    
string  S,T;
cin >> S>>T ;

if ((S.length()==1) &&(S[0]==T[0])){
cout <<"Yes"<< endl;
}   
else if((S.length()==2) &&(S[0]==T[0])&&(S[1]==T[1])){
cout <<"Yes"<< endl;
}    
else if((S.length()==3) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])){
cout <<"Yes"<< endl;
}
else if((S.length()==4) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])){
cout <<"Yes"<< endl;
}
else if((S.length()==5) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])){
cout <<"Yes"<< endl;
}
else if((S.length()==6) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])&&(S[5]==T[5])){
cout <<"Yes"<< endl;
}
else if((S.length()==7) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])&&(S[5]==T[5])&&(S[6]==T[6])){
cout <<"Yes"<< endl;
}
else if((S.length()==8) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])&&(S[5]==T[5])&&(S[6]==T[6])&&(S[7]==T[7])){
cout <<"Yes"<< endl;
}
else if((S.length()==9) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])&&(S[5]==T[5])&&(S[6]==T[6])&&(S[7]==T[7])&&(S[8]==T[8])){
cout <<"Yes"<< endl;
}
else if((S.length()==10) &&(S[0]==T[0])&&(S[1]==T[1])&&(S[2]==T[2])&&(S[3]==T[3])&&(S[4]==T[4])&&(S[5]==T[5])&&(S[6]==T[6])&&(S[7]==T[7])&&(S[8]==T[8])&&(S[9]==T[9])){
cout <<"Yes"<< endl;
}
else{
cout <<"No"<< endl;     
}
}

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

int main(){
  ll n,k,i,j,p;
  p=1000000007;
  cin >> n >> k;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  ll s=0,t=0;
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(a.at(i)>a.at(j)){
        s++;
      }
    }
  }
  
  s=(s*k)%p;
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(a.at(i)>a.at(j)){
        t++;
      }
    }
  }
  
  t=(t*(k*(k-1)/2%p))%p;
  
  cout << (s+t)%p << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll c[3][3];

int main(){
	bool f = true;
	rep(i,3){
		rep(j,3){
			cin >> c[i][j];
		}
	}
	rep(j,2){
		ll g = c[0][j] - c[0][j+1];
		rep(k,3){
			if(g != c[k][j] - c[k][j+1])f = false;
		}
	}
	rep(i,2){
		ll g = c[i][0] - c[i+1][0];
		rep(k,3){
			if(g != c[i][k] - c[i+1][k])f = false;
		}
	}
	if(f)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
open Printf open Scanf
open Array

let () = scanf " %d %d %d %d" @@ fun r g b n ->
  let res = ref 0 in
  for i=0 to n/r do
    for j=0 to n/g do
      let k = n - i*r - j*g in
      if 0<=k && k mod b = 0 then (
        (* printf "%d %d %d\n"
          i j (k/b); *)
        incr res
      )
    done;
  done;
  print_int @@ !res



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

queue<char> que[3];

int rec(int i){
    if(que[i].empty()) return i;
    char q = que[i].front();
    que[i].pop();
    return rec(q - 'a');
}

int main(){
    for(int i = 0; i < 3; i++){
        string s;
        cin >> s;
        for(int j = 0; j < s.size(); j++){
            que[i].push(s[j]);
        }
    }
    cout << (char)(rec(0) + 'A') << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<long> a(N+1);
  cin>>a.at(1);
  
  long A;
  for(int i=1;i<N;i++){
    cin>>A;
    a.at(i+1)=a.at(i)+A;
  }
  sort(a.begin(),a.end());
  
  long count=0,ans=0,k=a.at(0);
  for(int i=0;i<N+1;i++){
    if(k==a.at(i))count++;
    else{
      ans+=count*(count-1)/2;
      k=a.at(i);
      count=1;
    }
  }
  if(a.at(N)==a.at(N-1))ans+=count*(count-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#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 _GLIBCXX_DEBUG
int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    bool can=true;
    rep(i,n){
        if(!(a[i]%2)){
            if(((a[i]%3)!=0)&&((a[i]%5)!=0)){
                can=false;
                break;
            }
        }
    }
    if(can)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

ll dp[100005][2];

int main() {
    string s;cin >> s;
    int n = s.size();

    memset(dp,0,sizeof(dp));
    dp[0][0]=1;

    REP(i,n){
        // a+bのi桁目を0にする
        if(s[i]=='0'){
            // Lのi桁目も0の場合、一致と未満はそれぞれそのまま遷移する
            addM(dp[i+1][0],dp[i][0]);
            addM(dp[i+1][1],dp[i][1]);
        } else {
            // Lのi桁目が1の場合、一致と未満は両方とも未満側に遷移する
            addM(dp[i+1][1],(dp[i][0]+dp[i][1])%MOD);
        }

        // a+bのi桁目を1にする
        if(s[i]=='0'){
            // Lのi桁目が0の場合、一致は遷移先にないが、未満はaとbのどっちを１にするかで二通りの遷移がある            
            addM(dp[i+1][1],dp[i][1]*2%MOD);
        } else {
            // Lのi桁目も0の場合、一致と未満はそれぞれ二通り遷移する
            addM(dp[i+1][0],dp[i][0]*2%MOD);
            addM(dp[i+1][1],dp[i][1]*2%MOD);
        }
    }

    pl((dp[n][0]+dp[n][1])%MOD)

    return 0;
}

Measured memory_bytes: 2048
while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

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

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

	int N;
	scanf("%d", &N);

	int u, v, w;
	vector<vector<pair<int, bool>>> edge(N + 1, vector<pair<int, bool>>());
	vector<int> color(N + 1, -1);

	for (int i = 0; i < N - 1; i++)
	{
		scanf("%d %d %d", &u, &v, &w);
		bool isodd = (w % 2 == 1);
		edge[u].insert(edge[u].end(), make_pair(v, isodd));
		edge[v].insert(edge[v].end(), make_pair(u, isodd));
	}

	stack<int> st;
	int n;
	st.push(1);
	color[1] = 0;
	while (st.size() > 0)
	{
		n = st.top();
		st.pop();
		for (auto i : edge[n])
		{
			if (color[i.first] == -1)
			{
				// cout << color[n] << " " << i.second << "\n";
				color[i.first] = color[n] ^ i.second;
				// cout << i.first << "is" << color[i.first] << "\n";
				st.push(i.first);
			}
		}
	}

	for (int i = 1; i <= N; i++)
	{
		cout << color[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>
#define pll vector<pair<ll,ll>>
#define debug(x) cout<<x<<endl

ll n,k,arr[100];

ll store[1000001];


bool func(ll v)
{
    if(v==0) return 0;

    if(v<arr[0])
        return 0;

     if(store[v]!=-1)
            return store[v];

   bool ans=0;

    for(ll i=0;i<n&&arr[i]<=v;i++)
    {
        if(func(v-arr[i])==0){
            ans=1;
            break;
        }
    }
    return store[v]=ans;
}


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

    cin>>n>>k;

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

    for(ll i=1;i<=k;i++)
            store[i]=-1;
    func(k);

    if(store[k])
    {
        cout<<"First"<<endl;
    }
    else cout<<"Second"<<endl;
	}
	return 0;
}



Measured memory_bytes: 9048
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	cin >> N;
	VL T(N);
	FOR(i, 0, N)
		cin >> T[i];

	if (N == 1) {
		cout << T[0] << endl;
	}
	else {

		LL ans = lcm(T[0], T[1]);
		FOR(i, 2, N) {
			ans = lcm(ans, T[i]);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int T  = sc.nextInt();
		int A  = sc.nextInt();
		int B  = sc.nextInt();
		if(T * A < B) {
			System.out.println(T * A);
		}
		else {
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
	int N,M,X,Y;
	vector<int> x;
	vector<int> y;
	int a;
	cin >> N >> M >> X >> Y;
	for(int i=0; i<N;i++){
		cin >>a;
		x.push_back(a);
	}
	for(int i=0; i<M;i++){
		cin >> a;
		y.push_back(a);
	}
	int min = *min_element(y.begin(),y.end());
	int max = *max_element(x.begin(),x.end()); 
	if(X>max){
		max=X;
	}
	if(Y<min){
		min=Y;
	}
	if(max<min){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
}

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

#define ll long long

ll n, m;
ll cache[int(3e3 + 1)][int(3e3 + 1)];
ll p[int(3e3 + 1)];


string a, b;

ll dp(ll i, ll j)
{
	if (i >= n || j >= m){
		return 0;
	}
	if (cache[i][j] != -1)	return cache[i][j];
	vector <ll> ret(3);
	if (a[i] == b[j]){
		ret[0] = 1 + dp(i + 1, j + 1);
	}
	else{
		ret[1] = dp(i + 1, j);
		ret[2] = dp(i, j + 1);
	}
	return cache[i][j] = *max_element(ret.begin(), ret.end());
}

string reconstruct(ll i, ll j){
    if (i == n or j == m)
        return "";
    else if (a[i] == b[j])
        return reconstruct(i+1, j+1) + a[i];
    else if (cache[i][j] == cache[i+1][j])
        return reconstruct(i+1, j);
    else
        return reconstruct(i, j+1);
}

int main()
{	
	cin >> a >> b; 	n = a.size();	m = b.size();
	memset(cache, -1, sizeof(cache));
	dp(0, 0);
	string ans = reconstruct(0, 0);	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
}

Measured memory_bytes: 71296
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int P = 30000;
const int INF = (int)1e9;

int arr[20005];

int n;

void solve() {                   
	scanf("%d", &n);

    for (int i = 1, x; i <= n; ++i) {
    	scanf("%d", &x);
    	arr[x] = INF - n + i;
    }
        
    for (int i = 1; i <= n; ++i) {
    	printf("%d", P * i);
    	printf(i < n ? " " : "\n");
    }

    for (int i = 1; i <= n; ++i) {
    	printf("%d", arr[i] - P * i);
    	printf(i < n ? " " : "\n");
    }               
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct Edge { int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
    int k = 1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if(u == p)   continue;
        if(k == c)  ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}

 
int main() {

    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int>(n-1);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i,n-1) {
        cout << ans[i] << endl;
    }

 return 0;
}

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

void solve(long long N, std::vector<long long> L)
{
    sort(L.begin(), L.end());
    ll ans = 0;
    // for (auto x : L)
    //     cout << x << " ";
    // cout << endl;
    // cout << N << endl;
    rep (i, N - 2) {
        for (ll j = N - 2; j > i; j--) {
            bool double_break = false;
            for (ll k = j + 1; k < N; k++) {
                // cout << i << " " << j << " " << k << endl;
                if (L[j] + L[k] > L[i] &&  L[k] - L[j] < L[i]) {
                    // cout << L[i] << " " << L[j] << " " << L[k] << endl;
                    ans++;
                } else if(L[i] > L[j] + L[k]){
                    double_break = true;
                    break;
                }else if(L[i] < L[k] - L[j])
                    break;
            }
            if(double_break)
                break;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
word = []
counter = [0]*26
alphabed = list('abcdefghijklmnopqrstuvwxyz')
try:
  while True:
    input_word = list(input().lower())
    if word == '':
      break
    for i in range(len(input_word)):
      word.append(input_word[i])
except EOFError:
  pass
for i in range(len(word)):
  for j in range(26):
    if word[i] == alphabed[j]:
      counter[j] += 1
for i in range(26):
  print('%s : %d'%(alphabed[i], counter[i]))


Measured memory_bytes: 5580
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<"0"<<endl;
        return 0;
    }
    if(b-a>n){
        cout<<"0"<<endl;
        return 0;
    }
    
    n-=2;
    cout<<(b-a)*n+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

ll N,M;

//頂点...4回　裏
//辺...6回　裏
//中身...9回　表

int main() {

    cin >> N >> M;
    if (N == 1 && M == 1) {
        cout << 1 << endl; return 0;
    } else if (N==1) {
        cout << M - 2 << endl; return 0;
    } else if (M==1) {
        cout << N-2 << endl; return 0;
    }
    cout << (N-2) * (M-2) << endl;
    

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s; cin>>s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        String[] lunlun = new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
        List<String> lunlunList = new ArrayList<>(Arrays.asList(lunlun));
        int index = 0;
        while (lunlunList.size() <= 100000) {
            String str = lunlunList.get(index);
            int num = Integer.parseInt(String.valueOf(str.charAt(str.length() - 1)));
            if (num != 0) {
                lunlunList.add(str + (num - 1));
            }
            lunlunList.add(str + num);
            if (num != 9) {
                lunlunList.add(str + (num + 1));
            }
            index++;
        }

        String result = lunlunList.get(k - 1);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 46804
/*  -*- coding: utf-8 -*-
 *
 * 2723.cc: Surface Area of Cubes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int dxs[] = { 1, -1, 0,  0, 0,  0 };
const int dys[] = { 0,  0, 1, -1, 0,  0 };
const int dzs[] = { 0,  0, 0,  0, 1, -1 };

/* typedef */

typedef long long ll;

struct pt {
  int x, y, z;
  pt() {}
  pt(int _x, int _y, int _z): x(_x), y(_y), z(_z) {}
  bool operator<(const pt &p) const {
    return x < p.x || (x == p.x && (y < p.y || (y == p.y && z < p.z)));
  }
};

typedef set<pt> spt;

/* global variables */

/* subroutines */

inline bool inside(int x, int y, int z, int a, int b, int c) {
  return (x >= 0 && x < a && y >= 0 && y < b && z >= 0 && z < c);
}

/* main */

int main() {
  int a, b, c, n;
  scanf("%d%d%d%d", &a, &b, &c, &n);

  ll ar = ((ll)a * b + (ll)b * c + (ll)c * a) * 2;
  spt cbs;

  for (int i = 0; i < n; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);

    for (int di = 0; di < 6; di++) {
      int vx = x + dxs[di], vy = y + dys[di], vz = z + dzs[di];
      if (inside(vx, vy, vz, a, b, c) &&
	  cbs.find(pt(vx, vy, vz)) == cbs.end())
	ar++;
      else
	ar--;
    }

    cbs.insert(pt(x, y, z));
  }

  printf("%lld\n", ar);
  return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
int N;
int a[500][500] = {};

void solve(int l, int r, int level) {
    int m = (l + r) / 2;
    if(r - l == 1) return;
    for(int i=l; i<m; ++i) {
        for(int j=m; j<r; ++j) a[i][j] = level;
    }
    solve(l, m, level + 1);
    solve(m, r, level + 1);
}

void print() {
    for(int i=0; i<N; ++i) {
        for(int j=i+1; j<N; ++j) {
            cout << a[i][j] << (j + 1 == N ? '\n' : ' ');
        }
    }
}

int main() {
    cin >> N;
    solve(0, N, 1);
    print();
    return 0;
}

Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := make([]int, n)
	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				p := x*x + y*y + z*z + x*y + y*z + z*x
				if p <= n {
					ans[p-1]++
				}
			}
		}
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 1988
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)


N,K = MI()
print(min(N%K,K-N%K))


Measured memory_bytes: 59372
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 3e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

vector<pii> v[maxn];
int cof[maxn], iv[maxn], p[maxn];

int Pow(int a, int b){
    int ans = 1;
    for(; b; b>>=1, a = 1ll * a * a % mod)
	if(b & 1)
	    ans = 1ll * ans * a % mod;
    return ans;
}

int cnt[maxn];

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

    iv[0] = iv[1] = 1;
    cof[1] = 1;
    for(int i = 2; i < maxn; i++){
	cof[i] = 1ll * cof[i>>1] * i % mod;
	iv[i] = Pow(cof[i], mod-2);
    }
    
    int n;
    cin >> n;
    --n;
    int L = 1<<n;
    for(int i = 0; i < L; i++){
	cin >> p[i];
	--p[i];
    }
    int ans = 0;
    for(int a = 0; a < n; a++){
	for(int b = 0; b < n; b++){
	    for(int i = 0; i < L; i++){
		int A = L + i, B = L + p[i];
		int num = 1ll * cof[A] * cof[B] % mod;
		v[A>>a].PB({B>>b, num});
	    }
	}
    }
    for(int A = 1; A < maxn - 5; A++){
	if(v[A].empty() || v[A ^ 1].empty())
	    continue;
	for(auto [B, x] : v[A]){
	    cnt[B] = (cnt[B] + x) % mod;
	}
	for(auto [B, x] : v[A ^ 1]){
	    B^=1;
	    int lc1 = A >> 1, lc2 = B >> 1;
	    ans = (1ll * ans + 1ll * cnt[B] * x % mod * iv[lc1] % mod * iv[lc2] % mod * iv[lc1 >> 1] % mod * iv[lc2 >> 1] % mod) % mod;
	}
	for(auto [B, x] : v[A]){
	    cnt[B] = 0;
	}
    }
    ans = 1ll * ans * ((mod + 1) / 2) % mod;
    return cout << ans << endl, 0;
}


Measured memory_bytes: 468204
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int inf=0x3f3f3f3f;
const int N=10,M=1000;
int n,m,s;
char a[N+1][M+5];
int main(){
	cin>>n>>m>>s;
	for(int i=1;i<=n;i++)cin>>a[i]+1;
	int ans=inf;
	for(int i=0;i<1<<n-1;i++){
		vector<int> pos;
		pos.pb(0);
		for(int j=1;j<n;j++)if(i&1<<j-1)pos.pb(j);
		pos.pb(n);
		int now=pos.size()-2;
		vector<int> cnt(pos.size()-1,0);
		for(int j=1;j<=m;j++){
			bool ok=true;
			vector<int> cnt0(pos.size()-1,0);
			for(int k=0;k<cnt.size();k++){
				for(int o=pos[k]+1;o<=pos[k+1];o++)cnt0[k]+=a[o][j]^48;
				if(cnt0[k]>s)goto label_end;
				if(cnt[k]+cnt0[k]>s)ok=false;
			}
			if(ok)for(int k=0;k<cnt.size();k++)cnt[k]+=cnt0[k];
			else now++,cnt=cnt0;
		}
		ans=min(ans,now);
	label_end:;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<string>
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int mul(int a,int b){ return (a*1ll*b)%mod; }
inline int add(int a,int b){ a+=b;if(a>=mod) a-=mod; return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1) rt=rt*a;a=mul(a,a);b>>=1;} return rt;}
//for(int i=0;i<n;i++)

void solve(){
    string s;
    cin>>s;
    int ans=0,c=0;
    for(int i=0;i<3;i++){
       if(s[i]=='R')
         c++,ans=max(ans,c);
       else c=0;
       ans=max(ans,c);
    }
    //if()
    cout<<ans;
}

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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    ArrayList<Long> As = new ArrayList<Long>();
    HashMap<Long,Long> hm = new HashMap<>();
    for(int i = 0;i < N;i++) {
        Long a = sc.nextLong();
        Long count = hm.containsKey(a) ? hm.get(a) : new Long("0");
        hm.put(a,count + 1);
    }

    long count = 0;
    for(Long k: hm.keySet()){
        if(hm.get(k) % 2 != 0)
            count += 1;
    }

    System.out.println(count);

    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


Measured memory_bytes: 65324
var i:longint;s:string;
begin
	readln(s);
	if length(s)>=4 then
	if s[1]='Y' then
	if s[2]='A' then
	if s[3]='K' then
	if s[4]='I' then
	begin write('Yes');exit;end;
	write('No');
end.

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+b)==(c+d)) cout<<"Balanced"<<endl;
    else if((a+b)>(c+d)) cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int b[200][2];

int main(){
	int i, j, n, xmi, xma, ymi, yma, no, d;
	while(1){
		cin >> n;
		if(!n)break;
		b[0][0] = 0;
		b[0][1] = 0;
		for(i=1;i<=n-1;i++){
			cin >> no >> d;
			if(d==0){
				b[i][0] = b[no][0]-1;
				b[i][1] = b[no][1];
			}
			else if(d==1){
				b[i][0] = b[no][0];
				b[i][1] = b[no][1]-1;
			}
			else if(d==2){
				b[i][0] = b[no][0]+1;
				b[i][1] = b[no][1];
			}
			else if(d==3){
				b[i][0] = b[no][0];
				b[i][1] = b[no][1]+1;
			}
		}
		xma=0;
		xmi=0;
		ymi=0;
		yma=0;
		for(i=0;i<=n-1;i++){
			if(b[i][0] < xmi) xmi = b[i][0];
			if(b[i][0] > xma) xma = b[i][0];
			if(b[i][1] < ymi) ymi = b[i][1];
			if(b[i][1] > yma) yma = b[i][1];
			//cout << b[i][0] << " " << b[i][1] << endl;
		}
		
		cout << xma - xmi + 1 << " " << yma - ymi + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i<N; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		int sum = 0;
		for(int j = 0; j<N-1; j++) {
			sum += list.get(j);
		}
		if(sum > list.get(N-1)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

long long factorial(long long n) {
  if (n == 0) {
    return 1;
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}

long long combination(long long n, long long k) {
  if (n < k) {
    return 0;
  } else if (n == k) {
    return 1;
  }
  
  long long numerator = 1;
  long long denominator = factorial(k);
  for (int i = 0; i < k; i++) {
    numerator *= (n - i);
  }
  return numerator / denominator;
}


int main() {
  int n;
  cin >> n;
  vector<string> strs;
  strs.reserve(n);
  
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    strs.push_back(str);
  }
  
  sort(strs.begin(), strs.end());

  vector<long long> ns;
  string str = strs[0];
  long long count = 0;
  for (int i = 0; i < strs.size(); i++) {
    if (str == strs[i]) {
      count++;
    } else {
      ns.push_back(count);
      str = strs[i];
      count = 1;
    }
  }
  ns.push_back(count);
    
  long long ans = 0;
  for (int i = 0; i < ns.size(); i++) {
    ans += combination(ns[i], 2);
  }
  
  cout << ans;
}


  

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0, };
typedef pair<int, int>P;

vector<int> G[200020];
int N;
int a[200020], b[200020];
bool visited[200020];
int dist = 0;
int ed;
void dfs(int n,int d) {
	bool found = 0;
	for (auto x : G[n]) {
		if (!visited[x]) {
			visited[x] = true;
			dfs(x, d + 1);
			found = true;
		}
	}
	if (!found) {
		if (d > dist) {
			dist = d;
			ed = n;
		}
	}
}

signed main() {
	cin >> N;
	REP(i, N-1) {
		int A, B; cin >> A >> B; A--, B--;
		G[A].pb(B); G[B].pb(A);
	}
	m0(visited);
	visited[0] = 1;
	dfs(0, 0);
	//print(ed);
	int ed1 = ed;
	m0(visited);
	dfs(ed1, 0);
	//print(dist);
	//print(ed);
	dfs(ed, 0);
	//print(dist);
	if ((dist+1) % 3 == 2) {
		print("Second");
		return 0;
	}
	else {
		print("First");
	}
}


Measured memory_bytes: 22016
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, M = MI()
    A = LI()
    a = sum(A) / (4 * M)
    A.sort()
    cnt = bisect.bisect_left(A, a)
    if N - cnt >= M:
        print('Yes')
    else:
        print('No')
if __name__ == "__main__":
    main()

Measured memory_bytes: 74472
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var a = consoleReader.String;
            var b = consoleReader.String;
            b = b + b;
            return b.Contains(a) ? "Yes" : "No";
        }


        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    string str;
    cin >> str;
    string keyence = "keyence";
    if (str.length() < keyence.length()) {
        cout << "NO\n";
        return 0;
    }
    
    int i = 0;
    while (i < (int)keyence.length() && str[i] == keyence[i]) i++;
    int j = 0;
    while (j < (int)keyence.length() && str[(int)str.length()-1-j] == keyence[(int)keyence.length()-1-j]) j++;
    if (i+j >= (int)keyence.length()) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
import math
a, b = map(int, input().split())
ans = {1}

def calc_gcd(x, y):
    if y == 0: return x
    return calc_gcd(y, x%y)

def factrize(z):
    i = 2
    set = {1}
    while i*i <= z:
        while z%i==0:
            z//=i
            set.add(i)
        i+=1
    if z > 1:
        set.add(z)
    return set

gcd = calc_gcd(a, b)
print(len(factrize(gcd)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vint a(n), b(n);
    fr(i, 0, n)
    {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    if (n % 2 == 0)
    {
        int l = a[n / 2] + a[n / 2 - 1];
        int r = b[n / 2] + b[n / 2 - 1];
        cout << r - l + 1 << endl;
    }
    else
    {
        int l = a[n / 2];
        int r = b[n / 2];
        cout << r - l + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
import sys

n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
	numa,numb=map(int,input().split())
	a.append(numa)
	b.append(numb)
bb=[]
aa=[]
if not 1 in a or not n in b:
	print("IMPOSSIBLE")
	sys.exit()
for j in range(len(a)):
    if 1==a[j]:
        bb.append(b[j])
for k in range(len(b)):
    if n==b[k]:
        aa.append(a[k])
list=set(aa) & set(bb)
print("IMPOSSIBLE" if len(list)==0 else "POSSIBLE")


Measured memory_bytes: 28152
import sys
import itertools

input = sys.stdin.readline


def main():
    N = int(input())
    balls = [tuple(map(int, input().split())) for _ in range(N)]
    comb = list(itertools.combinations(balls, 2))
    ans = 0
    for c in comb:
        a, b = c
        p = b[0] - a[0]
        q = b[1] - a[1]
        ans_i = 0
        for d in balls:
            e = (d[0] + p, d[1] + q)
            if e in balls:
                ans_i += 1
        ans = max(ans, ans_i)
    print(N - ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73856
/*
 * ID: 3027
 * Problem: OOIIOII, counting bits in binary
 */

#include <stdio.h>

int main(void)
{
    long n;
    scanf("%ld", &n);

    long k, count;
    for (k = 1, count = 0; n >= k - 1; k *= 2, count++) 
        ;

    printf("%d\n", count - 1);

    return 0;
}



Measured memory_bytes: 2108