akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

	rep(i,n)
	{
		string s;
		cin >> s;

		vector<char> v;
		v.push_back(s[0]);
		int now = 0;

		rep(j,s.size())
		{
			if('a' <= s[j] && s[j] <= 'z')
			{
				int flag = 0;

				if(s[j+1] == '-' && s[j+2] == '>')
				{
					flag = 1;
				}
				else if(s[j+1] == '<' && s[j+2] == '-')
				{
					flag = 2;
				}

				if(flag == 1)
				{
					if('a' <= s[j+3] && s[j+3] <= 'z')
					{
						if(now == v.size() -1)
						{
							v.push_back(s[j+3]);
							now++;
						}
						else
						{
							now++;
						}
					}
				}
				else if(flag == 2)
				{
					if('a' <= s[j+3] && s[j+3] <= 'z')
					{
						if(now == 0)
						{
							vector<char> temp;
							std::copy(v.begin(),v.end(),std::back_inserter(temp));

							v[0] = s[j+3];
							v.resize(1);

							rep(h,temp.size())
							{
								v.push_back(temp[h]);
							}
						}
						else
						{
							now--;
						}
					}
				}
				else
				{
					break;
				}
			}

			if(j+3 == s.size()-1)
			{
				break;
			}
			else
			{
				j += 2;
			}
		}

		rep(j,v.size())
		{
			cout << v[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<vector>
    #include<iomanip>
    #include<math.h>
    #include<complex>
    #include<queue>
    #include<deque>
    #include<stack>
    #include<map>
    #include<set>
    #include<bitset>
    using namespace std;
    #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
    #define rep(i,n) REP(i,0,n)
    typedef long long ll;
    typedef pair<int,int> pint;
    typedef pair<ll,int> pli;
    typedef pair<ll,ll> pll;
    const int inf=1e9+7;
    const ll longinf=1LL<<60 ;
    const ll mod=1e9+7 ;
        using namespace std;

        int main(){
          ll n;
          cin >> n;
          ll a[n+1];
          rep(i,n) cin >> a[i];
          sort(a,a+n);
          pll x;
          ll ans=a[n-1]-a[0];
          x.first=a[0];
          x.second=a[n-1];
          pll kouho,kouho2;
          kouho.first=a[1];
          kouho.second=1;
            kouho2.first=a[n-2];
            kouho2.second=n-2;
          for(int i=1;i<n-1;i++){
            ll le1=abs(x.first-kouho.first);
            ll le2=abs(x.first-kouho2.first);
            ll ri1=abs(x.second-kouho.first);
            ll ri2=abs(x.second-kouho2.first);
           if(le1>=le2 && le1>=ri1 && le1>=ri2){
             ans+=le1;
            x.first=kouho.first;
              kouho.first=a[kouho.second+1];
               kouho.second++;
           }
            else if(le2>=le1 && le2>=ri1 && le2>=ri2){
             ans+=le2;
              x.first=kouho2.first;
              kouho2.first=a[kouho2.second-1];
                kouho2.second--;
            }
            else if(ri1>=le1 && ri1>=le2 && ri1>=ri2){
             ans+=ri1;
              x.second=kouho.first;
               kouho.first=a[kouho.second+1]; 
              kouho.second++;
            }
            else if(ri2>=le1 && ri2>=le2 && ri2>=ri1){
             ans+=ri2;
              x.second=kouho2.first;
              kouho2.first=a[kouho2.second-1];
                kouho2.second--;
            }
          }
          cout << ans << endl;
          return 0;}

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

void swap(int &x, int &y) {

	int temp;
	temp = x;
	x = y;
	y = temp;


}
int main(){
  
  
  int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z;
  
  
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  char c;
  set<char> sc;
  rep(i, 0, N) {
    cin >> c;
    sc.insert(c);
  }

  string ans = "Three";
  if (sc.size() == 4) ans = "Four";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);
my $m = length $s;
my @t = split //, $s;
my @u = sort {$a cmp $b} grep {my $x = 0; for my $i (0..$m-1) {$x++ if $_ eq $t[$i]}; $x} ('a'..'z');
my %h;
{
  my $c = 1;
  for my $i ('a'..'z') {
    $h{$i} = $c++;
  }
}
if (@u < 26) {
  for my $i ('a'..'z') {
    my $f = 1;
    for my $j (@u) {
      if ($j eq $i) {
        $f = 0;
        last;
      }
    }
    if ($f==1) {
      say $s.$i;
      exit;
    }
  }
} else {
  my $f = -1;
  my $ud;
  for my $i (0..24) {
    if ($t[$m-1-$i] gt $t[$m-2-$i]) {
      $f = $m - $i - 2;
      last;
    }
  }
  if ($f==-1) {
    say -1;
  } else {
    my @w = split '', substr($s, $f+1);
    @w = sort {$a cmp $b} grep {$_ gt substr($s, $f, 1)} @w;
    say substr($s, 0, $f).$w[0];
  }
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans=0;
  int c2 = c*2;
  
  if (a > c2 && b > c2) {
    ans += max(x,y) * c2;
    cout << ans << endl;
    return 0;
  }
  while(0 < x || 0 < y) {
    if (y <= 0) if (a < c2) {ans +=a; x--; continue;}
    if (x <= 0) if (b < c2) {ans +=b; y--; continue;}
    if (a+b > c2) {ans+=c2; x--; y--;}
    else {ans += a+b ; x--; y--;}
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char c = sc.next().toCharArray()[0];
        System.out.println(c >= 'a' ? 'a' : 'A');
    }

}

Measured memory_bytes: 35572
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N;
  cin >> N;
  if (N % 2) cout << N / 2 + 1 << endl;
  else cout << N / 2 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
n, d = map(int,input().split())
x = [list(map(int, input().split())) for _ in range(n)]
dist = lambda y, z : sum([(y_ - z_)**2 for y_,z_ in zip(y, z)]) ** 0.5
ret = 0
for i in range(n-1):
    for j in range(i+1, n):
        if i==j:
            continue
        distance = dist(x[i], x[j])
        if distance - int(distance)==0:
            ret += 1
print(ret)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> 				void _DO(I&&x){	cerr<<x<<endl;	}
template<typename I,typename...T>	void _DO(I&&x,T&&...tail){	cerr<<x<<" , ";	_DO(tail...);	}
template<typename _a,typename _b> 	ostream& operator << (ostream &_s,const pair<_a,_b> &_p)
{	return _s<<'('<<_p.first<<','<<_p.second<<')';	}
#define IOS
#else
#define debug(...)
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0);
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define stp setprecision(30)<<fixed
const ll INF=0x3f3f3f3f3f3f3f3f;
const int NF=0x3f3f3f3f;
const ll MAX=1e5+5,Mlg=__lg(MAX)+2;
const ll MOD=1e9+7;
// ready~ go!
// let's coding and have fun!
// I can't solve this problem!
int main(){
	IOS
	int x,y,z;	cin>>x>>y>>z;
	x-=z;
	cout<<x/(y+z)<< '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b&&b<c){
        printf("Yes\n");
    }
    else{
       printf("No\n");
    }
    return 0;
    
}
   




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

using namespace std;

long long int N, A, B;

int main(void) {

	cin >> N >> A >> B;

	long long int tmp;

	if (A > B) { tmp = B; B = A; A = tmp; }

	long long int ans;
	if ((B - A) % 2 == 0) { ans = (B - A) / 2; }
	else {
		tmp = A + (B - A - 1) / 2;
		ans = tmp;
		tmp = (N - B) + 1 + (B - A - 1) / 2;
		ans = min(ans, tmp);
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  int m=(sum+4*M-1)/(4*M);
  int cnt=0;
  for(int i=0;i<N;i++){
    if(A[i]>=m){cnt++;}
  }
  if(cnt>=M){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

 return 0;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<ll,ll> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	int n, k; cin >> n >> k;
	printf("%d", n - k + 1);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind {
    vector<int> par;

    UnionFind(int n) {
        par.resize(n);
        rep(i, n) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[ry] = rx;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

struct Edge {
    int u, v;
    ll cost;

    Edge(int u, int v, ll cost): u(u), v(v), cost(cost) {}
    bool operator< (const Edge rhs) const {
        return cost < rhs.cost;
    }
};

void add_edge(vector<Edge> &g, vector<pli> xs) {
    rep(i, xs.size() - 1) {
        int u = xs[i].second;
        int v = xs[i+1].second;
        ll cost = xs[i+1].first - xs[i].first;
        g.push_back(Edge(u, v, cost));
    }
}

int main() {
    int n; cin >> n;
    vector<pli> xs, ys;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        xs.emplace_back(x, i);
        ys.emplace_back(y, i);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    vector<Edge> g;
    add_edge(g, xs); add_edge(g, ys);
    sort(g.begin(), g.end());

    UnionFind mst(n);
    ll ans = 0;
    for (auto e: g) {
        if (!mst.same(e.u, e.v)) {
            ans += e.cost;
            mst.unite(e.u, e.v);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11080
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

/* binary search 
 *
 * In each round find the min number of cuts
 * needed to create size mid.
 *
 * If this number is lteq k mid is possible.
 */
void solve() {
    cini(n);
    cini(k);
    cinai(a,n);

    int l=0;
    int r=1e9+1;
    while(l+1<r) {
        int mid=(l+r)/2;

        int cnt=0;
        for(int i=0; i<n; i++) {
            cnt+=(a[i]-1)/mid;
            if(cnt>k)
                break;
        }

        if(cnt>k)
            l=mid;
        else 
            r=mid;
    }
    cout<<r<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 4772
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;

    vector<ll> a(3, 0);
    for(char c : s) a[c - 'a']++;
    ll m = *min_element(ALL_OF(a));
    ll M = *max_element(ALL_OF(a));
    cout << YES(M - m <= 1) << endl;
    
}

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

int main(int argc, char **argv)
{
	ll n,k,x,y;
  cin>>n>>k>>x>>y;
  ll sum=0;
  
  if (n>=k){
    sum+=k*x;
    sum+=(n-k)*y;
  }
  else sum+=n*x;
  cout<<sum<<"\n";
  
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>

int main()
{
    // 入力
    int D;
    int ret=0;
    std::cin >> D;
    if( D < 0 || 1 < D )
    {
        return -1;
    }

    if(D == 0)
    {
        ret=1;
    }
    else if(D == 1)
    {
        ret=0;
    }

    std::cout << ret;

    return 0;
}

Measured memory_bytes: 3592
import math


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        ans = 0
    else:
        ans = 1
        for x in A:
            ans *= x
            if ans > 10**18:
                ans = -1
                break
    print(ans)

 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 22684
//                                                              ۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ‎
//created by --------> Aslan Nesipbay;

#include<bits/stdc++.h>

#define F first
#define S second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef stringstream SS;
typedef pair< ll, ll > pll;

const ll N = 10e5 + 5;
const ll NN = 105;
const double pi = 3.14159;
const ll MAX = 2e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1000000000000000000;
const ll pw = 31;

void speed()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll dp[N][3];

void hajime()
{
    ll n;
    vector <ll> v[3];
    cin >> n;
    for (ll i = 1; i <= n; i ++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        v[0].push_back (a);
        v[1].push_back (b);
        v[2].push_back (c);
    }
    dp[0][0] = v[0][0];
    dp[1][0] = v[1][0];
    dp[2][0] = v[2][0];
    for (ll i = 1; i < n; i ++)
    {
        for (ll j = 0; j < 3; j ++)
        {
            if (j == 0)
            {
                dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + v[0][i];
            }
            if (j == 1)
            {
                dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + v[1][i];
            }
            if (j == 2)
            {
                dp[2][i] = max(dp[1][i - 1], dp[0][i - 1]) + v[2][i];
            }
        }
    }
    cout << max (dp[0][n - 1], max (dp[1][n - 1], dp[2][n - 1]));
}
int main()
{
    ll miyagi = 1;
    //scanf ("%I64d", &miyagi);
    speed();
    //cin >> miyagi;
    for (ll i = 1; i <= miyagi; i ++)
    {
        //cout << "Case " << i << ": ";
        hajime();
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

#define fi first
#define se second
typedef pair<int,int> pii;
vector<vector<int> > e;
vector<pii> dep;

void dfs(int n, int d) {
	dep.push_back(pii(d,n));
	for(int i = 0; i < e[n].size(); i++)
		dfs(e[n][i], d+1);
}

bool check[100100];
void dfs2(int n) {
	if(check[n]) return;
	check[n] = true;
	for(int i = 0; i < e[n].size(); i++)
		dfs2(e[n][i]);
}

int main() {
	int N, K;
	int res = 0;
	cin >> N >> K;
	vector<int> a(N);
	for(int i = 0; i < N; i++) {cin >> a[i]; a[i]--;}
	e.resize(N);
	for(int i = 1; i < a.size(); i++) {
		e[a[i]].push_back(i);
	}
	if(a[0] != 0) {
		res++;
		a[0] = 0;
	}
	dfs(0,0);
	sort(dep.rbegin(), dep.rend());
	for(int i = 0; i < dep.size(); i++) {
		if(dep[i].fi <= K) break;
		
		if(!check[dep[i].se]) {
			int n = dep[i].se;
			for(int j = 0; j < K-1; j++)
				n = a[n];
			dfs2(n);
			res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 11764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    map<string,int64_t> memo;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        memo[s]++;
    }
    int64_t Sum=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        Sum+=(it->second)*(it->second-1)/2;
    }
    cout<<Sum<<endl;
}

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

int main(){
  int n; cin >> n;
  int p, max=0,sum=0;
  for(int i=0;i<n;i++){
    cin >> p;
    sum+=p;
    if(p>max)
      max=p;
  }
  sum -=max/2;
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;


int main() {
    
    int n, k;
    scanf("%d%d",&n,&k);
    
    vector<bool> winIfIs(k+1, false);
    vi s(n);
    
    int minStone = oo;
    
    for(int i = 0; i< n; ++i) {
        scanf("%d",&s[i]);
        minStone = min(minStone, s[i]);
    }
    
    for(int i = minStone; i <= k; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i-s[j] >= 0 && winIfIs[i-s[j]] == false) {
                winIfIs[i] = true;
                break;
            }
        }
    }
    
    if(winIfIs[k] == true) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    
    return 0;
}




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

int N;
vector<int> H;
int dp[100000];

int f(int i)
{
	if (i == N)
		return 0;

	if (i + 2 < N)
	{
		if (dp[i+2] == -1)
			dp[i+2] = f(i+2);

		if (dp[i+1] == -1)
			dp[i+1] = f(i+1);

		return min(abs(H[i]-H[i+1]) + dp[i+1], abs(H[i]-H[i+2]) + dp[i+2]);
	}

	if (i + 1 < N)
	{
		if (dp[i+1] == -1)
			dp[i+1] = f(i+1);
	
		return abs(H[i]-H[i+1]) + f(i+1);
	}

	return 0;
}

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

	cin >> N;

	for (int i = 0, u; i < N; ++i)
	{
		cin >> u;
		H.push_back(u);
	}

	for (int i = 0; i < N; ++i)
		dp[i] = -1;
	cout << f(0) << endl;

	return 0;
}

Measured memory_bytes: 3576
import sys
def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])


Measured memory_bytes: 5584
#include<cstdio>
#include<algorithm>
using namespace std;

int a,b,c;

int main()
{
	scanf("%d%d%d",&a,&b,&c);
	
	swap(a,b);
	swap(a,c);
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
 } 

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  int x;
  for (int i = 0; i < N ; i++){
    cin >> x;
    if (x < K){
      if(x < K - x)
        sum += x * 2;
      else
        sum += (K - x) * 2;
    }
    
    else {
      sum += (x - K) * 2;
    }
  }
  
  cout << sum << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  int ev[100010]={};
  int od[100010]={};
  
  int r=0;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='R'){
      r++;
    }else{
      ev[i]+=r/2;
      od[i]+=(r+1)/2;
      r=0;
    }
  }
  for(int i=S.size()-1; i>=0; i--){
    if(S[i]=='L'){
      r++;
    }else{
      ev[i]+=r/2;
      od[i]+=(r+1)/2;
      r=0;
    }
  }
  
  for(int i=0; i<S.size(); i++){
    if(od[i]==0){
      cout << "0";
    }else{
      if(S[i]=='R'){
        cout << ev[i]+od[i+1];
      }else{
        cout << ev[i]+od[i-1];
      }
    }
    if(i<S.size()-1){
      cout << " ";
    }else{
      cout << endl;
    }
  }
} 

Measured memory_bytes: 1408
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    S = [list(readline().strip()) for _ in range(H)]

    dxdy8 = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1))

    for x in range(H):
        for y in range(W):
            if S[x][y] == '.':
                res = 0
                for dx, dy in dxdy8:
                    nx, ny = x + dx, y + dy
                    if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '#':
                        res += 1
                S[x][y] = str(res)

    for row in S:
        print(''.join(row))

    return


if __name__ == '__main__':
    main()


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

template <typename T>
vector<T> divisor(T n) {
  vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main() {
  ll N;
  cin >> N;

  auto ok = [&](ll k) {
    ll x = N;
    while (x && x % k == 0) x /= k;
    return x % k == 1;
  };

  ll ans;
  auto divs = divisor(N);
  for (auto d : divs)
    if (d > 1) ans += ok(d);

  divs = divisor(N - 1);
  for (auto d : divs)
    if (d > 1) ans += ok(d);

  cout << ans << endl;

  return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N,A,B;

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

	cin >> N >> A >> B;
	int ans = 0;
	FOR(i,0,N){
		int T;
		cin >> T;
		if(T < A || B <= T){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()

//use (__int128)to extend ll range
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
   if(a>b){
       return b;
   }
   return a;
}

ll max(ll a, ll b){
   if(a>b){
       return a;
   }else return b;
}
 
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
//-----comparision for pairs------
 
bool comp(const pair<int,int>pia,const pair<int,int>pib)
{
	if(pia.fi==pib.fi) return pia.se>pib.se;
	else return pia.fi>pib.fi;
}

const ll N=1e9+7;
int main()
{
  ll n,m;
  cin>>n>>m;
  cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;


}


Measured memory_bytes: 256
import sys
h, n = map(int, input().split())
# A = [0] * n
# B = [0] * n
AB = [list(map(int, input().split())) for _ in range(n)]
# for i in range(n):
#     A[i], B[i] = map(int, input().split())
min_hp = h
 
dp = [sys.maxsize] * (min_hp + 1)
dp[0] = 0
 
for i in range(0, min_hp + 1):
    for ab in AB: # type of spell
        next_index = min(i + ab[0], min_hp)
        dp[next_index] = min(dp[next_index], dp[i] + ab[1])
 
# dp = [[sys.maxsize] * (max_hp + 1) for i in range(n + 1)]
# for i in range(n + 1):
#     for j in range(min(A[1:]) + 1):
#         dp[i][j] = min(B[1:])
#
# for i in range(1, n + 1):
#     for j in range(1, max_hp + 1):
#         dp[i][j] = dp[i-1][j] if A[i] > j else min(dp[i-1][j-A[i]] + B[i], dp[i-1][j])
#         # dp[i][j] = dp[i][j-1] + B[i] if A[i] > j else min(dp[i][j-A[i]] + B[i], dp[i][j-1] + B[i])
print(dp[h])

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] V = Console.ReadLine().Split(' ');
            string[] C = Console.ReadLine().Split(' ');
            int V_num = 0;
            int C_num = 0;
            int X = 0;
            int Y = 0;

            for (int i = 0; i < N; i++)
            {
                V_num = int.Parse(V[i]);
                C_num = int.Parse(C[i]);
                X =  V_num - C_num;
                if(X > 0)
                {
                    Y += X;
                }
            }

            Console.WriteLine(Y);
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
using namespace std;
const int inf=1<<28;
struct node{
	int y,next;
}a[1010];int len=0,last[1010];
int f[1010],g[1010][5010],v[5010],w[5010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=last[x];last[x]=len;
}
int n;
void dfs(int x,int fa)
{
	for(int i=1;i<=w[x];i++) g[x][i]=inf;
	g[x][0]=0;
	for(int i=last[x];i;i=a[i].next)
	{
		int y=a[i].y;
		if(y==fa) continue;
		dfs(y,x);
		for(int i=0;i<=w[x];i++) v[i]=g[x][i],g[x][i]=inf;
		for(int i=0;i<=w[x];i++)
		{
			int t1=w[y],t2=f[y];
			if(i+t1<=w[x]) g[x][i+t1]=min(g[x][i+t1],v[i]+t2);
			if(i+t2<=w[x]) g[x][i+t2]=min(g[x][i+t2],v[i]+t1);
		}
	}
	int ans=inf;
	for(int i=0;i<=w[x];i++) ans=min(ans,g[x][i]);
	if(ans==inf) {printf("IMPOSSIBLE");exit(0);}
	f[x]=ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int fa;scanf("%d",&fa);
		ins(fa,i);
	}
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	dfs(1,0);
	printf("POSSIBLE");
}

Measured memory_bytes: 18176
#include <stdio.h>
 
int main(void)
{
  char name[6];
  int flag=0;
  scanf("%s", name);
  if(name[2]==name[3])
    if(name[4]==name[5])
      flag=1;
  if(flag==1)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

void call(int n)
{
	int i = 1;
	
	for (; i <= n; i++){
		int x = i;
		if (x % 3 == 0){
			printf(" %d", i);
			continue;
		}
		do{
			if (x % 10 == 3){
				printf(" %d", i);
				break;
			}
			x /= 10;
		} while (x);
	}
	putchar('\n');
}

int main()
{
	int n;
	scanf("%d", &n);
	call(n);
	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    string a,b;
    ll tf=0;
    cin >> a >> b;
    if(a.size() != b.size())
    {

        if(a.size() > b.size()) tf=1;
        else if(a.size() < b.size()) tf=2;
    }
    else
    {

        for(ll i=0; i < a.size(); i++)
        {

            ll x=a[i] - '0';
            ll y=b[i] - '0';
            if(x!=y)
            {

                if(x > y) tf=1;
                else tf=2;
                break;
            }
        }
    }
    if(tf==1) cout << "GREATER";
    else if(tf==2) cout << "LESS";
    else cout << "EQUAL";
}


Measured memory_bytes: 256
import math
import itertools
import statistics
#import collections

#n =  list(map(int, input().split()))
n = int(input())
data = []
for i in range(n):
    s, p = input().split()
    data.append((i+1, s, int(p)))

data.sort(key=lambda x:(x[1], -x[2]))

for i in range(n):
    print(data[i][0])


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll maxn = 100000;
vector<ll> v;
void sieve()
{
	vector<bool> is(maxn, true);
	for (ll i = 4; i < maxn; i += 2)
		is[i] = false;
	for (ll i = 3; i * i < maxn; i++)
	{
		if (is[i])
		{
			for (ll j = i * i; j < maxn; j += i)
				is[j] = false;
		}
	}
	for (ll i = 2; i < maxn; i++)
	{
		if (is[i])
			v.push_back(i);
	}
	return ;
}
vector<ll> spf(maxn);
void prime()
{
	for (ll i = 1; i < maxn; i++)
		spf[i] = i;
	for (ll i = 4; i < maxn; i += 2) spf[i] = 2;
	for (ll i = 3; i * i < maxn; i++)
	{
		if (spf[i] == i)
		{
			for (ll j = i * i; j < maxn; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
	return ;
}
vector<ll> get(ll x)
{
	vector<ll> ftrs;
	while (x != 1)
	{
		ftrs.push_back(spf[x]);
		x = x / spf[x];
	}
	return ftrs;
}
bool comp(pair<ll, ll>& a, pair<ll, ll>& b)
{
	if (a.fi > b.fi) return false;
	else if (a.fi == b.fi)
	{
		if (a.sec > b.sec)
			return false;
	}
	return true;
}
bool comp1(pair<ll, ll>& a, pair<ll, ll>& b)
{
	if (a.fi > b.fi) return false;
	else if (a.fi == b.fi)
	{
		if (a.sec < b.sec)
			return false;
	}
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n; cin >> n;
	ll miny = LLONG_MAX, maxy = LLONG_MIN;
	ll miny1 = LLONG_MAX, maxy1 = LLONG_MIN;
	for (ll i = 0; i < n; i++)
	{
		ll x, y; cin >> x >> y;
		miny = min(miny, x + y);
		maxy = max(maxy, x + y);
		miny1 = min(miny1, x - y);
		maxy1 = max(maxy1, x - y);
	}
	ll ans1 = abs(maxy - miny);
	ll ans2 = abs(maxy1 - miny1);
	ll ans = max(ans1, ans2);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int a, b;
    char s[12];

    scanf("%d %d %s", &a, &b, s);

    int i;
    for(i = 0; i < a; ++i){
        if(s[i] < '0' || s[i] > '9'){
            puts("No");
            return 0;
        }
    }
    if(s[i++] != '-'){
        puts("No");
        return 0;
    }
    for(; i < (a + b + 1); ++i){
        if(s[i] < '0' || s[i] > '9'){
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,a;
    cin>>n;
    vector<ll> csum(n);
    cin>>a;
    csum[0]=a;
    for(ll i=1;i<n;i++){
        cin>>a;
        csum[i]=a+csum[i-1];
    }
    ll mn=1e10;
    rep(i,n-1) mn=min(mn,abs(csum[i]-(csum[n-1]-csum[i])));
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 1792
//N = 35でのある操作の例 : 1 -> 2 -> 3 eat 0 -> 3 -> 6 -> 9 eat 0 -> 9 -> 18 eat 0 -> 18 -> 36 end.
//t1 = 3, t2 = 3, t3 = 2. for i=1,2,… (t_i秒->食べる) -> 最後N枚以上になるまで待つ.
//min. AK + (t1 + t2 + … + tK) + ceil(N / (t1t2…tK))
//K≦ceil(log2(N))≦40まで考えれば良い. Kを固定するとAKは定数. (K=0は例外処理(N秒))
//t1+…+tKが同じならt1t2…tKはなるべく大きくしたい. 相加相乗平均より、t1,…,tKの差は高々1(できるだけ均等に)
//t1t2…tK≦Nまで考えればよくて、このときのt1+…+tKは大体K * pow(N, 1/K)くらいまで. K≧2なら愚直でOK.
//K=1が問題。t + ceil(N / t)を最小化. t * t > Nのとき、N / t < √Nなので、ceil(N / t) ≦ √N.
//よって、t ≦ √N, ceil(N / t) ≦ √Nのどちらかは成立. 両方愚直に調べればO(√N).
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int INF = 1e+15;

int solve(int k, int n, int a) {
	int ret;
	
	if (k == 1) {
		ret = INF;
		for (int t = 1; t * t <= n; t++) {
			ret = min(ret, t +  (n + t - 1) / t);
		}
		for (int c = 1; c * c <= n; c++) {
			int t = (n + c - 1) / c; //ceil(N / t) ≦ cなる最小のt
			ret = min(ret, t + c);
		}
		return ret + a;
	}
	
	//k >= 2は愚直にできる.
	int i, j, l;
	for (i = 1; ; i++) { //最低値: t = i
		int mul = 1;
		for (j = 0; j < k; j++) {
			mul *= i;
			if (mul > n) break;
		}
		if (j < k) break;
		
		for (j = 0; j < k; j++) { //j個だけt = i + 1
			int tmul = 1;
			int tsum = 0;
			for (l = 0; l < k; l++) {
				if (l < j) {
					tmul *= i + 1;
					tsum += i + 1;
				}
				else {
					tmul *= i;
					tsum += i;
				}
			}
			
			//計算
			ret = min(ret, tsum + (n + tmul - 1) / tmul);
		}
	}
	return ret + a * k;
}

signed main() {
	int i;
	int n, a;
	
	cin >> n >> a;
	
	int ans = n;
	for (i = 1; i <= 40; i++) {
		int ret = solve(i, n, a);
		ans = min(ans, ret);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define sese cond
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

map<int,int>st;

signed main(){
	int x=1;
	for(int i=2;i<=100000;i++){
		st[x]=i-1;
		x+=i;
	}
	int n;
	cin>>n;

	if(!st.count(n)){
		cout<<"No"<<endl;
		return 0;
	}

	cout<<"Yes"<<endl;

	cout<<st[n]+1<<endl;

	int a=st[n];

	int ans[a+1][a],cnt=1;

	for(int i=a,k=0;i>=1;i--,k++){
		for(int j=0;j<i;j++){
			ans[k][j+k]=cnt;
			ans[k+j+1][k]=cnt;
			cnt++;
		}
	}
	r(i,a+1){
		cout<<a;
		r(j,a){
			cout<<' ';
			cout<<ans[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 9216
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(a * b - a - b + 1);
    }

}

Measured memory_bytes: 21460
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let lr = (0..n)
        .map(|_| (sc.read(), sc.read()))
        .collect::<Vec<(i64, i64)>>();

    let mut left = lr
        .iter()
        .enumerate()
        .map(|(i, &(l, _))| (l, i))
        .collect::<Vec<(i64, usize)>>();
    left.sort();
    left.reverse();
    let left = left.iter().map(|&(_, i)| i).collect::<Vec<_>>();
    let mut right = lr
        .iter()
        .enumerate()
        .map(|(i, &(_, r))| (r, i))
        .collect::<Vec<(i64, usize)>>();
    right.sort();
    let right = right.iter().map(|&(_, i)| i).collect::<Vec<_>>();

    let ans1 = solve(&left, &right, &lr);
    let ans2 = solve(&right, &left, &lr);
    println!("{}", cmp::max(ans1, ans2));
}

fn solve(left: &Vec<usize>, right: &Vec<usize>, lr: &Vec<(i64, i64)>) -> i64 {
    let n = lr.len();
    let mut ans = 0;
    let mut left_iter = left.iter();
    let mut right_iter = right.iter();
    let mut used = vec![false; n];
    let mut cur = 0;
    for i in 0..n {
        let iter = if i % 2 == 0 {
            &mut left_iter
        } else {
            &mut right_iter
        };

        while let Some(&index) = iter.next() {
            if used[index] {
                continue;
            }
            used[index] = true;
            let (left, right) = lr[index];
            if cur < left {
                ans += left - cur;
                cur = left;
            } else if right < cur {
                ans += cur - right;
                cur = right;
            }
            break;
        }
    }
    ans + cur.abs()
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14588
#include <iostream>
#include <iomanip>

using namespace std;

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

	cout << a/b << " " << a%b << " " << setiosflags(ios::fixed) << setprecision(10) << ((double)a)/b << endl;

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
 
using namespace std;
 
 
int main() {
	int t;
  	cin >> t;
  map<string, int> cnt;
  while(t--) {
   string s;
    cin >> s;
    cnt[s]++;
  }
  
  string x[] = {"AC", "WA", "TLE", "RE"};
  
  for(int i = 0; i < 4; i++) {
   cout << x[i] << " x " << cnt[x[i]] << "\n";
  }
  
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(void) {
  //a: 高橋の体力 b: 高橋の攻撃力
  //c: 青木の体力 d: 青木の攻撃力
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  // c%d!=0ならばturn+1ターンで高橋勝利
  int turn = c / b;
  // c%b==0の時turnターンで高橋勝利となる
  if(c % b == 0) {
    //したがってturn-1ターンで王手
    turn--;
  }
  // 上の処理でturnターンで王手となる．
  // この時高橋勝利の必要十分条件は a - d * turn > 0
  if(a-d*turn > 0) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 1644
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

while 1:
    n=int(input().rstrip())
    if n==0:
        break
    print(sum(sorted([int(input().rstrip()) for _ in range(n)])[1:-1])//(n-2))


Measured memory_bytes: 5616
# | Its_Rashid | #
v = [int(input()) for i in range(5)]
a = int(input())
for i in range(0 , 5) :
    for j in range(1 ,5) :
        if v[j] - v[i] > a:
            print(':(')
            quit()
else :
    print('Yay!')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define pb push_back
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}

int main(){
    #ifndef ONLINE_JUDGE    
    freopen("../../input", "r", stdin);
    freopen("../../output", "w", stdout);
    #else
    // online submission
    #endif

    boost
    int tt = 1;
    // cout << 0 << endl;
    // cin >> tt;
    while(tt--){
        string s, t;
        cin >> s >> t;
        int ans = INT_MAX;
        int n = s.size(), m = t.size();
        for(int i = 0; i <= n - m; i++){
            int eq = 0;
            for(int j = 0; j < m; j++){
                if(s[i + j] == t[j]) eq++;
            }
            ans = min(ans, m - eq);
        }
        cout << ans;
    }
}


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


void solution(){
	ll n,W;
	cin>>n>>W;
	vector<ll> dp(W+ 1);
	for(ll i=0;i<n;++i){
		ll weight,value;
		cin>>weight>>value;
		for(ll weight_already = W- weight; weight_already >= 0; --weight_already){
			dp[weight_already+weight] = max(dp[weight_already+weight], dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for(ll i=0; i<=W;++i)
		answer = max(answer, dp[i]);
	cout<<answer<<'\n';	
}

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

}

Measured memory_bytes: 3992