akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  char to[300];
  to['A'] = 'T';
  to['T'] = 'A';
  to['C'] = 'G';
  to['G'] = 'C';
  char b;
  while (cin >> b) {
    cout << to[b] << endl;
  }
  return 0;
}


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

int cnt[2019];
int ans = 0;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    int t = 0;
    int p = 1;
    cnt[0] = 1;
    for(int i=0;i<s.length();i++){
        t = t + p * (s[i] - '0');
        t = t % 2019;
        ans += cnt[t];
        cnt[t]++;
        p *= 10;
        p = p % 2019;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3376
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    string s,t;
    int ans=1000;
    cin>>s>>t;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int sum=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                sum++;
            }
        }
        if(sum<ans){
            ans=sum;
        }
    }
    cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint a,b,x;

ld calc(ld theta){
  if(theta>PI/2.0-EPS){
    return 0.0;
  }
  ld ret;
  if(a*tan(theta)<=b){
    ret=a*a*b-a*a*a*tan(theta)/2.0;
  }
  else{
    ret=b*b/tan(theta)*a/2.0;
  }
  return ret;
}

void solve(){
  cin >>a >> b >> x;
  ld ans=PI/2.0;
  ld no=0.0;
  for(int i=0;i<=100000;i++){
    ld mid=(ans+no)/2.0;
    if(calc(mid)<x)ans=mid;
    else no=mid;
  }
  printf("%.10Lf\n",ans/PI*180);
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long D,N;cin>>D>>N;
    if(N==100){
        long long ans=pow(100,D);
        ans*=N+1;
        cout<<ans<<endl;
    }
    else{
        cout<<pow(100,D)*N<<endl;
    }
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    long long int a, b, k;
    cin >> a >> b >> k;
    if (a > k)
    {
        a = a - k;
    }
    else if (a + b > k)
    {
        b = b - k + a;
        a = 0;
    }
    else
    {
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

#define mem(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
typedef long long ll;

const int maxn=35;
int n,m;
int vis[maxn];

int main() {
    while(~scanf("%d%d",&n,&m)) {
        mem(vis,0);
        rep(i,1,n) {
            int k;
            scanf("%d",&k);
            rep(j,1,k) {
                int a;
                scanf("%d",&a);
                vis[a]++;
            }
        }
        int res=0;
        rep(i,1,m) {
            if(vis[i]==n) res++;
        }
        printf("%d\n",res);
    }
    return 0;
}

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

using namespace std;

main(){
  string in, tmp;
  cin >> in;
  char pre = ' ', ans;
  int valM = 0;
  for(int i=0;i<in.size();){
    char c = (in[i] == 'e' ? 'e' : 'c');
    if(pre == c){
      if(valM < tmp.size()){
        valM = tmp.size();
        ans = pre;
      }
      tmp = "";
    }
    tmp += c;
    i += (c == 'e' ? 3 : 7);
    pre = c;
  }
  if(valM < tmp.size()) ans = pre;
  cout << (ans == 'e' ? "egg" : "chicken") << endl;
}

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

bool dp[10200];

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

    int s[N];
    rep(i, N) cin >> s[i];

    rep(i, 10001) dp[i] = false;
    dp[0] = true;

    rep(i, N) {
        for (int j=10000; j>=0; j--) {
            if (dp[j]) dp[j+s[i]] = true;
        }
    }

    int ans = 0;
    rep(i, 10000) {
        if (i%10 != 0 && dp[i]) ans = max(ans, i);
    }

    cout << ans << endl;

    return 0;
}



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

int main(){

    int n;
    int alice_point = 0, bob_point = 0;

    std::cin >> n;

    int a[n];

    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }

    std::sort(a, a + n);

    for(int i = n - 1; i >= 0; i -= 2){
        alice_point += a[i];
    }

    for(int i = n - 2; i >= 0; i -= 2){
        bob_point += a[i];
    }

    std::cout << alice_point - bob_point << std::endl;

    return 0;
}

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

