akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int maxN = 3100;
int a[maxN][maxN];
long long dp[2][maxN][4];

void solve() {
	int n, m, k;
	cin >> n >> m >> k;

	for (int i = 0; i < k; ++i) {
		int x, y, v;
		cin >> x >> y >> v;
		--x, --y;
		a[x][y] = v;
	}

	int u = 0, v = 1;

	for (int j = 0; j < m; ++j) {
		for (int k = 0; k <= 3; ++k) {
			dp[v][j][k] = 0;
			if (j - 1 >= 0) {
				dp[v][j][k] = max(dp[v][j - 1][k], dp[v][j][k]);
			}
			long long add = 0;
			if (j - 1 >= 0 && k > 0) {
				add = dp[v][j - 1][k - 1];
			}
			if (k > 0) {
				dp[v][j][k] = max(dp[v][j][k], add + a[0][j]);
			}
		}
	}

	swap(u, v);

	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			for (int k = 0; k <= 3; ++k) {
				long long myadd = (k == 0) ? 0 : a[i][j];
				dp[v][j][k] = max(dp[v][j][k], dp[u][j][0] + myadd);
				dp[v][j][k] = max(dp[v][j][k], dp[u][j][1] + myadd);
				dp[v][j][k] = max(dp[v][j][k], dp[u][j][2] + myadd);
				dp[v][j][k] = max(dp[v][j][k], dp[u][j][3] + myadd);

				if (j - 1 >= 0) {
					dp[v][j][k] = max(dp[v][j - 1][k], dp[v][j][k]);
				}
				long long add = 0;
				if (j - 1 >= 0 && k > 0) {
					add = dp[v][j - 1][k - 1];
				}
				if (k > 0) {
					dp[v][j][k] = max(dp[v][j][k], add + a[i][j]);
				}
			}
		}
		swap(u, v);
	}
	cout << max({dp[u][m - 1][0], dp[u][m - 1][1], dp[u][m - 1][2], dp[u][m - 1][3]}) << endl;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);

	int t;
	//cin >> t;
	t = 1;

	for (int tt = 0; tt < t; ++tt) {
		solve();
	}




	return 0;
}

Measured memory_bytes: 40036
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vi ab(n-1);
    for (int i=0;i<n-1;i++) {cin >> ab[i];}
    int sum = ab[0];
    for (int i = 0; i < n-2; i++)
    {
        sum += min(ab[i], ab[i+1]);
    }
    sum += ab[n-2];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
    vector< vector<int> >a(3,vector<int>(3));
    rep(i,3)rep(j,3){
        cin>>a[i][j];
    }
