akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;

using mat2d_t = std::vector<std::vector<int64_t>>;
int64_t combination(mat2d_t &res, int n, int k) {
    res = mat2d_t(n+1, std::vector<int64_t>(n+1, 0)); // init
    for (int i=0; i<res.size(); ++i)
        res[i][0] = res[i][i] = 1;
    for (int i=1; i<res.size(); ++i) {
        for (int j=1; j<i; ++j) {
            res[i][j] = res[i-1][j-1] % mod + res[i-1][j] % mod;
        }
    }
    return res[n][k];
}

int main(int argc, char **argv) {
    int n, k;
    cin >> n >> k;

    mat2d_t tmp_r, tmp_b;

    combination(tmp_r, n-k+1, k);
    combination(tmp_b, k-1, k-1);

    for (int i = 1; i<=k; ++i) {
        if (n-k+1 < i || k < i) {
            cout << 0 << endl;
            continue;
        }
        cout << (((tmp_r[n-k+1][i] % mod) * (tmp_b[k-1][i-1] % mod)) % mod) << endl;
    }

    return 0;
}

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a1 = h1*60+m1;
  int a2 = h2*60+m2;
  int ans = a2-a1-k;
  if(ans <0) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,k;
ll val[100000];
ll sum[100000];
int main()
{while(1){
	memset(val,0,sizeof(val));
	memset(sum,0,sizeof(sum));
	cin>>n>>k;
	if(!n) return 0;
	for(ll i=0;i<n;i++) cin>>val[i];
	for(ll i=0;i<k;i++) sum[0]+=val[i];
	ll ans=sum[0];
	for(ll i=1;i<=n-k;i++){
		sum[i]=sum[i-1]-val[i-1]+val[i+k-1];
		ans=max(ans,sum[i]);
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 4640
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

int n,ok,i;
string s;
int kk[100123];

void ispis(){
	for(i=0;i<n;i++){
		if(!kk[i])cout<<'S';
		else cout<<'W';
	}
	cout<<endl;
	exit(0);
}

void vuk(){
	if( kk[n-1]==1 ){
		if( s[n-1] == 'o' && kk[n-2] != kk[0] )ispis();
		else if( s[n-1] == 'x' && kk[n-2] == kk[0] )ispis();
	}
}

void ovca(){
	if( kk[n-1]==0 ){
		if( s[n-1] == 'o' && kk[n-2] == kk[0] )ispis();
		else if( s[n-1] == 'x' && kk[n-2] != kk[0] )ispis();
	}
}

void rush(){
	for( i=1;i<n-1;i++ ){
		if( s[i]=='o' ){
			if( !kk[i] )kk[i+1]=kk[i-1];
			else kk[i+1]=kk[i-1]^1;
		}
		else{
			if( !kk[i] )kk[i+1]=kk[i-1]^1;
			else kk[i+1]=kk[i-1];
		}
	}
}

int main(){

cin>>n;
cin>>s;

if( s[0]=='o' ){
	//ovca*2 pa vuk*2
	kk[0]=0;
	kk[1]=0;
	rush();
	ovca();
	
	kk[0]=0;
	kk[1]=1;
	rush();
	vuk();
	
	kk[0]=1;
	kk[1]=1;
	rush();
	ovca();
	
	kk[0]=1;
	kk[1]=0;
	rush();
	vuk();
	
}
else{
	//ovca*2 pa vuk*2
	kk[0]=0;
	kk[1]=0;
	rush();
	vuk();
	
	kk[0]=0;
	kk[1]=1;
	rush();
	ovca();
	
	
	kk[0]=1;
	kk[1]=0;
	rush();
	ovca();
	
	
	kk[0]=1;
	kk[1]=1;
	rush();
	vuk();
}
    
    cout<<-1<<endl;
    return 0;
}

/*

6
ooxoox

*/

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    string s,t;
    cin>>s;
    t=s;
    bool a[26]={0};
    for(char c:s)a[c-'a']=1;
    if(s.size()<26){rep(i,26)if(!a[i])cout<<s<<(char)(i+'a')<<endl,exit(0);}
    else if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<"-1\n";
    else {
        next_permutation(all(s));
        rep(i,26){
            cout<<s[i];
            if(s[i]!=t[i])cout<<endl,exit(0);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    while( true ) {
        int n;
        cin >> n;
        if( n == 0 ) break;

        int y;
        cin >> y;
        int resn = 0;
        double res = 0;
        for( int i = 0; i < n; ++i ) {
            double b, r, t;
            cin >> b >> r >> t;
            double tmp = 0;
            if( t == 1 ) {
                tmp = 1.0 + y * ( r / 100 );

            } else {
                tmp = pow( 1 + ( r / 100 ), y );

            }
            if( res < tmp ) {
                resn = b;
                res = tmp;

            }
        }
        cout << resn << endl;

    }
    return 0;
}



Measured memory_bytes: 3248
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int a = scan.nextInt(), b = scan.nextInt();

		if( b+w < a ) {
			System.out.println( a-(b+w));
		} else if ( a+w < b ){
			System.out.println( b-(a+w));
		} else {
			System.out.println(0);
		}

	}

}

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

int main()
{
    int n,i,j,p=0;
    int x[105];
    int y[1005];
    long long sum;
    int minone=99999;
    int maxone=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        minone=min(minone,x[i]);
        maxone=max(maxone,x[i]);
    }
    for(i=minone;i<=maxone;i++)
    {
        sum=0;
        for(j=0;j<n;j++)
        {
            sum += pow(( x[j]-i),2 );
        }
        y[p++]=sum;
    }
    sort(y,y+p);
    cout<<y[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int n;
	cin >> n;
	vi va(n);
	REP(i, n) cin >> va[i];

	int best = 10000000;
	for (int x = -100; x <= 100; ++x)
	{
		int tmp = 0;
		REP(i, n)
			tmp += (x - va[i]) * (x - va[i]);
		chmin(best, tmp);
	}

	cout << best << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll x;
    cin >> x;
    for(ll a = -2000; a <= 2000; a++){
        for(ll b = -2000; b <= 2000; b++){
            if(a * a * a * a * a - b * b * b * b * b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll Mod=1e9+7;



vector<ll> inv,fact,invfact;
void Mod_build(int n=2010101){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}

int main(){
  int i,j;
  int x,y;
  cin>>x>>y;
  int z=x+y;
  if(z%3!=0){
    cout<<0<<endl;
    return 0;
  }
  z/=3;
  x-=z;
  y-=z;
  Mod_build();
  cout<<comb(x+y,x)<<endl;
  
}



Measured memory_bytes: 47360
#include<iostream>
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b;
    cin >> a >> b;
    int x,y,z;
    x = a + b;
    y = a - b;
    z = a * b;
    int ans = max(x,y);
    ans = max(ans,z);
    cout <<ans <<endl;
}

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

int main() {
  int N;
  cin >> N;
  int a,b,c;
  a = N/100;
  b = N/10 - a*10;
  c = N%10;
  if(a==7 || b==7 || c==7){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e2 + 5;

char s[10];
int main(){
    #ifdef Irene
    freopen("in.txt","r",stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> s;
    int flag = 0;
    for(int i = 0; s[i]; i++)
        flag |= s[i] == '7';
    cout << (flag ? "Yes" : "No");
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int,int> P;


P pmake(int x)
{
   int a = x%10;
  
   int b=0;
   while(x>0)
   {
       b= x;
      x /=10;
   }

  return P(a,b);

}



int main()
{
  int n;
  cin>>n;
  ll ans =0;
  
  map<P,int>ma;
  for(int i=1;i<=n;i++)
  {
      P p = pmake(i);
  
      ma[p]++;
  
  }
  
  for(int i=1;i<=n;i++)
  {
     P p = pmake(i);
     
     P q(p.second,p.first);
  
     ans += ma[q];

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in5.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int d, t, s;
        cin >> d >> t >> s;
        if(d <= s*t) cout << "Yes";
        else cout << "No";
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> v(n);
    FOR(i,0,n)cin>>v[i];
    ll ans = 0;
    FOR(i,0,n)FOR(j,i+1,n) ans += v[i]*v[j];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    int n;
    cin>> n;
    std::vector<tuple<string,int,int>> restaurant(n);
    string s;
    int p;
    rep(i,n){
        cin >> s >> p;
        restaurant[i] = make_tuple(s,p,i);
    }
    sort(restaurant.begin(),restaurant.end());
    rep(i,n){
        rep(j,n){
            if(get<0>(restaurant[i]) == get<0>(restaurant[j])){
                if(get<1>(restaurant[i]) > get<1>(restaurant[j])) restaurant[i].swap(restaurant[j]);
            }
        }
    }
    for(tuple<string,int,int> elem : restaurant){
        string s ;
        int x ,i;
        tie(s,x,i) = elem;
       cout <<i + 1<< endl; 
    }
    
    
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))

seen = {1: 0}
a = 1

for i in range(1, n+1):
  if seen.setdefault(a:=A[a-1], i) != i:
    break

p = seen[a]
q = i - seen[a]

if k >= p+q:
  k = (k - p) % q + p

a = 1
for i in range(k):
  a = A[a-1]

print(a)

Measured memory_bytes: 38832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int mo = 1000000007;
using namespace std;
struct poi { int x, y; } a[200010]; int n;
bool cmp(poi a, poi b) { return a.x < b.x; }
int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i].x), a[i].y = 1;
	rep(i, 1, n) scanf("%d", &a[n + i].x), a[n + i].y = - 1;
	sort(a + 1, a + n * 2 + 1, cmp);
	ll ans = 1; int top = 0;
	rep(i, 1, 2 * n) {
		if (a[i].y == 1 && top < 0) ans = ans * (-top) % mo;
		if (a[i].y == - 1 && top > 0) ans = ans * top % mo;
		top += a[i].y;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if (s[1]!=s[2])
    {
        cout<<"No";
        return 0;
    }
    if (s[0]==s[1]||s[2]==s[3]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	string b[101];
	cin>>a;
	for (int i=0;i<a;i++)
		cin>>b[i];
	for (int i=0;i<a;i++)
		for (int n=i+1;n<a;n++)
			if (b[i]==b[n])
			{
				cout<<"No"<<endl;
				return 0;
			}
	for (int i=0;i<a-1;i++)
		if (b[i][b[i].size()-1]!=b[i+1][0])
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;	
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())

H = list( map(int, input().split()))

mindiff = 1e9
ans = -1

for i in range(N):
  if abs(T - 0.006*H[i] -A) < mindiff:
    mindiff = abs(T - 0.006*H[i] -A)
    ans = i+1
    
print(ans)


Measured memory_bytes: 38512
N = int(input())

Point = []
for _ in range(N):
    Point.append(tuple(map(int, input().split())))
Point.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x, y, h = Point[0]
        H = h + abs(x-cx) + abs(y-cy)
        flag = True
        for i in range(1,N):
            nx, ny, nh = Point[i]
            if max(H - abs(nx-cx) - abs(ny-cy),0) != nh:
                flag = False
                break
        if flag:
            print(cx, end=' ')
            print(cy, end=' ')
            print(H, end=' ')
            exit()

Measured memory_bytes: 41196
import scala.io.StdIn.readLine

object Main {
  def main(args:Array[String]) = {
    val n = readLine.split(" ").map(_.toInt)
    if(n(0) + n(1)*5 + n(2)*10 + n(3)*50 + n(4)*100 + n(5)*500 >= 1000)
      println(1)
    else
      println(0)
  }
}

Measured memory_bytes: 43780
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    vector<int>b(N);
    rep(i,N)cin>>b[i];
    int a=N;
    bool judge;
    vector<int>ans(N);
    rep(i,N){
        judge=true;
        rep(j,a){
            if(b[a-1-j]==a-j){
                ans[i]=a-j;
                b.erase(b.begin()+a-1-j);
                a--;
                //cout<<a-j<<" "<<a<<endl;
                judge=false;
                break;
            }
        }
        if(judge){
            cout<<-1<<endl;
            return 0;
        }
        }
        reverse(ans.begin(),ans.end());
        rep(i,N)cout<<ans[i]<<endl;
    }

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s;
  cin >> s;
  char now = s.at(0);
  ll ans = 0;
  for (long long i = 1; i < s.size(); i++) {
    if (s.at(i) != now) {
      ans++;
      now = s.at(i);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i<N; i++)
    cin >> L.at(i);
  sort(L.begin(), L.end());
  int max = L.at(N-1), sum=0;
  for (int i=0; i<N-1; i++)
    sum += L.at(i);
  if(L.at(N-1) < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,k;
  
  scanf("%d %d",&n,&k);
  
  int ans=0;
  int a[n];
  
  for(int i =0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>=k){ans++;}
  }
  
  printf("%d\n",ans);
  
  return 0;
}



Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
const int N=3003;
char a[N],b[N];int la,lb,dp[N][N],g[N][N];
void Out(int i,int j){
	if(!i||!j)return;
	switch(g[i][j]){
	  case 0:Out(i-1,j-1);putchar(a[i]);return;
	  case 1:Out(i,j-1);return;
	  case 2:Out(i-1,j);return;
	}
}
signed main(){
	scanf("%s%s",a+1,b+1);la=strlen(a+1),lb=strlen(b+1);
	for(int i=1;i<=la;i++)
	  for(int j=1;j<=lb;j++){
		if(a[i]==b[j])
		  dp[i][j]=dp[i-1][j-1]+1,g[i][j]=0;
		else if(dp[i][j-1]>dp[i-1][j])
		  dp[i][j]=dp[i][j-1],g[i][j]=1;
		else
		  dp[i][j]=dp[i-1][j],g[i][j]=2;
	  }
	Out(la,lb);
	return 0;
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;

    ll m1 = X;
    ll m3 = X;
    for(ll i=0; i<N; i++)
    {
        ll x;
        cin >> x;

        m1 = max(m1, x);
        m3 = min(m3, x);
    }

    ll m2 = Y;
    ll m4 = Y;
    for(ll i=0; i<M; i++)
    {
        ll x;
        cin >> x;

        m2 = max(m2, x);
        m4 = min(m4, x);
    }

    if(m1<m4 || m2<m3)
    {
        cout << "No War" << endl;
    }

    else
    {
        cout << "War" << endl;
    }
    
    return 0;
}

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

const int64_t MOD = 998244353;

int main() {
  int n, s;
  cin >> n >> s;
  int64_t dp[n + 1][s + 1];
  dp[0][0] = 1;
  for (int i = 1; i <= s; ++i) {
    dp[0][i] = 0;
  }
  for (int i = 1, a; cin >> a; ++i) {
    for (int j = s; j >= 0; --j) {
      dp[i][j] = (2 * dp[i - 1][j] + (j >= a ? dp[i - 1][j - a] : 0)) % MOD;
    }
  }
  cout << dp[n][s];
  return 0;
}


Measured memory_bytes: 73484
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAXOP 200
#define NUMBER '0'

int getop(char []);
void push(int);
int pop(void);

int main()
{
  int type;
  int op2;
  char s[MAXOP];

  while((type = getop(s)) != '\n') {
    switch (type) {
    case NUMBER:
      push(atof(s));
      break;
    case '+':
      push(pop() + pop());
      break;
    case '*':
      push(pop() * pop());
      break;
    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    default:
      break;
    }
  }
  printf("%d\n", pop());
  return 0;
}

#define MAXVAL 100

int sp = 0;
double val[MAXVAL];


void push(int f)
{
  if (sp < MAXVAL)
    val[sp++] = f;
  else
    printf("error: stack full, can't push %g\n", f);
}


int pop(void)
{
  if (sp > 0)
    return val[--sp];
  else {
    printf("error: stack empty\n");
    return 0;
  }
}

#include <ctype.h>

int getch(void);
void ungetch(int);


int getop(char s[])
{
  int i, c;

  while ((s[0]= c = getch()) == ' ' || c == '\t')
    ;
  s[1] = '\0';
  if (!isdigit(c) && c != '.')
    return c;
  i = 0;
  if (isdigit(c)) 
    while (isdigit(s[++i] = c = getch()))
      ;
  if (c == '.') 
    while (isdigit(s[++i] = c = getch()))
      ;
  s[i] = '\0';
  if (c != EOF)
    ungetch(c);
  return NUMBER;
}

#define BUFSIZE 100

char buf[BUFSIZE];
int bufp =0;

int getch(void) 
{
  return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) 
{
  if (bufp >= BUFSIZE)
    printf("ungetch: too many characters\n");
  else
    buf[bufp++] = c;
}

Measured memory_bytes: 544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] p = br.readLine().split(" ");
		Integer X = Integer.valueOf(p[0]);
		Integer A = Integer.valueOf(p[1]);
		Integer B = Integer.valueOf(p[2]);
		int C = B-A;
		if((C) > 0){
			if(C <= X){
				System.out.println("safe");
			} else {
				System.out.println("dangerous");
			}
		} else {
			System.out.println("delicious");
		}
	}
}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N);
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        AB[i] = {a, b};
    }
    sort(AB.begin(), AB.end());
    for(int i=0; i<N; i++){
        A[i] = AB[i].first;
        B[i] = AB[i].second;
    }

    UnionFind uf(N+1);
    vector<pair<int, int>> edges[100001];
    vector<int> deg(N+1);
    for(int i=0; i<M; i++){
        int l, r;
        cin >> l >> r;
        l = lower_bound(A.begin(), A.end(), l) - A.begin();
        r = upper_bound(A.begin(), A.end(), r) - A.begin();
        if(uf.unite(l, r)){
            edges[l].emplace_back(r, i);
            edges[r].emplace_back(l, i);
            deg[l]++;
            deg[r]++;
        }
    }

    map<int, vector<int>> mp;
    for(int i=0; i<=N; i++) mp[uf.find(i)].push_back(i);
    vector<int> R(N+1, -1);
    for(auto& p : mp){
        auto& v = p.second;
        int sz = v.size();
        for(int i=0; i<sz-1; i++) R[v[i]] = v[i+1];
    }

    vector<int> imos(N+1), use(N+1);
    for(int i=0; i<N; i++){
        B[i] ^= imos[i];
        if(B[i]){
            if(R[i] == -1){
                cout << -1 << endl;
                return 0;
            }
            use[i] ^= 1;
            use[R[i]] ^= 1;
            imos[i] ^= 1;
            imos[R[i]] ^= 1;
            B[i] = 0;
        }
        imos[i+1] ^= imos[i];
    }

    vector<int> ans;
    queue<int> que;
    bitset<100000> visited;
    for(int i=0; i<N; i++) if(deg[i] == 1) que.push(i);
    while(que.size()){
        int i = que.front(); que.pop();
        visited[i] = 1;
        for(auto& e : edges[i]) if(!visited[e.first]){
            int j = e.first, idx = e.second;
            deg[j]--;
            if(use[i]){
                use[i] ^= 1;
                use[j] ^= 1;
                ans.push_back(idx);
            }
            if(deg[j] == 1) que.push(j);
        }
    }
    sort(ans.begin(), ans.end());
    int sz = ans.size();
    cout << sz << endl;
    for(int i=0; i<sz; i++) cout << ans[i]+1 << " \n"[i==sz-1];
    return 0;
}


Measured memory_bytes: 12540
n=int(input())
a=[] ; b=[]
for _ in range(n):
    a.append(input())
m=int(input())
for _ in range(m):
    b.append(input())
from collections import Counter
a=Counter(a)
b=Counter(b)
for i in b:
    if i in a:
        a[i]=max(0,a[i]-b[i])
print(max(a.values()))
        


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;
string s;
int main() {
	ios_base::sync_with_stdio(false);

	cin >> s;
	int ans = (s.size() + 1) / 2;
	int j = 0;
	for(int i = 0; i< s.size();) {
		while(j < s.size() && s[i] == s[j]) j++;
		ans = max(ans, min(j, (int)s.size() - i));
		dbg(i, j, ans);
		i = j;
	}
	cout << ans << '\n';
}	

	

Measured memory_bytes: 512
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {
	string s;
	cin >> s;

	int a = 0, b = 0;
	for (auto& c : s) {
		if (c == '0') a++;
		else b++;
	}

	cout << min(a, b) * 2 << endl;

	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int primemaxnum = 10;
    for(; primemaxnum*primemaxnum <= n; primemaxnum++);
    vector<bool> isprime(primemaxnum+1, true);
    for(int i = 2; i*i <= primemaxnum; i++){
        if(isprime[i]){
            for(int j = 2; i*j <= primemaxnum; j++) isprime[i*j] = false;
        }
    }
    vector<int> prime;
    for(int i = 2; i <= primemaxnum; i++){
        if(isprime[i]){
            prime.push_back(i);
        }
    }
    long long int ans = 1;
    vector<long long int> memo(n+1, 1);
    vector<int> cur(n+1);
    for(int i = 1; i <= n; i++) cur[i] = i;
    for(long long int i = 2; i <= n; i++){
        long long int coans = 1;
        if(cur[i] > 1){
            int primemodoki = cur[i];
            for(int j = 1; primemodoki*j <= n; j++){
                long long int cocoans = 1;
                while(cur[primemodoki*j] > 1 && cur[primemodoki*j] % primemodoki == 0){
                    cocoans++;
                    cur[primemodoki*j] /= primemodoki;
                }
                memo[primemodoki*j] *= cocoans;
            }
        }

        ans += memo[i] * i;
    }

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

Measured memory_bytes: 120340
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N; cin >> N; 
	int A[200010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
	}
	int B[200010] = {}; 
	vector<int> ans = {}; 
	for(int i = N; i >= 1; i--){
		int kosuu = 0; 
		for(int j = 1; j * i <= N; j++){
			kosuu += B[j * i]; 
		}
		if(kosuu % 2 != A[i]){
			ans.push_back(i); 
			B[i] ++; 
			B[i] %= 2; 
		}
	}
	cout << ans.size() << endl; 
	for(int i = 0; i < ans.size(); i++){
		cout << ans.at(i) << " "; 
	}
	cout << endl; 
}

Measured memory_bytes: 3320
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k;
  std::cin>>n>>k;
  if(k>(n-2)*(n-1)/2){
    std::cout<<-1;
    return 0;
  }

  
  std::cout<<(n-1)*n/2-k<<"\n";

  
  k=((n-1)*(n-2)/2-k); 

  rep(i,1,n){
    std::cout<<1<<" "<<i+1<<"\n";
  }

  ll temp=n-2;
  while(k>0){
    if(k>=temp){
      rep(i,n-temp+1,n+1){
        std::cout<<n-temp<<" "<<i<<"\n";
      }
      k-=temp;
    }else{
      rep(i,n-temp+1,n-temp+1+k){
        std::cout<<n-temp<<" "<<i<<"\n";
      }
      k=0;
    }
    temp--;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll N,A,ans=1;
ll cnt[100010];

int main(){
    cin>>N;
    rep(i,100010){
        cnt[i]=0;
    }
    rep(i,N){
        cin>>A;
        cnt[A]++;
    }
    rep(i,N){
        if(i%2!=N%2){
            if(i==0){
                if(cnt[0]!=1){
                    out(0);
                    return 0;
                }
            }
            else{
                if(cnt[i]!=2){
                    out(0);
                    return 0;
                }
            }
        }
    }
    rep(i,N/2){
        ans=(ans*2)%1000000007;
    }
    out(ans);
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int cards[4][13] = {};
    
    for(int i = 0; i < n; i++){
        char mark;
        int rank;
        cin >> mark >> rank;
        if(mark == 'S'){
            cards[0][rank-1] = 1;
        }
        else if(mark == 'H'){
            cards[1][rank-1] = 1;
        }
        else if(mark == 'C'){
            cards[2][rank-1] = 1;
        }
        else if(mark == 'D'){
            cards[3][rank-1] = 1;
        }
    }
    
    for(int j = 0; j < 4; j++){
        for(int k = 0; k < 13; k++){
            if(cards[j][k] == 0){
                if(j == 0){
                    cout << "S" << " "<< k+1 << endl;
                }
                else if(j == 1){
                    cout << "H" << " "<< k+1 << endl;
                }
                else if(j == 2){
                    cout << "C" << " "<< k+1 << endl;
                }
                else if(j == 3){
                    cout << "D" << " "<< k+1 << endl;
                }
            }
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 3108
#include <cstdio>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;
    int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i=0; i<n1; i++) L[i] = A[left + i];
    for (i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for(k=left;k<right;k++){
        if(L[i].value <= R[j].value) A[k] = L[i++];
        else A[k] = R[j++];
    }
}

void mergeSort(struct Card A[],int n,int left,int right){
    int mid;
    if(left + 1 < right){
        mid =(left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}


int partition(struct Card A[],int n,int p,int r){
    int i,j;
    struct Card t,x;
    x = A[r];
    i = p-1;
    for(j = p; j<r;j++){
        if (A[j].value<=x.value){
            i++;
            t=A[i];A[i] = A[j]; A[j]=t;
        }
    }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}



void quickSort(struct Card A[],int n,int p, int r){
    int q;
    if (p<r){
        q=partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}


int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable = 1;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %d",S,&v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    for(i=0; i<n; i++){
        if (A[i].suit!=B[i].suit) stable=0;
    }

    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }

    return 0;
}


Measured memory_bytes: 4972
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    ll x=max(a+b,a-b);
    cout<<max(x,a*b)<<endl;
}


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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;

           s = Console.ReadLine();

            char[] cs = s.ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}


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

using namespace std;

int main() {
	int a, b, c, cnt, sum;

	cnt = 0;
	sum = 0;
	cin >> a >> b >> c;
	while (true) {
		if (sum >= c) {
			break;
		}
		sum += a;
		++cnt;
		if (cnt % 7 == 0) {
			sum += b;
		}
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

template <class Weight>
constexpr Weight inf=(Weight(1)<<(8*sizeof (Weight)-3));

template <class Weight>
class WeightedUnionFind {
  std::vector<intmax_t> tree;
  std::vector<Weight> cost;

public:
  WeightedUnionFind(size_t n): tree(n, -1), cost(n) {}

  size_t find(size_t v) {
    fprintf(stderr, "? %zu [%jd]\n", v, tree[v]);
    if (tree[v] < 0)
      return v;

    size_t r=find(tree[v]);
    cost[v] += cost[tree[v]];
    return (tree[v] = r);
  }

  bool unite(size_t u, size_t v, Weight w) {
    size_t ru=find(u), rv=find(v);
    if (ru == rv)
      return false;  // FIXME assuming no multi-edges

    if (-tree[ru] < -tree[rv]) {
      tree[rv] += tree[ru];
      tree[ru] = rv;
      cost[ru] = w-(cost[u]-cost[v]);
    } else {
      tree[ru] += tree[rv];
      tree[rv] = ru;
      cost[rv] = -w+(cost[u]-cost[v]);
    }
    fprintf(stderr, "%zu <-> %zu\n", u, v);
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  Weight diff(size_t u, size_t v) {
    return connected(u, v)? (cost[u]-cost[v]):inf<Weight>;
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N;
  int M;
  scanf("%zu %d", &N, &M);

  WeightedUnionFind<intmax_t> uf(N);

  for (int i=0; i<M; ++i) {
    size_t L, R;
    intmax_t D;
    scanf("%zu %zu %jd", &L, &R, &D);

    --L;
    --R;
    if (!uf.connected(L, R)) {
      uf.unite(L, R, D);
    } else if (uf.diff(L, R) != D) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
}


Measured memory_bytes: 1792
n = gets.chomp.to_i
kq = {}
(1..n).each do |i|
  sorted = gets.chomp.split("").sort.join("")
  if kq[sorted] != nil
    kq[sorted] = kq[sorted] + 1
  else
    kq[sorted] = 1
  end
end
sum = 0
kq.map {|key, value| sum+= value*(value-1)/2}
puts sum

Measured memory_bytes: 19344
a,b,c,x,y = gets.split.map &:to_i
s = [a+b,2*c].min
ans = 0

if x < y
  t = [b,2*c].min
  ans = x * s + (y-x) * t
  # p [1,s,t]
else
  t = [a,2*c].min
  ans = y * s + (x - y) * t
  # p [2,s,t]
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int a,b[100],c[100],d[100],e,f;
  
 
  cin >> a ;
  for(int i=0;i<a;i++)
  cin >> b[i];
  for(int i=0;i<a;i++)
  cin >> c[i];
  for (int i=0;i<a-1;i++)
    cin >> d[i];
 
   e=0;
  for(int i=0;i<a;i++){
    e += c[i];
  }
  
  for(int i =0;i<a;i++){
    if(b[i+1] == b[i]+1){
      e += d[b[i]-1];
    }
  }
  cout << e << endl;
  
  return 0;
}
  
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int h,a;
    cin>>h>>a;
    int ans = 0;
    while(h>0){
    	ans++;
    	h-=a;
    }
    cout<<ans;
}  

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
s=gc
sum = 700
s.each do |ss|
  if ss == 'o'
    sum+= 100
  end
end
puts sum


Measured memory_bytes: 2428
// Vicfred
// https://atcoder.jp/contests/abc158/tasks/abc158_a
// implementation
import std.stdio;
import std.string;

void main() {
    string s = readln.chomp;
    if(s.count('A') > 0 && s.count('B') > 0)
        "Yes".writeln;
    else
        "No".writeln;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string S,T;
cin >> S >> T;
int s,t;
s = S.size();
t = T.size();
int count = 0, sum = t;
for(int i = 0; i <= s - t; i++){
  count = 0;
  for(int j = 0; j < t; j++){
  if(S.at(i + j) != T.at(j)){
  count++;
  }
  
  }
  if (count<sum){
  sum = count;
  }
}
cout <<sum << endl;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
	ll n;
	cin>>n;
    if(n<2)
    {
    	cout<<0<<endl;
    	return;
    }
    if(n%2)
    {
    	cout<<0<<endl;
    	return;
    }
    else 
    {
    	n/=2;
    	ll div=5;
    	ll ans=0;
    	while(n)
    	{
    		ans+=(n/div);
    		n/=div;
    	}
    	cout<<ans<<endl;
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m;
ll a[2010]; 
ll b[2010][2];
ll res=0;
ll md=1e9+7;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<i;j++) if (a[i]>a[j]) b[i][0]++;
		for (int j=i+1;j<n;j++) if (a[i]>a[j]) b[i][1]++;
	}
	for (int i=0;i<n;i++)
	{
		//cout <<i<<" "<<b[i][0]<<" "<<b[i][1]<<" "<<res<<" ##\n";
		ll r=(m+1)*m/2;
		r%=md;
		r=(r*b[i][1])%md;
		res=(res+r)%md;
		r=m*(m-1)/2;
		r%=md;
		r=(r*b[i][0])%md;
		res=(res+r)%md;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  vector <int> h(n);
  REP(i,n) cin >> h[i];

  sort(ALL(h));

  //for(auto x: h) cout << x << endl;

  int INF = 1000000009;
  int mx = INF;
  REP(i,n-k+1){
    int t = 0;
    t = h[i + k - 1]- h[i];
    mx = min(mx, t);
  }

  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 3736
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    deque<int> que;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i & 1) {
            que.push_front(a);
        } else {
            que.push_back(a);
        }
    }

    if (n & 1) {
        for (int i = 0; i < n - 1; i++) {
            cout << que.back() << ' ';
            que.pop_back();
        }
        cout << que.front() << endl;
    } else {
        for (int i = 0; i < n - 1; i++) {
            cout << que.front() << ' ';
            que.pop_front();
        }
        cout << que.front() << endl;
    }

    return 0;
}


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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

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

    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }

    for (int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);
    }

    solve();
}



Measured memory_bytes: 3160