akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    for (i in 0 until s.size - 1) {
        if (s[i] == s[i + 1]) {
            println("${i + 1} ${i + 2}")
            return
        }
        if (i + 2 <= s.size - 1) {
            if (s[i] == s[i + 2]) {
                println("${i + 1} ${i + 3}")
                return
            }
        }
    }

    println("-1 -1")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 34016
myinput_H = input()
myinput_A = input()
mylist_H = list(map(int, myinput_H.split(" ")))
H = mylist_H[0]
list_A = list(map(int, myinput_A.split(" ")))
sum_A = sum(list_A)
if H > sum_A:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 14552
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout << max(0, a - b); 
}

Measured memory_bytes: 3640
#pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
const int N = 3*1e6+10;
const int MOD = 1e9+7;
#define LL long long
#define mi() (l+r)>>1
double const pi = acos(-1);

void fre() {
    freopen("in.txt","r",stdin);
}

// inline int r() {
//     int x=0,f=1;char ch=getchar();
//     while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();}
//     while(ch>='0'&&ch<='9') { x=x*10+ch-'0';ch=getchar();}return x*f;
// }

LL Gcd(LL a,LL b){ return b? Gcd(b, a % b) : a; }
int main()
{
    LL n,x; cin >> n >> x;
    LL d = Gcd(n,x);
    n/=d;
    cout << d*3*(n-1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
char fie[4][4]={"ABC",
		"DEF",
		"GHI"};
int N;
char s,t,b;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
double dp[16][4][4];
int used[16][4][4];
double solve(int no,int x,int y){
  if(no==N){
    if(fie[y][x]==t) return 1.0f;
    return 0.0f;
  }
  if(used[no][x][y]) return dp[no][x][y];
  double ret=0.0f;
  for(int i=0;i<4;i++){
    int nx = x+dx[i],ny = y+dy[i];
    if( nx < 0 || ny < 0 || nx>=3 || ny>=3 || fie[ny][nx]==b){
      ret += solve(no+1,x,y)/4.0f;
    } else{
      ret += solve(no+1,nx,ny)/4.0f;
    }
  }
  used[no][x][y]=1;
  return dp[no][x][y]=ret;
}
int main(){
  while(1){
    int x,y;
    cin >> N;
    if(!N) break;
    memset(used,0,sizeof(used));
    cin >> s >> t >> b;
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++)
	if(fie[i][j]==s){
	  x=j; y=i;
	}
    printf("%.9lf\n",solve(0,x,y));
  }
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;
  vector<ll> as, bs, cs;

  void init() {
    scanf("%lld", &N);
    ll a;
    rep(i, N) {
      scanf("%lld", &a);
      as.push_back(a);
    }
    rep(i, N) {
      scanf("%lld", &a);
      bs.push_back(a);
    }
    rep(i, N) {
      scanf("%lld", &a);
      cs.push_back(a);
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());
  }

  void solve() {
    ll ans = 0ll;
    for(const ll& b : bs) {
      if(b <= *(as.begin())) continue;
      if(*(cs.end()-1) <= b) continue;
      auto a_itr = lower_bound(as.begin(), as.end(), b);
      a_itr--;
      auto c_itr = upper_bound(cs.begin(), cs.end(), b);
      ans += (distance(as.begin(), a_itr)+1)*(distance(c_itr, cs.end()));
    }
    printf("%lld\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3316
//https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int N;
    cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long k;
	cin >> k;
	if(k==0)
	{
		cout << 2 << endl << "0 0" << endl;
		return 0;
	}
	if(k==1)
	{
		cout << 2 << endl << "0 3" << endl;
		return 0;
	}

	cout << 50 << endl;
	vector<long long> ans(50,0);
	for(long long i=0;i<50;i++)
	{
		long long now=k/50+(i<k%50 ? 1:0);
		long long plus=k-now;
		//cout << now << " " << plus << endl;
		ans[i]=50*now+49-(plus);
		if(ans[i]<0)
			ans[i]=0;
	}

	for(long long i=0;i<50;i++)
		cout << ans[i] << (i==49 ? "\n":" ");


/*
	long long cnt=0;
	while(true)
	{
		bool flag=true;
		for(long long i=0;i<50;i++)
			if(ans[i]>=50)flag=false;
		if(flag)break;
		for(long long i=0;i<50;i++)
			if(ans[i]>=50)
			{
				ans[i]-=50;
				for(long long j=0;j<50;j++)
					if(i!=j)
						ans[j]+=1;
				cnt++;
			}
	}
	cout << cnt << endl;
*/



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		int acnt = 0, bcnt = 0, ccnt = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'a') {
				acnt++;
			} else if (s[i] == 'b') {
				bcnt++;
			} else if (s[i] == 'c') {
				ccnt++;
			}
		}
		int min = Math.min(acnt, bcnt);
		min = Math.min(min, ccnt);
		acnt = acnt - min;
		bcnt = bcnt - min;
		ccnt = ccnt - min;
		if (acnt <= 1 && bcnt <= 1 && ccnt <= 1) {
			sb.append("YES");
		} else {
			sb.append("NO");
		}
		System.out.println(sb);
	}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = (int)2e5 + 50;

int n;
int a[N];

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

    cin >> n;
    rep(i, 0, n) cin >> a[i];
    sort(a, a + n);
    int rem = n - 1;
    ll res = 0;
    for(int i = n - 1; i >= 0; i--) {
        int take = min(rem, 2);
        if(i == n - 1) take = min(rem, 1);
        rem -= take;
        res += 1LL * take * a[i];
    }
    cout << res << '\n';

}