int main() {
  //vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))で宣言できる
  vector<vector<int>> c(3, vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> c.at(i).at(j);
    }
  }

  string ans = "Yes";
  vector<int> A(3, 0);
  vector<int> B(3);
  rep(i,3){B.at(i) = c.at(0).at(i) - A.at(0);}
  rep(i,3){A.at(i) = c.at(i).at(0) - B.at(0);}

  rep(i, 3){
    rep(j, 3){
      int y = A.at(i) + B.at(j);
      if (c.at(i).at(j) != y)
      {
        ans = "No";
        break;
      }
      
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main()
{
    vector<int> v;
    int cnt = 0;

    for (int i = 0; i < 3; i++) {
        int x; cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());

    if ((v[1] - v[0]) % 2 == 0 && (v[2] - v[0]) % 2 == 0) {
        // cout << "even, even" << endl;
        cnt = ((v[2] - v[1]) / 2) + ((v[2] - v[0]) / 2);
    } else if ((v[1] - v[0]) % 2 == 0 && (v[2] - v[1]) % 2 != 0) {
        // cout << "even, odd" << endl;
        cnt = ((v[1] - v[0]) / 2) + 2 * (v[2] - (v[1] + 1)) / 2 + 1;
    } else if ((v[1] - v[0]) % 2 != 0 && (v[2] - v[1]) % 2 == 0) {
        // cout << "odd, even" << endl;
        cnt = (((v[2] + 1) - v[0]) / 2) + ((v[2] - v[1]) / 2) + 1;
    } else if ((v[1] - v[0]) % 2 != 0 && (v[2] - v[1]) % 2 != 0) {
        // cout << "even, even" << endl;
        cnt = ((v[2] - v[0]) / 2) + (((v[2] + 1) - v[1]) / 2) + 1;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 508
#include<stdio.h>
int p[200010]={0};
int d[200010]={0};
int S[200010];//サイズ用配列 未実験
int Top(int a){
  for(;p[a]-a;a=p[a]);
  return a;
}
int Find(int a,int b){
  int n,r;
  for(r=Top(a);p[a]!=a;a=n){
    n=p[a];
    p[a]=r;
  }
  for(r=Top(b);p[b]!=b;b=n){
    n=p[b];
    p[b]=r;
  }
  return a-b?1:0;
}
void Union(int a,int b){
  if(Find(a,b)){
    a=Top(a);
    b=Top(b);
    d[a]<d[b]?(p[a]=b):(p[b]=a);
    if(d[a]==d[b])d[a]++;
    int n=(S[a]+S[b]);
    S[a]=S[b]=n;
  }
}
int main(){
  int n,a[200010],b[200020],c[200020],max,min,i,j;
  for(i=0;i<200010;i++)p[i]=i;
  for(i=0;i<200010;i++)S[i]=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a[i],&b[i]);
    c[a[i]]=b[i];
    d[b[i]]=a[i];
  }
  min=1e9;
  for(i=1;i<=n;i++){
    if(min>c[i])min=c[i];
    Union(min,c[i]);
  }
  max=-1;
  for(i=n;i;i--){
    if(max<c[i])max=c[i];
    Union(max,c[i]);
  }
  min=1e9;
  for(i=1;i<=n;i++){//printf("%d\n",d[i]);
    if(min>d[i])min=d[i];//printf("!!%d %d\n",min,d[i]);
    Union(c[min],c[d[i]]);
  }
  max=-1;
  for(i=n;i;i--){
    if(max<d[i])max=d[i];//printf("!!!%d %d\n",max,d[i]);
    Union(c[max],c[d[i]]);
  }
  for(i=0;i<n;i++)printf("%d\n",S[Top(b[i])]);
  return 0;
}


Measured memory_bytes: 6416
import sys
from collections import deque

sys.setrecursionlimit(10000)
INF = float('inf')

K = int(input())

# ある数に 1 を足すと各桁の和は 1 増える
# ある数に 10 を掛けると各桁の和は 0 増える
# mod K の世界で同じことやっても同じなので
# このグラフ上で 1 から 0 への最短距離が答え。

distances = [INF for _ in range(K)]

# 01BFS
distances[1] = 1
remains = deque()
remains.append((1, 1))
while True:
    d, mod_k = remains.popleft()
    if mod_k == 0:
        break
    if d + 1 < distances[(mod_k + 1) % K]:
        distances[(mod_k + 1) % K] = d + 1
        remains.append((d + 1, (mod_k + 1) % K))
    if d < distances[mod_k * 10 % K]:
        distances[mod_k * 10 % K] = d
        remains.appendleft((d, mod_k * 10 % K))
print(distances[0])


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];
vector<pair<int,int> >g[N+2];
//vector<int>g2[N+2];
int col[N+2];
//int vis[N+2];
void dfs(int u,int p){
  for(auto it:g[u]){
    int v=it.ff;
    int w=it.ss;
    if(v==p)continue;
    if(w==1){
      col[v]=1^col[u];
      dfs(v,u);
    }else{
      col[v]=col[u];
      dfs(v,u);
    }
  }
}
int32_t  main(){
	IOS;
  int n;cin>>n;
  for(int i=1;i<n;++i){
    int u,v;cin>>u>>v;
    int w;cin>>w;
    g[u].pb({v,w%2});
    g[v].pb({u,w%2});
  }
  //ohk now do dfs to find colorings
  memset(col,-1,sizeof(col));
  //do a dfs 
  col[1]=0;
  dfs(1,0); 
  for(int i=1;i<=n;++i){cout<<col[i]<<endl;}
  return 0;
}



Measured memory_bytes: 8448
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;


public class Main
{
    String a, b;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	if(a.length() == b.length()) {
	    int diff = a.compareTo(b);
	    
	    if(diff == 0) {
		out("EQUAL");
	    } else if(diff > 0) {
		out("GREATER");
	    } else {
		out("LESS");
	    }
	} else {
	    if(a.length() > b.length()) out("GREATER");
	    else out("LESS");
	}
	    
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	a = sc.next();
	b = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int ans)
    {
	System.out.println(ans);
    }
    
    void out(String ans)
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}

