akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

constexpr int D = 365;

int score(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i]-1];

		last[t[i] - 1] = i+1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i+1 - last[j]);
		}
	}

	return S;
}

int score_alpha(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t, const int& k) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i] - 1];

		last[t[i] - 1] = i + 1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}

	for (size_t i = t.size(); i < min(int(t.size() + k), D); i++) {
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}
	return S;
}

vector<int> solve(const vector<int>& c, const vector<vector<int>>& s, const int& k) {
	vector<int> t;
	t.reserve(D);

	for (size_t i = 0; i < D; i++) {
		int mscore = INT32_MIN, idx = 1;
		
		for (size_t j = 0; j < 26; j++) {
			t.push_back(j+1);
			int dscore = score(c, s, t);
			dscore = score_alpha(c, s, t, k);

			if (dscore > mscore) {
				mscore = dscore;
				idx = j+1;
			}
			t.pop_back();
		}

		t.push_back(idx);
	}

	return t;
}

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

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		//c[i] = rand() % 100;
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
			//s[i][j] = rand() % 20000;
		}
	}

	vector<int> bt = solve(c, s, 0);
	int sc = score(c, s, bt);

	for (int i = 1; i < 26; i++) {
		auto t = solve(c, s, i);
		auto tsc = score(c, s, t);
		if (sc < tsc) {
			sc = tsc;
			bt = t;
		}
	}
	
	for (size_t i = 0; i < D; i++) cout << bt[i] << endl;

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
long long n, p, cur, ans, num, alp; 
long long x[10000], pdes=1;
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> p >> s;
	if (p!=2 and p!=5){
		reverse(s.begin(), s.end());
	for (int i=0; i<s.size(); i++){
		pdes*=10; pdes%=p;
		cur+=(s[i]-'0')*pdes; 
	//	cout << cur << endl;
		cur%=p; x[cur]++;
	} x[0]++;
	for (int i=0; i<p; i++){
		num=x[i];
		ans+=num*(num-1)/2;
	} 
	cout << ans;
}
	else{
		for (int i=0; i<s.size(); i++){
			if ((s[i]-'0')%p==0) ans+=i+1;
		}
		cout << ans;
	}
return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    vector<string> a(3);
    rep(i, 3) cin >> a[i];
    int ans = 0;
    rep(i, n){
        int tmp = 0;
        rep1(j, 3){
            if(a[0][i] == a[j][i]) tmp++;
        }
        if(a[1][i] == a[2][i]) tmp++;
        if(tmp == 1) ans++;
        else if(tmp == 0) ans += 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		switch(D) {
		case 25:
			str = "Christmas";
			break;
		case 24:
			str = "Christmas Eve";
			break;
		case 23:
			str = "Christmas Eve Eve";
			break;
		case 22:
			str = "Christmas Eve Eve Eve";
			break;
		default:
			str = "";
		}

		System.out.println(str);

	}
}

Measured memory_bytes: 20948
#include <stdio.h>

int main(){
    int i = 0, j, temp;
    int nm[3001][2];

    for(i = 0; i < 3000; i++){
        scanf("%d%d", &nm[i][0], &nm[i][1]);
        if(nm[i][0] == 0 && nm[i][1] == 0) break;
        if(nm[i][0] > nm[i][1]){
        temp = nm[i][0];
        nm[i][0] = nm[i][1];
        nm[i][1] = temp;
        }
    }

    for(j = 0; j < i; j++){
        printf("%d %d\n", nm[j][0], nm[j][1]);
    }

    return 0;
}


Measured memory_bytes: 2088
def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


MOD = 10 ** 9 + 7
K = int(input())
S = input()
L = len(S)
modFacts, invs = prepare(K + L)

ans = 0
for n in range(L, L + K + 1):
    nonSi = (pow(25, n - L, MOD) * pow(26, L + K - n, MOD)) % MOD
    Si = (modFacts[n - 1] * invs[L - 1] * invs[n - 1 - (L - 1)]) % MOD
    ans += nonSi * Si
    ans %= MOD

print(ans)


Measured memory_bytes: 122836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << 48-a;
}


