akhauriyash/Code-Regression huggingface dataset:
n, ma, mb = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(n)]

inf = 10 ** 9
lst = [[inf for _ in range(401)] for _ in range(401)]
lst[0][0] = 0
for a, b, c in abc:
    for i in range(400, -1, -1):
        if i - a < 0:
            break
        for j in range(400, -1, -1):
            if j - b < 0:
                break
            lst[i][j] = min(lst[i][j], lst[i - a][j - b] + c)

ans = inf
a = ma
b = mb
while 1:
    try:
        ans = min(ans, lst[a][b])
        a += ma
        b += mb
    except IndexError:
        break
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 69308
s=input()
ans=1
l=len(s)
now=s[0]
i=1
while i<l:
    if now!=s[i]:
        now=s[i]
        ans+=1
        i+=1
    else:
        if len(now)==2:
            now=s[i]
            ans+=1
            i+=1
        else:
            if i<l-1:
                now=s[i:i+2]
                i+=2
                ans+=1
            else:
                break
    #print(i)
print(ans)


Measured memory_bytes: 73344
n,m=map(int, input().split())
a=[int(input()) for i in range(m)]
c=set(a)
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
for i in range(1,n):
    dp[i+1]=(dp[i]+dp[i-1])%(1000000007)
    if i+1 in c:
        dp[i+1]=0
print(dp[-1])

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

int main()
{
   int n, k;
   cin >> n >> k;
   ll ans = 0;

   // ①　bを固定してaを0からnまでずらすと
   // 0%b, 1%b, 2%b, .........n%b　となる
   // ↑をb = 5 で考える
   // 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, ......となる
   // bに戻すと
   // 0, 1, ..., b-1, 0, 1, ..., b-1, 0, 1, ..., b-1となる
   // ②  10 = 3 * 3 + 1 　　10を３で割ると　3余り1となる
   // a = qb + r　と置ける
   // ①と②よりaをずらしていった時の余りは
   // 0, 1, ..., b-1, 0, 1, ..., b-1, .......... ,0, 1, ....., r　となる
   // 0, 1 ..., b-1の数は　q個、残りはr個となる
   // kより大きい余りは 0, 1, .... b-1の中でいつくあるかを求め、さらに　q個かけると求められる
   // 0, 1, ...., k-1, .... b-1 すなわち　b > kの時は　b - k 個
   // 0, 1, ...., b-1, ...k-1 すなわち　b < kの時は　0個ある
   // 式としてはmax(b-k,0)となる
   // ③残りの部分(余りの部分)は余り rが　k-1より大きい時はその数分だけk以上の個数がある
   // すなわち  max(0, r − k + 1)　となる
   for(int b = 1; b <= n; b++){
      //各ブロックのk以上の数
      int base = max(b -k,0);
      int r = n%b;
      int ex = max(0,r-k +1);
      ans += base * (n/b) + ex;
      //printf("b:%d base:%d r:%d ex:%d \n",b, base, r, ex);
   }
   if(k ==0) ans -=n;
   cout << ans << endl;
   
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin >> N,N){
	map<string,int> country;
	vector<vector<string>> adj(N);
	VI bs(N);
	REP(i,N){
	  string s;
	  cin >> s;
	  country[s] = i;
	  cin >> bs[i];
	  int C; cin >> C;
	  REP(j,C){
		cin >> s;
		adj[i].EB(s);
	  }
	}
	if(N == 1){
	  cout << bs[0] << endl;
	  continue;
	}

	VVI G(N);
	REP(i,N){
	  for(auto& s: adj[i])
		G[i].PB(country[s]);
	}
	VL ban(N);
	REP(i,N){
	  for(int to: G[i])
		ban[i] = ban[i] | (1ll<<to);
	}

	int N2 = N / 2;
	int NR = N - N2;
	VI dp(1<<NR);
	REP(i,1<<NR){
	  int sum = 0;
	  LL x = (LL)(i) << N2;
	  REP(j,NR)
		if(i>>j&1){
		  sum += bs[j+N2];
		  if((ban[j+N2] & x) != 0){
			sum = -1e9;
			break;
		  }
		}
	  if(sum >= 0)
		dp[i] = sum;
	}

	for(int i=0;i<NR;++i){
	  for(int b=0;b<(1<<NR);++b){
		if((b>>i&1) == 1)
		  maxi(dp[b], dp[b^(1<<i)]);
	  }
	}

	int ans = 0;
	for(int b=1;b<1<<N2;b+=2){
	  int sum = 0;
	  LL x = b;
	  LL b2 = 0;
	  REP(j,N2)
		if(b>>j&1){
		  b2 = b2 | ban[j];
		  sum += bs[j];
		  if((ban[j] & x) != 0){
			sum = -1e9;
			break;
		  }
		}
	  if(sum < 0) continue;
	  b2 = (b2 >> N2) ^ ((1<<NR) - 1);
	  ans = max(ans, sum + dp[b2]);
	}
	cout << ans << endl;
  }
 
  return 0;
}

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

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            char[] A = new char[S.Length];
            int num;

            for(int i = 0; i < S.Count(); i++)
            {
                num = S[i] + N;
                if (num > 90)
                    num -= 26;
                A[i] = (char)num;
            }

            Console.WriteLine(A);
        }
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int Sn = 0;
            string imp = Console.ReadLine();
            int L = imp.Length;
            int[] ary = new int[L];
            int N = int.Parse(imp);
            for(int i = 0; i < L; i++)
            {
                ary[i] = int.Parse(imp[i].ToString());
            }
            Sn = ary.Sum();
            if (N % Sn == 0)
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


