akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    long long N, M;
    long long K;
    vector<long long> A, B, A_SUM, B_SUM;

    cin >> N >> M >> K;
    
    A_SUM.push_back(0);
    B_SUM.push_back(0);

    long long sum = 0;
    for(int i=0; i < N; ++i){
        long long tmp;
        cin >> tmp;
        sum += tmp;
        //A.push_back(tmp);
        A_SUM.push_back(sum);
    }

    sum = 0;
    for(int i=0; i < M; ++i){
        long long tmp;
        cin >> tmp;
        sum += tmp;
        //B.push_back(tmp);
        B_SUM.push_back(sum);
    }
    long long ans = 0;
    
    long long B2=M;
    for(long long i=0; i <= N; ++i ){
        long long left = K-A_SUM[i];
        
        //cout << "left=" << left << endl;
        if(left < 0){
            break;
        }
        chmax(ans, i);
        for(long long j=B2; j >= 0; --j){
            B2=j;
            if(B_SUM[j] <= left){
                chmax(ans, (j+ i));
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7936
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;



int MOD=1000000007;
int main(void){
	int m1,d1,m2,d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(m1!=m2) cout << 1 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d,e,sum;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	sum=0;
	if(a<0){
		sum+=(a*-1)*c+d;
		a=0;
	}
	sum+=(b-a)*e;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] bingo = new int[3][3];
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				bingo[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			int tmp = sc.nextInt();
			for(int j =0; j < 3; j++){
				for(int k = 0; k < 3; k ++){
					if(bingo[j][k] == tmp){
						bingo[j][k] = 0;
					}
				}
			}
		}
		for(int i = 0; i < 3; i++){
			if(bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0){
				System.out.println("Yes");
				break;
			}
			if(i == 2){
				System.out.println("No");
			}
		}
 	}
}




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

int main() {
	int n;
	cin >> n;
	
	while(n--) {
		int a, b, c;
		cin >> a >> b >> c;

		if (a*a == b*b + c*c ||
			b*b == a*a + c*c ||
			c*c == b*b + a*a) 

			cout << "YES" << endl;

		else
			cout << "NO" << endl;
	}

	return 0;
}

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template<class VECTOR_T>
void floyd_warshall(VECTOR_T& v, int origin = 0) {
    int stop = v.size();
    for (int k = origin; k < stop; k++)
        for (int i = origin; i < stop; i++)
            for (int j = origin; j < stop; j++)
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
}

int main()
{
    int H, W; cin >> H >> W;
    vector<vector<int>> C(10, vector<int>(10)); cin >> C;
    vector<vector<int>> A(H, vector<int>(W)); cin >> A;
    
    floyd_warshall(C);

    int ans = 0;
    for (auto a : A) for (auto b : a) if (b != -1) ans += C[b][1];
    cout << ans << endl;
}


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

int main() {
  int a,b,c,n;
  cin>>n>>a>>b>>c;
  vector<int> cal(n);
  for (int i=0; i<n; ++i) cin>>cal[i];
  sort(cal.begin(), cal.end(), greater<int>());
  double ans = (double)c/a;
  int csum = c, psum = a;
  for (int i=0; i<n; ++i) {
    csum += cal[i];
    psum += b;
    ans = max(ans, (double)csum/psum);
  }
  cout<<(int)ans<<endl;
}

Measured memory_bytes: 1216
package main

import (
	"fmt"
	"math"
)

var A, B, C, ans string

func main() {
	fmt.Scan(&A, &B, &C)

	if string(A[len(A)-1]) == string(B[0]) && string(B[len(B)-1]) == string(C[0]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B;
  cin>>A>>B;
  cout<<(A+B)%24<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int Num,alpha[Num];
	int color[9] = {0,0,0,0,0,0,0,0,0};
	int min=0,max=0;
	scanf("%d",&Num);
	for( int i=0; i<Num; i++){
		scanf("%d",&alpha[i]);
		if( alpha[i]>=1 && alpha[i]<=399) color[0]++;
		if( alpha[i]>=400 && alpha[i]<=799) color[1]++;
		if( alpha[i]>=800 && alpha[i]<=1199) color[2]++;
		if( alpha[i]>=1200 && alpha[i]<=1599) color[3]++;
		if( alpha[i]>=1600 && alpha[i]<=1999) color[4]++;
		if( alpha[i]>=2000 && alpha[i]<=2399) color[5]++;
		if( alpha[i]>=2400 && alpha[i]<=2799) color[6]++;
		if( alpha[i]>=2800 && alpha[i]<=3199) color[7]++;
		if( alpha[i]>=3200 ) color[8]++;
	}
	for( int j=0; j<8; j++){
		if( color[j] != 0 ){
		max++;
		min++;
		}
	}
	if( min==0 ) min=1;
	printf("%d %d",min,max+color[8]);
	return 0;
}

Measured memory_bytes: 128
package main
import(
        "fmt"
        "math"
        "bufio"
        "os"
      )


var dy = []int{-1,0,1,0}
var dx = []int{0,1,0,-1}
var limit = 0
var N = 4
var t = make([][]int, N)

func main(){ 
  var in=bufio.NewReader(os.Stdin)
  for i := 0; i<N;i++{t[i] = make([]int, N)}
  var py,px int
  for i:=0;i<N;i++ {
      fmt.Fscanf(in,"%d %d %d %d\n", &t[i][0], &t[i][1],&t[i][2],&t[i][3])
  }
  for i:=0;i<N;i++ {
    for j:=0;j<N;j++{
      if t[i][j]==0{
        py=i;
        px=j;
      }
    }
  }

  Solve(py,px);
}

func getH()(int){
  sum,x,i,j:=0,0,0,0
  for i=0;i<N;i++{
    for j=0;j<N;j++{
      if t[i][j]==0 {continue}
      x=t[i][j]-1
      sum+=int(math.Abs(float64(int(x/N)-i))+math.Abs(float64(int(x%N)-j)))
    }
  }
  return sum
}

func dfs(depth int,prev int, py int, px int)(bool){
  h:=getH();
  if h+depth>limit {return false}
  if h==0 {return true}
  for i:=0;i<N;i++ {
    if int(math.Abs(float64(i-prev)))==2{continue}
    ty,tx:=py+dy[i],px+dx[i]
    if ty<0||tx<0 || ty>=N ||tx>=N {continue}
    t[ty][tx],t[py][px] = t[py][px],t[ty][tx]
    if dfs(depth+1,i,ty,tx) {return true}
    t[ty][tx],t[py][px] = t[py][px],t[ty][tx]
  }
  return false
}

func Solve(py int ,px int){
  for limit=0;;limit++{
    if dfs(0,99,py,px){
      fmt.Println(limit)
      return
    }
  }
}





Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << "A"<<b[0]<<"C"<< endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()

ans = 1
cnt = 1
t_limit = T[0] + K

for i in range(1, N):
	if cnt == C:   #人数上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
	elif T[i] <= t_limit: #乗れる
		cnt += 1 
	else:          #待ち時間上限
		t_limit = T[i] + K
		cnt = 1
		ans += 1
print(ans)

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

int N, M, Q;
vector<vector<int>> vec(51, vector<int>(4));
vector<int> tmp;
long long Max = 0;

void calc(int a) {
  if (a == N) {
    long long sum = 0;
    for (int i = 0; i < Q; i++) {
      if (tmp[vec[i][1]] - tmp[vec[i][0]] != vec[i][2]) {
        continue;
      }
      sum += vec[i][3];
    }
    if (sum > Max) {
      Max = sum;
    }
    return;
  }

  for (int i = tmp[a]; i <= M; i++) {
    tmp.push_back(i);
    calc(a + 1);
    tmp.pop_back();
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> vec[i][0] >> vec[i][1] >> vec[i][2] >> vec[i][3];
  }

  tmp.push_back(1);
  calc(0);
  cout << Max << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int H, W, N;
typedef pair<int, int> P;
P points[100005];
map<P, int> mp;

int dx[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
int dy[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> H >> W >> N;
    REP(i, N) {
        int x, y;
        cin >> y >> x;
        REP(j, 9) {
            int nx = x + dx[j];
            int ny = y + dy[j];
            if (nx <= 1 || ny <= 1 || nx >= W || ny >= H) continue;
            mp[{nx, ny}]++;
        }
    }

    map<int, int> cnt;
    for (auto kv : mp) {
        cnt[kv.second]++;
    }

    cout << (H - 2) * (W - 2) - mp.size() << endl;
    REPS(i, 9) { cout << cnt[i] << endl; }

    return 0;
}


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

using ll = long long;
const long long INF = (1LL << 32);

class Dijkstra {
    class Node {
        public:
        int num;
        long long cost;

        Node(int v, long long c) {
            num = v;
            cost = c;
        }

        bool operator>(const Node &node) const { return cost > node.cost; }
    };

    private:
    vector<bool> checked;
    vector<long long> d;
    vector<unordered_map<int, long long>> adj;
    priority_queue<Node, deque<Node>, greater<Node>> nodes;

    public:
    Dijkstra(int n) {
        checked.resize(n, false);
        d.resize(n, INF);
        adj.resize(n);
    }

    long long get_distance(int nd) { return d[nd]; }

    void set_distances(int sp) {
        d[sp] = 0;
        Node snd(sp, 0);
        nodes.push(snd);

        while (!nodes.empty()) {
            Node cur = nodes.top();
            nodes.pop();
            checked[cur.num] = true;

            if (d[cur.num] < cur.cost) continue;

            for (auto e : adj[cur.num]) {
                int v = e.first;
                int w = e.second;

                if (checked[v]) {
                    continue;
                } else if (d[v] > d[cur.num] + w) {
                    d[v] = d[cur.num] + w;
                    Node nd(v, d[v]);
                    nodes.push(nd);
                }
            }
        }
    }

    void add_edge(int u, int v, int w) { adj[u][v] = w; }
};

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

    int V, E, r;
    cin >> V >> E >> r;

    Dijkstra dks(V);

    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        dks.add_edge(s, t, w);
    }

    dks.set_distances(r);

    for (int i = 0; i < V; ++i) {
        ll d = dks.get_distance(i);
        if (d < INF) cout << d << endl;
        else cout << "INF" << endl;
    }

    return 0;
}


Measured memory_bytes: 32632
module ABC141

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_C

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(INT32) :: id_player_answered
    integer(INT32) :: num_players
    integer(INT32) :: val_points_init
    integer(INT32) :: num_questions

    ! arrays for this <subroutine>
    integer(INT32), dimension(:), allocatable :: list_player_points

    ! support variables for this <subroutine>
    integer(INT32) :: itr_p
    integer(INT32) :: itr_q

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) num_players, val_points_init, num_questions

    ! STEP.02
    ! allocate the array to store the given data
    allocate( list_player_points  (1:num_players)   )

    ! STEP.03
    ! initialize the list of points
    list_player_points(:) = 0_INT32

    ! STEP.04
    ! read out the given data
    ! update the points of the players
    do itr_q = 1_INT32, num_questions, 1_INT32
      read(unit=INPUT_UNIT, fmt=*) id_player_answered
      list_player_points( id_player_answered ) = list_player_points( id_player_answered ) + 1_INT32
    end do

    ! STEP.05
    ! output the answer of this task
    ! update the points of the players
    do itr_p = 1_INT32, num_players, 1_INT32

      if (list_player_points(itr_p) .gt. num_questions - val_points_init) then
        write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') 'Yes'
      else
        write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') 'No'
      end if

    end do

    ! STEP.06
    ! deallocate the array to store the given data
    deallocate( list_player_points )

    ! STEP.END
    return

  end subroutine task_C

end module ABC141


program main

  ! <module>s to import
  use, non_intrinsic :: ABC141

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
 
using namespace std;
 
 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash(3000000);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}