Measured memory_bytes: 256
import java.util.*;


class Main{
	
	
	
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();
		
		int h = S/3600;
		int m = (S-h*3600)/60;
		int s = (S-h*3600)-m*60;
		
		System.out.println(h + ":" + m + ":" +s);

		
	}
}

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

using namespace std;

int main(void) {
    string str1, str2;
  	cin >> str1 >> str2;

    if (str1 == str2.substr(0,str1.size())) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h == 0 && w == 0)break;
			calc(h, w);
		}
	}
	public void calc(int h, int w){
		int now = h*h + w*w;
		int ans = Integer.MAX_VALUE;
		int ans_w = Integer.MAX_VALUE;
		int ans_h = Integer.MAX_VALUE;
		
		for(int i = 1; i < 200; i++){
			for(int j = 1; j < i; j++){
				int a = i*i + j*j;
				if(now == ans){
					if(a==now && h<j && j<ans_h){
						ans = a;
						ans_w = i;
						ans_h = j;
					}
				}
				else if ((now<a && a<ans)
						|| (now==a && j>h)
						|| (ans==a && j<ans_h)){
					ans = a;
					ans_w = i;
					ans_h = j;
				}
				if(a > ans) break;
			}
			if(i*i > ans) break;
		}
		System.out.println(ans_h + " " + ans_w);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 27480
let q = Scanf.scanf " %d" @@ (+) 0
let rmax = ref 0
let lrs = Array.init q @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b ->
  rmax := max !rmax b; a, b
let is_prime n =
  if n <= 1 then false
  else
    let rec loop i =
      if i * i > n then true
      else if n mod i = 0 then false
      else loop @@ i + 1 in
    loop 2
let sums = Array.make (!rmax + 1) 0
let f n = if n mod 2 = 1 && is_prime n && is_prime @@ (n + 1) / 2 then 1 else 0
let _ =
  for i = 0 to !rmax - 1 do sums.(i + 1) <- sums.(i) + f (i + 1) done;
  let f (l, r) =
    Printf.printf "%d\n" @@ sums.(r) - sums.(l - 1)
  in
  Array.iter f lrs

Measured memory_bytes: 8064
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

#line 2 "tmp.cpp"

// おしまい:-1, 男:0, 女:1
int query(int i) {
  cout << i << endl;
  string s;
  cin >> s;
  if (s == "Vacant") {
    return -1;
  } else if (s == "Male") {
    return 0;
  } else {
    return 1;
  }
}

int main() {
  int n;
  cin >> n;
  int init = query(0);
  if (init == -1) {
    return 0;
  }

  int rightVal = query(n / 2);
  if (rightVal == -1)
    return 0;
  int leftVal = query(n / 2 + 1);
  if (leftVal == -1)
    return 0;

  int right, left;
  if ((n / 2 % 2 == 1 && init == rightVal) || (n / 2 % 2 == 0 && init != rightVal)) {
    leftVal = init;
    left = 0;
    right = n / 2;
  } else {
    rightVal = init;
    left = n / 2 + 1;
    right = n;
  }

  while (abs(right - left) > 1) {
    int mid = ((right + left) / 2);
    int midVal = query(mid % n);
    if (midVal == -1)
      return 0;
    // 辻褄が合うときは相手
    if (((right - mid) % 2 == 0 && midVal == rightVal) || ((right - mid) % 2 == 1 && midVal != rightVal)) {
      right = mid;
      rightVal = midVal;
    } else {
      left = mid;
      leftVal = midVal;
    }
  }
  int tmp = query(left % n);
  if (tmp != -1) {
    query(right % n);
  }

  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

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

  int N,Q; cin >>N >>Q;
  string S; cin >>S;

  vi a(N+1,0);
  rep(i,0,N) {
    if (i+1<N && S[i]=='A' && S[i+1]=='C') {
      a[i+1]=a[i]+1;
    } else {
      a[i+1]=a[i];
    }
  }

  rep(q,0,Q) {
    int l,r; cin >>l >>r;
    cout <<a[r-1]-a[l-1] <<'\n';
  }
  return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

long a[200010];

bool chk(int l, int r){
  int rp=0;
  FOR (i,l,r){
    if (rp&a[i]) return false;
    rp+=a[i];
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  Yn(n%(n/1000000000%10+n/100000000%10+n/10000000%10+n/1000000%10+n/100000%10+n/10000%10+n/1000%10+n/100%10+n/10%10+n%10)==0);
  return 0;
}

Measured memory_bytes: 256
package main

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

type isSeen []bool
type edge struct {
	a, b int
}

var (
	n     int
	m     int
	graph [][]int
	seen  isSeen
)

func dfs(e edge, v int) {
	seen[v] = true

	for _, nv := range graph[v] {
		if (v == e.a && nv == e.b) || (v == e.b && nv == e.a) {
			continue
		}

		if !seen[nv] {
			dfs(e, nv)
		}
	}
}

func main() {
	n = getInt()
	m = getInt()
	seen = make(isSeen, n)

	graph = make([][]int, n)
	edges := make([]edge, m)
	for i := range graph {
		graph[i] = make([]int, 0, m)
	}
	for i := 0; i < m; i++ {
		a, b := getInt()-1, getInt()-1
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
		edges[i].a = a
		edges[i].b = b
	}

	ans := 0
	for _, e := range edges {
		seen.AssignBoolToSlice(false)
		cnt := 0
		for v := range graph {
			if !seen[v] {
				dfs(e, v)
				cnt++
			}
		}
		if cnt > 1 {
			ans++
		}
	}

	fmt.Println(ans)
}

func (seen isSeen) AssignBoolToSlice(b bool) {
	for i := range seen {
		seen[i] = b
	}
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
/**
 *    author:  tourist
 *    created: 28.04.2018 15:50:03       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int ans = 0;
  for (int rot = 0; rot < n; rot++) {
    int ok = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ok &= (s[i][j] == s[j][i]);
      }
    }
    ans += ok;
    for (int i = 0; i < n; i++) {
      s[i] = s[i].substr(1) + s[i].substr(0, 1);
    }
  }
  cout << ans * n << '\n';
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	int N, M;
	cin >> N >> M;

	cout << N*(N-1)/2 + M*(M-1)/2 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,e[2][4],f[2][4],dp[5000*5000+10];
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=3;j++) cin>>e[i][j];
	for(int i=1;i<=2;i++)
		for(int j=1;j<=3;j++)
		{
			if(i==1) f[i][j]=e[i+1][j]-e[i][j];
			else f[i][j]=-f[i-1][j];
		}
	for(int k=1;k<=2;k++)
	{
		memset(dp,0,sizeof dp);
		for(int i=1;i<=3;i++)
			for(int j=e[k][i];j<=n;j++)
				dp[j]=max(dp[j],dp[j-e[k][i]]+f[k][i]);
		n=dp[n]+n;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	map<int, int> mp[2];
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mp[i & 1][x]++;
	}
	vector<pair<int, int>> v[2];
	for(int i = 0; i < 2; i++) {
		for(auto &u : mp[i]) {
			v[i].push_back(make_pair(u.second, u.first));
		}
		if(v[i].size() == 1) {
			v[i].push_back(make_pair(0, -1));
		}
		sort(v[i].rbegin(), v[i].rend());
	}
	int ans = n;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			if(v[0][i].second != v[1][j].second) {
				ans = min(ans, n - v[0][i].first - v[1][j].first);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6140
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int i, j;
	long int n, k, q;
	long int sum;
	long int max;
	long int second;
	long int count;
	long int a[100000];
	long int player[100000] = {0};
	
	scanf("%ld%ld%ld", &n, &k, &q);
	
	for(i = 0; i < q; i++) {
		scanf("%ld", &a[i]);
		player[a[i] - 1]++;
	}
	
	for(i = 0; i < n; i++) {
		//printf("%ld\n", k - (q - player[i]));
		if( k - (q - player[i]) > 0) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <vector>
using namespace std;
vector<int> v[100001];
int p[100001];
int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	if (M == 1) {
		printf("YES");
		return 0;
	}
	for (int i = 1; i <= N; ++i) {
		int temp, parent=0;
		scanf("%d", &temp);
		for (int j = 0; j < temp; ++j) {
			int a;
			scanf("%d", &a);
			if (p[a] == 0 && parent == 0) {
				p[a] = a;
				v[a].push_back(a);
				parent = a;
			}
			else if(p[a]==0 && parent != 0) {
				p[a] = parent;
				v[parent].push_back(a);
			}
			else if(p[a]!=0 && parent==0) {
				parent = p[a];
			}
			else if (p[a] == parent) {}
			else {
				for (auto x : v[parent]) {
					v[p[a]].push_back(x);
					p[x] = p[a];
				}
				v[parent].clear();
				parent = p[a];
			}
		}
	}
	bool res = false;
	int K = -1;
	for (auto x : v) {
		if (res == false && x.size() > 0) res = true;
		else if (res == true && x.size() > 0) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	/*for (int i = 1; i <= N; ++i) {
		if (res == false && p[i] != 0) {
			res = true;
			K = p[i];
		}
		else if (res == true && p[i] != 0 && p[i] != K) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");*/
}

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


const int inf = 1e18L;

signed main(){
	int n,w;
	cin>>n>>w;
	vector<pair<int,int>> a(n);
	int s=0;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
		s+=a[i].second;
	}

	vector<int> dp(s+1,inf);
	// dp[i]-represents the minimum weight using values atleast i
	
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=s-a[i].second;j>=0;j--){
			dp[j+a[i].second]=min(dp[j+a[i].second],dp[j]+a[i].first);
		}
	}

	int ans=0;
	for(int i=0;i<=s;i++){
		if(dp[i]<=w){
			ans=i;
		}
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H,W;
  cin>>H>>W;
  int sum = 0;
  REP(i,0,H){
    REP(j,0,W){
      char c;
      cin>>c;
      if(c=='#')++sum;
    }
  }
  cout<<(sum==H+W-1?"Possible":"Impossible")<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int t = scanner.nextInt();
		int s = scanner.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			b[i] = scanner.nextInt();
		}
		int[] dp = new int[t + 1];
		int ans = 0;
		for (int i = 0; i < n; i++)
			for (int j = t; j - b[i] >= 0; j--) {
				if (j - b[i] >= s || s >= j)
					dp[j] = Math.max(dp[j], dp[j - b[i]] + a[i]);
			}
		for(int i = 0;i<=t;i++)
			ans = Math.max(ans, dp[i]);
		System.out.println(ans);
	}
}