Measured memory_bytes: 13268
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Mirshodjon Mirjonov
 */

#include<bits/stdc++.h>

using namespace std;

//int mpow(int base, int exp);
//void ipgraph(int n, int m);
//void dfs(int u, int par);

//=======================

//vi g[N];
//int a[N];

class APaymentEditorial {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        n = n % 1000;
        if(n == 0) out << 0;
        else out << 1000 - n;
	}
};
/*
 ******* Advanced Contests *******
int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}
*/

int main() {
	APaymentEditorial solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr;	} cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-6
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define all(x) (x).begin(), (x).end()


int problemB()
{
	int N, D, M, T;
	bool flag;
	map<int, int> mp;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D;
		mp[D]++;
	}

	flag = true;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T;
		if (mp[T] <= 0) flag = false;
		mp[T]--;
	}

	cout << (flag ? "YES" : "NO") << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemB();
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
	ll q, a, b;;
	cin >> q;
	for(ll i = 0; i < q; i++){
		cin >> a >> b;
		if(a > b){
			ll tmp = b;
			b = a;
			a = tmp;
		}//swap
		ll r = 2*(a-1);
		if(a < b-1){
			r++;
			ll bound = pow(a*b, 0.5);
			ll rbuf = ll(bound)-a;
			if((a+rbuf)*(a+rbuf) == a*b){rbuf--;}
			r += 2*rbuf;
			if(a*b <= (a+rbuf+1)*(a+rbuf)){r--;}
			//if(b-1-a-2*rbuf < 0){r--;}
		}
		cout << r <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 9; i++) {
            String name = scanner.next();
            int mae = scanner.nextInt();
            int ato = scanner.nextInt();
            System.out.println(name + " " + (mae + ato) + " " + (mae * 200 + ato * 300));
        }
    }
}



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

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            StringTokenizer st=new StringTokenizer(br.readLine());
            int h=Integer.parseInt(st.nextToken());
            int w=Integer.parseInt(st.nextToken());
            boolean h_bool=false;
            boolean w_bool=!h_bool;
            if(w==0&&h==0) break;
            for(int i=0;i<h;i++){
                h_bool=!h_bool;
                w_bool=!h_bool;
                for(int j=0;j<w;j++){
                    w_bool=!w_bool;
                    if(w_bool) System.out.print("#");
                    else System.out.print(".");
                }System.out.println();
            }System.out.println();
        }
    }
}