Measured memory_bytes: 4388
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

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

  if((a+b)%2==0)cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#define N 500001
 
typedef struct{
  int parent;
  int left;
  int right;
  int key;
}Node;
 
Node node[N], swap;
int n;
 
void maxHeapify(int i){
  int l = left(i), r = right(i), largest;
  if(l <= n && node[l].key > node[i].key) largest = l;
  else largest = i;
  if(r <= n && node[r].key > node[largest].key) largest = r;
  if(largest != i){
    swap = node[i];
    node[i] = node[largest];
    node[largest] = swap;
    maxHeapify(largest);
  }
}
 
void buildMaxHeap(){
  int i;
  for(i = n/2;i > 0;i--) maxHeapify(i);
}
 
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
 
int main(){
  int i, j;
  scanf("%d", &n);
  for(i = 1;i < n+1;i++){
    scanf("%d", &node[i].key);
    if(i == 1) node[i].parent = -1;
    else node[i].parent = parent(i);
    if(2*i > n) node[i].left = node[i].right = -1;
    else{
      node[i].left = left(i);
      if(2*i+1 > n) node[i].right = -1;
      else node[i].right = right(i);
    }
  }
  buildMaxHeap();
  for(i = 1;i < n+1;i++){
    printf(" %d", node[i].key);
  }
  printf("\n");
  return 0;
}

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

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

    if (N == 100) {
        N++;
    }

    long long ans;
    if (D == 0) ans = N;
    else if (D == 1) ans = N * 100;
    else ans = N * 10000;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INT long long int
#define N 3
#define PA pair<INT, INT>
#define oo 9876543219876543
#define MOD 1000000007
using namespace std;
INT T, n, m, k, x, y, z, a[500050], b[500040], c[500050], ans, Z, Y, dt[300030][2];
set<INT> u, d;
string s, t;

int main()
{
    ios::sync_with_stdio(false);
    T = 1; //cin>>T;
    while( T-- )
    {
        cin>>x;
        cout<<1-x<<endl;

    }
    return 0;
}


Measured memory_bytes: 3656
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	vv := make([]int, n)
	for i := 0; i < n; i++ {
		vv[i] = getNextInt(scanner)
	}
	var ans int
	for i := 0; i <= n && i <= k; i++ {
		for j := 0; i+j <= n && i+j <= k; j++ {
			ss := &stones{}
			heap.Init(ss)
			sum := 0
			for ii := 0; ii < i; ii++ {
				heap.Push(ss, vv[ii])
				sum += vv[ii]
			}
			for jj := 0; jj < j; jj++ {
				heap.Push(ss, vv[n-1-jj])
				sum += vv[n-1-jj]
			}
			for kk := 0; ss.Len() > 0 && kk < k-(i+j); kk++ {
				s := heap.Pop(ss).(int)
				if s > 0 {
					break
				}
				sum -= s
			}
			if ans < sum {
				ans = sum
			}
		}
	}
	fmt.Fprintln(writer, ans)
}

