akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  

int solve(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    int dp[n][3];
    dp[0][0]=a; dp[0][1]=b; dp[0][2]=c;
    rep(i,1,n){
        cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    
    return 0;
}   
     
signed main(){
    IOS;
    // freopen("input.txt", "r" , stdin);
    // freopen("output4.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long long n,d,b,j,k[200005],k2[200005],w,sum,ans,sum1[200005];
pair <long long, long long> a[200005];
int main()
{
	cin>>n>>d>>b;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1, a+n+1);
	j=1;
	for (int i=1; i<=n;i++)
	{
		
			while(k[j]<a[i].first  && j<i)
		{
			sum-=sum1[j];
			j++;
		} 
		a[i].second-=sum;  
		if(a[i].second>0){
		
		k[i]=a[i].first+2*d; 
		if (a[i].second%b==0)
		{
			w=a[i].second/b;
		}
		else
		w=a[i].second/b+1;
		sum+=w*b;
		sum1[i]=w*b;
	ans+=w;  
	} }
	cout<<ans<<endl;
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int n, m, p;

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

const int N = 7;
int h[N][N], v[N][N][N];

bool check(){
	rep(i, n) rep(j, n) rep(k, n){
		rep(p, 2) rep(q, 2) rep(r, 2)
		rep(dir, 7){
			int nx = i, ny = j, nz = k;
			int cnt[3] = {};
			rep(d, m){
				if (nx < 0 || ny < 0 || nz < 0) break;
				if (nx >= n || ny >= n || nz >= n) break;
				++cnt[v[nx][ny][nz]];
				nx += dx[dir] * (p ? 1 : -1), ny += dy[dir] * (q ? 1 : -1), nz += dz[dir] * (r ? 1 : -1);
			}
			FOR(col, 1, 3) if (cnt[col] == m) return true;
		}
	}
	return false;
}

int main(){
	while (cin >> n >> m >> p, n){
		MEMSET(v, 0);
		MEMSET(h, 0);
		bool end = false;
		rep(i, p){
			int x, y;
			cin >> x >> y;
			--x, --y;
			v[x][y][h[x][y]++] = (i&1)+1;
			if (!end && check()){
				end = true;
				if (i & 1) cout << "White " << i+1 << endl;
				else cout << "Black " << i+1 << endl; 
			}
		}
		if (!end) cout << "Draw" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <ctime>

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define TT int test_cases; cin >> test_cases; while(test_cases--)
#define TT1 int test_cases=1; while(test_cases--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
using namespace std;
typedef long long int ll;

 
int main() {
    
    FAST;
    TT1{
        
        int x,y;cin>>x>>y;
        if(y%2==1)
        {
            cout<<"No"<<"\n";continue;
        }
        int y1=y/2;
        int b=y1-x;
        
        if(b>=0 && x>=b) cout<<"Yes"<<"\n";
        else cout<<"No"<<"\n";
        
        
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  vector <vector <ll>> v(3, vector <ll> (3));
  rep(i, 3) {
    rep(j, 3) {
      cin >> v.at(i).at(j);
    }
  }
  bool flag = 0;
  if (v.at(0).at(0)-v.at(0).at(1) == v.at(1).at(0)-v.at(1).at(1)) {
    if (v.at(1).at(0)-v.at(1).at(1) == v.at(2).at(0)-v.at(2).at(1)) {
      if (v.at(0).at(1)-v.at(0).at(2) == v.at(1).at(1)-v.at(1).at(2)) {
        if (v.at(1).at(1)-v.at(1).at(2) == v.at(2).at(1)-v.at(2).at(2)) {
          flag = 1;
        }
      }
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
#define INF 250000001


int main() {
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    rep(i, C) rep(j, C) cin >> D[i][j];
    vector<vector<int>> c(N, vector<int>(N));
    rep(i, N) {
        rep(j, N) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    vector<vector<int>> memo(C, vector<int>(3));
    rep(k, C) {
        rep(i, N) {
            rep(j, N) {
                memo[k][(i+j)%3] += D[c[i][j]][k];
            }
        }
    }
    int ans = INF;
    rep(i, C) {
        rep(j, C) {
            rep(k, C) {
                if (i == j || i == k || j == k) continue;
                chmin(ans, memo[i][0]+memo[j][1]+memo[k][2]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4544
#include <stdio.h>
#include <stdlib.h>
#define N 101
typedef struct {
  int u; 
  int k; 
  int v[N]; 
} mat_t;

int main(){
  int n,i,j,k=0;
  int matrix[N][N];
  mat_t arr[N];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&arr[i].u,&arr[i].k);
    if(arr[i].k==0) continue;
    /*arr[i].v=(int *)malloc(sizeof(arr[i].k));*/
    for(j=0;j<arr[i].k;j++){
      scanf("%d",&arr[i].v[j]);
    }
  }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(arr[i].v[k]==j+1) {
          matrix[i][j]=1;
          k++;
        }
        else matrix[i][j]=0;
      }
      k=0;
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        printf("%d",matrix[i][j]);
        if(j!=n-1) printf(" ");
      }
      printf("\n");
    }

  /*for(i=0;i<n;i++) free(arr[i].v);*/
  return 0;
}

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

int main(){
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	for(int i=1; i<=3; i++)
	{
		for(int j=1; j<=3; j++)
		{
			cin>>x[i][j];
		}
	}
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	if(a2+b2==x[2][2] && a2+b3==x[2][3]&&a3+b2==x[3][2] && a3+b3==x[3][3])
    {
		 cout<<"Yes"<<endl;
		 return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A =[]
for _ in range(N):
  A.append(int(input()))
a = max(A)
a2= max(sorted(A)[:-1])
f = False
if(a == a2):
  f = True
for i in range(N):
  if(f):
    print(a)
  elif(A[i] == a):
    print(a2)
  else:
    print(a)

Measured memory_bytes: 14752
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);

  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  

  int ans = 1;
  int minimum = vec.at(0);
  for(int i = 1; i < N; i++){
    if(vec[i] < minimum){
      ans += 1;
      minimum = vec[i];
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int V[6] = { 500,100,50,10,5,1 };

int main() {

	int n,ans = 0;

	while (cin >> n, n) {
		n = 1000 - n;
		REP(i, 6) {
			int m = n / V[i];
			n -= V[i] * m;
			ans += m;
		}
		cout << ans << endl;
		ans = 0;
	}

	return 0;
}

Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int N;
int cnt[105];

int main(void)
{
	cin >> N;
	int a;
	for(int i = 0; i < N; i++){
		 cin >> a;
		cnt[a]++;
	}
	
	int max;
	for(max = N; max >= 0; max--) if(cnt[max]) break;
	
	if(max == 1){
		if(N > 2) goto NG;
	}
	else if(max % 2){
		for(int i = max; i > max/2+1; i--){
			if(cnt[i] < 2) goto NG;
		}
		if(cnt[max/2+1] != 2) goto NG;
		for(int i = max/2; i >= 0; i--){
			if(cnt[i]) goto NG;
		}
	}
	else{
		for(int i = max; i > max/2; i--){
			if(cnt[i] < 2) goto NG;
		}
		if(cnt[max/2] != 1) goto NG;
		for(int i = max/2-1; i >= 0; i--){
			if(cnt[i]) goto NG;
		}
	}
	
	cout << "Possible" << endl;
	return 0;
	
	NG: cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int n_A = 0, n_B = 0, n_AB = 0;

    // 先にABピザを最大限買った場合を求め、
    // ABピザを2枚ずつ減らしていく
    n_AB = max(X, Y) * 2;
    ll ans = n_AB * C;

    for (n_AB -= 2; n_AB >= 0; n_AB -= 2)
    {
        // 足りないAピザを求める
        n_A = max(0, X - (n_AB / 2));

        // 足りないBピザを求める
        n_B = max(0, Y - (n_AB / 2));

        // 金額計算
        ans = min(ans, (ll)A * n_A + (ll)B * n_B + (ll)C * n_AB);
    }

    // 結果出力
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,/*L,R,*/X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(L,lli,N/2,0);
  Vec(R,lli,N/2,0);
  rep(i,0,N/2)cin >> L[i] >> R[i];
  Sort(L);Sort(R);
  L.pb(-1);R.pb(-1);
  W=0;H=0;X=0;Y=0;M=0;K=0;sum=1;num=1;
  rep(i,1,N/2+1){
    if(L[i]==L[i-1])sum++;
    else{
      W=max(W,sum);
      if(W==sum)X=L[i-1];
      sum=1;
    }
    if(R[i]==R[i-1])num++;
    else{
      H=max(H,num);
      if(H==num)Y=R[i-1];
      num=1;
    }
  }
  if(X==Y&&W==N/2&&H==W)Out(N/2);
  else if(X==Y){
    rep(i,1,N/2+1){
      if(L[i]==X)continue;
      if(L[i]==L[i-1])sum++;
      else{
        M=max(M,sum);
        sum=1;
      }
    }
    rep(i,1,N/2+1){
      if(R[i]==Y)continue;
      if(R[i]==R[i-1])num++;
      else{
        K=max(K,num);
        num=1;
      }
    }
    A=N-W-K;
    B=N-H-M;
    Out(min(A,B));
  }
  else Out(N-W-H);
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.Scanner;

class Main
{
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    int num1 = scan.nextInt();
    num1 = num1 % 10;
    if((num1 == 2)||(num1 == 4)||(num1 == 5)||(num1 == 7)||(num1 == 9))
      System.out.println("hon");
    if((num1 == 3))
      System.out.println("bon");
    if((num1 == 0)||(num1 == 1)||(num1 == 6)||(num1 == 8))
      System.out.println("pon");
  };
};
    

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

int main(){
  map<int, bool>memo;
  int N;
  cin >> N;
  int cnt = 0;

  for(int i=0; i<N; i++){
    int p[3];
    cin >> p[0] >> p[1] >> p[2];

    sort(p, p+3);

    int k = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);

    if(memo.find(k)!=memo.end()){
      cnt++;
    }
    else{
      memo[k] = true;
    }
  }


  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3204
N,x = map(int,input().split(" "))
a = list(map(int,input().split(" ")))

share = 0
rm = [0] * (N-1)
for i in range(N-1):
	rm[i] = max(0,(a[i]+a[i+1])-x)


for i in range(N-2):
	s = min([rm[i],rm[i+1],a[i+1]])
	share += s
	rm[i] -= s
	rm[i+1] -= s

print(share + sum(rm))
	



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

using namespace std;

int main(){
  string S;
  int A,B;
  cin>>A>>B;
  cin >>S;

  bool check=true;

  for(int i=0;i<=(A+B);i++){
    if(i==A){
      if(S[i]!='-'){
        check=false; 
        break;
      }
    }
    else{
      if(S[i]<'0'||S[i]>'9'){
        check=false; 
        break;
      }
    }
  }
  if(check) cout << "Yes"<<endl;
  else cout <<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF = (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;

ll lcm( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / __gcd(m, n)) * n);
}
 
 
int main()
{
  int N,M;
  cin >> N >> M;
  string S;
  string T;
  cin >> S;
  cin >> T;
 
  ll L = lcm(N, M);
 
  int step = __gcd(N,M);
  // cout << step << endl;
  for(int i=0;i<step;i++){
    // printf("===== i %d\n",i);
    // cout << L/M <<endl;
    // cout <<"S:" << S[i*N/step] << endl;
    // cout << L/N <<endl;
    // cout <<"T:" << T[i*M/step] << endl;
    if(S[i*N/step] != T[i*M/step]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (ll) N/step*M << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		for(int tt = 0; tt < n; tt++){
			int sum = 0;
			int count = 0;
			for(char in : sc.next().toCharArray()){
				sum += (int)(in - '0');
				count++;
			}
			
			final int times = count - 1 + (sum - 1) / 9;
			
			if(times % 2 == 0){
				System.out.println("Audrey wins.");
			}else{
				System.out.println("Fabre wins.");
			}
			
		}
		
	}

}

Measured memory_bytes: 21056
n,m = map(int,input().split())
import math
mod  = 10**9+7
if abs(m-n) >= 2:
    print(0)
elif abs(m-n) == 1:
    print((math.factorial(m)*math.factorial(n))%mod)
else:
    print((2*math.factorial(m)*math.factorial(n))%mod)

Measured memory_bytes: 10852
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int K = int.Parse(ipt[1]);
    ipt = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(ipt[i]);
    }
    Array.Sort(arr);
    int sum = 0;
    for (int i = 0; i < K; i++) {
      sum += arr[i];
    }
    Console.WriteLine(sum);
  }
}

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

int main() {
  char A,B;
  cin>>A>>B;
  if(A==B){
    cout<<'='<<endl;
    return 0;
  }
  else if(A<B){
    cout<<'<'<<endl;
    return 0;
  }
    cout<<'>'<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int a[21];
int b[21];
int c[20];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i < n; i++) cin >> c[i];

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

    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
 
using namespace std;
 
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)

bool is_prime(int n) {
    if(n == 1) return false;
    else if(n == 2) return true;
    else if(n % 2 == 0) return false;

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

    return true;
}

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

    int ans = 0;
    rep(i,n) {
        int a; cin >> a;
        if(is_prime(a)) ++ans;
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> e(n+1);
  rep(i, m) {
    int a, b; cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> room(n+1, -1);
  queue<int> q;
  auto update = [&](int now) {
    for(auto next : e[now]) {
      if(room[next] == -1) {
        room[next] = now;
        q.push(next);
      }
    }
  };

  q.push(1);
  while(!q.empty()) {
    int now = q.front(); q.pop();
    update(now);
  }
  cout << "Yes" << endl;
  for(int i = 2; i <= n; ++i) cout << room[i] << endl;
}

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

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2<<endl;
    return 0;
}



Measured memory_bytes: 3092
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;


signed main()
{
    int A, B;

    cin >> A >> B;
    cout << (A + B) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [H, W] = lines[0].split(" ").map(v=>v-0);
    let ans = new Array(W+2).fill("#").join("")+"\n";
    ans += new Array(H).fill(0).map((v,i)=>{return "#"+lines[i+1]+"#"}).join("\n") + "\n";
    ans += new Array(W+2).fill("#").join("");
    console.log(ans);
    
});


Measured memory_bytes: 29972
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
S = inp()

NO = {}
for c in 'RBG':
    NO[c] = S.count(c)

left = {}
nbr = {k:0 for k in 'RGB'}
for i, c in enumerate(S):
    nbr[c] += 1
    for c in 'RBG':
        left[i,c] = NO[c] - nbr[c]

sm = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]: continue
        c = 'RGB'.replace(S[i], '').replace(S[j], '')
        cnt = left[j,c]
        k = 2*j - i
        if k < N and S[k] == c:
            cnt -= 1
        sm += cnt
print(sm)



Measured memory_bytes: 71676
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    double a,b;
    cin>>a>>b;
    double c[4];
    c[0]=a/0.08;
    c[1]=(a+1)/0.08;
    c[2]=b/0.1;
    c[3]=(b+1)/0.1;
    if(c[1]<=c[2]||c[3]<=c[0])
            cout<<-1<<endl;
    else{
        sort(c,c+4);
        if((int)c[2]-(int)c[1]<1)
            cout<<-2<<endl;
        else if(c[1]==(int)c[1])
            cout<<c[1]<<endl;
        else
            cout<<(int)(c[1]+1)<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;


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

	int a = -1, b = N + 1;

	for (int i = 0; i < M; i++) {
		int p, q; cin >> p >> q;
		a = max(a, p);
		b = min(b, q);
	}

	if (a <= b) {
		cout << b - a + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int n,m;
    priority_queue<int>pq;
    int i,k;
    sff(n,m);
    rep0(i,n)
    {
        sf(k);
        pq.push(k);
    }
    while(m--)
    {
        int x=pq.top()/2;
        pq.pop();
        pq.push(x);
    }
    ll sum=0;
    while(!pq.empty())
    {
        sum+=pq.top();
        pq.pop();
    }
    pf("%lld",sum);
}


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

int main(void){
    char s[200];
    char cpy[200];
    int sh, h;
    int i, j, len;
    while(1){
        scanf("%s", s);
        len = strlen(s);
        if(!strcmp(s, "-"))
            break;
        scanf("%d", &sh);
        for(i = 0; i < sh; i++){
            memset(cpy, '\0', sizeof(cpy));
            scanf("%d", &h);
            strcpy(cpy, &s[h]);
            strncat(cpy, s, h);
            cpy[len] = '\0';
            strcpy(s, cpy);
        }
        puts(s);
    }
    return 0;
}



Measured memory_bytes: 2076
using System;
using System.Linq;

namespace abc130
{
    class B
    {
        static void Main(string[] args)
        {
            var input = Input.IntArray();
            int N = input[0];
            int X = input[1];

            var LL = Input.IntArray();

            var D = 0;
            var count = 1;

            for (int i = 0; i < LL.Length; i++)
            {
                D += LL[i];
                if (D <= X) {
                    count++;
                } else {
                    break;
                }
            }

            Console.WriteLine(count);

            
        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }

    }
}

Measured memory_bytes: 13268
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	l := io.NextInts(n)
	cnt := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if l[i] == l[j] {
				continue
			}
			for k := j + 1; k < n; k++ {
				if l[j] == l[k] || l[k] == l[i] {
					continue
				}
				l1, l2, l3 := l[i], l[j], l[k]
				l1, l2 = swap(l1, l2)
				l2, l3 = swap(l2, l3)
				l1, l2 = swap(l1, l2)
				if l1+l2 > l3 {
					cnt++
				}
			}
		}
	}
	io.Println(cnt)
}

func swap(i, j int) (int, int) {
	if j < i {
		return j, i
	}
	return i, j
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

void change(string &s, vector<set<int>>& index, int i, char c){
    if (s[i] == c) return;
    int pre = s[i] - 'a';
    int to = c - 'a';
    index[pre].erase(i);
    index[to].insert(i);
    s[i] = c;
    return;
}

int calc(string &s, vector<set<int>>& index, int l, int r){
    int res = 0;
    rep(i, index.size()){
        if (index[i].size() == 0) continue;
        auto itr = index[i].lower_bound(l);
        if (itr == index[i].end()) continue;
        if (*itr <= r) res++;
    }
    return res;
}

int main(){
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> index(26);
    rep(i,n){
        int j = s[i] - 'a';
        index[j].insert(i);
    }

    vector<int> ans;
    rep(k,q){
        int t;
        cin >> t;
        if (t == 1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            change(s, index, i, c);
        }else{
            int l, r;
            cin >> l >> r;
            l--; r--;
            ans.push_back(calc(s, index, l, r));
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 27516
import java.io.*
import java.util.*

fun solve(N: Int, A: Array<Int>, B: Array<Int>, C: Array<Int>){
    val a = A.sorted()
    val b = B.sorted()
    val c = C.sorted()
    // 各biについて, biより大きいciの数
    val cumSum = b.map{ (N - c.upperBound(it)).toLong() }.scanLeft(0L){ a,b -> a+b }.toList()
    // println(cumSum)
    val ans = a.map{ cumSum.last() - cumSum.getOrElse(b.upperBound(it)-1){ 0L } }.sum()
    println(ans)
    return
}


fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}

fun <T : Comparable<T>> List<T?>.upperBound(
        element: T,
        fromIndex: Int = 0,
        toIndex: Int = size
): Int {
    var low = fromIndex
    var high = toIndex
    while (low < high) {
        val mid = (low + high) / 2
        if (element >= this.get(mid)!!) {
            low = mid + 1
        } else {
            high = mid
        }
    }
    return low
}



fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = Array<Int>(N){ sc.next().toInt() }
    val B = Array<Int>(N){ sc.next().toInt() }
    val C = Array<Int>(N){ sc.next().toInt() }
    // for (i in 0 until N) {
    //     A[i] = sc.next().toInt()
    // }
    // val B = Array<Int>(N)
    // for (i in 0 until N) {
    //     B[i] = sc.next().toInt()
    // }
    // val C = Array<Int>(N)
    // for (i in 0 until N) {
    //     C[i] = sc.next().toInt()
    // }
    solve(N, A, B, C)
}



Measured memory_bytes: 84192
use std::i64;
use std::cmp;

// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main(){
    input! {
        s: chars,
        t: chars,
    }

    let mut dp = vec![vec![0;t.len()+1]; s.len()+1];
    for i in 1 .. s.len()+1 {
        for j in 1 .. t.len()+1 {
            if s[i-1] == t[j-1] {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = cmp::max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    let mut ans = String::new();
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if s[i-1] == t[j-1] {
            ans.push(s[i-1]);
            i -= 1;
            j -= 1;
        } else {
            if dp[i-1][j] < dp[i][j-1] {
                j -= 1;
            } else {
                i -= 1;
            }
        }
    }

    println!("{}", ans.chars().rev().collect::<String>());
}




Measured memory_bytes: 41212
def main():
  N, K = map(lambda i: int(i), input().split(' '))
  S = list(input())
  score = 0
  for i in range(N):
    if i >= 1 and S[i] == 'L' and S[i - 1] == 'L':
      score += 1
    elif i <= N - 2 and S[i] == 'R' and S[i + 1] == 'R':
      score += 1
  print(min(N - 1, score + 2 * K))

main()


Measured memory_bytes: 3956
from collections import defaultdict
N,C=map(int,input().split())
D=[[int(i) for i in input().split()] for j in range(C)]
M=[[int(i) for i in input().split()] for j in range(N)]
ans=10**9
L=[defaultdict(int) for i in range(3)]

for i in range(N):
    for j in range(N):
        L[(i+j)%3][M[i][j]-1]+=1
#print(L)
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            num=0
            for color,number in L[0].items():
                #num+=D[i][color]*number
                num += D[color][i] * number
                #print(num)
            for color,number in L[1].items():
                #num+=D[j][color]*number
                #print(num)
                num += D[color][j] * number
            for color,number in L[2].items():
                #num+=D[k][color]*number
                #print(num)
                num += D[color ][k] * number
            ans=min(ans,num)

            #print(ans,i,j,k)
#for color,number in L[0].items():
    #print(color,number)

print(ans)



Measured memory_bytes: 47452
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
ll a[200005], s[200005];
map<ll, ll>m;
void solve()
{
	ll n, k;
	cin >> n >> k;
	for (ll i = 1; i <= n; i++)
		cin >> a[i];
	for (ll i = 1; i <= n; i++)
	{
		s[i] = s[i - 1] + a[i];
	}
	ll sol = 0;
	for (ll i = 0; i <= n; i++)
	{
		if (i >= k)
			m[(s[i-k]-(i-k))%k]--;
		sol = sol + m[(s[i] - i)%k];
		m[(s[i] - i)%k]++;
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
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; }

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

#define MAX 1e15

int main() {
  
  ll x,y,ans1,ans2;
  cin>>x;
  
  for(ll a=1;a<1000;a++){
    for(ll b=-1000;b<a;b++){
      y=a*a*a*a*a-b*b*b*b*b;
      if(y==x){
        ans1=a;
        ans2=b;
        break;
      }
    }
  }
  
  cout<<ans1<<" "<<ans2<<endl;
  
  return 0;
}

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

int main(){
    int64_t N,x;
    cin>>N>>x;
    int64_t dp[N][N];//魔法を唱えた回数, スライムの色の最小コスト
    vector<int64_t> A(N);
    for(auto &a:A) cin>>a;
    int64_t ans=0;
    for(int i=0;i<N;i++){
        dp[0][i]=A[i];
        ans+=A[i];
    }
    for(int m=1;m<N;m++){
        int64_t sum=x*m;
        dp[m][0]=min(A[0],dp[m-1][N-1]);
        sum+=dp[m][0];
        for(int i=1;i<N;i++){
            dp[m][i]=min(A[i],dp[m-1][i-1]);
            sum+=dp[m][i];
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 31488
//STLを用いた二分探索
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int A[1000000], n;

int main(){
  cin >> n;
  for(int i = 0; i<n; i++){
    scanf("%d", &A[i]);
  }

  int q, k, sum = 0;
  cin >> q;
  for(int i = 0; i < q; i++){
    scanf("%d", &k);
    //標準ライブラリのlower_boundを使用(kを挿入できる最初の位置が取得できる)
    if(*lower_bound(A, A+n, k) == k) sum ++;//kを挿入できる最初の位置に対して*を使うことでその値が取れて、それがkと等しければTrue
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
struct BIT {
  int n;
  vector<int> xs;
  BIT (int n) : n(n) {
    xs.resize(n+1);
  }
  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
  }
  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s += xs[x];
    return s;
  }
  int sum(int a, int b) {
    return sum(b) - sum(a-1);
  }
};

int N;
string S;
deque<int> G[26];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  N = S.length();
  rep(i, N) G[S[i]-'a'].pb(i);
  int odd = 0, oc = -1;
  rep(i, 26) if (G[i].size()%2) odd++, oc = i;
  if (odd > 1) {
    cout << -1 << "\n";
    return 0;
  }
  int l = 0, r = N-1;
  long long ctr = 0;
  BIT bit(N);
  rep(i, N) bit.add(i, 1);
  rep(pos, N/2) {
    while (bit.sum(l, l) == 0) l++;
    while (bit.sum(r, r) == 0) r--;
    if (S[l] == S[r]) {
      bit.add(l, -1);
      bit.add(r, -1);
      G[S[l]-'a'].pop_front();
      G[S[r]-'a'].pop_back();
    }
    else {
      if (S[l]-'a' == oc) {
        int p = G[S[r]-'a'].front();
        ctr += bit.sum(p)-1;
        bit.add(r, -1);
        bit.add(p, -1);
        G[S[r]-'a'].pop_front();
        G[S[r]-'a'].pop_back();
      }
      else {
        int p = G[S[l]-'a'].back();
        ctr += max(bit.sum(p, N-1)-1, 0);
        bit.add(l, -1);
        bit.add(p, -1);
        G[S[l]-'a'].pop_back();
        G[S[l]-'a'].pop_front();
      }
    }
  }
  cout << ctr << "\n";
  return 0;
}


Measured memory_bytes: 2068
def main():
    N = int(input())
    h = list( map(int,input().split()) )

    cost = [0]*N
    cost[1] = abs(h[1]-h[0])
    for i in range(2,N):
        c1 = abs(h[i]-h[i-1]) + cost[i-1]
        c2 = abs(h[i]-h[i-2]) + cost[i-2]
        if c1 < c2 :
            cost[i] = c1
        else:
            cost[i] = c2
    
    print(cost[-1])
    return

if __name__=="__main__":
    main()

Measured memory_bytes: 13980
#include <stdio.h>

int main() {
    int n, cnt;
    while ( scanf("%d", &n) != EOF ) {
        cnt = 0;
        for (int a=0; a<10; a++) {
            for (int b=0; b<10; b++) {
                for (int c=0; c<10; c++) {
                    for (int d=0; d<10; d++) {
                        if ( a + b + c + d == n ) cnt++;
                    }
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}


Measured memory_bytes: 1984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int x = ni();
        if(400 <= x && x <= 599) out.println(8);
        else if(x <= 799) out.println(7);
        else if(x <= 999) out.println(6);
        else if(x <= 1199) out.println(5);
        else if(x <= 1399) out.println(4);
        else if(x <= 1599) out.println(3);
        else if(x <= 1799) out.println(2);
        else if(x <= 1999) out.println(1);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main() {
	int r=2;
  int x=20;
  int d=10;
  cin>>r;
  cin>>d;
  cin>>x;
  
  for(int i=0; i<10;i++){
    x=r*x-d;
    cout<< x<<endl;
  }
  
	return 0;
}


Measured memory_bytes: 3584