Measured memory_bytes: 29908
l = [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]
n = int(input())
print(l[n - 1])

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

//Start
typedef long long ll;

//Data
ll a,v,b,w,t;

//Main
int main(){
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	if(a<b){
		if(a+v*t<b+w*t) puts("NO");
		else puts("YES");
	} else {
		if(a-v*t>b-w*t) puts("NO");
		else puts("YES");
	}
	return 0;
}

Measured memory_bytes: 3112
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


for i in range(d):
    arr = list(map(int,input().split()))
    s.append(arr)

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 90
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores
    else:
        tp_scores = []
        for i in range(min(childs,len(good))):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]

# print(good[0])


# for g in good:
#     tp = 0
#     root = list(map(int,g[-1].split(",")))
#     F = field()
#     for i in range(len(root)):
#         F.ans[i] = root[i]
#         F.last[root[i]] = i
#         tp += F.score_day(i,root[i])
#     print(root,tp)

# print("bestscore:"+str(best_score))

root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)


Measured memory_bytes: 196888
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/
#define tiii tuple<int,int,int>
int t[101][101];
int main(){
  int n,m; cin >> n >> m;
  fill_n(t[0],101*101,INF);
  queue<tiii>q;
  rep(i,m){
    int a,b,c; cin >> a >> b >> c;
    a--,b--;
    t[a][b] = c;
    t[b][a] = c;
    q.push(tiii{a,b,c});
  }
  rep(k,n)rep(i,n)rep(j,n){
    t[i][j] =min(t[i][j],t[i][k]+t[k][j]);
  }
  int ans = m;
  while(!q.empty()){
    int a,b,c;
    tie(a,b,c) = q.front(); q.pop();
    if(t[a][b] == c)
      ans--;
    else
      ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
char s[N], t[N];
int nxt[N];
void get_nxt(int n, char* a) {
    int i, j;
    for (nxt[0] = j = -1, i = 1; i < n; nxt[i++] = j) {
        while (~j && a[j + 1] != a[i]) j = nxt[j];
        if (a[j + 1] == a[i]) j++;
    }
}
int main() {
    int L1;
    scanf("%d", &L1);
    scanf("%s", s);
    scanf("%s", t);
    for (int i = 0; i < L1; i++) t[L1 + i] = s[i];
    int L = L1 + L1;
    get_nxt(L, t);
    int k;
    for (k = nxt[L - 1]; k >= L1; k = nxt[k])
        ;
    printf("%d\n\n", L - k - 1);
    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int H, W, K;
string A[802];

int dist(int y, int x) {
    int ret = min(y, x);
    ret = min(ret, H - y - 1);
    ret = min(ret, W - x - 1);
    return ret;
}
using P = pair<int, int>;

vector<P> getNear(P s) {
    queue<P> que;
    que.push(s);
    map<P, int> dp;
    dp[s] = 0;
    vector<P> ps;
    ps.push_back(s);

    while (que.size()) {
        auto now = que.front();
        que.pop();
        rep(k, 4) {
            auto next = now;
            next.first += dy[k];
            next.second += dx[k];
            if (next.first < 0 || next.second < 0) continue;
            if (next.first >= H || next.second >= W) continue;
            if (dp.count(next)) continue;
            if (A[next.first][next.second] == '#') continue;
            dp[next] = dp[now] + 1;
            que.push(next);
            if (dp[next] <= K) {
                ps.push_back(next);
            }
        }
    }
    return ps;
}

int INF = 1e9;
int main() {
    cin >> H >> W >> K;
    rep(i, H) cin >> A[i];
    int ans = INF;
    P s;
    rep(i, H) rep(j, W) {
        if (A[i][j] == 'S') {
            s.first = i;
            s.second = j;
        }
    }
    auto ps = getNear(s);
    // cout << ps.size() << endl;
    // for (auto p : ps) {
    // cout << p.first << ", " << p.second << endl;
    // }
    for (auto p : ps) {
        int t = dist(p.first, p.second);
        // cout << p.first << ", " << p.second << ": " << t << endl;
        ans = min(ans, t);
    }
    ans = ceil(1.0 * ans / K);
    ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 46568
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll n,M=1e9+7;
	cin>>n;
	ll ans=1,x=1,y=1;
	fo(i,0,n)ans=ans*10%M;
	fo(i,0,n)x=x*8%M;
	fo(i,0,n)y=y*9%M;
	cout<<(ans+2*M+x-2*y)%M<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
ll a[200020];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5192
#include <stdio.h>

void bsort(int a[], int n)
{
  int i, j;
  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j - 1] > a[j]) {
        int temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
      }
    }
  }
}