Measured memory_bytes: 78832
#include<stdio.h>

int main(void){

int r,x,y,w,h;

scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){

printf("Yes\n");

}

else{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;

  if(U == S){
    cout << A-1 << " " << B;
  }
  else{
    cout << A << " " << B-1;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    int x=800*n;
    int y=(200)*(n/15);
    cout<<x-y<<endl;



    return 0;
}


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

int main(void){
  int n;
  int cards[4][13];
  char mark;
  int number;

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      cards[i][j] = 0;
    }  
  }

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> mark >> number;
    number--;
    switch(mark){
    case 'S':
      cards[0][number] = 1;
      break;

    case 'H':
      cards[1][number] = 1;
      break;

    case 'C':
      cards[2][number] = 1;
      break;

    case 'D':
      cards[3][number] = 1;
      break;
    }
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(cards[i][j] == 0){
	switch(i){
	case 0:
	  cout << "S " << j + 1 << endl;
	  break;

	case 1:
	  cout << "H " << j + 1 << endl;
	  break;

	case 2:
	  cout << "C " << j + 1 << endl;
	  break;

	case 3:
	  cout << "D " << j + 1 << endl;
	  break;

	}
      }
    }
  }

  return 0;
}

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

const int BIT = 18;
const int MAX = 1 << BIT;
typedef std::pair <int, int> pii;

