akhauriyash/Code-Regression huggingface dataset:
//                                  _                 ______   ______   ______   ______
//                                 | |               |  __  | |  __  | |  __  | |____  |
//   __ _   ____    _____    _  _  | |____           | |__| | | |__| | | |__| |      | |
//  / _` | |  __| /  __  |  / _` | |  __  |          |____  | |____  | |____  |      | |
// | (_| | | |    | |  | | | (_| | | |__| |  ______   ____| |  ____| |  ____| |      | |
//  \__,_| |_|    |_|  |_|  \__,_| |______| |______| |______| |______| |______|      |_|

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9+7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

bool comp(const pair<int, int> &a, const pair<int, int> &b){
  return (a.first > b.second);
}

int main(){

  FAST();
  //Code goes past here:
  ll x, y, a, b, c, i, j, k;
  ll ans = 0;
  cin>>x>>y>>a>>b>>c;

  vector<ll> p(a), q(b), r(c);

  REP(i, 0, a)  cin>>p[i];
  REP(j, 0, b)  cin>>q[j];
  REP(k, 0, c)  cin>>r[k];

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  while(p.size() > x) p.pop_back(); //size of p is now x
  while(q.size() > y) q.pop_back(); //size of q is now y

  vector<ll> abc(a+y+c);
  k=0;
  REP(i, 0, x)
    abc[k++] = p[i];
  REP(i, 0, y)
    abc[k++] = q[i];
  REP(i, 0, c)
    abc[k++] = r[i];

  sort(abc.rbegin(), abc.rend());
  REP(i, 0, x+y)  ans += abc[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,k,g=0;
    cin>>n>>m>>k;
    for(int i=0;i<=m;i++)
        for(int j=0;j<=n;j++)
        {
            if((i*n+j*m-2*(i*j))==k){cout<<"Yes"<<endl;return 0;}
        }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  int N; cin >> N;
  map <int, int> mp;
  for (int i = 0; i < N; i++){
    int A; cin >> A; 
    mp[A]++;
    if (mp[A] > 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

class Main {
public static void main(String[] args){

  Scanner stdIn = new Scanner(System.in);
  int a = stdIn.nextInt();
  int b = stdIn.nextInt();
  if (a == b){
  System.out.println("a == b");
  } else if (a < b){
  System.out.println("a < b");
  } else if (a > b){
  System.out.println("a > b");
  }

}

}


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

bool isPrime(int n)
{
	if ((n < 2) || ((n > 2) && (n % 2 == 0))) return false;

	for (int i = 3; int64_t(i) * i <= n; i += 2)
	{
		if (n % i == 0) return false;
	}

	return true;
}

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

	int x; cin >> x;
	if (x != 2)
	{
		x += !(x % 2);
		while (!isPrime(x)) { x += 2; }
	}

	cout << x << '\n';
}

Measured memory_bytes: 3660
n = int(input())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append([a,b])
li = sorted(li,key = lambda x:x[1])
ok = True
sa = 0
for i in range(n):
    #print(li[i])
    f,s = li[i]
    sa += f
    if sa > s:
        ok = False
print('Yes' if ok else 'No')


Measured memory_bytes: 39704
#include<stdio.h>
int main(void)
{
 int a,b;
 char op;
 
 while(1)
 {
  scanf("%d %c %d",&a,&op,&b);
  if(op=='?')break;
  else if(op=='+')printf("%d\n",a+b);
  else if(op=='-')printf("%d\n",a-b);
  else if(op=='*')printf("%d\n",a*b);
  else if(op=='/')printf("%d\n",a/b);
 }
 return 0;
}

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

const double EPS = 1e-10;
const int INF = 100000000;
const ll MOD = 1000000007;

int n;
vector<int> e[100000];
int ansa = 1;

bool checker(vector<int> vec, int mid, int x) {
    int i = 0, j = vec.size()-1;
    bool ok = true;
    rep(_,vec.size()/2) {
        if (i == mid) i++;
        if (j == mid) j--;
        if (vec[i]+vec[j] > x) {
            ok = false;
            break;
        }
        i++; j--;
    }
    return ok;
}

int dfs(int v, int par, int x) {
    vector<int> vec;
    rep(i,e[v].size()) {
        if (e[v][i] == par) continue;
        int z = dfs(e[v][i], v, x);
        if (z == INF) {
            return INF;
        }
        vec.push_back(z);
    }
    if (vec.size() == 0) {
        return 1;
    }
    if (vec.size() == 1) {
        return vec[0]+1;
    }
    sort(vec.begin(), vec.end());
    if (vec.size()%2 == 0) {
        bool ok = true;
        rep(i,vec.size()/2) {
            if (vec[i]+vec[vec.size()-1-i] > x) {
                ok = false;
                break;
            }
        }
        if (ok) {
            return 1;
        }
        if (v == 0) return INF;
        if (vec[vec.size()-1] > x) return INF;
        vec.pop_back();
    }
    int st = -1, en = vec.size(), mid;
    while (en-st > 1) {
        mid = (st+en)/2;
        if (checker(vec, mid, x)) {
            en = mid;
        } else {
            st = mid;
        }
    }
    if (en == vec.size()) {
        return INF;
    }
    return vec[en]+1;
}

bool solve(int x) {
    int z = dfs(0, 0, x);
    if (z-1 > x) return false;
    return true;
}

int main(){
    cin >> n;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    if (n == 2) {
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    rep(i,n) {
        if (e[i].size() > 2) {
            ansa += (e[i].size()-2+1)/2;
        }
    }
    int st = 1, en = n, mid;
    while (en-st > 1) {
        mid = (st+en)/2;
        if (solve(mid)) {
            en = mid;
        } else {
            st = mid;
        }
    }
    cout << ansa << " " << en << endl;
}
































Measured memory_bytes: 17664
#include <stdio.h>

int main(){
    int i,dice[7];
    char order[101];

    for(i=1;i<7;i++){
        scanf("%d",&dice[i]);
    }

    scanf("%s",order);

    for(i=0;order[i]!='\0';i++){
        dice[0]=dice[1];

        switch(order[i]){

            case 'E':
                dice[1]=dice[4];
                dice[4]=dice[6];
                dice[6]=dice[3];
                dice[3]=dice[0];
                break;
            case 'N':
                dice[1]=dice[2];
                dice[2]=dice[6];
                dice[6]=dice[5];
                dice[5]=dice[0];
                break;
            case 'S':
                dice[1]=dice[5];
                dice[5]=dice[6];
                dice[6]=dice[2];
                dice[2]=dice[0];
                break;
            case 'W':
                dice[1]=dice[3];
                dice[3]=dice[6];
                dice[6]=dice[4];
                dice[4]=dice[0];
                break;

        }
    }
    printf("%d\n",dice[1]);
}


Measured memory_bytes: 2120
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll A[2];
	for (ll i = 0; i < 2; ++i) cin >> A[i];
 
	// 解法
	// DP
	sort(A,A+2);
	ll ans = 0;
	ans += A[1];
	A[1]--;
	sort(A,A+2);
	ans += A[1];
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int N, M;
string S;
ll D[5000][5002], res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y >>= 1;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	cin >> N >> S;
	M = S.size();
	D[0][0] = 1;
	D[0][1] = 2;
	for (int i = 1; i < N; ++i) {
		D[i][0] = D[i - 1][1] + D[i - 1][0];
		D[i][0] %= mod;
		for (int j = 1; j <= i + 1; ++j) {
			D[i][j] = D[i - 1][j - 1] * 2 + D[i - 1][j + 1];
			D[i][j] %= mod;
		}
	}
	res = D[N - 1][M];
	res = res*pw(modinv(2), M) % mod;
	cout << res << endl;
}

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

int main() {
  vector<string> x(100000);
  vector<int> y(100000);
  int idx = 0;
  while(true) {
    cin >> x.at(idx);
    if(x.at(idx) == "0") {
      y.at(idx) = 0;
      break;
    }
    for(int i = 0; i < x.at(idx).size(); i++) {
      y.at(idx) += x.at(idx).at(i) - '0';
    }
    idx++;
  }
  idx = 0;
  while(y.at(idx) != 0) {
    cout << y.at(idx) << "\n";
    idx++;
  }
}


Measured memory_bytes: 3828
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>

using namespace std;

int main()
{
	long long int i, j, k, l, m, n, s;
	long long int sum;
	sum = 0;
	char S[11];
	cin >> S;
	s = S[0] - '0';
	n = strlen(S);
	m = 1;
	for (i = 1; i <= n - 1; i++) {
		m *= 2;
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < n - 1; j++) {
			if (i&(1 << j)) {
				sum += s;
				s = 0;
			}
			s *= 10;
			s += S[j + 1] - '0';
		}


		sum += s;
		s = S[0] - '0';


	}
	cout << sum << endl;

	return 0;
}




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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int view_e = 0, view_w = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (s.at(i) == 'E') {
      view_e++;
    }
  }

  int result = view_e;
  for (i = 0; i < n; i++) {
    if (s.at(i) == 'E') {
      view_e--;
    }
    result = min(result, view_e + view_w);
    if (s.at(i) == 'W') {
      view_w++;
    }
  }
  result = min(result, view_e + view_w);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 900
#include <stdio.h>
int n,i,A[2000];
int solve(int,int);
int main(){
  int m[2000],q;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&m[i]);
  for(i=0;i<q;i++){
    if(solve(0,m[i])==1)
      printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res;
  if(m==0)
    return 1;//真                                                               
  if(i>=n)
    return 0;//負                                                               
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}




Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    ll d ,n;
    cin >> d >> n;
    if(d == 0) {
        if(n<=99) cout << n << endl;
        else cout << n+1 << endl;
    } else if (d == 1) {
        if(n<=99) cout << n*100 << endl;
        else cout << (n+1)*100 << endl;
    } else {
        if(n<=99) cout << n*10000 << endl;
        else cout << (n+1)*10000 << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <bitset>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <random>
#include <cassert>

using namespace std;

//#define FAST_ALLOCATOR_MEMORY 1e8
#undef LOCAL
//#include "optimization.h"

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

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long n, c;
	cin >> n >> c;
	vector< pair<long long, int> > a(n + 1);
	a[0] = { 0, 0 };
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	a.push_back({ c, 0 });
	vector<long long> l(n + 2), r(n + 2), l2(n + 2), r2(n + 2);
	for (int i = 1; i <= n; i++) {
		l[i] = l[i - 1] + a[i].second - (a[i].first - a[i - 1].first);
		l2[i] = l2[i - 1] + a[i].second - 2 *(a[i].first - a[i - 1].first);
	}
	for (int i = 1; i <= n; i++) {
		l[i] = max(l[i], l[i - 1]);
		l2[i] = max(l2[i], l2[i - 1]);
	}

	for (int i = n; i >= 0; i--) {
		r[i] = r[i + 1] + a[i].second - (a[i + 1].first - a[i].first);
		r2[i] = r2[i + 1] + a[i].second - 2 * (a[i + 1].first - a[i].first);
	}
	for (int i = n; i >= 0; i--) {
		r[i] = max(r[i], r[i + 1]);
		r2[i] = max(r2[i], r2[i + 1]);
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, l[i] + r2[i + 1]);
		ans = max(ans, l2[i] + r[i + 1]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6372
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
DP = []
for s in range(2**n):
    tmp = 0
    bit = bin(s)[2:].zfill(n)
    for i in range(n):
        for j in range(i + 1, n):
            if bit[i] == '1' and bit[j] == '1':
                tmp += A[i][j]
    msk = [i for i in range(n) if bit[i] == '1']
    DP.append(tmp)
    t = (s - 1) & s
    while t:
        DP[s] = max(DP[s], DP[t] + DP[s - t])
        t = (t - 1) & s
print(DP[-1])


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vi dp(k + 1);
    dp[0] = 1;
    for (int i = 1; i <= k; i++) {
        int cnt = 0;
        for (int j = 1; j <= n; j++) {
            if (i - a[j] < 0) {
                continue;
            } 
            cnt += dp[i-a[j]];
        }
        if (!cnt) {
            dp[i] = 1;
        } 
    } 
    if (dp[k]) {
        cout << "Second";
    } else {
        cout << "First";
    }
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() << " ms.\n";
}


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

int main(){
	int n;
	scanf("%d", &n);
	deque<long> deq;
	for(int i = 0; i < n; i++) {
		int y;
		scanf("%d", &y);
		if(y == 0) {
			int d;
			long x;
			scanf("%d%ld", &d, &x);
			if(d == 0) deq.push_front(x);
			if(d == 1) deq.push_back(x);
		}
		if(y == 1) {
			int p;
			scanf("%d", &p);
			printf("%ld\n", deq[p]);
		}
		if(y == 2) {
			int d;
			scanf("%d", &d);
			if(d == 0) deq.pop_front();
			if(d == 1) deq.pop_back();
		}
	}
}



Measured memory_bytes: 6348
def abc():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    ans = 0
    for a in range(A+1):
        for b in range(B + 1):
            for c in range(C + 1):
                if a * 500 + b * 100 + c * 50 == X:
                    ans += 1
    print(ans)


abc()


Measured memory_bytes: 3060
# B - Qualification simulator
n, a, b = map(int, input().split())
passed_count = 0
oversea_rank= 0

for s in input():
	if s == 'a':
		if passed_count < a + b:
			print('Yes')
			passed_count += 1
		else:
			print('No')
	elif s == 'b':
		oversea_rank += 1
		
		if passed_count < a + b and oversea_rank <= b:
			print('Yes')
			passed_count += 1
		else:
			print('No')
	else:
		print('No')

Measured memory_bytes: 53592
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    map<string, LL> cnt;
    for(LL i = 0; i < n; ++i){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        cnt[s] += 1;
    }
    LL ans = 0;
    for(auto p: cnt){
        ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
int main()
{
    ll n,i,j,ans,temp;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++) 
    {
        cin>>a[i];
    }
    temp=a[0];
    for(i=1;i<n;i++) 
    {
     ans=__gcd(temp,a[i]);
     temp=ans;
    }
    cout<<temp;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
Hlist = list(map(int, input().split()))
maxH = 0
a = True
for n in range(N):
    if maxH == Hlist[n]:
        maxH = Hlist[n]
    elif maxH < Hlist[n]:
        if maxH <= Hlist[n] - 1:
            maxH = Hlist[n] - 1
    else:
        a = False
        break
if a == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14224
#include <iostream>

using std::cout;
using std::cin;
using std::endl;;

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

        if (h == 0 && w == 0) {
            break;
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
// C - Average Length
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi X(N),Y(N); rpz(i, N) cin>>X[i]>>Y[i];
	double sum = 0.0;
	rpz(i, N) rpz(j, i){
		int dx = X[i] - X[j];
		int dy = Y[i] - Y[j];
		sum += sqrt(dx*dx + dy*dy);
	}
	printf("%.10f\n", sum*2/N);
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//変数
vector<int> num;
string ans = "";

//サブ関数
//入力
void input() {
	string s;
	cin >> s;
	for (auto c : s) {
		num.push_back(c - '0');
	}
}


void rec(int id, int sum, string s) {
	if (id == 4) {
		if(sum==7)ans = s + "=7";
		return;
	}
	rec(id + 1, sum + num[id], s + "+" + to_string(num[id]));
	rec(id + 1, sum - num[id], s + "-" + to_string(num[id]));
}


//計算
void calc() {
	rec(1, num[0], to_string(num[0]));
}


//出力
void output() {
	cout << ans << endl;
}

//デバッグ
void debug() {
	int N;
	cin >> N;
}


//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 256
d = {}
N = int(input())
for i in range(N):
    s = input()
    d[s] = d.get(s, 0) + 1
M = int(input())
for i in range(M):
    t = input()
    d[t] = d.get(t, 0) - 1
print(max(max(d.values()), 0))

Measured memory_bytes: 3060
iN = int(input())
aX = [int(_) for _ in input().split()]

aXs = sorted(enumerate(aX),key=lambda x:x[1])

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,(map(lambda x: iMuV if aX[x] < iMuV else iMdV ,range(iN))))))


Measured memory_bytes: 49216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct segmentTree {
	int n;
	vector<ll> t;
	segmentTree(int N) {
		n = N;
		t.resize(2 * N, 0);
	}

	void build() {
		for (int i = 0; i < n; i++)cin >> t[i + n];
		for (int i = n - 1; i > 0; i--)t[i] = max(t[2 * i] , t[2 * i + 1]);
	}
	void update(int pos, int val) {
		pos += n;
		t[pos] = val;
		for (; pos > 1; pos /= 2)t[pos / 2] = max(t[pos] , t[pos ^ 1]);
	}
	ll query(int l, int r) { //interval on [l,r]
		r++;
		ll res = 0;
		for (l += n, r += n; l < r; l /= 2, r /= 2) {
			if (l & 1)res = max(res, 1ll * t[l++]);
			if (r & 1)res = max(res, 1ll * t[--r]);
		}
		return res;
	}
};

void solve() {
	int mx = 3e5 + 1;
	int n, k; cin >> n >> k;
	segmentTree temp(mx);
	for (int i = 0; i < n; i++) {
		int cur; cin >> cur;
		int wow = temp.query(max(0, cur - k), min(cur + k, mx)) + 1;
		temp.update(cur, wow);

	}
	cout << temp.query(0, mx);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x = 0):x((x % mod + mod) % mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll cnt(60);
    rep(i, n) {
        rep(j, 60) {
            if (a[i]>>j&1) cnt[j]++;
        }
    }
    mint ans = 0;
    rep(i, n) {
        rep(j, 60) {
            mint x;
            if (a[i]>>j&1) {
                cnt[j]--;
                x = (n-1-i) - cnt[j];  
            } else {
                x = cnt[j];
            }
            ans += (mint)pow(2, j) * x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#coding:utf-8
n=[int(i) for i in input().split()]
if(n[0]==1):
  n[0]+=13
if(n[1]==1):
  n[1]+=13
if(n[0]==n[1]):
  print("Draw")
elif(n[0]<n[1]):
  print("Bob")
else:
  print("Alice")

Measured memory_bytes: 3064
#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);

    int n; cin>>n;
    vector<int> a(n), b(n), c(n-1);
    for(int i=0; i<n; i++) cin>>a[i];
    int bsum = 0;
    for(int i=0; i<n; i++){
        cin>>b[i];
        bsum += b[i];
    }
    for(int i=0; i<n-1; i++) cin>>c[i];

    int csum = 0;
    for(int i=0; i+1<n; i++){
        if(a[i] + 1 == a[i+1]){
            csum += c[a[i] - 1];
        }
    }

    cout << bsum + csum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 105
#define MOD 1000000007

int main()
{
    //freopen("output.txt","r",stdin);
    //freopen("input.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    if(a<=9 && b<=9)
    {
        cout << a*b << endl;
    }else
    {
        cout << -1 << endl;
    }
}





Measured memory_bytes: 256
N=int(input())
nt=0
np=(0,0)
ok=True
for t,x,y in [map(int,input().split()) for _ in range(N)]:
  el,nt=t-nt,t
  dist=abs(np[0]-x)+abs(np[1]-y)
  
  if el<dist: 
    ok=False 
    break
  if (el-dist)%2!=0:
    ok=False 
    break
  np=(x,y)
if ok:
  print("Yes")
else:
  print("No")

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

long long modpow(long long a, long long n, long long p){
	long long res = 1;
	while(n > 0){
		if(n & 1){
			res = res*a%p;
		}
		a = a*a%p;
		n >>=1;
	}
	return res;
}


int main()
{
	int n;
	long long ans = 0;
	cin>> n;
	vector<int> a(n);
	vector<int> cnt(n);
	for(int i=0;i<n;i++){
		cin>> a[i];
	}
	
	int cnt0 = 3;
	if(a[0] == 0){
		ans = 3;
		cnt[0]++;
		cnt0--;
	}
	for(int i=1;i<n;i++){
		if(a[i] == 0){
			ans *= cnt0;
			cnt0--;
			cnt[0]++;
			if(cnt0<0) ans = 0;
		}else{
			ans *= (cnt[a[i]-1] - cnt[a[i]]);
			cnt[a[i]]++;
			if(3<cnt[a[i]]) ans = 0;
		}
		if(1E9+7<=ans) ans %= (long long)(1E9+7);
	}
	
	
	
	
	
	cout<<ans<<endl;
}


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

int main() {

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

    vector<ll> dp(n);
    dp[0] = 0;
    dp[1] = std::max(a[0], a[1]);
    dp[2] = std::max(dp[1], a[2]);
    ll oddSum = a[0] + a[2]; //a[0]+a[2]+...と、奇数番目の要素のみを足したもの。
    for (int i = 3; i < n; i++) {
        if (i % 2 == 0) {
            dp[i] = std::max(dp[i - 3] + a[i - 1], dp[i - 2] + a[i]);
            oddSum += a[i];
        }
        else {
            dp[i] = std::max(oddSum, dp[i - 2] + a[i]);
        }
    }
    cout << dp[n - 1] << endl;

    return 0;

}


Measured memory_bytes: 6424
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int V,E,r;
const int INF=1e9;

struct edge{int to,cost;};
vector<edge> G[100010];
int d[100010];

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();  que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(void){
	int i;

	cin >> V >> E >> r;
	for(i=0;i<E;i++){
		int s,t,d;
		cin >> s >> t >> d;
		edge e;
		e.to=t;  e.cost=d;
		G[s].push_back(e);
	}

	dijkstra(r);
	for(i=0;i<V;i++){
		if(d[i]!=INF) cout << d[i] << endl;
		else cout << "INF" << endl;
	}
	 return 0;
}

Measured memory_bytes: 13036
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int N, a = 0, b = 0, c = 0, d = 0;
	string S;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S;
		if (S == "AC")
		{
			a++;
		}
		if (S == "WA")
		{
			b++;
		}
		if (S == "TLE")
		{
			c++;
		}
		if (S == "RE")
		{
			d++;
		}
		S = "";
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn], M[maxn], Mi[maxn];

int main() {
    int n;
    while(~scanf("%d", &n)) {
        for(int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            M[i] = a[i];
        }
        ll sum = 0;
        if(n == 2) {
            printf("%d\n%d\n", abs(2 * a[1]),  abs(2 * a[0]));
            continue;
        }
        for(int i = 1; i < n; i++) {
            M[i] = a[i] - a[i - 1];
            sum += abs(M[i]);
        }
        sum += abs(a[n - 1]);
        sum += abs(a[0]);
        printf("%lld\n", sum - abs(M[1]) - abs(a[0]) + abs(a[1]));
        for(int i = 1; i < n - 1; i++) {
            printf("%lld\n", sum - abs(M[i + 1]) - abs(M[i]) + abs(a[i + 1] - a[i - 1]));
        }
        printf("%lld\n", sum - abs(a[n - 1]) + abs(a[n - 2]) - abs(M[n - 1]));
    }
    return 0;
}


Measured memory_bytes: 2048
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    vs <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let vmin = V.minimum vs
        vmax = V.maximum vs
    mv <- MV.replicate (vmax - vmin + 3) 0 :: IO (MV.MVector (PrimState IO) Int)
    V.forM_ vs $ \i -> MV.modify mv succ (i + 1 - vmin)
    v <- V.unsafeFreeze mv
    let v1 = v
        v2 = V.tail v1
        v3 = V.tail v2
    print $ V.maximum $ V.zipWith3 (\x y z -> x + y + z) v1 v2 v3


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 1; i < (int)1e8; i++) {
    if ((ans * x) % 360 == 0) {
      cout << i << '\n';
      return 0;
    }
    ans++;
  }
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	char p = s[0];
	int ans = 0;
	for(auto i = 1; i < (int)s.size(); ++i){
		if(s[i] != p) ++ans;
		p = s[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll ans, n, f[N],v,q,a,b;
void solve(){
    scanf("%lld", &n);
    for(int i=0;i<n;i++){
        scanf("%lld",&v);
        f[v]++;
        ans+=v;
    }
    scanf("%lld",&q);
    while(q--){
        scanf("%lld%lld",&a,&b);
        ans+=(b-a)*f[a];
        f[b]+=f[a];
        f[a]=0;
        printf("%lld\n", ans);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 4616
#include <stdio.h>

struct Dice {
	int face[6];
};

int main(void)
{
	struct Dice dice;
	char comm[101];
	int i, t;

	for (i = 0; i < 6; i++) {
		scanf("%d", &dice.face[i]);
	}
	scanf("%s", comm);
	for (i = 0; comm[i] != '\n' && comm[i] != '\0'; i++) {
		switch (comm[i]) {
		case 'N':
			t = dice.face[0];
			dice.face[0] = dice.face[1];
			dice.face[1] = dice.face[5];
			dice.face[5] = dice.face[4];
			dice.face[4] = t;
			break;
		case 'S':
			t = dice.face[0];
			dice.face[0] = dice.face[4];
			dice.face[4] = dice.face[5];
			dice.face[5] = dice.face[1];
			dice.face[1] = t;
			break;
		case 'E':
			t = dice.face[0];
			dice.face[0] = dice.face[3];
			dice.face[3] = dice.face[5];
			dice.face[5] = dice.face[2];
			dice.face[2] = t;
			break;
		case 'W':
			t = dice.face[0];
			dice.face[0] = dice.face[2];
			dice.face[2] = dice.face[5];
			dice.face[5] = dice.face[3];
			dice.face[3] = t;
			break;
		default:
			break;
		}
	}
	printf("%d\n", dice.face[0]);

	return 0;
}



Measured memory_bytes: 2104
// luogu-judger-enable-o2
var s,st:string;
n,m,i,k,j,t:longint;
begin
read(s);
for i:=1 to length(s)do
begin
if s[i]='0'then st:=st+'0';
if s[i]='B'then delete(st,length(st),1);
if s[i]='1'then st:=st+'1';
end;
writeln(st);
end.

Measured memory_bytes: 128
using System;

namespace Hi
{
    class Program
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            int h = 0, m = 0, s = 0;

            while (x >= 3600)
            {
                x -= 3600;
                h++;
            }

            while (x >= 60)
            {
                x -= 60;
                m++;
            }

            s = x;


            Console.WriteLine("{0}:{1}:{2}",h,m,s);

        }
    }
}

Measured memory_bytes: 9064
import sys
def input():
    return sys.stdin.readline()
    
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    for k in range(1, min(K+1, i+1)):
        dp[i] = min(dp[i], dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])

Measured memory_bytes: 55004
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}


int main(){
 ll d ; cin>> d ;
 ll c[26] ; rep(i,26) cin>>c[i] ;
 ll s[d][26] ;
 vector<ll> bns(d)  ;
  rep(i,d){
     rep(j,26){
        cin>> s[i][j] ;
        if(s[i][bns[i]] <s[i][j]) bns[i]= j ;
     }
 }
 
 ll t[d] ; 
 
 rep(i,d){
   t[i]=(bns[0]+i)%26 ;
 }
 
 ll m= 365*100 ;
 ll p[m] ;ll q[m] ;
 rep(i,m){
   p[i]=m%365 ;
   ll a= p[i] ;
   q[i]= bns[a] ;
 }
 ll ans=0 ;
ll last[26] ; rep(i,26) last[i]=0 ;
rep(i,d){
  ans+= s[i][t[i]] ;
  rep(i,26) last[i] ++ ;
  last[t[i]]=0 ;
  ll sum=0 ;
  rep(i,26) sum+= c[i]*last[i] ;
  ans-= sum ;
  }
  
  
  
  rep(i,m){
   ll rans= ans ;
   ll memo = t[p[i]] ;
   t[p[i]]= q[i] ;
   ll maex=p[i]+1, atox= d-p[i] ;
   ll maey=p[i]+1 ,atoy= d-p[i] ;
    rep(j,d){
     if(t[j]==memo&&j<p[i]) maex=p[i]-j ;
     if(t[j]==memo&&j>p[i]){
       atox= j-p[i] ;
       break ;
     }
    }
    rep(j,d){
     if(t[j]==q[i]&&j<p[i]) maey=p[i]-j ;
     if(t[j]==q[i]&&j>p[i]){
       atoy= j-p[i] ;
       break ;
     }
    }
    ans -= c[memo]*atox*maex ;
    ans += c[q[i]]*atoy*maey ;
    ans = ans- s[p[i]][memo] + s[p[i]][q[i]] ;
    if(ans<rans){
      t[p[i]]= memo ;
    }
  }

   rep(i,d) cout<< t[i]+1<<endl ;
 return 0 ;
}


Measured memory_bytes: 4256
while aaa = gets
	
array = aaa.chomp.split("\s")
array.map!{|item| item.to_f}

a = array[0]; b = array[1]; c = array[2]
d = array[3]; e = array[4]; f = array[5]

y = (d*c-a*f)/(d*b-a*e)
x = (c-b*y)/a


print sprintf("%.3f %.3f\n", x,y)

end

Measured memory_bytes: 6140
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), x = scanner.nextInt(), ans = 0;
        int[] a = IntStream.range(0, n)
                .map(i -> scanner.nextInt())
                .sorted()
                .toArray();

        for (int i = 0; i < n; i++, ans++) {
            if (x >= a[i]) {
                x -= a[i];
            } else {
                break;
            }
        } if (ans == n && x != 0) {
            ans--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28752
N, X = map(int, input().split())
S = 0
M = 2 ** (N + 2) - 3
P = 2 ** (N + 1) - 1
for i in range(N+1):
  P -= 1
  P //= 2
  M -= 1
  M //= 2
  if X - 1 == 0:
    if M != 0:
      break
    else:
      S += 1
      break
  if X - 1 == M:
    S += 1 + P
    break
  elif X - 1 == 2 * M:
    S += 1 + 2 * P
    break
  elif (X - 1) % M != 0 and (X - 1) > M:
    S += 1 + P
    X -= M + 1
    M -= 1
  elif (X - 1) % M != 0 and (X - 1) < M:
    X -= 1
    M -= 1
print(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, L, R;
vector<int> val[N];
int lch[N << 2], rch[N << 2], Max[N << 2], lazy[N << 2];
inline void update(int x, int v) {
    lazy[x] += v; Max[x] += v;
}
inline void pushup(int x) {Max[x] = max(Max[x << 1], Max[x << 1 | 1]);}
inline void pushdown(int x) {
    if(lazy[x]) {
        update(x << 1, lazy[x]); update(x << 1 | 1, lazy[x]); lazy[x] = 0; 
    }
}
void build(int x,int l, int r) {
    lch[x] = l; rch[x] = r;
    if(l == r) {
        Max[x] = l; return;
    }
    int mid = (l + r) / 2;
    build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r);
    pushup(x);
}
void update(int x, int l, int r, int v) {
    if(l <= lch[x] && rch[x] <= r) {
        update(x, v); return;
    }
    pushdown(x);
    int mid = (lch[x] + rch[x]) / 2;
    if(r <= mid) update(x << 1, l, r, v);
    else if(l > mid) update(x << 1 | 1, l, r, v);
    else update(x << 1, l, mid, v), update(x << 1 | 1, mid + 1, r, v);
    pushup(x);
}
int query(int x, int l, int r) {
    if(l <= lch[x] && rch[x] <= r) {
        return Max[x];
    }
    pushdown(x);
    int mid = (lch[x] + rch[x]) / 2;
    if(r <= mid) return query(x << 1, l, r);
    else if(l > mid) return query(x << 1 | 1, l, r);
    else return max(query(x << 1, l, mid), query(x << 1 | 1, mid + 1, r));
}
int ans = 0;
int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) {
        scanf("%d%d", &L, &R); val[L].push_back(R);
    }
    build(1, 0, m + 1);
    for(int i = 0; i <= m; ++i) {
        for(int j = 0; j < val[i].size(); ++j) {
            update(1, 0, val[i][j], 1);
        }
        ans = max(ans, query(1, i + 1, m + 1) - m - i - 1);
    }
    printf("%d\n", max(ans, n - m));
    return 0;
}

