akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    string S;
    cin >> N >> S;
    int res=0;
    for(int i=0;i<1000;i++){
        char one='0'+(i/100);
        char two='0'+(i%100/10);
        char three='0'+(i%100%10);
        int ptr=0;
        bool  a=false;
        bool b=false;
        bool c= false;
        for(int j=ptr;j<S.size()-2;j++){
            if(S.at(j)==one){
                ptr=j+1;
                a=true;
                break;
            }
        }
        for(int j=ptr;j<S.size()-1;j++){
            if(S.at(j)==two){
                ptr=j+1;
                b=true;
                break;
            }
        }
        for(int j=ptr;j<S.size();j++){
            if(S.at(j)==three){
                c=true;
                break;
            }
        }
        if(a&&b&&c) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n > b - 1) {
    n = b - 1;
  }
  cout << (ll)floor(a * n / b) << endl;
  return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] D = W.split(" ");

		int n = Integer.parseInt(D[0]);
		int d = Integer.parseInt(D[1]);

		ArrayList<ArrayList<Integer>> x = new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<n;i++){
			W = in.readLine();
			ArrayList<Integer> tmp = new ArrayList<Integer>();
			D = W.split(" ");
			for(int k=0;k<D.length;k++){
				tmp.add(Integer.parseInt(D[k]));
			}
			x.add(tmp);
		}

		int ans =0;
		for(int i=0;i<x.size();i++){
			for(int k=i+1;k<x.size();k++){
				if(calc(x.get(i),x.get(k))){
					ans++;
				}

			}
		}

		System.out.println(ans);
	}

	public static boolean calc(ArrayList<Integer> y , ArrayList<Integer> z ){
		long ans = 0;
		for(int i=0;i<y.size();i++){
			ans += Math.pow((y.get(i)-z.get(i)), 2);
		}
		double sqrt = Math.sqrt(ans);
		long c = (long)sqrt;
		return ans == Math.pow(c,2);
	}

}