int main(void)
{
  int i;
  int a[3];
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  bsort(a, 3);
  printf("%d %d %d\n", a[0], a[1], a[2]);

  return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] += a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

int main()
{
  int n,q; cin >> n >> q;
  vector<int> c(n+1);
  rep1(i,n) cin >> c[i];
  vector<int> l(q),r(q);
  rep(i,q) {
    cin >> l[i] >> r[i];
  }
  using pii = pair<pi, int>;
  vector<pii> vec(q);
  rep(i,q) {
    vec[i] = {{l[i], r[i]}, i};
  }
  sort(vec.begin(), vec.end(), [](pii a, pii b) {
				 return a.F.S < b.F.S;
			       });
  auto f = [&](int a,int b){ return a+b;}; // 二項演算:和
  int id = 0; //単位元:0
  SegTree<decltype(f),int> seg(f,id);
  seg.init(n+1);
  
  vector<int> lastappend(n+1, 0);
  int idx = 0;
  vector<int> res(q);
  rep1(i,n) {
    seg.update(lastappend[c[i]], -1);
    seg.update(i, 1);
    lastappend[c[i]] = i;
    while(idx < q && vec[idx].F.S == i) {
      res[ vec[idx].S ] = seg.query(vec[idx].F.F, vec[idx].F.S + 1, 0, 0, seg.size);
      idx++;
    }
  }
  for(auto val: res) cout << val << "\n";
  
  
  return 0;
}