void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=LLONG_MIN;
	if((a<=0&&b>=0)||(c<=0&&d>=0))ans=0;
	ans=max({a*c,a*d,b*c,b*d,ans});
	cout<<ans<<'\n';
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const ll INF = 1e9+7;

ll f(ll a, ll b) {
   ll ans = 1;
   while (b > 0) {
      if (b&1) {
         ans = ((ans%INF) * (a%INF))%INF;
      }
      a = ((a%INF) * (a%INF))%INF;
      b /= 2;
   }
   return ans;
}

int main() {
   ll n, m;
   cin >> n >> m;
   cout << f(n, m) << endl;

   return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  if(a[0]!=0) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  rep(i,1,n) {
    cerr << i-1 << " " << a[i-1] << " " << ans << endl;
    if(a[i]==0) {
      continue;
    }
    if(a[i] > a[i-1]+1) {
      cout << -1 << endl;
      return 0;
    }
    if(a[i] == a[i-1]+1) {
      ans++;
    }
    else /* if(a[i] <= a[i-1]) */ {
      ans += a[i];
    }
  }
  cout << ans << endl;
}


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


int main(){
    int k, x; cin >> k >> x;
    
    if(500*k >=  x){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    
    
}




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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N,M,C;
int B[100];
int A[100][100];

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

	cin >> N >> M >> C;

	int ans = 0;

	for (int i = 0;i < M;i++){
		cin >> B[i];
	}

	for (int i = 0;i < N;i++){
		int sum = 0;
		for (int j = 0;j < M;j++){
			cin >> A[i][j];
			sum += A[i][j]*B[j];
		}
		sum += C;
		if(sum > 0) ans++;
	}

	cout << ans << endl;

	return 0;

}


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