Measured memory_bytes: 31548
N = int(input())
a = list(map(int, input().split()))

if 1 not in a:
    print(-1)
else:
    now = a.index(1)
    if now == N-1:
        print(N-1)
    else:
        ans = now
        search = 2
        now += 1
        while now <= N-1:
            if a[now] == search:
                search += 1
            else:
                ans += 1
            now += 1
        print(ans)

Measured memory_bytes: 26268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[100010],cnt=0,id;
int gcd(int a,int b){if (!b) return a;return gcd(b,a%b);}
bool dfs()
{
    id=-1;cnt=0;
    for (int i=1;i<=n;i++) if (!(a[i]&1)) cnt++;else if (a[i]!=1) id=i;
    if (cnt&1) return 1;
    if (cnt!=n-1||(cnt==n-1&&id==-1)) return 0;
    a[id]--;int g=a[id];
    for (int i=1;i<=n;i++) g=gcd(g,a[i]);
    for (int i=1;i<=n;i++) a[i]/=g;
    return !dfs();
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    printf("%s",dfs()?"First":"Second");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	int a[3];
  int x=0,y=0;
  cin>>a[0]>>a[1]>>a[2];
  for(int i=0;i<3;i++){
    if(a[i]==5)
      x++;
    else if(a[i]==7)
      y++;
  }
  if(x==2 && y==1){
    cout<<"YES\n";
  }
else{
  cout<<"NO\n";
}
	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

constexpr int MOD = 1e9+7;

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n, m);
    Cinss(char, n, n, a);
    Cinss(char, m, m, b);
    
    For(i, n-m+1) For(j, n-m+1){
        if([a, b, m, i, j](){
            For(x, m) For(y, m){
                if(a[i+x][j+y] != b[x][y]) return false;
            }
            return true;
        }()){
            Cout("Yes");
            return 0;
        }
    }
    Cout("No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e3+10;
int dp[maxn][maxn],a[maxn][maxn];

int main(){
    int n,m,ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
    }
    for(int i=1;i<=n;i++){
        for(int j=m;j>=1;j--){
            if(a[i][j]) dp[i][j]=0;
            else dp[i][j]=min(min(dp[i-1][j],dp[i][j+1]),dp[i-1][j+1])+1;
            ans=max(ans,dp[i][j]);
//            printf("dp[%d][%d]=%d\n",i,j,dp[i][j]);
        }
    }
    printf("%d\n",ans*ans);
    return 0;
}



Measured memory_bytes: 24724
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Dec  5 21:48:31 2018
//
package main

import "fmt"

var x1, x2, y1, y2 int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	fmt.Scan(&x1, &y1, &x2, &y2)
	dx := x2 - x1
	dy := y2 - y1

	x3 := x2 - dy
	y3 := y2 + dx

	fmt.Println(x3, y3, x3-dx, y3-dy)
}


Measured memory_bytes: 512
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

l = []
th = max(words.values())

for i,j in words.items():
    if th == j:
        l.append(i)

l.sort()

print(*l, sep="\n", end="")

Measured memory_bytes: 98064
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let N = read_line().trim().parse::<i32>().unwrap();
	let mut c = 0;
	for i in 0..N {
		let s = read_line().split_whitespace().map(|e|e.parse().unwrap())
		.collect::<Vec<i32>>();
		c = c + ((s[1] - s[0]) + 1);
	}
	println!("{}",c);
}


Measured memory_bytes: 4352
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

int a[200000];

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

	int n, k; cin >> n >> k;
	forn(i,n) cin >> a[i];
	sort(a, a + n);
	
	vector<int> amounts;
	int left = 0;
	forn(right, n + 1) {
		if (right == n || a[right] != a[left]) {
			amounts.push_back(right - left);
			left = right;
		}
	}
	sort(all(amounts));
	
	int res = 0;
	forn(i, amounts.size() - k) {
		res += amounts[i];
	}
	
	cout << res << endl;
}