Measured memory_bytes: 21204
#include<stdio.h>
int sum(int a)
{
    int b,s=0;
    while(a!=0)
    {
       b=a%10;
       a=a/10;
       s=s+b;
       if(a==0)
       {
           break;
       }
    }
    return s;
}
int main()
{
    int n,a,b,i,cnt=0;
    scanf("%d %d %d",&n,&a,&b);
    for(i=1;i<=n;i++)
    {
        if(sum(i)>=a && sum(i)<=b)
        {
            cnt=cnt+i;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

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

Measured memory_bytes: 256
import sys
N, M, K = map(int, input().split())

if M == 1 :
    if K == N-1:
        print(1)
    else:
        print(0)
    sys.exit()

def power_func(a, n, p):
    bi = str(format(n,"b"))#2進表現に
    if a == 0:
        return 0
    res = 1
    for i in range(len(bi)):
        res = (res*res) % p
        if bi[i] == "1":
            res = (res*a) % p
    return res

P = 998244353
inv_t = [0] + [1]
for i in range(2, max(M,K)+2):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

ans = (M * power_func(M-1, N-1, P))%P
curr = ans
for k in range(K):
    curr = (curr*(N-k-1)*inv_t[k+1]*inv_t[M-1]) % P
    ans += curr
    ans %= P

print(ans)

Measured memory_bytes: 16944
import collections
n=int(input())
a=list(map(int,input().split()))
q=int(input())
numl=collections.Counter(a)
s=sum(a)
for qq in range(q):
  x,y=map(int,input().split())
  s+=numl[x]*(y-x)
  print(s)
  numl[y]+=numl[x]
  numl[x]=0
  

Measured memory_bytes: 23992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, k, r=0, m;
    cin >> n >>k;
    m = n;
    r = n%k;
    n = n/k;
    cout<<min(r,k-r)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=b;i++){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;


}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    FOR(i, a, b+1){
        if(i % k == 0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

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

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



int main(){
  int k,t;
  cin >> k >> t;
  int p = -1;
  rep(i,t){
    int x; cin >> x;
    p = max(p, x);
  }
  int ans = p-(k-p)-1;
  if(ans<0 || k==1) ans=0;
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 256
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


s = S()
ans = ''
if 'C' in s:
    ans += 'C'
    if 'F' in s[s.find('C'):]:
        ans += 'F'
if ans == 'CF':
    print('Yes')
else:
    print('No')


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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> b(n + 1, MOD);
    for(int i = 1; i < n; ++i)
        cin >> b[i];
    i64 ans = 0;
    for(int i = 0; i < n; ++i){
        ans += min(b[i], b[i + 1]);
    }
    cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  
  string ans = "Heisei";
  if ( S[5] == '1' ) {
    ans = "TBD";
  } else if ( S[6] - '0' >= 5 ) {
    ans = "TBD";
  }
  cout << ans << "\n";
  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;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    string S;
    cin >> S;
    int ans = 0, n = S.size();
    rep(i, n / 2) {
        if (S[i] != S[n - 1 - i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

    vector<int> v;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            v.push_back(i);
        }
    }

    ll sum = 0;
    for (int x : v) {
        sum += x;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 7364
#include <iostream>
#include <vector>
#include <string>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> perm(n + 1);
    perm[0] = 0;
    for (int i = 1; i <= n; ++i) {
        std::cin >> perm[i];
    }
    int cnt = 0;
    bool free = false;
    for (int i = 1; i <= n; ++i) {
        if (perm[i] == i) {
            if (!free) {
                ++cnt;
                free = true;
            } else {
                free = false;
            }
        } else {
            free = false;
        }
    }
    std::cout << cnt;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct indexode{
  int a;
  int index;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  if(p->a!=q->a) return p->a-q->a;
  return p->index-q->index;
}

void run(void){
  int n;
  scanf("%d",&n);
  node *a=(node *)malloc(sizeof(node)*(n+1));
  int i;
  for(i=1;i<=n;i++){
    int b;
    scanf("%d",&b);
    a[i].a=b;
    a[i].index=i;
  }
  a[0].a=0;
  a[0].index=0;
  qsort(a,n+1,sizeof(node),cmp);
  int64 *ans=(int64 *)calloc(n+1,sizeof(int64));
  int min=n;
  for(i=n;i>0;i--){
    int j=i;
    while(j>0 && a[j].a==a[i].a) j--;
    min=MIN(min,a[j+1].index);
    ans[min]+=(int64)(a[i].a-a[j].a)*(n-j);
    i=j+1;
  }
  for(i=1;i<=n;i++){
    printf("%lld\n",ans[i]);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2548
class Dice:
  arr = []
  tmpArr = []
  def __init__(self, arr):
    self.arr = arr
  def move(self, pos):
    if pos == 'E':
      self.eastMove()
    elif pos == 'N':
      self.northMove()
    elif pos == 'S':
      self.sorthMove()
    elif pos == 'W':
      self.westMove()
  def out(self):
    return self.arr[0]
  def eastMove(self):
    self.changeArr(3, 6)
    self.changeArr(3, 4)
    self.changeArr(3, 1)
  def northMove(self):
    self.changeArr(5, 6)
    self.changeArr(5, 2)
    self.changeArr(5, 1)
  def sorthMove(self):
    self.changeArr(2, 6)
    self.changeArr(2, 5)
    self.changeArr(2, 1)
  def westMove(self):
    self.changeArr(4, 6)
    self.changeArr(4, 3)
    self.changeArr(4, 1)
  def changeArr(self, f, t):
    tmp = self.arr[f - 1]
    self.arr[f - 1] = self.arr[t - 1]
    self.arr[t - 1] = tmp

diceNum = list(map(int, input().split(' ')))
dice = Dice(diceNum)
posAction = input()
for pos in posAction:
  dice.move(pos)
print(dice.out())


Measured memory_bytes: 5608
n,m=map(int,input().split())
ll=[]
rl=[]
for i in range(m):
    l,r=map(int, input().split())
    ll.append(l)
    rl.append(r)
#print(ll)
#print(rl)
max_l=max(ll)
min_r=min(rl)
ans=min_r-max_l+1
if ans<=0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 10996
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	vector<int> n;

	if (a > b)
	{
		int nn = a;
		a = b;
		b = nn;
	}

	for (int i = 0;i < b;i++)
	{
		if (a % (i + 1) == 0 && b % (i + 1) == 0)
		{
			n.push_back(i + 1);
		}
	}
	reverse(n.begin(), n.end());
	cout << n[k - 1] << endl;
	return 0;
}

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

int main() {
	// your code goes here
	
	int x;
	
	cin >> x;
	
	int h = x/60/60;
	int m1 = x-h*60*60;
	int m = m1/60;
	int ss = m1-m*60;
	
	cout << h << ":" <<  m << ":" << ss << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld EPS = 1e-11;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T> 
ll round(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

#define all(a) (a).begin(), (a).end()

const int N = 2020;

int n, k;
vector<int> g[N];
int maxLen[N];
int f[N][N];


void calc(int v, int p) {
	maxLen[v] = 0;
	for (int to : g[v]) {
		if (to == p) continue;
		calc(to, v);
		maxLen[v] = max(maxLen[v], maxLen[to] + 1);
	}
}

void mergeTo(int a[], int & sz, int b[], int lenB) {
	static int res[N];
	for (int i = 0, r = max(sz, lenB + 1); i <= r; i++) {
		res[i] = a[i];
	}
	for (int x = 0; x <= sz; x++) {
		for (int y = 0; y <= lenB && x + y + 1 <= k; y++) {
			chmax(res[max(x, y + 1)], a[x] + b[y]);
		}
	}
	sz = max(sz, lenB + 1);
	for (int i = 0; i <= sz; i++) {
		a[i] = res[i];	
	}
}

void dfs(int v, int p) {
	f[v][0] = 1;
	int sz = 0;
	for (int to : g[v]) {
		if (to == p) continue;
		dfs(to, v);
		mergeTo(f[v], sz, f[to], maxLen[to]);
	}
}

int main() {
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	scanf("%d%d", &n, &k);

	for (int i = 1; i <= n - 1; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}

	fill(&f[0][0], &f[0][0] + sizeof(f) / sizeof(f[0][0]), -INF);	

	calc(1, -1);
	dfs(1, -1);

	int res = *max_element(&f[0][0], &f[0][0] + sizeof(f) / sizeof(f[0][0]));

	cout << n - res << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
          cin >> a.at(i).at(j);
      }
  }

  //行を空白に
  for(int i = 0; i < H; i++){
      int counter = 0;
      for(int j = 0; j < W; j++){
          if(a.at(i).at(j) == '.' || a.at(i).at(j) == ' ') counter++;
      }
      if(counter == W){
          for(int j = 0; j < W; j++){
              a.at(i).at(j) = ' ';
          }
      }
  }
  //列を空白に
  for(int i = 0; i < W; i++){
      int counter = 0;
      for(int j = 0; j < H; j++){
          if(a.at(j).at(i) == '.' || a.at(j).at(i) == ' ') counter++;
      }
      if(counter == H){
          for(int j = 0; j < H; j++){
              a.at(j).at(i) = ' ';
          }
      }
  }

  for(int i = 0; i < H; i++){
      int counter2 = 0;
      for(int j = 0; j < W; j++){
          if(a.at(i).at(j) != ' ') cout << a.at(i).at(j);
          else counter2++;
          if(j == W-1 && counter2 != W){
              cout << endl;
          }
      }
  }
}


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

#define llong long long
#define pb push_back
#define SPEED_PLUS_PLUS ios_base::sync_with_stdio(0), cin.tie(), cout.tie();

const llong MXN = 1e4 + 2;

using namespace std;

llong ans;

int main(){

    SPEED_PLUS_PLUS

    llong a, b;
    cin >> a >> b;
    b += a * 3;

    cout << b / 2;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int D = int.Parse(Console.ReadLine());
		int[]C = new int[26];
		string[]str = Console.ReadLine().Split();
		for(var i=0;i<26;i++){
			C[i] = int.Parse(str[i]);
		}
		int[,]A = new int[D,26];
		for(var i=0;i<D;i++){
			string[]str2 = Console.ReadLine().Split();
			for(var j=0;j<26;j++){
				A[i,j] = int.Parse(str2[j]);
			}
		}
		int[]ans = new int[D];
		int[]W = new int[26];
		for(var i=0;i<D;i++){
			int maxValue = 0;
			int maxj = 0;
			for(var j=0;j<26;j++){
				int value = A[i,j] + W[j]*(i+1-W[j])/10;
				if(value > maxValue){
					maxValue = value;
					maxj = j;
				}
			}
			ans[i] = maxj+1;
			W[maxj] = i+1;
		}
		for(var i=0;i<D;i++){
			Console.WriteLine(ans[i]);
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> time;
  int total = 0;
  for (int i = 0; i < n; i++) {
    cin >> time[i];
    total += time[i];
  }
  int m;
  cin >> m;
  vector<pair<int, int>> drink(m);
  for (int i = 0; i < m; i++) {
    cin >> drink[i].first >> drink[i].second;
  }
  for (auto a : drink) {
    cout << total - time[a.first - 1] + a.second << endl;
  }
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        vector<_i64> A; _i64 N, v, j; cin >> N; A.resize(N);
        _foreach(e, A) { cin >> e; }
        _rep(i, N) {
            v = A[i]; j = i - 1;
            while(j >= 0 && A[j] > v) { A[j + 1] = A[j]; --j; }
            A[j + 1] = v;
            _rep(k, N) { cout << (k != 0 ? " " : "") << A[k]; } cout << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3132
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=305,mod=998244353;
char s[N];
int f[N][N][N],n,ans;
bool ok[N][N][N];

signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	ok[0][0][0]=1;
	for(int i=0;i<n;i++) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++) if(ok[i][j][k]){
		if(s[i+1]=='0'||s[i+2]=='0') ok[i+2][j+1][k]=1;
		if(s[i+1]=='1'||s[i+2]=='1') ok[i+2][j][k+1]=1;
		ok[i+1][j][k]=1;
		if(s[i+1]=='1'&&j) ok[i+1][j-1][k+1]=1;
		if(s[i+1]=='0'&&k) ok[i+1][j+1][k-1]=1; 
	}
	ok[n][0][0]=0;
	f[n][0][0]=1;
	for(int i=n;i;i--) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++){
		(f[i-1][j][k]+=f[i][j][k])%=mod;
		if(s[i]=='0') (f[i][j][k+1]+=f[i][j][k])%=mod;
		if(s[i]=='1') (f[i][j+1][k]+=f[i][j][k])%=mod;
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++) (ans+=ok[i][j][k]*f[i][j][k])%=mod;
	write(ans);
}

Measured memory_bytes: 66748
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 1500000

static inline int update_incline(int prev, int cur, int incline) {
  if(prev == cur) {
    incline = incline & 3;
  } else {
    incline = incline & ((prev < cur)+1);
  }
  return incline;
}

int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int i;
  int cnt = 1;
  int incline = 3; // unknown
  char *tmp = strtok(line, " ");
  int prev = strtol(tmp, NULL, 10);
  for(i = 1; i < num; i++) {
    char *tmp = strtok(NULL, " ");
    int cur = strtol(tmp, NULL, 10);
    incline = update_incline(prev, cur, incline);
    if(incline == 0) {
      incline = 3;
      cnt++;
    }
    prev = cur;
  }

  printf("%d\n", cnt);
}

Measured memory_bytes: 1152
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v: Vec<i32> = procon_read();
	let n = v[0];
	let v: Vec<i32> = procon_read();
	let L:Vec<i32> = v.clone();
	let mut s:i32 = 0;
	let mut maxi = 0;
	for i in L {
		s += i;
		maxi = max(i, maxi);
	}
	if maxi < s - maxi {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
p = 10**9 + 7

fac = [0] * (N + 33)
inv = [0] * (N + 33)
finv = [0] * (N + 33)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

for i in range(2, N+33):
  fac[i] = fac[i-1] * i % p
  inv[i] = p - inv[p%i] * (p // i) % p
  finv[i] = finv[i-1] * inv[i] % p

primes = {}
i = 2
while(M > 1):
  if(M % i == 0):
    primes[i] = primes.get(i, 0) + 1
    M //= i
  else:
    i += 2 - (i + 1) % 2
r = 1
for v in primes.values():
  r = r * fac[N+v-1] * finv[N-1] * finv[v] % p
print(r)

Measured memory_bytes: 41580
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, m, p, d[2500], INF = 1e12;
vector<pair<int, LL>> g[2500];

int main() {
	cin >> n >> m >> p;
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p;
		g[a].EB(b, c);
	}
	
	inc(i, n) { d[i] = -INF; }
	d[0] = 0;
	inc(q, 3 * n) {
		bool f = false;
		
		inc(v, n) {
		RF(e, g[v]) {
			bool flag = setmax(d[e.FI], d[v] + e.SE);
			f |= flag;
			if(flag && q >= n && e.FI == n - 1) { cout << -1 << endl; return 0; }
		}
		}
		
		if(! f) { break; }
	}
	
	cout << max(0LL, d[n - 1]) << endl;
	
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        String[] a = new String[n];
        String[] b = new String[m];
        boolean isAns = false;

        for (int i = 0; i < n; i++) {
            a[i] = sc.next();
        }
        for (int i = 0; i < m; i++) {
            b[i] = sc.next();
        }

        label: for (int i = 0; i < n-m+1; i++) {   // 行
            for (int j = 0; j < n-m+1; j++) {   // 列
                for (int k = 0; k < m; k++) {
                    String s = a[i+k].substring(j, j+m);
                    if (!(s.equals(b[k]))) {
                        break;
                    }
                    if (k >= m-1) {
                        isAns = true;
                        break label;
                    }
                }
            }
        }
        
        System.out.println(isAns ? "Yes" : "No");
    }
}


Measured memory_bytes: 22736
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

int main(int argc, char* argv[]) {
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
  
	vector<ll> p(a), q(b), r(c);
	rep(i,a) cin >> p[i];
	rep(i,b) cin >> q[i];
	rep(i,c) cin >> r[i];
	
	sort(all(p), greater<ll>());
	sort(all(q), greater<ll>());
	//sort(all(r), greater<ll>());

	vector<ll>pqr;
	rep(i,x) pqr.push_back(p[i]);
	rep(i,y) pqr.push_back(q[i]);
	rep(i,c) pqr.push_back(r[i]);

	sort(all(pqr), greater<ll>());

	ll ans = 0;
	rep(i,x+y) ans += pqr[i];

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


Measured memory_bytes: 8688
import math

N, M = map(int, input().split())
mod = 10**9+7

if abs(N-M) >= 2:
    print(0)
    exit()
    
N_fac = math.factorial(N) % mod
M_fac = math.factorial(M) % mod

if N == M:
    print(N_fac * M_fac * 2 % mod)
else:
    print(N_fac * M_fac % mod)

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll i,a[100000]={0},dp[100001]={0},n,cost,cost2;
 cin>>n;
 for(i=0;i<n;i++)
 {
     cin>>a[i];
 }
 for(i=2;i<=n;i++)
    {if(i==2)
     dp[i]=abs(a[i-1]-a[i-2]);
    else
    {
        cost=dp[i-2]+abs(a[i-1]-a[i-3]);
        cost2=dp[i-1]+abs(a[i-1]-a[i-2]);
        dp[i]=min(cost,cost2);
    }

 }
   cout<<dp[n];
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int k, x; std::cin >> k >> x;
  if (500 * k >= x)
    std::cout << "Yes" << "\n";
  else
    std::cout << "No" << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(S: str):
    dp = [[0] * 5 for _ in range(len(S) + 1)]
    dp[0][1] = 1

    for i, s in enumerate(S):
        for j, a in enumerate('_ABC', 1):
            dp[i+1][j] = (3 * dp[i][j]) if s == '?' else dp[i][j]
            if s == a or s == '?':
                dp[i+1][j] += dp[i][j-1]
            dp[i+1][j] %= MOD
    return dp[-1][-1] % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;




int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int ans = min(b, d) - max(a, c);

	if (ans < 0) ans = 0;

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



Measured memory_bytes: 256
s = input()
atgc = ["A","T","C","G"]
str = 0
max_ = 0
for i in range(len(s)):
  	if s[i] in atgc:
  		str += 1
  		if str >= max_:
  			max_ = str
  	else:
  		str = 0
print(max_)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> vp;
  rep1(i,n){
    string s;
    int x;
    cin >> s >> x;
    vp.push_back(make_pair(make_pair(s,-x),i));
  }
  sort(vp);
  rep(i,n) cout << vp[i].second << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    string ans="YES";
    if(a+b<c) ans="NO";
    if(a>c) ans="NO";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(2019)

using namespace std;

void solve(){
    string s;
    cin>>s;
    reverse(begin(s),end(s));
    map <int,int> mp;
    mp[0]=1;
    int ans=0;
    int csum=0;
    int p=1;
    for(int i=0;i<s.length();i++){
        csum=(csum+(s[i]-'0')*p)%hell;
        p=(p*10)%hell;
        if(s[i]=='0')
            continue;
        if(mp.count(csum))
            ans+=mp[csum];
        mp[csum]++;
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>

using namespace std;

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

int main() {
  int n, m;
  string s;
  cin >> n;
  while (cin >> s, s != "=") {
    cin >> m;
    if (s == "+") n += m;
    if (s == "-") n -= m;
    if (s == "*") n *= m;
    if (s == "/") n /= m;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 1204
num_array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
print(num_array[int(input()) - 1])

Measured memory_bytes: 3060
sx, sy, tx, ty = [int(i) for i in input().split()]
dx, dy = tx - sx, ty - sy
p1 = "U" * dy + "R" * dx
p2 = "D" * dy + "L" * dx
p3 = "LU" + p1 + "RD"
p4 = "RD" + p2 + "LU"
print(p1 + p2 + p3 + p4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown";
    }    
    else{
        cout<<"Alice";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll H, W;

int main(void) {
  ll i, j, k, l;
  
  cin >> H >> W;
  
  ll c[111][111];
  for(i=0; i<H; i++) {
    for(j=0; j<W; j++) {
      char t;
      cin >> t;
      c[i][j]=(t=='#');
    }
  }
  
  ll dp[111][111];
  for(i=0; i<H; i++) for(j=0; j<W; j++) dp[i][j]=INF;
  dp[0][0]=c[0][0];
  for(i=0; i<H; i++) {
    for(j=0; j<W; j++) {
      ll f;
      f=(c[i][j]==0&&c[i+1][j]==1);
      chmin(dp[i+1][j], dp[i][j]+f);
      f=(c[i][j]==0&&c[i][j+1]==1);
      chmin(dp[i][j+1], dp[i][j]+f);
    }
  }
  
  pt(dp[H-1][W-1]);
  
}




Measured memory_bytes: 384
def d_preparing_boxes(N, A):
    boxes = [0] * (N + 1)
    result = []

    for i in range(N, 0, -1):
        # N以下のiの倍数(i自身を除く)の箱に入っているボールの数を求める
        total = 0
        for j in range(1, N // i):
            total += boxes[(j + 1) * i]
        # 求めたボール数と条件の偶奇が一致しないなら、i番の箱にボールを入れる
        if total % 2 != A[i - 1]:
            boxes[i] = 1
            result.append(i)
    return '\n'.join(map(str, [len(result)] + result)) if len(result) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))

Measured memory_bytes: 20004
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>

#define rep(i,p,n) for(int i=p;i<n;i++)
#define lli long long int
#define vi vector<int> 

using namespace std;

//int max(int x, int y) {
//	int a;
//	(x > y) ? a = x : a = y;
//	return a;
//}
//
//int min(int x, int y) {
//	int a;
//	(x < y) ? a = x : a = y;
//	return a;
//}


int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);

	int max=0, min = -1;
	for (int i = 0; i < n; i++) {
		cin >> v[i].first >> v[i].second;
		if (max < v[i].first) max = v[i].first;
		if (min == -1)min = v[i].second;
		else if (min > v[i].second) min = v[i].second;
	}

	cout << max + min << endl;
	return 0;
}


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

int main() {
    int64_t N, M;
    string S;
    cin >> N >> M >> S;

    vector<int64_t> ans;
    int64_t curr = N;
    while (curr != 0) {
        bool move = false;
        for (int64_t i = M; i >= 1; i--) {
            if (curr - i < 0) {
                continue;
            }
            if (S[curr - i] != '1') {
                ans.push_back(i);
                curr -= i;
                move = true;
                break;
            }
        }
        if (!move) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(ans.begin(), ans.end());
    for (int64_t i = 0; i < ans.size(); i++) {
        cout << ans[i] << " \n"[i == ans.size() - 1];
    }
}

Measured memory_bytes: 1528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0};
V<int> dy = { 0, 0, -1, 1};

const int INF = 1e9;
char c[1010][1010];
int d[1010][1010];

int main () {
    int h, w; cin >> h >> w;
    int sy, sx; cin >> sy >> sx; sy--; sx--;
    int gy, gx; cin >> gy >> gx; gy--; gx--;
    //V<V<char>> c(h, V<char> (w));
    rep(i, h) rep(j, w) cin >> c[i][j];
    //V<V<int>> d(h, V<int> (w, INF));
    rep(i, h) rep(j, w) d[i][j] = INF;
    d[sy][sx] = 0;
    deque<P> que;
    que.push_back({sx, sy});
    while (!que.empty()) {
        P p = que.front(); que.pop_front();
        int x = p.first, y = p.second;
        rep(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
            if (c[ny][nx] == '#') continue;
            if (chmin(d[ny][nx], d[y][x])) {
                que.push_front({nx, ny});
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nx = x + i, ny = y + j;
                if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                if (c[ny][nx] == '#') continue;
                if (chmin(d[ny][nx], d[y][x] + 1)) {
                    que.push_back({nx, ny});
                }
            }
        }
    }
    if (d[gy][gx] != INF) cout << d[gy][gx] << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 8516
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>

//別にqueue使わずに実装余裕じゃん
//いや無理だわ
//セグフォのデバッグができるようになりたい

using namespace std;


int main(){
  //エラトステネスの篩を実装する
  int np;
  int n[9999]={0};//i番目が整数i+2に対応(2~10000)
  vector<int> pr;
  for(int i=2;i<=100;i++){
    if(n[i-2]==0){
      for(int j=1;j<=floor(10000/i);j++){
        if(j==1){
          n[j*i-2]=0;
        }else{
          n[j*i-2]=1;
        }
      }
    }
  }
  //prのなかに素数が入っている
  for(int i=0;i<9999;i++){
    if(n[i]==0){
      pr.push_back(i+2);
    }
  }
  int prs=pr.size();

  /*
  for(int i=0;i<prs;i++){
    cout << pr[i] << endl;
  }
  */

  while(cin>>np && np!=0){
    int c=0;//いくつあるかを記録する
    int s=0;//その時点での和
    queue<int> q;
    int j;
    for(j=0;j<prs;j++){
      s+=pr[j];
      if(s>=np){
        s-=pr[j];
        break;
      }
      q.push(pr[j]);
    }
    for(;j<prs;j++){
      s+=pr[j];
      q.push(pr[j]);
      while(s>np){
        s-=q.front();
        q.pop();
      }
      if(s==0) break;
      if(s==np) c+=1;
    }
    cout << c << endl;
  }


}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


ll inv(ll a){
	
	ll res=1;
	int p=MOD-2;
	while(p>0){
		if(p&1==1){res*=a;res%=MOD;}
		a=a*a%MOD;
		p>>=1;
	}
	return res;
}

int main() {
	
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	ll fact[310000];
	ll invfact[320000];
	
	fact[0]=1;
	fx(H+W+5){
		fact[x+1]=fact[x]*(x+1);
		fact[x+1]%=MOD;
	}
	invfact[H+W+4]=inv(fact[H+W+4]);
	for(int x=H+W+3;x>=0;x--){
		invfact[x]=invfact[x+1]*(x+1);
		invfact[x]%=MOD;
	}
	
	ll ans=0;
	
	for(int x=1;x<=H-A;x++){
		ll sum=fact[B+x-2]*invfact[x-1];
		sum%=MOD;
		sum=(sum*invfact[B-1])%MOD;
		ll sum2=fact[W-B-1+H-x]*invfact[W-B-1];
		sum2%=MOD;
		sum2=(sum2*invfact[H-x])%MOD;
		ans+=(sum*sum2)%MOD;
      ans%=MOD;

	}
	ce(ans)
	
	
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=2010, inf=2e9;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string S;
    cin>>S;
    if(S.substr(0,4)=="YAKI") cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def swap(a,b):
    c=a
    a=b
    b=c
    return a,b
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    bc=sorted([list(map(int, input().split())) for _ in range(m)])
    bc.sort(key=lambda x:x[1],reverse=True)
    a.sort()
    i=j=0
    while bc[i][1]>a[j]:
        for _ in range(bc[i][0]):
            if bc[i][1]<=a[j]:
                break
            a[j]=bc[i][1]
            j+=1
            if j==n:
                break
        i+=1
        if i==m or j==n or bc[i][1]<=a[j]:
            break
    print(sum(a))
    
main()

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

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

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ld a, b;
    cin >> a >> b;
    ld temp = a * b;
    ll ans = temp;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3732
A,B,C,X,Y = map(int, input().split())
countA = X
countB = Y
price = X*A + B*Y

for countC in range(1, 2*(X+Y)):
    if countC % 2 == 0:
        countA -= 1
        if countA < 0:
            countA = 0
        countB -= 1
        if countB < 0:
            countB = 0
        tmpPrice = countA * A + countB * B + countC * C
        if tmpPrice < price:
            price = tmpPrice
print(price)

Measured memory_bytes: 3064