int main() {
	string s,t,u;
	int a,b;
	cin >> s >> t >> a >> b >> u;
	if(s==u)
	cout << a-1 << " " << b << endl;
	else
	cout << a << " " << b-1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

const int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin();
    vector<int> As(N), Xs(N, 0);
    for (auto &Ai : As) Ai = Cin();
    // A_0 != 0 や A_i - A_{i-1} > 1 は実現できない
    int Aprev = -1;
    for (const int &Ai : As)
    {
        if (Ai - Aprev > 1)
        {
            cout << -1 << endl;
            return 0;
        }
        Aprev = Ai;
    }
    LLONG ans = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        // A_i + 1 = A_{i+1} のときは，X_i = Ai としてから１回操作を行えばよい
        if (As[i] + 1 == As[i + 1])
        {
            ++ans;
        }
        // そうでない場合（A_i >= A_{i+1} のとき）は，
        // まず X_{i+1} を A_{i+1} にするために As_{i+1} 回の操作が必要
        else
        {
            ans += As[i + 1];
        }
    }
    cout << ans << endl;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>sc(m, vector<int>(2));
	for (size_t i = 0; i < m; i++)cin >> sc.at(i).at(0) >> sc.at(i).at(1);
	vector<int>number(n,-1);
	for (size_t i = 0; i < m; i++) {
		if (number.at(sc.at(i).at(0) - 1) == -1 || number.at(sc.at(i).at(0) - 1) == sc.at(i).at(1))number.at(sc.at(i).at(0) - 1) = sc.at(i).at(1);
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	if (n == 1) {
		if (number.at(0) == -1) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << number.at(0) << endl;
			return 0;
		}
	}
	if (number.at(0) == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (number.at(0) == -1)number.at(0) = 1;
	for (size_t i = 1; i < n; i++)if (number.at(i) == -1)number.at(i) = 0;
	for (size_t i = 0; i < n; i++)cout << number.at(i);
	cout << endl;
}

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

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; ++i)
    {
        cin >> D[i];
    }
    sort(D.begin(), D.end());
    int midbefore = N / 2 - 1;
    int midafter = N / 2;
    
    cout << D[midafter] - D[midbefore];
}


Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    string s;
    cin >> s;
    if(s=="Sunny")cout << "Cloudy";
    else if(s=="Cloudy")cout << "Rainy";
    else cout << "Sunny";
    cout << endl;
    
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A; cin >> A;
  double B; cin >> B;
  ll x = 100 * B + 0.5;
  ll y = A * x;
  cout << y / 100 << endl;

  return 0;
}



Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int R, G;
	cin >> R >> G;
	cout << R + (G-R) * 2 << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    if (N % 10 == 3) {
        cout << "bon" << endl;
    }else if(N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8) {
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

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

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

    for(int i = 0; i < 1e5; i++) {
        if((int) (i * 0.08) == a && (int) (i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int h , f , m ;
    int A , B ;

    while(scanf("%d%d",&A,&B) && A != 0 && B != 0){
        A = B - A ;
        m = A / 1000 ;
        A %= 1000 ;
        f = A / 500 ;
        A %= 500 ;
        h = A / 100 ;
        printf("%d %d %d\n",h,f,m);
    }
    return 0 ;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<vector<int>> c(h,vector<int>(w));
  int x=0;
  for(int i=0;i<h;i++){
    bool p=(i%2==0);
    for(int j=(p?0:w-1);j<w&&j>=0;j+=(p?1:-1)){
      c.at(i).at(j)=x+1;
      a.at(x)--;
      if(a.at(x)==0)
        x++;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout<<c.at(i).at(j)<<' ';
    cout<<endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		String ans = S.substring(0, K - 1);
		ans += S.substring(K - 1, K).toLowerCase();
		ans += S.substring(K);
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
public class Hello{
    public static void Main(){

        string S = System.Console.ReadLine();
        int n = S.Length;
        int count = 0;
        
        for(int i = 0; i < n - 1; i++){
            if(S[i] != S[i + 1]){
                count++;
            }
        }
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N;
    cin>>N;
    vector<pair<int,int>> xy(N);
    rep(i,0,N){
        cin>>xy[i].first>>xy[i].second;
    }
    double sum=0;
    for(int i=0;i<N-1;i++){
        for(int r=i+1;r<N;r++){
            int xx=pow(xy[i].first-xy[r].first,2);
            int yy=pow(xy[i].second-xy[r].second,2);
            sum+=sqrt(xx+yy);
            //printf("%.16f", sum);
        }
    }
    printf("%.16f", sum*2.0/N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  long N,K;
  cin >> N >> K;
 
  long MAX = 1000000000000;
  vector<long> h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
 
  vector<long> dp(N, MAX);
 
  dp[0] = 0;
 
  for(int i = 0; i < N; i++){
    for(int j = 1; (j <= K) && (i+j < N) ; j++){
      dp[i+j] = min(dp[i] + abs(h.at(i) - h.at(i+j)), dp[i+j]);
    }
  }
 
  cout << dp[N-1] << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// 約数の全列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    map<ll, ll> M;

    ll ans = 0;
    REP(i, N){
        ll t = A[i];

        vector<ll> P = divisor(t);

        ll flag = true;
        for(auto p: P){
            // cout << p << endl;
            if(M.count(p)) flag = false;
        }
        // cout << endl;
        M[t]++;

        if(i != N-1){
            if(A[i] == A[i+1]) continue;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17184
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong D, N;
    llong ans=0;
    llong cnt;
    llong n;
    llong ANS;
    cin >> D >> N;
    for(int i=1; ; i++){
        cnt=0;
        n = i;
        while(n%100==0){
            n = n/100;
            cnt++;
        }
        if(cnt==D){
            ans++;
        }
        if(ans==N){
            ANS = i;
            break;
        }
    }
    cout << ANS << endl;
    return 0;
}


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

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

	int d, n;
	cin >> d >> n;
 	
 	if (n == 100) n = 101;
	for (int i = 0; i < d; i++)
		n *= 100;
 
	cout << n << "\n";

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

char judge(const int& m, const int& f, const int& r){
    if(m == -1 || f == -1) return 'F';
    
    int sum = m + f;
    if(sum >= 80) return 'A';
    else if(sum >= 65) return 'B';
    else if(sum >= 50) return 'C';
    else if(sum >= 30){
        if(r >= 50) return 'C';
        return 'D';
    }
    return 'F';
}

int m, f, r;
int main(){
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        cout << judge(m, f, r) << endl;
    }
    return 0;
}


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

bool FIND(string S, string T){
	if(S.find(T) == string::npos){
		return false;
	} else {
		return true;
	}
}

int main(){
    char S[10];
    scanf("%s", S);
    printf(FIND(S, "AC") ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int k;
  cin >> k;
  int n = 0, m = 0;
  for(int i = 1; i <= k; i++){
    if(i % 2 == 0) n++;
    else m++;
  }
  cout << m * n << endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 1000000007

N = int(input())
A = sorted(list(map(int,input().split())))

def sumXOR(arr,n):
    xorsum = 0
    for i in range(64):
        zc = 0
        oc = 0
        idsum = 0
        for j in range(n):
            if arr[j] % 2 == 0:
                zc += 1
            else:
                oc += 1
            arr[j] = arr[j]//2
        idsum = oc*zc*(1 << i)
        xorsum += idsum
        xorsum %= MOD
    return xorsum

XORSUM = 0
XORSUM = sumXOR(A,N);
print(XORSUM%MOD)

Measured memory_bytes: 122808
from bisect import bisect
n = int(input())
a = [int(x) for x in input().split()]
 
r = 0
s = []
for i in a:
  r += i
  s.append(r)

def bs(x,y):
  b = bisect(x, y)
  if abs(x[b-1] - y) < abs(x[b] - y):
    b = b-1
  return b
 
m = 10**20
for i in range(1, n-1):
  k = bs(s, s[i] / 2)
  l = bs(s, (s[n-1] + s[i]) / 2)
  s4 = [s[k],s[i]-s[k],s[l]-s[i],s[n-1]-s[l]]
  m = min(m, max(s4) - min(s4))

print(m)

Measured memory_bytes: 24688
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var s1 = Console.ReadLine().Trim();
            if (s1 == "-") break;
            var s2 = Console.ReadLine().Trim();
            var s3 = Console.ReadLine().Trim();
            var u = s1.ToCharArray();
            var L = s2.ToCharArray();
            var d = s3.ToCharArray();
            var ans = getAns(u, L, d);
            Console.WriteLine(ans);
        }
    }
    static string getAns(char[] u, char[] L, char[] d)
    {
        var uL = u.Length;
        var LL = L.Length;
        var dL = d.Length;
        var up = 0; var Lp = 0; var dp = 0;
        var u1st = true;
        var c0 = "L"; var c1 = 0;
        var ans = "";
        while (dp < dL)
        {
            char t;
            t = c0 == "u" ? u[c1] : L[c1];
            if (d[dp] == t)
            {
                c0  = "u";
                if (u1st) {  c1 = 0; u1st = false;  up = 0; }
                else { up++;  c1 = up; }
                dp++; 
            }
            else
            {
                  Lp++;  ans += t;  c0 = "L"; c1 = Lp;
            }
        }
        while (ans.Length < uL + LL - dL)
        {
            char t;
            t = c0 == "u" ? u[c1] : L[c1];
            Lp++;
            ans += t;
            c0 = "L";
            c1 = Lp;
        }
        return ans;
    }
}




Measured memory_bytes: 15848
var outputArray = function(array)
{
  var str = "";
  for (var i = 0; i < array.length; i++)
  {
    str = str + array[i];
    if (i<array.length-1)
      str = str + " ";
    else
      console.log(str);
  }
  return str;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  var result = input.split(' ').map(Number)
  .sort(
    function(a,b){
    if( a < b ) return -1;
      if( a > b ) return 1;
      return 0;
  }
);

  outputArray(result);
});

Measured memory_bytes: 7648
#include <stdio.h>
#include <string.h>

int min(int a, int b)
{
    return (b > a ? a : b);
}

void printStep(int n, int num, int *array)
{
    int i;
    
    if (n == 0){
        for (i = 0; i < num; i++){
            printf("%d%c", array[i], i == num - 1 ? '\n' : ' ');
        }
        return;
    }
    for (i = min(n, num != 0 ? array[num - 1] : n); i >= 1; i--){
        array[num] = i;
        printStep(n - i, num + 1, array);
    }
    return;
}

int main(void)
{
    int array[31];
    int n;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        printStep(n, 0, array);
    }
    return (0);
}

Measured memory_bytes: 0
n=input()
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if n=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    if len(n)==26:
        q=a.index(n[-1])
        c=0
        d=[n[-1]]
        for i in range(24,-1,-1):
            c+=1
            d.append(n[i])
            d.sort()
            if d.index(n[i])<len(d)-1:
                print(n[:26-c-1]+d[d.index(n[i])+1])
                break
    else:
        for i in range(len(n)):
            a.pop(a.index(n[i]))
        print(n+a[0])

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void) {
    long long a1, a2, x, y, i;
    int amari;
     
    while(scanf("%lld%lld",&a1,&a2) != EOF){
        if(a1<=0 && a2<=0) break;
        x=a1;
        y=a2;
     
        if(a1<a2){
            x = a2;
            y = a1;
        }
     
        for(i = 0; y > 0; i++){
            amari = x % y;
            x = y;
            y = amari;
     
        }
     	//lcm = a1*a2/x;
        printf("%lld %lld\n", x, a1*a2/x);
    }
        return 0;
}


Measured memory_bytes: 2008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int pow(int A, int P){
	int a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	int adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}

int main(){
	int X;
	cin >> X;
	int ans = 1;
	for(int p=2;p<=X;p++){
		for(int i=1;pow(i,p)<=X;i++){
			ans = max(ans,pow(i,p));
		}
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s1, s2;
	cin>>n>>s1>>s2;
	int st;
	ll ans;
	bool flag=false;
	if(s1[0]==s2[0]){
		st=1;
		ans=3;
		flag=true;
	}
	else{
		st=2;
		ans=6;
	}
	FOR(i, st, n){
		if(flag){
			ans=(ans*2)%MOD;
			if(s1[i]!=s2[i]){
				flag=false;
				++i;
			}
		}
		else{
			if(s1[i]==s2[i]){
				flag=true;
			}
			else{
				ans=(ans*3)%MOD;
				flag=false;
				++i;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

flag=0
for h in range(1,3501):
  for n in range(h,3501):
    if flag==0:
      val=4*h*n-n*N-h*N
      if val != 0:
        w=N*h*n/val
        if int(w)==w and w > 0:
          print(h,n,int(w))
          flag=1
    if flag==1:
      break
        


Measured memory_bytes: 41052
#include<stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=1.00000*a/b;
  printf("%d %d %lf",d,r,f);
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
int a[200001];
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  i=0;
  if(n>1){
    for(i=n-1;i>=0;i-=2)printf("%d ",a[i]);
    i=(i==-1)?0:1;
    for(;i<n-2;i+=2)printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
  
 
int32_t  main() {

	IOS;

	int X;

	cin >> X;
	 
	for (int i = -200; i <= 200; i++) {

		for (int j = -200; j <= 200; j++) {

			int A = pow(i, 5);
			int B = pow(j, 5);

			if ((A - B) == X) {

				cout << i << " " << j << endl;
				return 0;
			}


		}


	}


}


Measured memory_bytes: 3472
t =1
#t = int(input())
for _ in range(t):
    #a,b = map(int,input().split(' '))
    n = int(input())
    f=0
    #ls = list(map(int,input().split(' ')))
    for i in range(-1000,1001):
        for j in range(-1000,1001):
            if((i**5 - j**5) == n):
                print(i,j)
                f=1
                break
        if(f==1):
            break
    
    

Measured memory_bytes: 65620
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void foo(T)(BinaryHeap!(T) q) {
    writeln(typeid(q));
}

// sum[p] = xs[0..p] の中から値の大きい順に N 個の要素の総和
long[] calcBestN(int[] xs, bool function(long, long) cmp) {
    assert(xs.length % 3 == 0);

    auto sum = new long[xs.length];
    auto q = new BinaryHeap!(Array!long, cmp); // 小さい順から取り出す
    long s = 0;
    int N = cast(int)xs.length / 3;
    for (int i = 0; i < xs.length; i++) {
        q.insert(xs[i]);
        s += xs[i];
        if (q.length > N) {
            s -= q.front;
            q.popFront();
        }
        sum[i] = s;
    }
    return sum;
}

// sum[p] = 0..p の中から n 個の要素を選び、最大の和を格納
long[] calcLeft(int[] xs) {
    long[] sum = new long[xs.length];
    long s = 0;
    int d = cast(int)xs.length / 3;
    auto q = new BinaryHeap!(Array!long, "a > b"); // 小さい順から取り出せる
    for (int i = 0; i < d * 2; i++) {
        q.insert(xs[i]);
        s += xs[i];
        if (q.length > d) {
            s -= q.front;
            q.removeFront;
        }
        sum[i] = s;
    }
    return sum;
}

// sum[p] = p..$ の中から n 個の要素を選び、最小の和を格納
long[] calcRight(int[] xs) {
    long[] sum = new long[xs.length];
    long s = 0;
    int d = cast(int)xs.length / 3;
    auto q = new BinaryHeap!(Array!long, "a < b"); // 大きい順から取り出す
    for (int i = cast(int)xs.length-1; i >= d; i--) {
        q.insert(xs[i]);
        s += xs[i];
        if (q.length > d) {
            s -= q.front;
            q.popFront;
        }
        sum[i] = s;
    }
    return sum;
}

long calc(int[] xs) {
    /*
    auto lefts  = calcLeft(xs);
    auto rights = calcRight(xs);

    auto n = xs.length;
    auto d = cast(int)xs.length / 3;
    long ans = long.min;
    for (int i = d - 1; i < 2 * d; i++) {
        long diff = lefts[i] - rights[i + 1];
        ans = max(ans, diff);
    }
    return ans;
    */

    auto lsum = calcBestN(xs, (a, b) => a > b);

    auto ys = xs.dup;
    ys.reverse();
    auto rsum = calcBestN(ys, (a, b) => a < b);
    rsum.reverse();

//    writeln(lsum);
//    writeln(rsum);

    long ans = long.min;
    int N = cast(int)(xs.length / 3);
    for (int i = N-1; i < 2 * N; i++) {
        // i までが左側に属する。i+1 以降は右側
        long diff = lsum[i] - rsum[i + 1];
        ans = max(ans, diff);
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    auto ans = calc(xs);
    writeln(ans);
}


Measured memory_bytes: 20964
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int d,g;
    cin>>d>>g;
    pair<int,int> P[10];
    rep(i,d) cin>>P[i].first>>P[i].second;
    int ans=1001;
    for(int bit=0;bit<(1<<d);bit++){//コンプリートする数でbit全探索
        int point=0;
        int solved=0;
        rep(i,d) if(bit&(1<<i)){
            point+=100*(i+1)*P[i].first+P[i].second;
            solved+=P[i].first;
        }
        //cout<<solved<<" "<<point<<endl;
        if(point>=g) ans=min(ans,solved);
        else{
            for(int i=d-1;i>=0;--i){//残りは得点の高い方から解く
                if(bit&(1<<i)) continue;
                if(point+(i+1)*100*(P[i].first-1)<g){
                    //効率悪そうだけどコンプリートしない
                    solved+=P[i].first-1;
                    point+=(i+1)*100*(P[i].first-1);
                }
                else{
                    //gを超えるのにi*100点の問題を何問解けばいいか
                    int need=(g-point+(i+1)*100-1)/((i+1)*100);
                    solved+=need;
                    point+=(i+1)*100*need;
                }
                //cout<<" "<<solved<<" "<<point<<endl;
                if(point>=g) break;
            }
            if(point>=g) ans=min(ans,solved);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
n = N

ans = defaultdict(int)
i = 2
while i ** 2 <= n:
    count = 0
    while n > 1:
        if n % i != 0:
            break
        n //= i
        count += 1
    if count > 0:
        ans[i] = count
    i += 1
if n > 1:
    ans[n] = 1
print(str(N) + ':', end="")
for i, count in ans.items():
    for j in range(count):
        print(" ", end="")
        print(i, end="")
print()


Measured memory_bytes: 6084
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

const int64 mod = 1000000007;

int main()
{
	int64 nn, ans = 0, sum = 0;
	cin >> nn;
	vector<int64> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
		sum += aa[ii];
		sum %= mod;
	}
	for(int64 ii = 0;ii < nn;ii++)
	{
		sum -= aa[ii];
		if(sum < 0)
		{
			sum += mod;
		}
		ans += (sum * aa[ii]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4844
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

struct Vertex {
  int32_t distance{INT32_MAX};
  bool explored{false};
  int32_t parent{-1};
  vector<int32_t> neighbours;
};

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

  using DistanceIndexPair = pair<int32_t, int32_t>;
  priority_queue<DistanceIndexPair, vector<DistanceIndexPair>, greater<DistanceIndexPair>> pqueue;

  constexpr int32_t kStart = 1;
  int32_t number_of_vertices, number_of_edges;
  cin >> number_of_vertices >> number_of_edges;
  vector<Vertex> vertices(number_of_vertices + 1);

  for (int32_t i = 0; i < number_of_edges; ++i) {
    int32_t a, b;
    cin >> a >> b;
    vertices[b].neighbours.push_back(a);
    vertices[a].neighbours.push_back(b);
  }

  pqueue.push(DistanceIndexPair(0, kStart));
  while (pqueue.size() > 0) {
    const DistanceIndexPair p = pqueue.top();
    pqueue.pop();
    const int32_t target_distance = p.first;
    const int32_t target_index = p.second;

    Vertex &cvertex = vertices[target_index];

    cvertex.explored = true;
    for (const int32_t next_index : cvertex.neighbours) {
      if (!vertices[next_index].explored) {
        const int32_t temp_distance = (target_distance != INT32_MAX) ? target_distance + 1 : INT32_MAX;
        if (temp_distance < vertices[next_index].distance) {
          vertices[next_index].distance = temp_distance;
          vertices[next_index].parent = target_index;
          pqueue.push(DistanceIndexPair(temp_distance, next_index));
        }
      }
    }
  }
  bool found = true;
  for (int32_t i = 2; i <= number_of_vertices; ++i) {
    if (vertices[i].parent < 0) {
      found = false;
    }
  }

  if (!found) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int32_t i = 2; i <= number_of_vertices; ++i) {
      cout << vertices[i].parent << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 11920
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s_list = gets_nsp_list
N = s_list.size
K = gets_i

if s_list.size == 1
  puts K/2
  exit
end

if s_list.uniq.size == 1
  puts N * K / 2
  exit
end

count = 0
s_list2 = s_list.dup

1.upto(N - 1) do |i|
  if s_list2[i] != "#" && s_list2[i-1] == s_list2[i]
    s_list2[i] = "#"
    count += 1
  end
end

if s_list.first == s_list.last
  c = s_list.first
  f_count, l_count = 0, 0
  s_list.each do |s|
    f_count += 1 if s == c
    break if s != c
  end
  s_list.reverse_each do |s|
    l_count += 1 if s == c
    break if s != c
  end
  dpp [count, f_count, l_count]
  puts count * K - (f_count/2 + l_count/2  - (f_count + l_count)/2) * (K - 1)
else
  puts count * K
end

Measured memory_bytes: 2556
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		String S = tokens[0];
		String T = tokens[1];
		tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		String U = in.readLine();
		if (S.equals(U)) {
			--A;
		} else {
			--B;
		}
		System.out.println(A + " " + B);
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 23252