Measured memory_bytes: 2168
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, a := nextInt2()
	x := nextInts(n)

	// dp[i][j][k]: 1~i番目の範囲で選択する，j枚のカードの合計がkとなる場合の数
	dp := make([][][50*50 + 1]int, n+1)
	for i := range dp {
		dp[i] = make([][50*50 + 1]int, n+1)
	}
	dp[0][0][0] = 1
	maxsum := n * a
	for i := 1; i <= n; i++ {
		for j := 0; j <= n; j++ {
			for k := 0; k <= maxsum; k++ {
				if x[i-1] > k {
					dp[i][j][k] = dp[i-1][j][k]
				} else if j > 0 {
					dp[i][j][k] = dp[i-1][j-1][k-x[i-1]] + dp[i-1][j][k]
				}
			}
		}
	}

	ans := 0
	for j := 1; j <= n; j++ {
		ans += dp[n][j][j*a]
	}

	puts(ans)
}


Measured memory_bytes: 52224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while(true){
			int x = scan.nextInt();
			int y = scan.nextInt();

			if(x == 0 && y == 0) {
				break;
			}

			if(x < y) {
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}
		}
	}

}

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

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

    const int MAXN = 200000;

    static int a[MAXN];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;
    }

    int cur = 0,
        ans = 0;
    static bool visited[MAXN] = {};
    while (!visited[cur]) {
        visited[cur] = true;
        if (cur == 1) {
            cout << ans << endl;
            return 0;
        }
        cur = a[cur];
        ans++;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define INF 9999999999999
#define D 2//空间维数
#define M 200005//坐标个数
struct Point
{
    int x[D];
}pt[M];
int dis[1<<D][M],minx[1<<D],maxx[1<<D];

//去掉绝对值后有2^D种可能
void Get(int N)//取得所有点在指定状态（S）下的“本点有效距离”
{
    int tot=(1<<D);
    for(int s=0;s<tot;s++)//遍历所有维数正负状态
    {
        int coe[D];
        for(int i=0;i<D;i++)//设定当前状态的具体正负参数
        if(s&(1<<i)) coe[i]=-1.0;
        else coe[i]=1.0;

        for(int i=0;i<N;i++)//遍历所有点，确定每个点在当前状态下的“本点有效距离”
        {
            dis[s][i]=0.0;
            for(int j=0;j<D;j++)
            dis[s][i]=dis[s][i]+coe[j]*pt[i].x[j];
        }
    }
}
//取每种可能中的最大差距
void Solve(int N)
{
    int tot=(1<<D);
    int tmp,ans;
    for(int s=0;s<tot;s++)
    {
        minx[s]=INF;
        maxx[s]=-INF;
        for(int i=0;i<N;i++)
        {
            if (minx[s]>dis[s][i]) minx[s]=dis[s][i];
            if (maxx[s]<dis[s][i]) maxx[s]=dis[s][i];
        }
    }
    ans=0;
    for(int s=0;s<tot;s++)
    {
        tmp=maxx[s]-minx[s];
        if(tmp>ans) ans=tmp;
    }

    cout<<ans<<endl;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        cin>>pt[i].x[0]>>pt[i].x[1];
        Get(n);
        Solve(n);
    }
    return 0;
}

Measured memory_bytes: 8368
// ABC111
// A - AtCoder Beginner Contest 999
#include<bits/stdc++.h>

using namespace std;