Measured memory_bytes: 23528
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;/*最初の訪問*/
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;/*訪問完了*/
}
void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=WHITE;
  }
  tt=0;
  for(u=0;u<n;u++){
    /*未訪問のuを始点に深さ優先探索*/
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}


int main(){

  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){

      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int i;
    char s[105];
    bool gasitC=false, gasitF=false;

    cin >> s;
    int n = strlen(s);
    for (i=0;i<n;i++)
    {
        if (s[i] == 'C')
        {
            gasitC = true;
            break;
        }
    }
    if (!gasitC)
        cout << "No\n";
    else
    {
        for (;i<n;i++)
            if (s[i] == 'F')
            {
                gasitF=true;
                break;
            }
        if (!gasitF)
        {
            cout << "No\n";
        }
        else cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
 
class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.parseInt(br.readLine());
	String str[] = br.readLine().split(" ");

        for(int i = 0; i < count; i++) {

            if(i == count - 1) {
                System.out.println(str[count - i - 1]);
            } else {
                System.out.print(str[count - i - 1] + " ");
            }
        }
    }
}

Measured memory_bytes: 24452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=2e6+5;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n;cin >> n;
	int r[n];
	int a,b,c,d;cin >> a >> b >> c >>d;
	bool ans=0;
	if(a==b)r[0]=1;else r[0]=0;
	if(c==d)r[1]=1;else r[1]=0;
	for(int i=2;i<n;++i){
		int x,y;cin >> x >> y;
		if(x==y)r[i]=1;
		else{r[i]=0;}
		if(r[i]==1 and r[i-1]==1 and r[i-2]==1){ans=1;}
	}
	if(ans)cout<<"Yes"<<endl;
	else