int ans[MAX];
int a[MAX];
int dp[MAX][BIT + 1][2];

pii calc(int a, int b, int c, int d){
    std::vector <int> vec = {a, b, c, d};
    std::sort(vec.begin(), vec.end(), std::greater <int>());
    return {vec[0], vec[1]};
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 1 << n; ++ i){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < 1 << n; ++ i){
        dp[i][0][1] = a[i];
        for (int j = 1; j <= n; ++ j){
            if (!(i >> j - 1 & 1)){
                dp[i][j][0] = dp[i][j - 1][0];
                dp[i][j][1] = dp[i][j - 1][1];
            }
            else{
                pii p = calc(dp[i][j - 1][0], dp[i][j - 1][1], dp[i ^ 1 << j - 1][j - 1][0], dp[i ^ 1 << j - 1][j - 1][1]);
                dp[i][j][1] = p.first;
                dp[i][j][0] = p.second;
            }
        }
    }
    for (int i = 1; i < 1 << n; ++ i){
        ans[i] = std::max(ans[i - 1], dp[i][n][0] + dp[i][n][1]);
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 44032
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	if(n == 1){
		cout << "Hello World\n";
		return 0;
	}
	cin >> a >> b;
	cout << a + b << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll num[200005];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	ll cnt=1;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&num[i]);
		if(num[i]==cnt)
		{
			cnt++;
		}
		else
		{
			ans++;
		}
	}
	
	if(cnt==1)
	printf("-1");
	else
	printf("%lld",ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

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

    int num = 1;
    int count = 0;
    while (num < b) {
        num--;
        num += a;
        count++;
    }

    cout << count << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val XY = rd.readListLongCols(N)

    val PXPY = LongArray(N)
    val MXMY = LongArray(N)
    val MXPY = LongArray(N)
    val PXMY = LongArray(N)

    for (i in 0 until N) {
        val (X, Y) = XY[i]
        PXPY[i] = X+Y
        MXMY[i] = -X-Y
        MXPY[i] = -X+Y
        PXMY[i] = X-Y
    }

    val ans = max(
            max(PXPY.max()!! + MXMY.max()!!, PXMY.max()!! + MXPY.max()!!),
            max(MXPY.max()!! + PXMY.max()!!, MXMY.max()!! + PXPY.max()!!)
    )
    println(ans)
}