Measured memory_bytes: 20992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll h, w, a[2010][2010], ans, b[2010][2010];
string s[2010];

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (s[i][j] == '#')
			{
				a[i][j] = 0;
			}
			else
			{
				if (j == 0)
				{
					a[i][j] = 1;
				}
				else
				{
					a[i][j] = a[i][j - 1] + 1;
				}
			}
		}
		for (int j = w - 1; j >= 0; j--)
		{
			if (a[i][j + 1] != 0 && a[i][j] != 0)
			{
				a[i][j] = a[i][j + 1];
			}
		}
	}
	for (int i = 0; i < w; i++)
	{
		for (int j = 0; j < h; j++)
		{
			if (s[j][i] == '#')
			{
				b[j][i] = 0;
			}
			else
			{
				if (j == 0)
				{
					b[j][i] = 1;
				}
				else
				{
				b[j][i] = b[j - 1][i] + 1;
				}
			}
		}
		for (int j = h - 1; j >= 0; j--)
		{
			if (a[j + 1][i] != 0 && a[j][i] != 0)
			{
				b[j][i] = b[j + 1][i];
			}
		}
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			ans = max(ans, a[i][j] + b[i][j] - 1);
		}
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 67328
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;

    int N = S.size();

    string ans = "No";

    for(int i=0;i<N;i++){
        if(S != T){
            char tmp = S[N-1];
            //string tmp = tmp;
            //string tmp = c_str;
            string tmp_S = "";
            tmp_S.append(1,tmp);
            //cout << tmp_S << endl;
            tmp_S += S;
            //cout << tmp_S << endl;
            tmp_S.erase(N);
            S = tmp_S;

            //cout << i << ":" <<  S << " " << T << endl;
            
        }else{
            ans = "Yes";
            break;
        }
    }

    cout << ans << endl;
    return 0;

}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N%2) cout << N/2 << endl;
    else cout << N/2 - 1 << endl;

    return 0;
}


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

int main() {
    int x;
    string ans;

    cin >> x;
    if (x == 3) {
        ans = "YES";
    } else if (x == 5) {
        ans = "YES";
    } else if (x == 7) {
        ans = "YES";
    } else {
        ans = "NO";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    lint s[n];
    rep(i, n) scanf("%lld", &s[i]);
    lint ans = 0;
    For(d, 1, n/2){
        lint sum = 0;
        for(int l=0, r=n-1; (n-1)%d==0 ? l<r : d<r; l+=d, r-=d, sum+=s[l]+s[r]){
            chmax(ans, sum);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N;cin>>N;
  ll tmp;
  for(ll i=ll(pow(N,0.5))+1;i>=1;--i){
    if(N%i==0){
      tmp=i;
      break;
    }
  }
  ll ans = 0;
  tmp = N/tmp;
  while(tmp!=0){
    tmp/=10;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint k;
string s;

const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> k >> s;
	llint n = s.size();
	
	llint ans = 0;
	for(int i = 0; i <= k; i++){
		llint tmp = comb(n-1+k-i, n-1) * modpow(25, k-i) % mod;
		tmp *= modpow(26, i), tmp %= mod;
		ans += tmp, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 51132