int main(){
    string n;
    cin >> n;
    for(char c :n){
        if(c=='1') cout << '9';
        else if (c=='9') cout << '1';
        else cout << c;
    }
    cout << endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    int X;
    cin >> X;
    while(true){
        bool isOK = true;
        for (int i = 2 ;i<X; i++){
            if( X%i == 0){
                isOK = false;
                break;
            }
        }
        if(isOK) break;
        X++;
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

from collections import deque

n = ii()
a = li()

a.sort(reverse = True)

l = deque()
l.append(a[1])
l.append(a[1])

ans = a[0]

if n != 2:
    for i in range(2,n):
        ans += l.popleft()
        l.append(a[i])
        l.append(a[i])

print(ans)



Measured memory_bytes: 106412
N, M, V, P = map(int, input().split())
As = sorted(list(map(int, input().split())))[::-1]

capacity = M * (N-V)
def isOK(i):
    Ai = As[i]
    s = 0
    for j in range(P-1, i):
        d = As[j] - Ai
        if d > M:
            return False
        s += d
        if s > capacity:
            return False
    return True

ok = -1
ng = N
while ng - ok > 1:
    mid = ok + (ng - ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)

Measured memory_bytes: 14484
N=int(input())
p=[[]for _ in range(N+1)]
for _ in range(N-1):
 u,v,w=map(int,input().split())
 p[u].append((v,w))
 p[v].append((u,w))
s=[(1,0)]
l=[-1]*N
while s:
 a,w=s.pop()
 l[a-1]=w%2
 for b,c in p[a]:
  if l[b-1]==-1:
   s.append((b,w+c))
for i in l:
 print(i)

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

int main() {
	char s[1005];
	int W, N;
	scanf("%s%d", s, &W);
	N = strlen(s);
	for (int i = 0; i < N; i += W)
		printf("%c", s[i]);
	puts("");
	return 0;
}

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

struct Card{
    char suit;
    char value;
};

void trace(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;

}

int bubbleSort(struct Card A[], int N){
    int flag = 1;
    int count = 0;
    int i = 0;
    while(flag){
        flag = 0;
        for(int j = N -1; j > i; j--){
            if(A[j].value < A[j-1].value){
                struct Card tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
        i++;
    }
    return count;

}

int selectionSort(struct Card A[], int N){
    int count = 0;

    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j].value < A[minj].value){
                minj = j;
            }
        }
        if(i != minj){
            struct Card tmp = A[i];
            A[i]= A[minj];
            A[minj] = tmp;
            count++;
        }
    }
    return count;

}

bool isStable(struct Card A[], struct Card B[], int N){
    for(int i = 0; i < N; i++){
        if(A[i].suit != B[i].suit)return false;
    }
    return true;
}

int main(){
    struct Card C1[100], C2[100];
    int N;

    cin >> N;
    for(int i = 0; i < N; i++)cin >> C1[i].suit >> C1[i].value;

    for(int i = 0; i < N; i++)C2[i] = C1[i];


    bubbleSort(C1, N);
    trace(C1, N);
    cout << "Stable" << endl;
    selectionSort(C2, N);
    trace(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 100100;

vpi V[MAXN];
int p[MAXN];
int N,E,a,b;
vpi t;
int l[MAXN];
int deg[MAXN];
int vis[MAXN];
int done[MAXN];
int avis[MAXN];
stack<int> S;

int dfs(int x, int pa){
  // cerr<<x<<' '<<pa<<'\n';
  // for (int i=1;i<=E;++i)cout<<done[i]<<' ';cout<<'\n';
  vis[x] = 1;
  for (auto v:V[x])if (!done[v.s]){
    // cout<<v.f<<' '<<x<<' '<<v.s<<'\n';
    if (vis[v.f] && v.f != pa){
      done[v.s] = 1;
      --deg[x];--deg[v.f];
      S.push(x);
      return v.f;
    }
    if (vis[v.f])continue;
    int t = dfs(v.f,x);
    if (t!=-1){
      done[v.s] = 1;
      --deg[x];--deg[v.f];
      S.push(x);
      if (x == t)return -1;
      else return t;
    }
    return -1;
  }
  // for (auto l:V[x])cout<<l.f<<' '<<l.s<<'\n';
  assert(0);
  return 0;
}

void die(){
  cout<<"No";
  exit(0);
}

int main(){
  cin>>N>>E;
  for (int i=0;i<E;++i){
    cin>>a>>b;
    ++deg[a];
    ++deg[b];
    V[a].pb(b,i);
    V[b].pb(a,i);
  }
  for (int i=1;i<=N;++i){
    assert(deg[i] > 0);
    if (deg[i]%2==1){
      die();
    }
  }
  int c = 1;
  int a = 0;
  while (c<=N){
    // cout<<c<<'\n';
    if (deg[c] == 0){
      ++c;
      continue;
    }else{
      memset(vis,0,sizeof(vis));
      // for (int i=1;i<=N;++i)cout<<deg[i]<<' ';cout<<'\n';
      ++a;
      dfs(c,-1);
      int overlap = 0;
      while (SZ(S)){
        if (avis[S.top()])++overlap;
        avis[S.top()]=1;
        S.pop();
      }
      // cout<<overlap<<'\n';
      if (overlap >= 3)a = 3;
      if (a >= 3){
        cout<<"Yes\n";
        return 0;
      }
    }
  }
  cout<<"No";
}


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

#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n;
string s;

void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int e=(c*d)/__gcd(c,d);
	int ans=(b/c)-(a-1)/c+(b/d)-(a-1)/d-((b/e)-(a-1)/e);
	cout<<(b+1-a)-ans;

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m;
    int a[10000];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        n-=a[i];
    }

    if(n<0){
        cout<<-1<<endl;
    }else{
        cout<<n<<endl;
    }

    return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    char c = 'A';
    rep(i, 0, n){
        if(c != s[i]) {
            cnt++;
        }
        c = s[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 1e5+10;

int dp[MAX_N][3] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VVI abc(N,VI(3));
    REP(i,N){
        REP(j,3) cin >> abc[i][j];
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j == k) continue;
                chmax(dp[i+1][j], dp[i][k] + abc[i][j]);
            }
        }
    }
    int ans = 0;
    REP(i,3){
        chmax(ans,dp[N][i]);
    }
    cout << ans << endl;

}