//val rd = debug.Reader("abc", "178", "e", "rndsample-024")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 79576
#include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;

string rev(string);

int main()
{
    string str;
    cin >> str;
    cout << rev(str) << endl;
    return 0;
}


string rev(string str){
    int len, s, t;
    char buf;
    len = str.size();
    s = 0, t = len-1;
    while(s < t){
        buf = str[s], str[s] = str[t], str[t] = buf;
        s++, t--;
    }
    return str;
}

Measured memory_bytes: 1176
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

int main() {
    int x;
    cin>>x;
    int ans=0;
    while (x >= 5) {
        if (x >= 500) {
            x -= 500;
            ans += 1000;
        } else if (x >= 5) {
            x -= 5;
            ans += 5;
        }
    }
    cout<<ans;
}

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

#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

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

    int max_cnt = 0;
    int max_num = 0;
    for(int i=1; i<N+1; i++){
        int cnt = 0;
        int cur = i;
        while(true){
            if(cur%2==0){
                cnt++;
                cur/=2;
            }
            else break;
        }
        if(cnt>max_cnt){
            max_cnt = cnt;
            max_num = i;
        }
    }

    if(N!=1) cout << max_num << endl;
    else cout << 1 << endl;
    
    return 0;
}

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
string a;
int m;
long long d[100001][101][2];
const long long mod=1e9+7;
int n;
long long d__p(int step,int sum,int tt)
{
    if(step==n)
    {
        return d[step][sum][tt] = sum==0;
    }
    if(d[step][sum][tt]!=-1)
        return d[step][sum][tt];
    int limit=9;
    if(tt)
    {
        limit=a[step]-'0';
    }
    long long res=0;
    for(int j=0;j<=limit;j++)
    {
        res=res+d__p(step+1,(sum+j)%m,tt && j==limit);
        res%=mod;
    }
    return d[step][sum][tt]=res;
}
int main()
{
    cin>>a;
    cin>>m;
    n=a.length();
    memset(d,-1,sizeof d);
    cout<<(d__p(0,0,1)-1+mod)%mod;
    return 0;
}