type stones []int

func (h stones) Len() int { return len(h) }
func (h stones) Less(i, j int) bool {
	return h[i] < h[j]
}
func (h stones) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *stones) Push(x interface{}) {
	*h = append(*h, x.(int))
}
func (h *stones) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 2432
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	scan(v);

	ll cost = 0;

	REP(i, 0, n - 1) {
		ll length = v[i + 1] - v[i];
		cost += min(a * length, b);
	}
	cout << cost << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a[5], k;
	for (int i = 0; i < 5; i++){
		cin >> a[i];
	}
	cin >> k;
	cout << (a[4] - a[0] <= k ? "Yay!" : ":(") << endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 1e5 + 5;
int main(){
	int a[maxn],dp[maxn],n,k;
	memset(dp,0x3f3f,sizeof(dp));
	scanf("%d%d",&n,&k);
	for(int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	dp[1] = 0;
	for(int i = 2;i <= n;i++){
		for(int j = 1;j <= min(k,i);j++){
			dp[i] = min(dp[i],dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int N;
vector<VI> G;
VI d;
int q[200005];


void bfs(int s) {
	REP(i, N)d[i] = INF;
	int qh = 0, qt = 0;
	q[qh++] = s;
	d[s] = 0;
	while (qt < qh) {
		int x = q[qt++];
		for (int y : G[x]) {
			if (d[y] == INF) {
				d[y] = d[x] + 1;
				q[qh++] = y;
			}
		}
	}
}


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

	cin >> N;
	d.resize(N);
	G.resize(N);
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bfs(0);
	VI tmp = d;
	bfs(N - 1);
	int a = 0;
	REP(i, N)if (d[i] < tmp[i])a++;
	if (a < N - a)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;

	return 0;
}



Measured memory_bytes: 8448
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
N = int(input())
H = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if ans <= cnt:
            ans = cnt
        cnt = 0

if ans <= cnt:
    ans = cnt
print(ans)


Measured memory_bytes: 15804
# ABC 145 D - Knight
# https://atcoder.jp/contests/abc145/tasks/abc145_d

x, y = gets.chomp.split(/ /).map(&:to_i)

class Factorial
  def self.calc(n)
    new(n).get(n)
  end

  def initialize(max, mod)
    @max = max
    @mod = mod

    @array = []
    set_up
  end

  attr_reader :max, :mod, :array

  def get(n)
    raise ArgumentError if n > max
    @array[n]
  end

  private

  def set_up
    array.push(1) # 0
    array.push(1) # 1

    if max >= 2
      2.upto(max) do |i|
        f = array.last * i
        f = f % mod unless mod.nil?
        array.push(f)
      end
    end
  end
end

class Inverse
  def initialize(max, mod)
    @max = max
    @mod = mod

    @array = []
    set_up
  end

  attr_reader :max, :mod, :array

  def get(n)
    array[n]
  end

  private

  def set_up
    array.push(nil) # 0
    array.push(1)   # 1

    if max >= 2
      2.upto(max) do |i|
        inv = mod - array[mod % i] * (mod / i) % mod
        array.push(inv)
      end
    end
  end
end

class FactorialInverse
  def initialize(max, inverse, mod)
    @max = max
    @inverse = inverse
    @mod = mod

    @array = []
    set_up
  end

  attr_reader :max, :inverse, :mod, :array

  def get(n)
    array[n]
  end

  private

  def set_up
    array.push(1) # 0
    array.push(1) # 1

    if max >= 2
      2.upto(max) do |i|
        finv = array.last * inverse.get(i) % mod
        array.push(finv)
      end
    end
  end
end

class Combination
  def self.calc(n, k, mod)
    if n < k
      0
    elsif n < 0 || k < 0
      0
    else
      factorial = Factorial.new(n, mod)
      inverse = Inverse.new(n, mod)
      factorial_inverse = FactorialInverse.new(n, inverse, mod)
      factorial.get(n) * (factorial_inverse.get(k) * factorial_inverse.get(n - k) % mod) % mod
    end
  end
end

if (x + y) % 3 == 0
  mod = 10 ** 9 + 7
  n = (x + y) / 3
  k = x - n

  puts Combination.calc(n, k, mod)
else
  puts 0
end


Measured memory_bytes: 19580
#include <vector>
#include <iostream>
using namespace std;
struct edge{
    int to;
    int cap;
    long long cost;
    int inv;
};
struct primal{
    long long INF;
    int V;
    vector<int> prevv, preve;
    vector<vector<edge>> G;
    primal(int N){
        V = N;
        prevv.resize(V);
        preve.resize(V);
        G.resize(V);
        INF = 1e18;
    }
    void add(int s, int t, int cap, long long cost){
        edge e1 = {t, cap, cost, (int)G[t].size()};
        G[s].push_back(e1);
        edge e2 = {s, 0, -cost, (int)G[s].size() - 1};
        G[t].push_back(e2);
    }
    long long solve(int s, int t, int f){
        long long res = 0;
        while(f > 0){
            vector<long long> d(V, INF);
            bool update = true;
            d[s] = 0;
            while(update){
                update = false;
                for(int i = 0; i < V; i++){
                    if(d[i] == INF) continue;
                    for(int j = 0; j < (int)G[i].size(); j++){
                        edge e = G[i][j];
                        if(e.cap > 0 && d[e.to] > d[i] + e.cost){
                            d[e.to] = d[i] + e.cost;
                            prevv[e.to] = i;
                            preve[e.to] = j;
                            update = true;
                        }
                    }
                }
            }
            if(d[t] == INF) return INF;
            int dmin = f;
            for(int v = t; v != s; v = prevv[v]){
                dmin = min(dmin, G[prevv[v]][preve[v]].cap);
            }
            f -= dmin;
            res += d[t] * dmin;
            for(int v = t; v != s; v = prevv[v]){
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= dmin;
                G[v][e.inv].cap += dmin;
            }
        }
        return res;
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<long long>> A(N, vector<long long>(N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cin >> A[i][j];
    }
    primal pd(N * 2 + 2);
    const int start = 2 * N, goal = 2 * N + 1;
    pd.add(start, goal, N * K, 0);
    for(int i = 0; i < N; i++){
        pd.add(start, i, K, 0);//行
        pd.add(N + i, goal, K, 0);//列
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            pd.add(i, j + N, 1, -A[i][j]);
        }
    }
    long long ans = 0;
    ans = -pd.solve(start, goal, N * K);
    cout << ans << endl;
    vector<vector<char>> judge(N, vector<char>(N, '.'));
    for(int i = 0; i < N; i++){
        for(edge e: pd.G[i]){
            if(e.to == start || e.cap > 0) continue;
            if(e.cap == 0){
                int j = e.to - N;
                judge[i][j] = 'X';
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cout << judge[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 3844
D = int(input())

last_list = [0 for i in range(27)]
c_list = list(map(int, input().split()))
c_list = [""] + c_list
# print(c_list)
S_list = [[]for i in range(D)]
P_list = [0 for i in range(27)]
for i in range(D):
    S_list[i] = list(map(int, input().split()))
    S_list[i] = [""] + S_list[i]
S_list = [""] + S_list
# print(S_list)

for i in range(1,D+1):
    S = 0
    t = int(input())
    for j in range(1,27):
        if j == t:
            P_list[j] += S_list[i][j]
            last_list[j] = i
            # print(S_list[i][j])
        else:
            P_list[j] -= c_list[j] * (i-last_list[j])
    for i in range(1,27):
        S += P_list[i]
    print(S)





# t_list = []
# for i in range(D):
#     t_list.append(int(input()))


Measured memory_bytes: 69872
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;

unsigned getdigit(unsigned num) {
	return std::to_string(num).length();
}

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

	map< pair<int,int> , string> data;
	vector< vector<int> > v(m);
	vector< vector<int> > vbef(m);
	rep(i, 0, m) {
		int p, y;
		cin >> p >> y;
		v[i] = {p,y};
		vbef[i] = {p,y};
	}
	sort(v.begin(), v.end());


	int citycnt;
	rep(i, 0, m) {
		string s="";
		rep(j, 0, 6 - getdigit(v[i][0]))s += "0";
		s += to_string(v[i][0]);
		if (i == 0 || v[i - 1][0] != v[i][0]) {
			s += "000001";
			citycnt = 2;
		}
		else {
			rep(j, 0, 6 - getdigit(citycnt))s += "0";
			s += to_string(citycnt);
			citycnt++;
		}
		auto d = make_pair(v[i][0], v[i][1]);
		data[d] = s;
	}

	rep(i, 0, m) {
		auto temp = make_pair(vbef[i][0], vbef[i][1]);
		cout << data[temp] << endl;
	}

	return 0;
}

Measured memory_bytes: 24960
#include <stdio.h>
#include <stdlib.h>

int getNumbersOfElements();
int* creatArrayThroughNumbersOfElemets(int numbersOfElements);
void printArrayElements(int* array, int numbersOfElements);
void insertionSortArrayElemets(int* array, int numbersOfElements);


int main(void)
{
	int N = getNumbersOfElements();
	int *array = creatArrayThroughNumbersOfElemets(N);
	printArrayElements(array, N);
	insertionSortArrayElemets(array, N);
	return 0;
}

int getNumbersOfElements()
{
	int input;
	scanf("%d", &input);
	return input;
}

int* creatArrayThroughNumbersOfElemets(int numbersOfElements)
{
	int *p = (int*) malloc(numbersOfElements * sizeof(int));
	int i;
	for (i = 0; i < numbersOfElements; i++)
		scanf("%d", p + i);
	return p;
}

void printArrayElements(int* array, int numbersOfElements)
{
	int i;
	for (i = 0; i < numbersOfElements - 1; i++)
		printf("%d ", *(array + i));
	printf("%d\n", *(array + i));
}

void insertionSortArrayElemets(int* array, int numbersOfElements)
{
	int i, j, key;
	for (j = 1; j < numbersOfElements; j++)
	{
		key = *(array + j);
		for (i = j - 1; i >= 0 && *(array + i) > key; i--)
		{
			// printf("%d > %d\n", *(array + i), *(array + j) );
			*(array + i + 1) = *(array + i);
		}
		*(array + i + 1) = key;
		printArrayElements(array, numbersOfElements);
	}
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string str;
	cin>>n>>str;
	int num = 0;
	int best = 0;
	for(int i =0;i<n;i++)
	{
		if(str[i]=='I')
			num++;
		else if(str[i]=='D')
			num--;
			
			
		best = max(best,num);
	}
	cout<<best<<endl;
	return 0;
}

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

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

    if (s[0] == 'S') cout << "Cloudy" << endl;
    if (s[0] == 'C') cout << "Rainy" << endl;
    if (s[0] == 'R') cout << "Sunny" << endl;

    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

char buf[108];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k; gi(k);
	gstr(buf);
	int n = strlen(buf);
	if(n > k) { rep(i, k) pc(buf[i]); pstr("..."); }
	else pstr(buf);
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

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

    map<long long, long long> mp;
    ++mp[0];
    reverse(S.begin(), S.end());
    long long ten = 1, now = 0;
    for (auto& e : S) {
        now = (now + (e - '0') * ten);
        ten *= 10;
        ten %= 2019;
        now %= 2019;
        ++mp[now];
    }

    long long ans = 0;
    for (auto& m : mp) {
        ans += (m.second * (m.second - 1)) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3752
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

string n;

int main(){
    cin>>n;
    n[3]='8';
    cout<<n<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 10001
int c[N];
int main(){
    for(int i = 0; i <= N; i++) c[i] = 0;
    int n;
    scanf("%d", &n);
    int a[n+1];
    int b[n+1];

    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        c[a[i]]++;
    }
    for(int i = 1; i <= N; i++) c[i] += c[i-1];

    for(int j = n; j >= 1; j--){
        b[c[a[j]]] = a[j];
        c[a[j]] --;
    }

    for(int j = 1; j <= n; j++){
        if(j != n) printf("%d ", b[j]);
        else printf("%d\n", b[j]);
    }
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int n, a, b;
	cin >> n >> a >> b;
	int x = 0, y = 0, z = 0;
	for(int i = 0; i < n; i++){
		int l;
		cin >> l;
		if(l <= a) x++;
		else if(l > a && l <= b) y++;
		else z++;
	}
	cout << min(min(x, y), z);
}

Measured memory_bytes: 256
program cc
  implicit none
  integer :: n,k
  character :: s*128,ans*128,instead*1
  read *, n, k
  read *, s
  if (s(k:k) == "A") then
    instead = "a"
  else if (s(k:k) == "B") then
    instead = "b"
  else if (s(k:k) == "C") then
    instead = "c"
  end if

  if (k == 1) then
    ans = instead//s(2:n)
  else if (k == n) then
    ans = s(1:n-1)//instead
  else
    ans = s(1:k-1)//instead//s(k+1:n)
  end if
  print '(a)', ans
  stop
end program cc


Measured memory_bytes: 256
import itertools
 
n = int(input())
lis = [x for x in range(1,n+1)] # 0からn-1までのリスト
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

A = map(str, P)
P = "".join(A)
B = map(str, Q)
Q = "".join(B)

permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成
# 以下出力
for i, one_case in enumerate(permutations_lis):
    C = map(str, one_case)
    R = "".join(C)
    if P == R:
        a = i + 1
    if Q == R:
        b = i + 1

ans = abs(a-b)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<set>
#define ll long long
using namespace std;
double a[1000000]={0};
int main(){
    int t , x;
    cin>>t>>x;
  for(int i=x-t+1;i<=x+t-1;i++)
    if(i!=x+t-1)cout<<i<<" ";
    else cout<<i<<endl;
     return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

struct str {
    ll time;
    int city;
    ll money;
    bool operator<(const str& right) const
    {
        return time != right.time ? time < right.time : city != right.city ? city < right.city : money < right.money;
    }
};

int main()
{
    int n, m;
    ll money;
    cin >> n >> m >> money;
    money=min(money,2500LL);
    vector<vector<pair<ll, ll>>> edge(n, vector<pair<ll, ll>>(n, { -1, -1 }));
    REP(i, m)
    {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        edge[u][v] = { a, b };
        edge[v][u] = { a, b };
    }
    vector<pair<ll, ll>> change(n);
    REP(i, n)
    {
        ll c, d;
        cin >> c >> d;
        change[i] = { c, d };
    }
    vector<vector<ll>> time(n, vector<ll>(2501, 1e18)); //city money
    set<str> sstr;
    sstr.insert({ 0, 0, money });
    time[0][money] = 0;
    set<int> visited;
    visited.insert(0);
    while (1) {
        auto it = sstr.begin();
        str now = *it;
        sstr.erase(it);
        visited.insert(now.city);
        if (visited.size() == n) {
            break;
        }
        ll a = now.money;
        ll b = 0;
        while (1) {
            if (time[now.city][a] > now.time + b) {
                time[now.city][a] = now.time + b;
                sstr.insert({ now.time + b, now.city, a });
            }
            if (a == 2500)
                break;
            a += change[now.city].first;
            if (a > 2500)
                a = 2500;
            b += change[now.city].second;
        }
        REP(i, n)
        {
            if (edge[now.city][i].first != -1) {
                if (now.money >= edge[now.city][i].first) {
                    if (time[i][now.money - edge[now.city][i].first] > now.time + edge[now.city][i].second) {
                        time[i][now.money - edge[now.city][i].first] = now.time + edge[now.city][i].second;
                        sstr.insert({ now.time + edge[now.city][i].second, i, now.money - edge[now.city][i].first });
                    }
                }
            }
        }
    }
    FOR(i, 1, n)
    {
        ll ans = 1e18;
        REP(j, 2501)
        {
            ans = min(ans, time[i][j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 66568
#include<bits/stdc++.h>
using namespace std;
class C{
 public:
  constexpr C():xss(){
    for(int D=0;D<3;++D){
      for(int N=1;N<=100;++N){
        xss[D][N]=N;
        if(N==100)++xss[D][N];
        for(int d=0;d<D;++d){
          xss[D][N]*=100;
        }
      }
    }
  }
  int xss[3][101];
};
constexpr C c;
int D,N;
main(){
  cin>>D>>N;
  static_assert(c.xss[0][5]==5,"foo");
  static_assert(c.xss[1][11]==1100,"foo");
  static_assert(c.xss[2][85]==850000,"foo");
  static_assert(c.xss[0][100]==101,"foo");
  static_assert(c.xss[1][100]==10100,"foo");
  static_assert(c.xss[2][100]==1010000,"foo");
  cout<<c.xss[D][N]<<endl;
}


Measured memory_bytes: 256
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    high = x
    low = x
    while(1):
        if low not in p:
            print(low)
            return
        if high not in p:
            print(high)
            return
        low -= 1
        high +=1






x, n  = RA()
if n:
    p = set(RA())
else:
    p = set()
solve()


Measured memory_bytes: 64992
n=int(input())
lst=list(map(int,input().split()))
anslst=[None]*n
for i in range(n,0,-1):
    amari=lst[i-1]
    tmp=i*2
    kosuu=0
    while tmp-1<n:
        if anslst[tmp-1]==1:
            kosuu+=1
        tmp+=i
    kosuu%=2
    if kosuu==amari:
        anslst[i-1]=0
    else:
        anslst[i-1]=1
cnt=0
ans=[]
for i in range(n):
    if anslst[i]==1:
        cnt+=1
        ans.append(i+1)
print(cnt)
print(*ans)

Measured memory_bytes: 98108
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

vector<ll> PF;
ll num[100010];

void DecompositPrime(int n){
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			num[a]++;
			n/=a;
		}
		else{
			a++;
		}
	}
	num[n]++;
}

int main(){
	ll n,ans=1;
	cin>>n;
	for(int i=0;i<=10000;i++){
		num[i]=1;
	}
	for(int i=1;i<=n;i++){
		DecompositPrime(i);
	}
	for(int i=2;i<=10000;i++){
		ans=ans*num[i]%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n, m;
	int countn(0), countm(0),score(0);
	cin >> n;
	vector<string>vecn(n);
	for (int i = 0; i < n; i++) {
		cin >> vecn.at(i);
	}

	cin >> m;
	vector<string>vecm(m);
	for (int i = 0; i < m; i++) {
		cin >> vecm.at(i);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (vecn.at(i) == vecn.at(j)) {
				countn++;
			}
		}

		for (int k = 0; k < m; k++) {
				if (vecn.at(i) == vecm.at(k)) {
					countm++;
				}
		}

		if ((countn - countm) > score) {
			score = (countn - countm);
			}
		countn = 0;
		countm = 0;
	}

	cout << score;


	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
std::vector<long long int> a;
std::vector<long long int> b;
std::vector<long long int> c;
long long int n;
// std::vector<pair<long long int,long long int>> best;
long long int best[1000005][4]={-1,-1,-1};
long long int solve(long long int day,long long int j){
     // cout << x << " " << y << " " << z << endl;
     // cout  << day << " " << j << " " << best[day][j] << endl;
     if(day==n){
          return 0;
     }
     long long int add = 0;
     if(best[day][j]==-1){
          long long int f=0;
          if(j==0){
               f = 0;
               f = max({solve(day+1,1)+a[day],solve(day+1,2)+b[day],solve(day+1,3)+c[day]});
          }
          else if(j==1){
               f = 0;
               f = max({solve(day+1,2)+b[day],solve(day+1,3)+c[day]});
          }
          else if(j==2){
               f = 0;
               f = max({solve(day+1,1)+a[day],solve(day+1,3)+c[day]});
          }
          else if(j==3){
               f = 0;
               f = max({solve(day+1,2)+b[day],solve(day+1,1)+a[day]});
          }
          // best[day]=max({solve(day+1,x+1,0,0)+a[day],(solve(day+1,0,y+1,0))+b[day],(solve(day+1,0,0,z+1))+c[day  ]});
          best[day][j] = f;
     }
     return best[day][j];
}
int main() {
     memset(best,-1,sizeof best);
     cin >> n;
     // long long int pie[n][n]={-1};
     // best = pie;
     for(long long int i=0;i<n;i++){
          long long int x,y,z;
          cin >> x >> y  >> z;
          a.push_back(x);
          b.push_back(y);
          c.push_back(z);
     }
     cout << solve(0,0);
}


Measured memory_bytes: 43092
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int s, w;
	cin >> s >> w;

	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}


Measured memory_bytes: 3628
s = input()

s_len = len(s)

is_even = False

if s_len % 2 == 0:
    is_even = True

half_s_len = s_len // 2


if is_even:
    s_len_half = half_s_len
    mae = s[:half_s_len]
    ato = s[s_len_half:]
else:
    s_len_half = half_s_len + 1
    mae = s[:half_s_len]
    ato = s[s_len_half:]


ato_gya9 = ato[::-1]


count = 0

x = len(mae)

for i in range(x):
    if mae[i] != ato_gya9[i]:

        count += 1

print(count)


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

int main(){
    string s;
    int min1 = 0, min2 = 0;
    int ans;
    cin >> s;

    rep(i, s.size()){
        if(s[i] == (char)('0' +(i % 2))) min1++;
        else if(s[i] == (char)('0' +((i+1) % 2))) min2++;
    }

    ans = min(min1, min2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  char s[10000];
  while(scanf("%s",s)!=EOF){
    int n=strlen(s);
    vi a(n);
    rep(i,n)
      if(s[i]=='I')a[i]=1;
      else if(s[i]=='V')a[i]=5;
      else if(s[i]=='X')a[i]=10;
      else if(s[i]=='L')a[i]=50;
      else if(s[i]=='C')a[i]=100;
      else if(s[i]=='D')a[i]=500;
      else if(s[i]=='M')a[i]=1000;
    int ans=0;
    rep(i,n-1)
      if(a[i]>=a[i+1])ans+=a[i];
      else ans-=a[i];
    cout<<ans+a[n-1]<<endl;
  }
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using pii = pair<int, int>;
#define int ll
#define INF 1e18
using ll = long long;
signed main(){
    int n,m; cin>>n>>m;
    vector<vector<int>>d(n,vector<int>(n,INF));
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        d[a-1][b-1]=d[b-1][a-1]=c;
    }
    vector<vector<int>>d_min;
    rep(i,n)d[i][i]=0;
    d_min=d;
    rep(k,n)rep(i,n)rep(j,n)d_min[i][j]=min(d_min[i][j],d_min[i][k]+d_min[k][j]);
    int ans=0;
    rep(i,n)rep(j,n)if(i!=j&&d[i][j]!=INF&&d_min[i][j]!=INF&&d[i][j]!=d_min[i][j])
        ans++;
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum=0;
    int max=0;
    for(int i=0;i<n;i++){
      int a=sc.nextInt();
      sum+=a;
      max=Math.max(max,a);
    }
    if(max<(sum-max)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35392
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<ll> s(n+1);
    rep(i, n) {
        ll a;
        cin >> a;
        a--;
        s[i+1] = (s[i] + a)%k;
    }

    map<ll, ll> mp;
    queue<ll> Q;
    ll ans = 0;
    rep(i, n+1) {
        ans += mp[s[i]];
        mp[s[i]]++;
        Q.push(s[i]);
        if(Q.size() == k) {
            mp[Q.front()]--;
            Q.pop();
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>

int main(){
    int a, b, c;
    int max = 0, middle= 0, min= 0;
    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b && a > c){
        max = a;
        if (b > c){
            middle = b;
            min = c;
        }else {
            middle = c;
            min = b;
        }
    } else if (b > a && b > c){
        max = b;
        if (a > c){
            middle = a;
            min = c;
        }else {
            middle = c;
            min = a;
        }
    } else if (c > a && c > b){
        max = c;
        if (a > b){
            middle = a;
            min = b;
        }else {
            middle = b;
            min = a;
        }
    }
    printf("%d %d %d\n", min, middle, max);
    }


Measured memory_bytes: 2144
s = input()
import itertools
def judge(k):
    if s[k] == "A" or s[k] == "C" or s[k] == "G" or s[k] == "T":
        return True
    return False

ans = 0
for comb in itertools.combinations(range(len(s)),2):
    i,j = comb
    true = 1
    for k in range(i,j+1):
        if not judge(k):
            true = 0
            break
    if true == 1:
        ans = max(ans,j-i+1)
if ans == 0:
    for k in range(len(s)):
        if judge(k):
            ans = 1
            break
print(ans)

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

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

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

  vector<int> a(n);
  rep(i, n) cin>>a.at(i);

  int now=1;
  int kudaku=0;

  rep(i, n){
    if(a.at(i)==now) now++;
    else kudaku++;
  }

  if(now==1&&n!=1) cout << -1;
  else cout << kudaku;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    
   


return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(){
    long H,N;
    std::cin >> H >> N;
    long sum = 0;
    for (int i = 0;i < N;i++){
        int A_i;
        std::cin >> A_i;
        sum += A_i;
    }

    if (sum >= H){
        std::cout << "Yes\n";
    }else{
        std::cout << "No\n";
    }
}


Measured memory_bytes: 256