cout << "No" << endl;
}
	


Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>


int main (void)
{
	int a, b, C;
	double  PI, S, L, h, c;

	scanf("%d %d %d", &a, &b, &C);
	S = ((double)a * (double)b * (double)sin((M_PI / 180)  *C))/2;
	printf("%f\n",S);
	
	c = sqrt(a*a + b*b - (2*a*b*cos((M_PI / 180)  *C)));
	L = a + b + c;
	printf("%f\n", L);

	h = 2 * S / a ;
	printf("%f\n",h);




	return 0;
}

Measured memory_bytes: 684
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// 正方形の一辺の長さの最大値をmとすると、mはHとWの最大公約数となる
//最大公約数
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W,C;
  cin>>H>>W>>C;
  int m = gcd(H, W);
  cout<<H/m*W/m*C<<endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   ll n=s.size();
   ll ans=0;
   ll mint=INF;
    for (int i = 0; i < n; ++i) {
        ans+=s[i]-'0';
        ans%=1000;
        mint=min(mint,abs(753-ans));
        ans*=10;
    }
    cout <<mint<<endl;
   return 0;
}

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

int main(){
  int a,b;

  scanf("%d %d", &a, &b);
  if(a >= 13) printf("%d\n", b);

  else if(a < 6) printf("0\n");

  else printf("%d\n", b/2);

  return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ei13333
 */

#include <bits/stdc++.h>

using namespace std;

class TaskC
{
public:
  void solve(istream &cin, ostream &cout)
  {
    int N, M;
    cin >> N >> M;
    double fact = 1;
    for(int i = 0; i < M; i++) {
      fact *= 2;
    }
    cout << fact * (100 * (N - M) + 1900 * M) << endl;
  }
};


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


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

using namespace std;

int main(int argc, char* argv[]) {
    string str;
    int count = 0;
    char get_str[100];
    char ans_str[100];
    scanf("%s", get_str);
    scanf("%s", ans_str);
    string rstr = string(get_str);
    string astr = string(ans_str);
    for(int i = 0; i < rstr.size(); i++) {
      rotate(rstr.rbegin(), rstr.rbegin()+1, rstr.rend());
      count++;
      if(rstr == astr) {
        printf("Yes");
        return 0;
      }
    }
    if(count == rstr.size()) {
      printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
da = list(map(int,input().split()))
 
m = 0
l = pow(10,18)
  
if da[3] % 2 == 1:
  k = da[1] -da[0]
else:
  k = da[0] -da[1]

if abs(da[0] - da[1]) <= l:
  print(k)
elif abs(da[0] - da[1]) > l:
  print("Unfair")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		for(int i =0;i < N;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		int cnt = 1;
		int flg = 0;
		for(int i = 0;i < N-1;i++) {
			if(A[i] > A[i+1]) {
				if(flg == -1) {
					cnt++;
					flg = 0;
				}else if(flg == 0) {
					flg = 1;
				}
			}else if(A[i] < A[i+1]) {
				if(flg == 1) {
					cnt++;
					flg = 0;
				}else if(flg == 0) {
					flg = -1;
				}
			}
		}
		System.out.println(cnt);
	}

}

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

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

using namespace std;
const long long MOD = 998244353;
const long long INF = 1LL << 61;

int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);

	rep(i, N) {
		cin >> A[i];
		cin >> B[i];
	}
	int sumA = accumulate(A.begin(), A.end(), 0);
	int sumB = accumulate(B.begin(), B.end(), 0);
	vector<vector<long long>> dp(N+1, vector<long long>(H+1, INF));
	dp[0][0] = 0;

	rep(i, N) {
		rep(w, H+1) {
			dp[i + 1][w] = min(dp[i + 1][w], dp[i][w]);
			dp[i + 1][min(w + A[i], H)] = min(dp[i + 1][min(w + A[i], H)], dp[i + 1][w] + B[i]);
		}
	}
	cout << dp[N][H];
}