Measured memory_bytes: 6912
s = input()


if s=='SUN':
    ans = 7
elif s=='MON':
    ans = 6
elif s=='TUE':
    ans = 5
elif s=='WED':
    ans = 4
elif s=='THU':
    ans = 3
elif s=='FRI':
    ans = 2
elif s=='SAT':
    ans = 1

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string a, b, c; cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int x, y, z; cin >> x >> y >> z;
    cout << (x * y) / 2 << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A=find_divisor(N);
  vector<ll> B=find_divisor(N-1);
  ll S=A.size();
  ll t=N;
  ll ans=0;
  rep(i,S){
    t=N;
    if(i>=1){
      while(true){
        if(t%A.at(i)==0)t/=A.at(i);
        else {
          t=t%A.at(i);
          break;
        }
      }
      if(t==1){
        ans++;
      }
    }
  }
  cout<<ans+B.size()-1<<endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
    public static void main(String[] args){
        final long mod = 1000000007;
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long a = 1;
        long b = 1;
        long c = 1;
        long d = 1;
        for(int i = 0; i < n; i++){
            //0~9のいずれかをN個並べてできる数列の数
            a *= 10;
            a %= mod;
            //1~8のいずれかをN個並べてできる数列の数
            b *= 8;
            b %= mod;
            //0~8のいずれかをN個並べてできる数列の数
            c *= 9;
            c %= mod;
            //1~9のいずれかをN個並べてできる数列の数
            d *= 9;
            d %= mod;
        }
        //条件を満たす数列の数
        long ans = (a - (c + d - b)) % mod;
        if(ans < 0){
            ans += mod;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 35816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n;
	cin>>n;
	
	int res;
	for(int i=1;;i++){
		if(i*(i+1)/2>=n){
			res = i*2;
			break;
		}
	}
	
	
	string s = string(res/2,')')+string(res/2,'(');
	
	swap(s[res/2],s[res/2-((res/2*(res/2+1)/2)-n)]);
	
	
	cout<<s<<endl;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    ll ans = 0;
    rep(i, n) {
        if (!i) continue;
        if (a[i] - a[i - 1] <= t)
            ans += a[i] - a[i - 1];
        else
            ans += t;
    }
    ans += t;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 4824
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(isr);
        
        /* ????????????(????????????????????????????????£??????????????°n)??????????????? */
        String buf = reader.readLine();
        int n = Integer.parseInt(buf);
        
        while (true) {
            int[] point;
            point = new int[n];
            
            /* n???(??????????????????????????°s)??????????????? */
            for (int i = 0; i < n; i++) {
                buf = reader.readLine();
                point[i] = Integer.parseInt(buf);
            }
            
            int max = 0, min = 1000, sum = 0;
            for (int i = 0; i < n; i++) {
                if (point[i] < min) {
                    min = point[i];
                }
                if (point[i] > max) {
                    max = point[i];
                }
                sum += point[i];
            }
            sum -= min;
            sum -= max;
            System.out.println(sum / (n - 2));
            
            buf = reader.readLine();
            n = Integer.parseInt(buf);
            if (n < 2) {
                break;
            }
        }
    }
}