Measured memory_bytes: 158848
S=list(input())
T=list(input())
A=[]
for i in range(len(S)-len(T)+1):
    B=0
    for j in range(len(T)):
        if T[j]==S[i+j]:
            continue
        else:
            B =B+1
    A.append(B)

A.sort()
print(A[0])



Measured memory_bytes: 9124
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- words <$> getLine
	putStrLn $ which "YES" "NO" $ last a == head b && last b == head c


Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll A, B, C, K;

	cin >> A >> B >> C >> K;

	if (K <= A) cout << K << endl;
	else if (K <= A + B) cout << A << endl;
	else cout << A - (K - (A + B)) << endl;

	return 0;
}


Measured memory_bytes: 3644
from collections import deque

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())

ch,cw,dh,dw = ch-1,cw-1,dh-1,dw-1
S = [[""]*w for i in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        S[i][j] = s[j]
        
visited = [[-1]*w for _ in range(h)]

visited[ch][cw] = 0

INF = 10**9
dist = [[INF]*w for _ in range(h)]
Q = deque([])
Q.append([ch,cw])
dist[ch][cw] = 0

while Q:
    y,x = Q.popleft()
    d = dist[y][x]
    
    for i, j in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
      nx = x + i
      ny = y + j
      if (nx < 0 or nx >= w or ny < 0 or ny >= h): 
          continue
      if S[ny][nx] == "#":
          continue
      if dist[ny][nx] <= d:
          continue
      dist[ny][nx] = d
      Q.appendleft([ny,nx])
      
    
    for ey in range(-2,3):
        for ex in range(-2,3):
            nx = x + ex
            ny = y + ey
            if (nx < 0 or nx >= w or ny < 0 or ny >= h): 
              continue
            if S[ny][nx] == "#":
              continue
            if dist[ny][nx] <= d+1:     
              continue
            dist[ny][nx] = d+1
            Q.append([ny,nx])
      
ans = dist[dh][dw]

if ans == INF:
    print(-1)
else:
    print(ans)

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

using namespace std;


int main(int argc, char const* argv[])
{
  int n, k, r, s, p;
  string t;
  string hands;
  int ans = 0;

  scanf("%i %i", &n, &k);
  scanf("%i %i %i", &r, &s, &p);
  cin >> t;

  int iter = 0;
  for (; iter < k; iter++) {
    switch(t[iter]) {
      case 'r':
        hands += "p";
        ans += p;
        break;
      case 'p':
        hands += "s";
        ans += s;
        break;
      case 's':
        hands += "r";
        ans += r;
        break;
    }
  }

  for (; iter < n; iter++) {
    switch(t[iter]) {
      case 'r':
        if (hands[iter - k] != 'p') {
          hands += 'p';
          ans += p;
        } else {
          hands += 'x';
        }
        break;
      case 'p':
        if (hands[iter - k] != 's') {
          hands += 's';
          ans += s;
        } else {
          hands += 'x';
        }
        break;
      case 's':
        if (hands[iter - k] != 'r') {
          hands += 'r';
          ans += r;
        } else {
          hands += 'x';
        }
        break;
    }
  }

  printf("%i\n", ans);

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int i,a,m,n,x;
  a = 0;
  m = N;
  for (i = 0; N > 0; i++)
  {
    n = N % 10;
    a += n;
    N /= 10;
  }
  x = m % a;
  if (x == 0){
      cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int MOD = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vector<int>ans(N, 0);
  vector<bool>sta(N, true);
  for (int i = 0; i < M; i ++) {
    int a;
    cin >> a;
    sta[a - 1] = false;
  }
  if (sta[0]) ans[0] = 1;
  if (sta[1]) ans[1] = ans[0] + 1;
  for (int i = 2; i < N; i ++) {
    if (sta[i]) {
      ans[i] = ans[i - 1] + ans[i - 2];
      ans[i] %= MOD;
    }
  }
  cout << ans[N - 1] << endl;
}
  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define in insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007


int main()
{
FIO

    ll x, n;   cin >> x >> n;
    if(n == 0)
    {
        cout << x;
        return 0;
    }
    ll a[n];
    For(n) cin >> a[i];
    sort(a,a+n);
    int high = upper_bound(a,a+n,x)-a;
    // cout << high << endl;
    if(high == 0)
        cout << x;
    else
    {
        int low = high-1;
        if(a[low] == x)
        {
            low--;
            int x1 = x-1, x2 = x+1;
            // cout << low << " " << high << endl;
            // cout << x1 << " " << x2 << endl;
            while(1)
            {
                if(low >= 0)
                {
                    if(a[low--] != x1)
                    {
                        cout << x1 ;
                        return 0;
                    }
                    else
                        x1--;
                }
                else
                {
                    cout << x1;
                    return 0;
                }
                if(high < n)
                {
                    if(a[high++] != x2)
                    {
                        cout << x2 ;
                        return 0;
                    }
                    else
                        x2++;
                }
                else
                {
                    cout << x2;
                    return 0;
                }
            }
        }
        else
            cout << x << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3584
import sys
import math
from collections import deque

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,M=LI()
RES = [-1]*(N+1)
RES[N] = 0.0

MP=[[] for i in range(N+1)]
for _ in range(M):
    i, j = LI()
    MP[i].append(j)

for i in range(N-1, 0, -1):
    div = len(MP[i])
    next_E = 0
    for j in MP[i]: next_E += RES[j] + 1
    RES[i] = next_E / div

result = RES[1]
RESN = [0]*(N+1)

for i in range(1, N-1):
    if len(MP[i]) == 1: continue
    max_j = max((RES[w],w) for w in MP[i])[1]

    for k in range(N-1, 0, -1):
        div = len(MP[k])
        next_E = 0
        for j in MP[k]:
            if k != i or j != max_j:
                next_E += RESN[j]
            else:
                div -= 1
        RESN[k] = (next_E / div) + 1.0
    result = min(result, RESN[1])

print(result)


Measured memory_bytes: 66776
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n, count=0;
    double P1=0, P2=0, total = 0, a, gosa;
    queue<double> A;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        A.push(a);
        total+=a;       
    }
    while(total/2>P2){
        P1=P2;
        P2+=A.front();
      	A.pop();
    }
    while(total/2!=P1 && total/2!=P2){
        if(abs(P2-total/2)>abs(P1-total/2)){
          	gosa = round(abs(P1-total/2));
            P1+=gosa;
            total+=gosa;
        }else{
          	gosa = round(abs(P2-total/2));
            P2-=gosa;
            total-=gosa;
        }
        count+=gosa;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  string s;
  cin>>s;
  
  ll k;
  cin>>k;
  
  ll ans=0;
  
  ll n=s.size();
  if(s[0]!=s[n-1]){
      
      for(ll i=0;i<n;i++){
          ll j=i;
          while(j<n&&s[j]==s[i])j++;
          
          ll have=j-i;
          j--;
          i=j;
          ans+=have/2;
      }
      
      ans*=k;
      
  }
  else{
      ll c1=0;
      ll c2=0;
      
      for(ll i=0;i<n&&s[i]==s[0];i++)c1++;
      for(ll i=n-1;i>=0&&s[i]==s[n-1];i--)c2++;
      
      
      for(ll i=c1;i<n-c2;i++){
           ll j=i;
          while(j<n&&s[j]==s[i])j++;
          
          ll have=j-i;
          j--;
          i=j;
          ans+=have/2;
      }
      
      ans*=k;
      ans+=c1/2;
      ans+=c2/2;
      
      ans+=((c1+c2)/2)*(k-1);
      
      if(c1==c2&&c1==n){
          ans=(n*k)/2;
      }
  }
  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    if (S[K - 1] == 'A') S[K - 1] = 'a';
    else if (S[K - 1] == 'B') S[K - 1] = 'b';
    else S[K - 1] = 'c';
    cout << S << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int A[N];
  vector<pair<int,int>>vec;
  for(int i=0;i<N;i++){
    cin>>A[i];
    vec.push_back({A[i],i});
  }
  sort(vec.begin(),vec.end());
  int cnt=0;
  for(int i=0;i<N;i++){
    //cout<<vec.at(i).second<<" "<<i<<endl;
    if((vec.at(i).second-i)%2 !=0){
      cnt++;
    }
  }
  cout<<cnt/2<<endl;
  return 0;
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int a[105];
void print(vector<int> &vec){
	int checksum = 0;
	for(int i=0;i<vec.size();i++){
		assert(vec[i]>=0);
		checksum+=vec[i];
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	assert(checksum==N);
}
int main(){
	cin >> N >> M;
	vector<int> odd,even;
	for(int i=0;i<M;i++){
		cin >> a[i];
		if(a[i]&1){
			odd.pb(a[i]);
		}else even.pb(a[i]);
	}
	vector<int> A,B;
	if(N&1){
		if(odd.size()>1){
			cout << "Impossible" << endl;
			return 0;
		}
		assert((int)odd.size()==1);
		if(even.size()>0){
			A.pb(odd[0]);
			for(int i=0;i<even.size();i++)A.pb(even[i]);
			B.pb(odd[0]+1);
			for(int i=0;i+1<even.size();i++)B.pb(even[i]);
			B.pb(even.back()-1);
		}else{
			A = odd;
			if(odd[0]>1)B.pb(odd[0]-1);
			B.pb(1);
		}
	}else{
		if(odd.size()>2){
			cout << "Impossible" << endl;
			return 0;
		}
		if(odd.size()==0){
			B.pb(1);
			for(int i=0;i<M-1;i++)B.pb(even[i]);
			B.pb(even[M-1]-1);
			A = even;
		}else{
			assert((int)odd.size()==2);
			if(odd[0]>1)B.pb(odd[0]-1);
			for(int i=0;i<even.size();i++){
				B.pb(even[i]);
			}
			B.pb(odd[1]+1);
			A.pb(odd[0]);
			for(int i=0;i<even.size();i++){
				A.pb(even[i]);
			}
			A.pb(odd[1]);
		}
	}
	print(A);
	cout << B.size() << endl;
	print(B);
	return 0;
}

Measured memory_bytes: 256
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<cmath>
typedef long long ll;
using namespace std;
int main()
{	
    ll n;
    cin>>n;
    cout<<pow(n,3)<<endl;

	return 0;
}

Measured memory_bytes: 4148
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()

yes = "Yes"
s = input()
ans = "YAKI"

if len(s) >= 4:
    if s[:4] == ans:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 38384
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 03 May 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        ArrayList<String> arr = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            arr.add(String.valueOf(i));
        }
        String a;
        for (int j = 0; j < k; j++) {
            int d = Integer.parseInt(br.readLine());
            st = new StringTokenizer(br.readLine());
            while (st.hasMoreTokens()) {
                a = st.nextToken();
                arr.remove(a);
            }
        }
        br.close();
        System.out.println(arr.size());
    }
}


Measured memory_bytes: 33476