Measured memory_bytes: 81656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second

#define MAX_V 110
#define INF 1e9

struct edge{int to,cost;};
typedef pair<int,int> P;
int d[MAX_V];
int V;
vector<edge> G[MAX_V];

edge makeedge(int t,int c){
    edge e;
    e.to=t;
    e.cost=c;
    return e;
}

void addedge(int s,int t,int c){
    G[s].push_back(makeedge(t,c));
    //G[t].push_back(makeedge(s,cost));
}

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s)); 

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}


int main(){
    int i,j,n;
    cin>>n;
    V=n;
    int u,k;
    int x,y;
    for(i=0;i<n;i++){
        cin>>u>>k;
        for(j=0;j<k;j++){
            cin>>x>>y;
            addedge(i,x,y);
        }
    }
    dijkstra(0);
    for(i=0;i<n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}



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

int main(){
    int A,B,num = 0;

    cin >> A >> B;
    for(int i = 0; i < 2; i++){
        if(A>B)
            num += A--;
        else
            num += B--;
        
    }

    cout << num << endl;
    return 0;
}

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

using namespace std;

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

    long long l[90] = {};
    l[0] = 2; l[1] = 1;

    if (n == 1) return cout << l[1] << endl, 0;

    for (int i = 2; i <= n; i++) {
        l[i] = l[i - 1] + l[i - 2];
        // cout << "l[" << i << "] = " << l[i] << endl;
    }

    cout << l[n] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
min_A = min(A)

ans = 10**9
for y in range(min_A, max_A+1):
    tmp = 0
    for a in A:
        xsuby = a - y
        tmp += xsuby ** 2
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N, A;
	int card[100] = { 0 };
	cin >> N;
	long int a = 0, b = 0;
	for (int i = 0;i < N;i++)
		cin >> card[i];
	sort(card,card+N, greater<int>());
	for (int i = 0;i < N;i++) {
		if (i % 2 == 0)
			a += card[i];
		else
			b += card[i];
	}
	cout << a - b << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    s = input().strip()
    K = int(input())
    ans = ""
    for c in s:
        if c == "a":
            ans += c
        else:
            cost = 26 - (ord(c) - ord("a"))
            if cost <= K:
                K -= cost
                ans += "a"
            else:
                ans += c
    finalletter = ans[-1]
    ans = ans[:-1] + chr(ord("a") + (ord(finalletter) - ord("a") + K) % 26)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,s[1000],p[1000],q[1000],r[1000],a,b,c,d;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    FOR(n)scanf("%d %d %d %d",&s[i],&p[i],&q[i],&r[i]);
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int flg=1;
    FOR(n){
      if(p[i]<=a&&q[i]<=b&&r[i]<=c&&(p[i]+r[i])*4+q[i]*9<=d){
        PRN(s[i]);
        flg=0;
      }
    }
    if(flg)PRS("NA");
  }
  return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define mod 1000000007