Measured memory_bytes: 24256
#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <queue>

#define rep(i, m, n) for (int(i)(m); (i) < (n); ++(i))
#define repv(i, v) for (int(i)(0); (i) < (v.size()); ++(i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(v) (v).begin(), (v).end()

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

class P {
  public:
	int i;
	int l;
	P(int a, int b)
		: i(a), l(b){};
};

bool operator>(const P &pl, const P &pr) {
	return pl.l > pr.l;
}

int main() {
	int N, M;
	cin >> N >> M;
	vvi T;
	rep(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		vi v = {a, b, c};
		T.push_back(v);
	}
	vvi minT(N + 1, vi(N + 1, 1000));
	rep(i, 1, N + 1) {
		priority_queue<P, vector<P>, greater<P> > q;
		q.push(P(i, 0));
		while (!q.empty()) {
			P p = q.top();
			q.pop();
			repv(j, T) {
				if (p.i == T[j][0] || p.i == T[j][1]) {
					int ni(T[j][p.i == T[j][0] ? 1 : 0]);
					int nl(p.l + T[j][2]);
					if (minT[i][ni] > nl) {
						minT[i][ni] = nl;
						q.push(P(ni, nl));
					}
				}
			}
		}
	}
	int sum(0);
	repv(i, T) {
		if (minT[T[i][0]][T[i][1]] < T[i][2]) {
			++sum;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
S = int(input())

x3, y3 = 0, 0
y1 = 1
y2 = 10**9
x1, m = divmod(S, y2)
x1 += 1
x2 = x1*y2 - S
if S==10**18:
    x1,y1,x2,y2 = y2,0,y2,y2
print(x1,y1,x2,y2,x3,y3)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int d,i;
  cin >> d;

  cout << "Christmas";
  while(d < 25){
    cout << " Eve";
    d++;
  }
  cout << endl;
}

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

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

void inputread()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll gd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gd(b % a, a); 
} 
  
ll gcd(ll i, ll j, ll k)
{
    return gd(gd(i,j),k);
}

int32_t main()
{
    fio();
    ll i,j,k,n,s=0;
    cin >> n;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                s+=gcd(i,j,k);
            }            
        }        
    }

    cout << s ;
    return 0;
}

Measured memory_bytes: 3648
N, T = [int(i) for i in input().split()]

t = [int(i) for i in input().split()]

ans = N*T

for i in range(N-1):
    time_gap = t[i+1] - t[i] 
    if time_gap > T:
        loss_i =0
    else:
        loss_i = T - time_gap
    ans -= loss_i
    
print(int(ans))

Measured memory_bytes: 25196
n=int(input())
a=input()
b=input()
mod=10**9+7
ans=0
i=1
mae=-1
if a[0]==b[0]:
    ans=3
    mae=1
else:
    ans=6
    i+=1
    mae=0

while i<n:
    if a[i]==b[i]:
        if mae:
            ans*=2
        else:
            pass

        i+=1
        mae=1
    else:
        if mae:
            ans*=2
        else:
            ans*=3
        i+=2
        mae=0
    ans%=mod