int n;
cin>>n;
vector<int>b(n);
rep(i,n)cin>>b[i];
rep(i,n)rep(j,3)rep(k,3){
    if(b[i]==a[j][k])a[j][k]=-1;
}
rep(i,3){
    bool x=true;
    rep(j,3){
   if(a[i][j]!=-1)x=false;}
   if(x){cout<<"Yes";return 0;}
}
rep(i,3){
    bool x=true;
    rep(j,3){
   if(a[j][i]!=-1)x=false;}
   if(x){cout<<"Yes";return 0;}
}
if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1){cout<<"Yes";return 0;}
if(a[1][1]==-1&&a[0][2]==-1&&a[2][0]==-1){cout<<"Yes";return 0;}
cout<<"No";
return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i=0; i<M; i++){
    cin >> A.at(i);
  }
  int sum = 0;
  for (int j=0; j<M; j++){
    sum += A.at(j);
  }
  if (sum <= N){
    cout << N - sum << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3668
#include <stdio.h>
int main(){
  double w,h,x,y;
  scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  
  if(x==w/2 && y==h/2){
    printf("%lf 1",(w*h)/2);
  }else{
    printf("%lf 0",(w*h)/2);
  }
  
  return 0;
}


Measured memory_bytes: 128
function Main(arg) {
    var arg = arg.trim().split('\n');
    let x = Number(arg[0].split(' ')[0]);
    let n = arg[0].split(' ')[1];
    
    if(n == 0){
      console.log(x);
      return;
    }
    
    let p = arg[1].split(' ');
    for(let i = 0; i < 100; i++){
      if(!p.includes(`${x-1*i}`)){
        console.log(x-1*i);
        return;
      } else if(!p.includes(`${x+i}`)){
        console.log(x+i);
        return;
      }
    }
    console.log('error');
    return;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	while (a % b != 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return b;
}

int lcm(int a, int b) {
	int ans = a;
	ans /= gcd(a, b);
	ans *= b;
	return ans;
}

int lcms(vector<int> a) {
	int ans = a[0];
	for (int i = 1; i < a.size(); ++i) {
		ans = lcm(ans, a[i]);
	}
	return ans;
}


signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& e : a) {
		cin >> e;
	}

	cout << lcms(a) << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> l(2 * n);
	
	for(int i = 0;i < (2 * n);i++){
		cin >> l[i]; 
	}
	sort(l.begin(), l.end());
	
	int sum = 0;
	for(int i = 0;i < (2 * n);i += 2){
		sum += min(l[i], l[i + 1]);
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
char s[105];
char st[] = "keyence";
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> (s + 1);
	int n = strlen(s + 1);
	int fir = 0, las = 0;
	for (int i = 1; i <= 7; ++i)
		if (s[i] == st[i - 1])
			fir = i;
		else
			break;
		
	for (int i = 1; i <= 7; ++i)
		if (s[n - i + 1] == st[7 - i])
			las = i;
		else 
			break;
	cout << ((fir + las) >= 7 ? "YES" : "NO") << endl; 
	return 0;
}


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

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

  
  if (A % 2 == 0 || B % 2 == 0 ) {
  	cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

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

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	init();
	int h, n, a;
	cin >> h >> n;
	for(int i = 0; i < n; ++i){
		cin >> a;
		h -= a;
		if(h <= 0){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
using System;

class program
{
    public static void Main()
    {
        var strs = Console.ReadLine().Split(' ');
        var n = int.Parse(strs[0]);
        var m = int.Parse(strs[1]);
        var l = int.Parse(strs[2]);

        long[,] a = new long[n, m];
        long[,] b = new long[m, l];
        // int[,] c = new int[n, l];

        for (int i = 0; i < n; i++)
        {
            strs = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++)
            {
                a[i, j] = long.Parse(strs[j]);
            }
        }

        for (int i = 0; i < m; i++)
        {
            strs = Console.ReadLine().Split(' ');
            for (int j = 0; j < l; j++)
            {
                b[i, j] = long.Parse(strs[j]);
            }
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < l; j++)
            {
                long c = 0;
                for (int k = 0; k < m; k++)
                {
                    c += a[i, k] * b[k, j];
                }

                Console.Write(c);

                if (j < l - 1)
                {
                    Console.Write(' ');
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 17896
package main

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

// 解説みた
// memo化で解く

func ok(last4 string) bool {
	for i := range last4 {
		t := []byte(last4)
		if i >= 1 {
			t[i-1], t[i] = t[i], t[i-1]
		}
		if strings.Contains(string(t), "AGC") {
			return false
		}
	}
	return true
}

var memo = make(map[int]map[string]int)
var N int

func dfs(cur int, last3 string) int {
	if memo[cur] == nil {
		memo[cur] = make(map[string]int)
	}
	if v, ok := memo[cur][last3]; ok {
		return v
	}
	if cur == N {
		return 1
	}
	ret := 0
	for _, c := range "ACGT" {
		if ok(last3 + string(c)) {
			ret = (ret + dfs(cur+1, last3[1:]+string(c))) % 1000000007
		}
	}
	memo[cur][last3] = ret
	return ret
}

func main() {
	sc := NewScanner(os.Stdin)
	N = sc.NextInt()
	fmt.Println(dfs(0, "TTT"))
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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

long long a,b,c,d,n,t1,t2,t3,t4,ans;
int main()
{
    cin>>a>>b>>c>>d>>n;
    t1=1LL*n*4*a;
    t2=1LL*n*2*b;
    t3=1LL*n*c;
    t4=0;
    if(n%2==0) t4=1LL*n/2*d;
    else t4=min(min(a*4,b*2),c)+1LL*((n-1)/2)*d;
    ans=min(min(t1,t2),min(t3,t4));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
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! {
        n: usize,
        q: usize,
        s: chars,
        lrs: [(usize1, usize1); q],
    }
    let mut inc_list = vec![0; s.len()];
    for s_index in 1..s.len() {
        inc_list[s_index] = inc_list[s_index - 1];
        if s[s_index - 1] == 'A' && s[s_index] == 'C' {
            inc_list[s_index]+=1;
        }
    }
    for lr in lrs {
        println!("{}", inc_list[lr.1] - inc_list[lr.0]);
    }
}

Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	bool b = false;
	if (X == 3) b = true;
	if (X == 5) b = true;
	if (X == 7) b = true;

	cout << (b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int kuraiwa(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}
int main(){
   int n;
  cin>>n;
  if(n%kuraiwa(n)==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x ,ans = 20000000;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
  }
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    int anss = 0;
    vector<int> d(m);
    for (int i = 0; i < n; i++)
    {
      if ((tmp>>i)&1)
      {
        for (int j = 0; j < m; j++)
        {
          d[j] += a[i][j];
        }
        anss += c[i];
      }
    }
    bool test = true;
    for (int i = 0; i < m; i++)
    {
      if (d[i] < x)
      {
        test = false;
      }
    }
    if (test)
    {
      ans = min(ans, anss);
    }
  }
  if (ans == 20000000)
  {
    cout << -1 <<endl;
  }else
  {
    cout << ans << endl;
  }
  return 0;
}

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

struct pos{
	int x,y;
};

map<int,map<int,int>> smap;

int index(int x,int y){
	auto i0 = smap.find(x);
	if( i0==smap.end() ) return -1;
	auto i1 = i0->second.find(y);
	if( i1 == i0->second.end()) return -1;
	return i1->second;
}

int main() {
	while(true){
		int m,n;
		cin >> m;
		if(m==0)break;
		
		vector<pos> star(m);
		for(int i=0;i<m;i++){
			cin >> star[i].x >> star[i].y;
		}
		cin >> n;
		vector<pos> sky(n);
		for(int i=0;i<n;i++){
			cin >> sky[i].x >> sky[i].y;
			smap[sky[i].x][sky[i].y]=i;
		}
		
		for(int i=0;i<n;i++){
			int dx = sky[i].x-star[0].x;
			int dy = sky[i].y-star[0].y;
			bool same=true;
			for(int j=0;j<m;j++){
				int id = index(star[j].x+dx,star[j].y+dy);
				if(id<0){
					same=false;
					break;
				}
			}
			if(same){
				cout << dx << " " << dy << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1652
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if( a < b)
		printf("a < b\n");
	else if( a > b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}

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

int main(){
  int m, m1 = 0, m2 = 0, m3 = 0;
  for(int i=0;i<10;i++){
    cin >> m;
    if(m > m1){
      m3 = m2;
      m2 = m1;
      m1 = m;
    }else if(m > m2){
      m3 = m2;
      m2 = m;
    }else if(m > m3){
      m3 = m;
    }
  }
  cout << m1 << endl;
  cout << m2 << endl;
  cout << m3 << endl;
  return 0;
}



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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll lucas[n + 1];
    lucas[0] = 2;
    lucas[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        lucas[i] = lucas[i - 2] + lucas[i - 1];
    }
    cout << lucas[n] << endl;
}


Measured memory_bytes: 3592
import sys
readline=sys.stdin.readline

S = int(readline())

# 最も多い箱の数は、N = S // 3個
# Nから1個の箱i個に対して、残った数値（S - 3 * i）を分ける場合の数を足し合わせる

N = S // 3

DIV = 10 ** 9 + 7

from functools import reduce
def nCr(n,r,DIV):
  if r < n - r:
    r = n - r
  if r == 0:
    return 1
  f = lambda x,y:x*y%DIV
  X = reduce(f,range(n-r+1, n+1))
  Y = reduce(f,range(1, r+1))
  return X * pow(Y, DIV - 2, DIV) % DIV

ans = 0
for i in range(N, 0, -1):
  rest = S - 3 * i
  if rest <= 0:
    ans += 1
    continue
  # rest個をi個の箱に分ける
  # rest + i - 1 C min(rest, i - 1)
  ans += nCr(rest + i - 1, rest, DIV)
  ans %= DIV
  
print(ans)


Measured memory_bytes: 9560
#include<stdio.h>
int main(){
  int i;
  char s[1002];
  fgets(s,1002,stdin);
  for(i=0;s[i];i++){
    if(s[i  ]=='a'&&
       s[i+1]=='p'&&
       s[i+2]=='p'&&
       s[i+3]=='l'&&
       s[i+4]=='e'){
      printf("peach");
      i+=4;
    }
    else if(s[i  ]=='p'&&
       s[i+1]=='e'&&
       s[i+2]=='a'&&
       s[i+3]=='c'&&
       s[i+4]=='h'){
      printf("apple");
      i+=4;
    }
    else printf("%c",s[i]);
  }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,c,s,g,e[21][101][101],un[21][20001];

int solve(){
  int used[101]={};
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P(0,s));
  while(!Q.empty()){
    int ct=Q.top().first,pos=Q.top().second;Q.pop();
    if(used[pos]++)continue;
    if(pos==g)return ct;
    for(int i=1;i<=c;i++)
      for(int j=1;j<=n;j++)
	if(e[i][pos][j]!=1e9)Q.push(P(ct+un[i][e[i][pos][j]],j));
  }
  return -1;
}

int main(){
  while(cin>>n>>m>>c>>s>>g,n){
    for(int i=1;i<=c;i++)
      for(int j=1;j<=n;j++)
	for(int k=1;k<=n;k++)e[i][j][k]=1e9;
    for(int i=0,x,y,d,k;i<m;i++){
      cin>>x>>y>>d>>k;
      e[k][x][y]=e[k][y][x]=min(e[k][x][y],d);
    }
    for(int i=1;i<=c;i++)
      for(int j=1;j<=n;j++)
	for(int k=1;k<=n;k++)
	  for(int l=1;l<=n;l++)
	    e[i][k][l]=min(e[i][k][j]+e[i][j][l],e[i][k][l]);
    int p[101];
    for(int i=1;i<=c;i++)cin>>p[i];
    for(int i=1;i<=c;i++){
      int q[50],r[50];
      q[p[i]-1]=1e9;
      for(int j=0;j<p[i]-1;j++)cin>>q[j];
      for(int j=0;j<p[i];j++)cin>>r[j];
      int nw=0;
      for(int j=0;j<20000;j++){
	if(q[nw]<=j)nw++;
	un[i][j+1]=un[i][j]+r[nw];
      }
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 7204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    string s; cin >> s;
    string ans = "NO";
    if(s == "keyence") ans = "YES";
    else {
        for(int i = 0; i < 7; i++){
            if(s.substr(0,i) + s.substr(s.size()+i-7,7-i) == "keyence"){
                ans = "YES";
                break;
            }
        }
    }
    cout << ans << endl;
}



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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define printlist(l) for(auto x: l) cout << x << ' '; cout << endl;

#define mod 1000000007
#define maxn 100005

ll n, x, y, m, q, t, k, a[maxn];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if (a1 + a2 + a3 >= 22)
		cout << "bust";
	else
		cout << "win";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in4(a, b, c, d);
	int ans = max(a*c, max(a*d, max(b*c, b*d)));
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


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

using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  int ans = x + y + z;
  if(ans >= 22)cout << "bust" << endl;
  else cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MOD 1000000007
#define LL long long

LL ans(LL e){
	int n=2;
	LL res=1;
	LL temp=n;
	while(e>0){
		if(e%2!=0){
			res=(res*temp)%MOD;
		}
		temp=(temp*temp)%MOD;
		e=e/2;
	}
	return res%MOD;
}

int main(){
	LL n;
	cin>>n;
	int arr[MAXN];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int flag;
	bool key;
	if(n%2==1){		//odd
		key=1;
		flag=0;
		int cor=0;
		for(int i=0;i<n;i++){
			if(arr[i]!=cor){
				flag=1;
				break;
			}
			if(key==1){
				cor+=2;
			}
			key=!key;
		}
		if(flag==1){
			cout<<0;
		}else{
			cout<<ans(n/2);
		}
	}else{
		key=0;
		flag=0;
		int cor=1;
		for(int i=0;i<n;i++){
			if(arr[i]!=cor){
				flag=1;
				break;
			}
			if(key==1){
				cor+=2;
			}
			key=!key;
		}
		if(flag==1){
			cout<<0;
		}else{
			cout<<ans(n/2);
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a,b,q;
ll A[100001],B[100001];
int main(){
    cin>>a>>b>>q;
    rep(i,a) cin>>A[i];
    rep(i,b) cin>>B[i];
    sort(A,A+a);
    sort(B,B+b);
    ll xi;
    rep(i,q){
        cin>>xi;
        int ai=lower_bound(A,A+a,xi)-A;
        int bi=lower_bound(B,B+b,xi)-B;
        ll ans=min(abs(xi-A[ai]),abs(xi-B[bi]))+abs(A[ai]-B[bi]);
        ll dist;
        if(ai>0){
            dist=min(abs(xi-A[ai-1]),abs(xi-B[bi]))+abs(A[ai-1]-B[bi]);
            ans=min(ans,dist);
        }
        if(bi>0){
            dist=min(abs(xi-A[ai]),abs(xi-B[bi-1]))+abs(A[ai]-B[bi-1]);
            ans=min(ans,dist);
        }
        if(ai>0&&bi>0){
            dist=min(abs(xi-A[ai-1]),abs(xi-B[bi-1]))+abs(A[ai-1]-B[bi-1]);
            ans=min(ans,dist);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll sum(ll x){
    ll ans=0;
    while(x>0) ans+=x%10,x/=10;
    return ans;
}
vec ans;
int main(){
    ll k;
    cin>>k;
    rep(i,16){
        ll z=0;
        rep(j,i) z+=9*pow(10,j);
        for(ll j=0;true;j++){
            if(j%10==9) continue;
            ll x=j*pow(10,i)+z;
            if(x<=sum(x)*pow(10,i)) ans.push_back(x);
            else break;
        }
    }
    sort(all(ans));
    rep(i,k) cout<<ans[i+1]<<"\n";
}

Measured memory_bytes: 256
n = int(input())
m =list(map(int,input().split()))
ans = 0
currentmin = 1e9

for i in range(len(m)):
    currentmin = min(currentmin,m[i])
    #print(s)
    #print(max(s))
    if m[i] == currentmin:
        ans+=1
        
print(ans)


Measured memory_bytes: 24744
n = int(input())
aa = sorted(list(map(int, input().split())))
list1 = []
ma = aa[-1]
for i in range(n):
  d = abs(aa[i]-(ma+1)//2)
  list1.append([d,i])
md = min(list1, key=lambda x:x[0])

print(ma, aa[md[1]])

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O2")
//#pragma GCC optimization ("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 300005;
int tree[4 * N];

void update(int at,int L,int R,int pos,int val)
{
    if(pos<L or R<pos)return;

    if(pos==L and pos==R)
    {
        tree[at] = tree[at] + val;
        return;
    }

    int mid = (L+R)/2;
    update(2*at,L,mid,pos,val);
    update(2*at+1,mid+1,R,pos,val);
    tree[at]=max(tree[2*at],tree[2*at+1]);
}

int query(int at,int L,int R,int l,int r)
{
    if(r<L or R<l)return 0;
    if(l<=L and R<=r)return tree[at];

    int mid = (L+R)/2;
    int x = query(2*at,L,mid,l,r);
    int y = query(2*at+1,mid+1,R,l,r);

    return max(x,y);
}

vector<int>g[N];
int H , W , m;
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> H >> W >> m;
    FOR(i,1,m){
        int x , y;
        cin >> x >> y;
        g[y].push_back(x);
        update(1,1,H,x,1);
    }
    int ans = 0;
    FOR(i,1,W){
        int got = g[i].size();
        for(int j : g[i]){
            update(1,1,H,j,-1);
        }
        int mx = query(1,1,H,1,H);
        ans = max(ans,mx + got);
        for(int j : g[i]){
            update(1,1,H,j,1);
        }
    }
    cout << ans << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 24096
#include<iostream>
    #include<bits/stdc++.h>
    #define mod 1000000007
    using namespace std;
    int main() {
        long long n;
        cin>>n;
        long long a=LONG_MAX,b=LONG_MIN,c=LONG_MAX,d=LONG_MIN;
        long long x,y,a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,d1=0,d2=0;
        vector<vector<long>> v(n,vector<long> (2));
        //long long x,y;
       while(n--)
       {   cin>>x>>y;
           if(b<x+y)
               {

                b=x+y;
                b1=x;
                b2=y;
               }
          if(a>x+y)
           {


                a=x+y;
                a1=x;
                a2=y;


           }
           if(d<x-y)
                {
                    d=x-y;
                    d1=x;
                    d2=y;
                }
           if(c>x-y)
            {
                c=x-y;
                c1=x;
                c2=y;
            }

       }
       long long ans=max(b-a,d-c);
      
       cout<<ans<<endl;
    }


Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
 
int N;
map<int,int>mp;

struct SegmentTree{
    private:
    int n;
    vector<int> node;


    public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;while(n < sz)n *= 2;
        node.resize(2*n-1,0);

        for(int i=0;i<sz;i++)node[i+n-1] = v[i];
        for(int i=n-2;i>=0;i--)node[i]=max(node[2*i+1],node[2*i+2]);
    }

    //min
    void update(int x,int val){
        //最下段のノードにアクセス
        x+=(n - 1);
        node[x]=val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }
    //[a,b)中の最小の要素
    int find(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0)r = n;
        if(r <= a || b <= l)return 0;
        if(a <= l && r <= b)return node[k];
        int vl = find(a,b,2*k+1,l,(l+r)/2);
        int vr = find(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

signed main() {
    IOS();
    cin>>N;
    vint a(N),b(N);
    rep(i,0,N){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(all(b));
    SegmentTree seg(vint(N,0));
    
    int tmp=0;
    rep(i,0,N){
        if(mp.count(b[i]))continue;
        mp[b[i]]=tmp;
        tmp++;
    }
    
    rep(i,0,N){
        if(mp[a[i]]==0){
            seg.update(0,1);
            continue;
        }
        seg.update(mp[a[i]],seg.find(0,mp[a[i]])+1);
    }
    cout<<seg.find(0,N+1)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 12704
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include<bits/stdc++.h>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;


int main()
{
    int n;
    cin>>n;
    int k=n%10;
    if(k==0||k==1||k==6||k==8)
        cout<<"pon\n";
    else if(k==3)
    {
        cout<<"bon\n";
    }
    else{
        cout<<"hon\n";
    }
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &h[i])
	}
	c := make([]int, N)
	for i := 1; i < N; i++ {
		c[i] = c[i-1] + abs(h[i]-h[i-1])
		if i >= 2 {
			cc := c[i-2] + abs(h[i]-h[i-2])
			if cc < c[i] {
				c[i] = cc
			}
		}
	}
	fmt.Printf("%d\n", c[N-1])
	return
}


Measured memory_bytes: 5504
#include <cstdio>

#define NIL -1
#define MAX 10000

struct Node{int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if (u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if (T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if (T[u].parent == NIL) return NIL;
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if (T[u].left != NIL) deg++;
  if (T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if (T[u].parent == NIL) {
    printf("root\n");
  } else if (T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(int argc, char const *argv[]) {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for (size_t i = 0; i < n; i++) T[i].parent = NIL;

  for (size_t i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (size_t i = 0; i < n; i++) if (T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for (size_t i = 0; i < n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2720
#include<stdio.h>
int main(){
  int N,i,j,k,v;
  int a[100];
  scanf("%d",&N);
  for(i = 0;i < N; i++){
    scanf("%d",&a[i]);
  }
  for(i = 1;i <= N-1; i++){
    for(k = 0;k < N; k++){
      printf("%d",a[k]);
      if(k != N-1)
	printf(" ");
    }
    printf("\n");
    v = a[i];
    j = i-1;
    while(j >= 0&&a[j]>v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    
  }
  
  for(k = 0;k < N; k++){
    printf("%d",a[k]);
    if(k != N-1)
	printf(" ");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2124
A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)

if A+B<=K:
    print(0,0)
elif A<K and A+B>K:
    B=B-(K-A)
    print(0,B)
elif A>=K:
    print(A-K,B)


Measured memory_bytes: 3060
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 10**13
for i in range(n-k+1):
    left = l[i]
    right = l[k+i-1]
    if right <= 0:
        time = abs(left)
    elif 0 <= left:
        time = abs(right)
    else:
        time = min(abs(left),abs(right))*2 + max(abs(left),abs(right))
    ans = min(ans,time)
print(ans)

Measured memory_bytes: 85356
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	//sc.Buffer(nil, 100000000)

	s := nextString()

	if s[len(s)-1] == 's' {
		s += "es"
	} else {
		s += "s"
	}
	fmt.Println(s)
}


Measured memory_bytes: 1776
from itertools import product
n=int(input())
tmp=2
ans=0
Flag=True
while Flag:
    tmp+=1
    iterator=product(range(3),repeat=tmp)
    for idxs in iterator:
        num=''.join(map(str,idxs))
        num753=str(num).replace('0', '3').replace('1', '5').replace('2', '7')
        if '7' in num753 and '5' in num753 and '3' in num753:
            if int(num753)<=n:
                ans+=1
            else:
                Flag=False
                break
print(ans)

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

string padding(string str);

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

  vector<tuple<int, int, int>> PY;
  for (int i = 0; i < M; i++)
  {
    int p, y;
    cin >> p >> y;

    PY.emplace_back(p, y, i); // 要素構築
  }

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

  vector<string> ID(M);
  int cnt = 1;

  ID[get<2>(PY[0])] = padding(to_string(get<0>(PY[0]))) + padding(to_string(cnt));

  for (int i = 1; i < M; i++)
  {
    if (get<0>(PY[i]) != get<0>(PY[i - 1]))
      cnt = 1;
    else
      cnt++;

    ID[get<2>(PY[i])] = padding(to_string(get<0>(PY[i]))) + padding(to_string(cnt));
  }

  for (int i = 0; i < M; i++)
  {
    cout << ID[i] << endl;
  }

  return 0;
}

string padding(string str)
{
  int zeros = 6 - (int)str.size();

  for (int i = 0; i < zeros; i++)
  {
    str = "0" + str;
  }
  return str;
}


Measured memory_bytes: 8180
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

r = "R" * x
u = "U" * y
l = "L" * x
d = "D" * y

print("".join([r, u, l, d, "D", r, "R", "U", u, "L", "U", l, "L", "D", d, "R"]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pi 3.14159265  //35897932384626433
#define MOD 1000000007
#define all(s) s.begin(),s.end()
#define mp make_pair
#define vc vector<int>
#define vp vector<pair<ll,ll> >
#define sec second
#define sz(x) (int)((x).size())
#define timesaver ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const int N =  2e6 + 9;
ll gcd(ll a, ll b){ if(a==0) return b; else return gcd(b%a,a);}
ll power(ll base,ll exp,ll mod=MOD) {ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

int main()
{
 int x, y;
 cin >> x >> y;
 if(x % 3 == 0)
    cout << "Possible";
 else if(y % 3 == 0)
    cout << "Possible";
 else if((x + y) % 3 == 0)
    cout << "Possible";
 else
    cout << "Impossible";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long long A,B;
  int K;

  scanf("%lld%lld%d",&A,&B,&K);

  for(int i = A;i < A+K && i <= B;i++){
    printf("%d\n",i);
  }
  for(int i = B-K+1;i <= B;i++){
    if(i >= A+K)
      printf("%d\n",i);
  }

  return 0;
}

Measured memory_bytes: 128
import random

class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

  def print_all(self):
    print "top = " + self.top
    print "front = " + self.front
    print "right = " + self.right
    print "left = " + self.left
    print "back = " + self.back
    print "bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

  def random_roll(self):
    ram = random.randint(1, 4)
    if ram == 1:
      self.roll_E()
    elif ram == 2:
      self.roll_N()
    elif ram == 3:
      self.roll_S()
    else:
      self.roll_W()

my_dice = Dice(raw_input().split(" "))
q = int(raw_input())

for i in xrange(q):
  input_dice = raw_input().split(" ")
  while True:
    if my_dice.top == input_dice[0] and my_dice.front == input_dice[1]:
      break
    else:
      my_dice.random_roll()
  print my_dice.right

Measured memory_bytes: 10164
#include <iostream>
using namespace std;
 
int main() {
  string S , T;
  cin >> S >> T;
  int nbDay = 0;
  for (int i ; i < 3; i++) {
    if ( S[i] == T[i]) {
      nbDay += 1;
    }
  }
  cout << nbDay<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
  string s;
  cin>>s;
  ll dp[s.size()][13]={};
  if(s[0]=='?'){
    for(int i=0;i<10;i++){
      dp[0][i]=1;
    }
  }
  else{
    dp[0][s[0]-'0']=1;
  }
  for(int i=1;i<s.size();i++){
    if(s[i]!='?'){
      for(int j=0;j<13;j++){
        dp[i][(j*10+(s[i]-'0'))%13]+=dp[i-1][j];
      }
      for(int j=0;j<13;j++){
        dp[i][j]%=mod;
      }
    }
    else{
      for(int k=0;k<10;k++){
        for(int j=0;j<13;j++){
          dp[i][(j*10+(k))%13]+=dp[i-1][j];
        }
        for(int j=0;j<13;j++){
          dp[i][j]%=mod;
        }
      }
    }
  }
  cout<<dp[s.size()-1][5];
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    string S;
    cin >> S;

    vector<ll> ans(S.size(), 0), check(S.size(), 0);
    char hint = 'R';
    int cnt = 1;
    for (int i = (int)S.size() - 1; i >= 0; i--) {
        if (S[i] == 'R') {
            check[i] = cnt;
            cnt++;
        }
        else {
            cnt = 1;
        }
    }

    cnt = -1;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'L') {
            check[i] = cnt;
            cnt--;
        }
        else {
            cnt = -1;
        }
    }
    /*
    rep(i, S.size()) {
        cout << check[i] << " ";
    }
    */

    rep(i, S.size()) {
        if (check[i] > 0) {
            if (check[i] % 2 == 0) {
                ans[i + check[i]]++;
            }
            else {
                ans[i + check[i] - 1]++;
            }
        }
        else {
            if ((-1 * check[i]) % 2 == 0) {
                ans[i + check[i]]++;
            }
            else {
                ans[i + check[i] + 1]++;
            }
        }
    }

    rep(i, S.size() - 1) {
        cout << ans[i] << " ";
    }
    cout << ans[S.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
 
 
//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )
 
//#define MOD 1000000007ll
#define INF 1000000000
#define endl "\n"
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= ed; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
// const int INF=0x3f3f3f3f;
const db PI=acos(-1);
const ll mod=1e9+7;
const ll MOD=998244353;
const ll N=3e5+5,K=105;
const int si=(1<<20);
const ll M=2000+5;
const double INFdb=1e10;
const ll oo=1e18;

int n,m;
vector<pii> v[55];
vi found,path;
vi containMe;

void add_self(ll& a,ll b)
{
	a=(a+b)%mod;
}

void dfs(int a,int goal,int par)
{
	if(a==goal)
	{
		found=path;
		return;
	}
	for(pii x:v[a])
	{
		int ff=x.X,ss=x.Y;
		if(ff!=par)
		{
			path.PB(ss);
			dfs(ff,goal,a);
			path.P();
		}
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // 	freopen("input.txt", "r", stdin);
    // 	freopen("out.txt", "w", stdout);
    // #endif
	cin>>n;
	for(int i=0;i<n-1;++i)
	{
		int x,y;
		cin>>x>>y;
		v[x].PB(mp(y,i));
		v[y].PB(mp(x,i));
	}
	cin>>m;
	containMe.resize(n+1);
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		found={-1};
		dfs(x,y,-1);
		for(int x:found)
		{
			containMe[x]|=(1<<i);
		}
	}
	vll dp(1<<m);
	dp[0]=1;
	for(int i=0;i<n-1;++i)
	{
		vll new_dp(1<<m);
		for(int mask=0;mask<(1<<m);++mask)
		{
			new_dp[mask]+=dp[mask];
			new_dp[mask|containMe[i]]+=dp[mask];
		}
		dp=new_dp;
	}
	cout<<dp[(1<<m)-1];
    cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";                                                                          
    return 0;
}


Measured memory_bytes: 16764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll ps[100009],n,a[10009],dp[409][409];

ll f(ll l, ll r){
    if(l==r)return 0;
    ll tmp=1e17;
    if(dp[l][r]!=-1)return dp[l][r];
    for(int i=l; i<r; i++){
        tmp=min(tmp,f(l,i)+f(i+1,r)+ps[r]-ps[l-1]);
    }
    return dp[l][r]=tmp;
}

int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        ps[i]=ps[i-1]+a[i];
    }
    memset(dp,-1,sizeof dp);
    cout << f(1,n) << endl;
}

Measured memory_bytes: 1536
N = int(input())
A = [int(i) for i in input().split()]
ret = 1
up, down = False, False
for i in range(N - 1):
    if A[i] < A[i + 1]:
        up = True
    elif A[i] > A[i + 1]:
        down = True
    if up == down == True:
        ret += 1
        up, down = False, False
print(ret)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<vector<char>> vec(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >> vec[i][j];
    }
  }
  int ans=0;

  vector<vector<char>> vec2(H,vector<char>(W));
  for (int bit=0; bit<(1<<(H+W)); bit++){
    vec2 = vec;
    for (int i=0; i< H; i++){
        if  (bit & (1<<i))  rep(j,W) vec2[i][j] ='.';
    }
    for (int i=0; i< W; i++){
        if  (bit & (1<<(i+H)))  rep(j,H) vec2[j][i] = '.'; 
    }       
				int count=0;
				rep(i,H){
					rep(j,W){
						if (vec2[i][j] == '#') count++;
					}
				}
				if (count == K){
                  ans++;
//                  cout << bit << " ";
                }
  
  }
//  cout << endl;
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	char S[100];
	cin >> S;

	if (N % 2 == 1) {
		cout << "No";
		return 0;
	}

	bool ans = true;
	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[i + N / 2]) {
			ans = false;
		}
	}

	cout << (ans == true ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256