int main(){

	ll a, b;
	cin >> a >> b;
	string r;
	if (a*b <= 0) r = "Zero";
	else if (a > 0 && b > 0) r = "Positive";
	else if( (b - a + 1) % 2 == 0) r = "Positive";
	else r = "Negative";

	cout << r << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  int ans = 0;
  for (int i = 0, mi = INT_MAX; i < N; i++) {
    if (P.at(i) < mi) ans++;
    mi = min(mi, P.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3976
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

k,s=map(int,input().split())
if s<=k:
    print(cmb(s+2,2))
elif s>2*k:
    print(cmb(3*k-s+2,2))
else:
    ans=0
    for i in range(k+1):
        if s-i>=k:
            ans+=2*k-s+1+i
        else:
            ans+=s+1-i
    print(ans)

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        int r = sc.nextInt();

        if (n>=10)
            System.out.println(r);
        else
            System.out.println(r+(100*(10-n)));
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
pii ranges[353531];
pii pora[353531];
int ans[125252];
const int B = 525;
const int C = 252;
struct data{
  // id, position, in-iterator, out-iterator
  int id,pos,in,out;
};
data pts[C];
int M[353531];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    ranges[i] = pii(l,r);
  }
  // small
  FOR(d,1,min(B,m+1)){
    int tmp = 0;
    REP(i,n){
      int x = (ranges[i].first+d-1)/d;
      if(x*d<=ranges[i].second)tmp++;
    }
    ans[d]=tmp;
  }
  // large
  sort(ranges,ranges+n);
  REP(i,n)pora[i]=pii(ranges[i].second, i);
  sort(pora,pora+n);
  // d = B, points = kd

  data yo;
  yo.id=0; yo.pos=0; yo.in=0; yo.out=0;
  set<int> S;
  int tmp = 0;
  FOR(i,1,m+1){
    yo.pos++;
    while(yo.in<n && ranges[yo.in].first==yo.pos){
      S.insert(yo.in);
      yo.in++;
    }
    while(yo.out<n && pora[yo.out].first<yo.pos){
      S.erase(S.find(pora[yo.out].second));
      yo.out++;
    }
    if(i%B==0){
      // pts
      pts[yo.id] = yo;
      yo.id++;
      for(int x : S){
        if(M[x]==0)tmp++;
        M[x]++;
      }
    }
  }
  FOR(d,min(B,m+1),m+1){
    ans[d] = tmp;
    if(d==m)break;
    REP(i,yo.id){
      if(pts[i].pos > m)break;
      // step pts[i]
      pts[i].pos += i+1;
      while(pts[i].in<n && ranges[pts[i].in].first<=pts[i].pos){
        if(M[pts[i].in]==0)tmp++;
        M[pts[i].in]++;
        pts[i].in++;
      }
      while(pts[i].out<n && pora[pts[i].out].first<pts[i].pos){
        int id = pora[pts[i].out].second;
        M[id]--;
        if(M[id]==0)tmp--;
        pts[i].out++;
      }
    }
  }
  FOR(d,1,m+1)printf("%d\n",ans[d]);
  return 0;
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
  cin>>n>>k;
  vector<int >fruit(n,0);
  for(int i=0;i<n;i++)cin>>fruit[i];
  sort(fruit.begin(),fruit.end());
  int tot=0;
  for(int i=0;i<k;i++){
  	tot+=fruit[i];
  }
  cout<<tot;
}

Measured memory_bytes: 3628