print(ans%mod)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n) scanf("%lld",&a[i]);
    ll up=0,down=0;
    rep(i,1,n){
        if(up==0&&down==0){
            if(a[i]>a[i-1]){
                up=1;
            }
            if(a[i]<a[i-1]){
                down=1;
            }
        }else if(up){
            if(a[i]<a[i-1]){
                ans++;
                up=0;
            }
        }else{
            if(a[i]>a[i-1]){
                ans++;
                down=0;
            }
        }
    }
    ans++;
    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
import java.util.*;
import static java.lang.System.*;

public class Main{
public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
  int A=0;
	koko: for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
    if((i*j)==N){
    out.println("Yes");
    break koko;
    }
    }
      A=i;
    }
if(A==9)
  out.println("No");



}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;


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

    long long AB = A + B;
    long long  sum = N / AB * A;
    long long  res = N % AB;
    if(res > A){
        sum += A;
    }else{
        sum += res;
    }

    cout << sum << endl;

    return 0;
}


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

int main()
{
    int a,n,k,arr[111]={0},d,c=0;
    cin>>n>>k;

    while(k--){
        cin>>d;
        while(d--){
            cin>>a;
            arr[a]++;
        }
    }
    for(int i=1;i<=n;i++)if(!arr[i])c++;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>


int main(){
    int n,x,t,ans;
    std::cin >> n >> x >> t;
    if(n%x==0){
        ans =(n/x)*t;
    }
    else{
        ans = (n/x +1)*t;
    }

    std::cout << ans << std::endl;
    return 0;


}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;

const int N = 4054;

int n, A, B;
int top = 0, stack[N];
char ans[N];

inline bool query(int x, int y) {static char _[4]; return cout << '?' << ' ' << x << ' ' << y << endl, cin >> _, *_ == 89;}

int main() {
	int i, x;
	std::ios::sync_with_stdio(false), cin.tie(NULL);
	cin >> A >> B, n = A + B;
	if (A <= B) return cout << "Impossible\n", 0;
	for (i = 0; i < n; ++i)
		!top || query(stack[top - 1], i) ? stack[top++] = i : --top;
	x = stack[top - 1];
	for (i = 0; i < n; ++i) ans[i] = 48 + (i == x || query(x, i));
	return cout << '!' << ' ' << ans << '\n', 0;
}

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

int main()
{
    long long int n,w;
    cin>>n>>w;
    long long int z[n],v[n];
    for (long long int i = 0; i < n; ++i) {
        cin>>z[i]>>v[i];
    }
    long long int dp[n+1][w+1];
    for (long long int i = 0; i < n+1; ++i) {
        dp[i][0]=0;
    }
    for (long long int i = 0; i < w+1; ++i) {
        dp[0][i]=0;
    }
    for (long long int i = 1; i < n+1; ++i) {
        for (long long int j = 1; j < w+1; ++j) {
            if(j<z[i-1])
            {
                dp[i][j]=dp[i-1][j];
            }
            else if(j==z[i-1])
            {
                dp[i][j]=max(dp[i-1][j],v[i-1]);
            }
            else
            {
//                if(dp[i-1][j-z[i-1]]==0)
//                {
//                    dp[i][j]=0;
//                }
//                else
//                {
                    dp[i][j]=max(dp[i-1][j-z[i-1]]+v[i-1],dp[i-1][j]);
//                }
            }
        }

    }
    long long int maxa = 0;
    for (long long int i = 0; i < n+1; ++i) {
        for (long long int j = 0; j < w+1; ++j) {
            if(dp[i][j]>maxa)
                maxa=dp[i][j];
        }
    }
    cout<<maxa;
}

Measured memory_bytes: 79104
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double h,w,x,y;
  cin>>h>>w>>x>>y;
  auto ans=h*w/2.0;
  cout<<ans;
  if(2*x==h&&2*y==w){cout<<' '<<1;}
  else{cout<<' '<<0;}
}

Measured memory_bytes: 256