akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

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

using namespace std;                                                   

int main(){
    int k, ans = 0; cin >> k;
    int array[k]; REP(i, k) cin >> array[i];
    
    sort(array, array + k);
    
    if(array[k/2 - 1] != array[k/2])
        for(int i = array[k/2 - 1] + 1; i <= array[k/2]; i++) ans++;
    cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int x, a, b; std::cin >> x >> a >> b;
  if ( std::abs(x-a) < std::abs(x-b) ) std::cout << "A" << std::endl;
  else std::cout << "B" << std::endl;
  return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a < b && b < c) {
    /* code */
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long uLL;
typedef pair<int,int> Pii;
typedef pair<ll,ll>   Pll;
typedef pair<ll,int>  Pli;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+100;
int v[N];
int prime[N];
int k=0;
void e_prime()
{
	memset(v,0,sizeof(v));
	v[1]=1;
	for(int i=2; i*i<N; i++)
		if(!v[i])
			for(int j=i*i; j<N; j+=i)
				v[j]=1;
	for(int i=2; i<N; i++)
		if(!v[i]) prime[k++]=i;
}
int main()
{
	IOS();
	e_prime();
	int n;
	cin>>n;
	for(int i=0; i<k; i++)
	{
		if(prime[i]>=n)
		{
			cout<<prime[i]<<endl;
			break;
		}
	}



	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 100055
#define ll long long
int ar[N];
vector<int>adj[N];
bitset<N>visited;
int n,m,ans[N];
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; ++i) {
        int a,b;
        scanf("%d%d",&a,&b);
        ar[b]++;
        adj[a].push_back(b);
    }
    queue<int> q;
    for(int i=1; i<= n; ++i) {
        if(ar[i]==0)
            q.push(i);
    }
    while(q.size()) {
        int node = q.front();
        q.pop();
        for(auto nx: adj[node]) {
            ans[nx] = max(ans[nx], ans[node]+1);
            ar[nx]--;
            if(ar[nx]==0)
                q.push(nx);
        }
    }
    printf("%d",*max_element(ans+1,ans+n+1));


    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;


void solve()
{
    int n, w;
    cin>>n>>w;
    vector<pair<int, int>> v(n);
    int mx=-1;
    for(int i=0;i<n;i++)
    {
        cin>>v[i].ff>>v[i].ss;
        mx=max(mx, v[i].ss);
    }
    mx=mx*n+1;
    int dp[n+1][mx+1];
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=mx;i++)
    {
        dp[0][i]=-1;
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=mx;j++)
        {
            if(v[i-1].ss<=j)
            {
                if(dp[i-1][j]==-1 && dp[i-1][j-v[i-1].ss]==-1)
                {
                    dp[i][j]=-1;
                }
                else if(dp[i-1][j]==-1)
                dp[i][j]=v[i-1].ff+dp[i-1][j-v[i-1].ss];
                else if(dp[i-1][j-v[i-1].ss]==-1)
                {
                    dp[i][j]=dp[i-1][j];
                }
                else
                dp[i][j]=min(v[i-1].ff+dp[i-1][j-v[i-1].ss], dp[i-1][j]);
            }
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    for(int i=mx;i>=0;i--)
    {
        if(dp[n][i]<=w && dp[n][i]!=-1)
        {
            cout<<i<<"\n";
            return;
        }
    }
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 82556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll X, K, D;
double f(ll x) {
	double y = x;
	y *= D;
	y += X;
	return y;
}
ll g(ll x) {
	ll y = x;
	y *= D;
	y += X;
	return y;
}
int main() {
	cin >> X >> K >> D;
	auto x0 = f(-K);
	auto x1 = f(K);
	if (x0 >= 0) {
		cout << abs(g(-K)) << endl;
		return 0;
	} else if (x1 <= 0) {
		cout << abs(g(K)) << endl;
		return 0;
	}
	ll L = 0, R = K;
	while (R-L >= 2) {
		ll m = (L+R)/2;
		if (f(2*m-K) < 0) {
			L = m;
		} else {
			R = m;
		}
	}
	auto x2 = -g(2*L-K);
	auto x3 = g(2*R-K);
	cout << min(x2, x3) << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
const int SIZE = 181 + 1;
const int MAX = 1000000;
 
int T[SIZE];
int cost1[MAX], cost2[MAX];
 
int main( void )
{  
    for(int i=0; i < SIZE; ++i) T[i] = i * (i + 1) * (i + 2) / 6;
 
    fill(cost1, cost1+MAX, MAX);
    fill(cost2, cost2+MAX, MAX + MAX);
    cost1[0] = cost2[0] = 0;
    for(int i=0; i < MAX; ++i) {
        //if(cost1[i] < 6) {
            for(int j=0; j < SIZE; ++j) {
                if(i + T[j] < MAX && cost1[i] < 5)
                    cost1[i + T[j]] = min(cost1[i + T[j]], cost1[i] + 1);
                if(T[j] & 1) {
                    if(i + T[j] < MAX)
                        cost2[i + T[j]] = min(cost2[i + T[j]], cost2[i] + 1);
                }
            }
    }
    int n;
    while(cin >> n, n) {
        cout << cost1[n] << ' ' << cost2[n] << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n,ans=0;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        if((i+1)%2 && a%2)ans++;
    }

    cout<<ans<<"\n";

    return 0;

}

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

int main(){
  char c[10000];
  int i,j,k;
  j=0;
  while(cin >> c[j]){
    j++;
  }

  for(i=0;i<j;i++){
    if(c[i] == 65){
      cout << 'X' ;
    }
    else if (c[i] == 66){
      cout << 'Y' ;
    }
    else if (c[i] == 67){
      cout << 'Z' ;
    }
    else{
      printf("%c",c[i]-3);
      }
  }
  cout << endl;




}

Measured memory_bytes: 0
while True:
    try:
        m, f, r = map(int, input().split())
        result = ""
        if m == f == r == -1:
            break
        s = m + f
        if m == -1 or f == -1:
            result = "F"
        elif s >= 80:
            result = "A"
        elif s >= 65:
            result = "B"
        elif s >= 50:
            result = "C"
        elif s >= 30:
            if r >= 50:
                result = "C"
            else:
                result = "D"
        elif s >= 0:
            result = "F"
    except EOFError:
        break
    print(result)

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}


int main() {
    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    ll L = lcm(N, M);
    map<int, char> c1, c2;
    for (int i=0; i<N; ++i) {
        ll a = (L/N)*i + 1;
        c1[a] = S[i];
    }
    for (int i=0; i<M; ++i) {
        ll a = (L/M)*i + 1;
        c2[a] = T[i];
    }
    bool ok = true;
    for (auto tmp : c1) {
        ll num = tmp.first;
        char ch = tmp.second;
        if (c2.count(num) > 0) {
            if (ch != c2[num]) {
                ok = false;
                break;
            }
        }
    }
    cout << (ok ? L : -1) << endl;
}


Measured memory_bytes: 8192
def xx(x: int):
    """
    2で何回割れるのか
    """
    counter = 0
    while True:
        x_, y = divmod(x, 2)
        if y != 0:
            return counter
        x, counter = x_, counter + 1

n = int(input())
ns =  list(map(int, input().split()))

res = 0
for n in ns:
    res += xx(n)
print(res)

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

int main() {
    string S;
    cin >> S;
    if( S=="SUN"){
        cout << 7 << endl;
    }
    else if( S=="MON"){
        cout << 6 << endl;
    }
    else if( S=="TUE"){
        cout << 5 << endl;
    }
    else if( S=="WED"){
        cout << 4 << endl;
    }
    else if( S=="THU"){
        cout << 3 << endl;
    }
    else if( S=="FRI"){
        cout << 2 << endl;
    }
    else if( S=="SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
int N;
typedef pair<int, pair<int, int> > P;

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

  cin >> N;
  vector<P> Z(N);
  int a,b,c;
  rep(i, N){
    cin >> a >> b >> c;
    P p = make_pair(c, make_pair(a, b));
    Z[i] = p;
  }
  sort(Z.begin(), Z.end(), greater<P>());

  rep_down(i, 101){ // x座標
    rep_down(j, 101){ // y座標
      int max_h = abs(i - Z[0].second.first)+abs(j-Z[0].second.second)+Z[0].first;
      bool flag = true;
      for (int k=1; k<N; k++){
        int h = Z[k].first;
        int x = Z[k].second.first;
        int y = Z[k].second.second;
        if (h==0){
          if (max_h > abs(i-x)+abs(j-y)){
            flag = false;
            break;
          }
        }else{
          if (max_h!=abs(i-x)+abs(j-y)+h){
            flag = false;
            break;
          }
        }
      }
      if (flag){
        cout << i << ' ' << j << ' ' << max_h << "\n";
        return 0;
      }
    }
  }
  return 0;
}


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

template <typename T>
void print(const T &v);

const int MAX = 510'000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int n, k;
    cin >> n >> k;
    COMinit();
    for (int i = 1; i <= k; i++)
    {
        ll left = COM(n - k + 1, i) % MOD;
        ll right = COM(k - 1, i - 1) % MOD;
        cout << (left * right) % MOD << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 15560
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}

Measured memory_bytes: 23380
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i, stop) for(int i = 0; i < (stop); i++)
#define PI 3.141592653589793
using namespace std;

int main(){
  
  int n,x,t;
  cin >> n >> x >> t;

  int i=0;
  int ans=t;
  for(i=1; ;i++){
    if(n <= x*i) break;
    ans += t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>



int main(){
   int N;
   do{
      scanf("%d", &N);
   }while(N < 2 || N > 3000);
   int a[N];

   for(int i = 0; i < N; i++){
      do{
         scanf("%d", &a[i]);
      }while(a[i] < 2 || a[i] > 100000);
   }

   int answer = 0;
   for(int i = 0; i < N; i++){
      answer += a[i] -1;
   }


   printf("%d", answer);
}

Measured memory_bytes: 128
n, x = map(int, input().split())
if x in [1, 2*n-1]:
    print("No")
else:
    print("Yes")
    mid = [x-1,x,x+1]
    if x != 2*n-2:
        mid = [x+2]+mid
    if x != 2:
        mid += [x-2]
    hoge = [i for i in range(1,2*n) if i not in mid]
    ans = hoge[:n-2] + mid + hoge[n-2:]
    print(*ans,sep="\n")

Measured memory_bytes: 17688
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int[] ww = new int[s.length]; // [0, i] を全て白にするコスト
    int[] bb = new int[s.length]; // [i, $] を全て黒にするコスト
    int cost = 0;
    for (int i = 0; i < s.length; i++) {
        if (s[i] == '#') cost++;
        ww[i] = cost;
    }

    cost = 0;
    for (int i = cast(int)s.length-1; i >= 0; i--) {
        if (s[i] == '.') cost++;
        bb[i] = cost;
    }

    int ans = min(ww[$-1], bb[0]);
    for (int i = 0; i < s.length; i++) {
        // [0, i] を白、[i+1, $-1] を黒にするコスト
        int c = ww[i] + (i + 1 < s.length ? bb[i + 1] : 0);
        ans = min(ans, c);
    }
    return ans;
}

int calc2(string s) {
    int n = cast(int)s.length;
    int[] ws = new int[s.length]; // [0, i] の白の個数
    for (int i = 0; i < s.length; i++) {
        if (s[i] == '.') ws[i]++;
        if (i > 0) ws[i] += ws[i-1];
    }

    int countW(int l, int r) {
        return ws[r] - (l > 0 ? ws[l-1] : 0);
    }
    int countB(int l, int r) {
        return (r - l + 1) - countW(l, r);
    }

    int ans = countW(0, n-1); // 全ての白を黒にするコスト
    // [0, i] を白、[i+1, n-1] を黒にするコスト
    for (int i = 0; i < n; i++) {
        int b = countB(0, i);
        int w = i == n-1 ? 0 : countW(i+1, n-1);
        ans = min(ans, b + w);
    }
    return ans;
}

void main() {
    readint;
    string s = read!string;
    int ans = calc2(s);
    writeln(ans);
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define _GLIBCXX_DEBUG
#define int long long
#define float long double
#define len(x) ((int)(x).size())
using namespace std;

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

  int N, X, T;

  cin >> N >> X >> T;

  int count = N / X + (N % X == 0 ? 0 : 1);

  cout << (count * T) << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int root(int* la, int p)
{
	if (la[p] < 0)
	{
		return p;
	}
	return la[p] = root(la, la[p]);
};

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

	vector<std::pair<int, int>> br(m);
	vector<int> la(n, -1);

	for (size_t i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		br[m - i - 1] = make_pair(a, b);
	}

	vector<UINT> ans(m, 0);

	UINT ans0 = (UINT)n * (n - 1) / 2;

	for (size_t i = 0; i < br.size(); i++)
	{
		ans[i] = ans0;

		int a = br[i].first;
		int b = br[i].second;

		int rt_a = root(la.data(), a);
		int rt_b = root(la.data(), b);

		if (rt_a != rt_b)
		{
			ans0 -= (UINT)(-la[rt_a]) * (UINT)(-la[rt_b]);
			la[rt_a] += la[rt_b];
			la[rt_b] = rt_a;
		}
	}

	for (auto it = ans.rbegin(); it != ans.rend(); it++)
	{
		cout << *it << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
/*hello! guys~*/
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,max=0;
  string ss;
  map<string,int>vote;
  vector<string> words;
  cin>>t;
  for(int i=0;i<t;i++)
  {
  	cin>>ss;
  	++vote[ss];
  	words.push_back(ss);
  	if(max<vote[ss])
  	max=vote[ss];
  } 
  sort(words.begin(),words.end());
  for(int i=0;i<words.size();i++)
  {
  	if(i+1!=words.size()&&words[i]==words[i+1])continue;
  	if(vote[words[i]]==max)
  	cout<<words[i]<<"\n";
  	
  }
   
  return 0;
} 

Measured memory_bytes: 26736
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){

 int n ; 
 cin >> n ;

 vector<int> c(n) ;
 for(int i =  0 ; i < n ; i++ ){
     cin >> c[i] ;
     c[i]-- ;
 }

 vector<bool> b(n ,false) ;
 int pos =  0 ;
 b[pos] = true ;
 int cnt = 0 ;
  while(pos != 1){
    pos = c[pos];
    if(b[pos]){
      cout << -1 << endl;
      return 0;
    }
    cnt++;
    b[pos] = true;
  }
 
  cout << cnt << endl;
 

 return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int k, q; cin >> k >> q;
    vector<LLONG> ds(k); for (auto &di : ds) cin >> di;
    for (int i = 0; i < q; ++i)
    {
        LLONG ni, xi, mi; cin >> ni >> xi >> mi;
        // (mod mi)に対するdiの増加量を調べる
        // 同時に、(mod mi)の増加値が正のものの個数をカウント：O(k = 10^3)
        vector<LLONG> dsModMi(k);
        LLONG addNum = 0;
        for (int i = 0; i < k; ++i)
        {
            dsModMi[i] = ds[i] % mi;
            if (dsModMi[i] > 0) ++addNum;
        }
        // k個進むごとにいくつ余りが増えるかどうか：O(k = 10^3)
        LLONG inc = accumulate(dsModMi.begin(), dsModMi.end(), 0LL);
        // 基本的に、k個進むごとに答えはaddNumずつ増える
        LLONG cycleNum = (ni - 1LL) / k;
        LLONG ans = addNum * cycleNum;
        // ただし、余りの累計がmiの倍数になる度に答えが１ずつ減る
        LLONG beg = xi % mi;
        LLONG end = beg + inc * cycleNum;
        LLONG dec = end / mi;
        ans -= dec;
        // サイクルからはみ出た分を計算する：O(k = 10^3)
        LLONG rem = (ni - 1LL) % k;
        LLONG prevMod = end % mi;
        for (LLONG i = 0LL; i < rem; ++i)
        {
            LLONG newMod = (prevMod + dsModMi[i]) % mi;
            if (prevMod < newMod) ++ans;
            prevMod = newMod;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <cstring>
#include <algorithm>

using namespace std;

const int INF = 1e9 + 7;

int n, w;
vector<pair<int, int>> goods;

long long dp[100][100001];

long long dfs(int now, int weight){
    if(w < weight) return -INF;
    if(now == n) return 0;
    if(~dp[now][weight]) return dp[now][weight];
    return dp[now][weight] = max(dfs(now + 1, weight), dfs(now + 1, weight + goods[now].first) + goods[now].second);
}

int main(){
    cin >> n >> w;
    goods.resize(n);
    memset(dp, -1, sizeof dp);
    for(auto&& i : goods){
        cin >> i.first >> i.second;
    }
    cout << dfs(0, 0) << "\n";
}

Measured memory_bytes: 78336
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "No";
    int64_t a,b,c,d,e,f;
    std::cin>> word;
 
    for( int i = 0; i < word.size(); i++ )
    {
        if( word[i] == '7' )
        {
            w = "Yes";
            break;
        }
    }
 
    std::cout<< w;
 
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int a;
    vector<int>v;
    for(int i=0;i<3;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<"\n";

    return 0;
}

Measured memory_bytes: 3104
from sys import *
from collections import Counter
N = int(stdin.readline())
things = []
if N ==1:
    print(0)
    exit()
for i in range(2,N):
    if i*i > N:
        if len(things) == 0:
            print(1)
            exit()
        if N > 1:
            things.append(int(N))
        break
    while(N%i == 0):
        things.append(i)
        N = N/i
c = Counter(things)
vals = 0
for item in c:
    hue = 0
    for i in range(1,100000):
        if (hue + i) > c[item]:
            break
        else:
            hue += i
            vals += 1

print(vals)


Measured memory_bytes: 9540
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def solve_small(K):
    if K == 0:
        return [0, 1]
    elif K == 1:
        return [0, 2]

    return [i for i in range(1, K+1)]

def solve(K):
    N = 50
    q = K // N
    r = K %  N

    A = [q+i for i in range(N)]
    for i in range(r):
        for j in range(N):
            if j == i:
                A[j] += N
            else:
                A[j] -= 1

    return A

def main():
    K = int(input())

    if K < 50:
        A = solve_small(K)
    else:
        A = solve(K)

    print(len(A))
    print(" ".join(map(str, A)))

if __name__ == "__main__": main()


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

using namespace std;

const int N = 2e5+5;

int main() {
    string a  , b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = 0; i < a.size(); i++){
        cnt += (a[i] != b[i]);
    }
    cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3860
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			@SuppressWarnings("unchecked")
			Set<Data>[] prefectures = new Set[n];
			IntStream.range(0, n).forEach(i -> prefectures[i] = new TreeSet<>());
			IntStream.range(0, m).forEach(i -> {
				int p = scanner.nextInt() - 1, y = scanner.nextInt();
				prefectures[p].add(new Data(i, y));
			});
			String[] result = new String[m];
			IntStream.range(0, n).forEach(i -> {
				int index = 1;
				for (Data data : prefectures[i]) {
					result[data.index] = String.format("%06d%06d", (i + 1), index);
					index++;
				}
			});
			Arrays.stream(result).forEach(System.out::println);
		}
	}

	/**
	 * indexとyを表すクラス
	 */
	private static class Data implements Comparable<Data> {
		/** 番号 */
		int index;
		/** 誕生した年数 */
		int y;

		Data(int index, int y) {
			super();
			this.index = index;
			this.y = y;
		}

		@Override
		public int compareTo(Data data) {
			return Integer.compare(y, data.y);
		}
	}
}


Measured memory_bytes: 89924
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const double eps = 1e-10;
const int maxn = 100 + 100;
int a[maxn];
int main() {
#ifdef ac
    //freopen("in.txt" , "r" , stdin);
//    freopen("out.txt" , "w" , stdout);
#endif
    int n;
    cin >> n;
    for(int i=1;i<=n;++i) {
        cin >> a[i];
    }
    long long mn=INF,flag=-100;
    for(int i=-100;i<=100;++i) {
        long long tmp=0;
        for(int j=1;j<=n;++j) {
            tmp+=(a[j]-i)*(a[j]-i);
        }
        if(tmp<mn)mn=tmp;
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
A1 = gets.chop.split.map(&:to_i)
A2 = gets.chop.split.map(&:to_i)
A3 = gets.chop.split.map(&:to_i)
N = gets.to_i
b = []
N.times { b << gets.to_i }
A1_bng= ['D','D','D']
A2_bng= ['D','D','D']
A3_bng= ['D','D','D']

for n in 0..N-1 do
	bs = b[n]
  	#puts bs
    for num in 0..2 do
      if bs == A1[num] then
        A1_bng[num] = bs
        #puts A1_bng
      elsif bs == A2[num] then
        A2_bng[num] = bs
        #puts A2_bng
      elsif bs == A3[num] then
        A3_bng[num] = bs
       	#puts A2_bng
      end
  	end
end
#puts A1_bng
#puts A2_bng
#puts A3_bng

# A1[0]
if A1_bng[0]!='D' && A1_bng[1]!='D' && A1_bng[2]!='D' then
    puts 'Yes'
elsif A1_bng[0]!='D' && A2_bng[0]!='D' && A3_bng[0]!='D' then
    puts 'Yes'
elsif A1_bng[0]!='D' && A2_bng[1]!='D' && A3_bng[2]!='D' then
    puts 'Yes'

# A1[2]
elsif A1_bng[2]!='D' && A2_bng[1]!='D' && A3_bng[0]!='D' then
    puts 'Yes'
elsif A1_bng[2]!='D' && A2_bng[2]!='D' && A3_bng[2]!='D' then
    puts 'Yes'

# A3[2]
elsif A3_bng[0]!='D' && A3_bng[1]!='D' && A3_bng[2]!='D' then
    puts 'Yes'

# 縦線中央
elsif A1_bng[1]!='D' && A2_bng[1]!='D' && A3_bng[1]!='D' then
    puts 'Yes'

# 横線中央
elsif A2_bng[0]!='D' && A2_bng[1]!='D' && A2_bng[2]!='D' then
    puts 'Yes'   

else 
    puts 'No'
end

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

char c1[3];
char c2[3];

using namespace std;

int main() {
  cin >> c1[0] >> c1[1] >> c1[2];
  cin >> c2[0] >> c2[1] >> c2[2];

  cout << (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0] ? "YES" : "NO")
       << endl;

  return 0;
}


Measured memory_bytes: 3608
S = input()

s = []
count = 0

for i in range(0, len(S)):
    s.append(S[i])

s = sorted(s)

a = s[0]
b = s[2]

for i in range(0, len(s)):
    if a == s[i] or b == s[i]:
        count += 1

if s[0] == s[2]:
    print('No')
elif count == 4:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

type Pair struct {
	X, Y int
}

func main() {
	var pairs []Pair

	for {
		var x, y int
		fmt.Scan(&x, &y)

		if x == 0 && y == 0 {
			break
		}

		pair := Pair{X: x, Y: y}
		pairs = append(pairs, pair)
	}

	for _, pair := range pairs {
		if pair.X < pair.Y {
			fmt.Println(pair.X, pair.Y)
		} else {
			fmt.Println(pair.Y, pair.X)
		}
	}
}



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

int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long ans=max(b*d,a*c);
	if (ans<0) ans=max(ans,max(a*d,b*c));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();C[d-P[f]?P[d]=f,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:d:0]=I++->second)d=I->first;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];a=H[a],S(*Z=O[c]=++b))X[c=a]=n;for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}


Measured memory_bytes: 37296
import math

m, d = map(int, input().split())
kotae=0

for k in range(m):
    for l in range(d):
        i=k+1
        j=l+1
        d1=j%10
        d10=int((j-d1)/10)
        if d1>=2 and d10>=2 and d1*d10==i:
            kotae+=1

print(kotae)

Measured memory_bytes: 40176
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    int H, W;
    void solve()
    {
        H = cin.nextint;
        W = cin.nextint;
        var C = new char[H][];
        for (int i = 0; i < H; i++)
        {
            C[i] = cin.next.ToCharArray();
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (C[i][j] == '#')
                {
                    Write('#');
                    continue;
                }
                int cnt = 0;
                for (int k = -1; k <= 1; k++)
                {
                    for (int l = -1; l <= 1; l++)
                    {
                        if (k == 0 && l == 0) continue;
 
                        int y = i + k;
                        int x = j + l;
                        if (y < 0 || y >= H || x < 0 || x >= W) continue;
                        if(C[y][x] == '#')cnt++;
                    }
                }
                Write(cnt);
            }
            WriteLine();
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
N = int(input())
H = list(map(int, input().split()))
import copy
H_memo = copy.copy(H)
cnt = 0
for i in range(N):
    cnt += H[i]
    if i < N-1 and H_memo[i] <= H_memo[i+1]:
        H[i+1] -= H_memo[i]
    elif i < N-1 and H_memo[i] > H_memo[i+1]:
        H[i+1] = 0
print(cnt)

Measured memory_bytes: 3572
array = list(map(int, input().strip().split(' ')))

N = array[0]

array1 = list(map(int, input().strip().split(' ')))

kazu = len(array1)

ans = 0

for i in range(N):

    ans = ans + array1[i]

heikin = ans / N

min_ans = 999
ans2 = 0

for i in  range(N):

    test = abs(array1[i] - heikin)
    

    if test < min_ans:

        min_ans = test
        ans2 = i

print(ans2)


Measured memory_bytes: 3064
import java.util.Scanner;

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

        int count5 = 0;
        int count7 = 0;
        for(String s: abc) {
            if(s.equals("5")) {
                count5++;
            } else if(s.equals("7")) {
                count7++;
            }
        }
        if(count5 == 2 && count7 == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int aa[123], bb[123], cc[123];
signed main() {
	int n, a, b, c, d, e, f, ans = 0; cin >> n;
	cin >> a;
	for (int h = 0; h < a; h++) {
		cin >> d; aa[d] = 1;
	}
	cin >> b;
	for (int h = 0; h < b; h++) {
		cin >> e; bb[e] = 1;
	}
	cin >> c;
	for (int h = 0; h < c; h++) {
		cin >> f; cc[f] = 1;
	}
	for (int h = 0; h <= n; h++) {
		if (cc[h] == 1) {
			if (bb[h] == 1) {
				ans++;
			}
			if (aa[h] == 0 && bb[h] == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
   cin>>s;
   l=s.length()-1;
   cout<<s;
   if(s[l]=='s') cout<<"es";
   else cout<<"s";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3648
n,m=map(int,input().split())
island=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    island[a].append(b)
    island[b].append(a)
for i in range(n+1):
    if 1 in island[i] and n in island[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Measured memory_bytes: 80844
n,m = map(int,input().split())
a = list(map(int,input().split()))
q = []
for i in a:
    q.append(-i)

import heapq
heapq.heapify(q)

while m>0:
    x = heapq.heappop(q)
    m-=1
    x = -(-x//2)
    heapq.heappush(q,x)

print(-sum(q))

Measured memory_bytes: 73196
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion

signed main() {
    FASTIO

    int n; cin>>n;
    vpii a = READ<pii>(n);
    min_heap<pii> pq;

    dsu ds(n);

    FOR(i,n) {
        pq.push({a[i].first, i});
    }

    map<int,int> yc;

    while(pq.size()) {
        int idx = pq.top().second;
        int y = a[idx].second;
        pq.pop();

        int miny = y;
        while(yc.size() && yc.begin()->first < y) {
            ds.merge(yc.begin()->second, idx);
            miny |= MIN(yc.begin()->first);
            yc.erase(yc.begin());
        }

        yc.insert({miny, idx});
    }

    FOR(i,n) {
        cout<<ds.size(i)<<endl;
    }

}

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

void func_c(int N) {
	int* A = new int[N];
	
	int max=0, max_index=0;
	int sub_max = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] > max) {
			sub_max = max;
			max = A[i];
			max_index = i;
		}
		else if (A[i] > sub_max) {
			sub_max = A[i];
		}
	}
	for (int i = 0; i < N; i++) {
			if (i != max_index)
				cout << max << endl;
			else
				cout << sub_max << endl;
	}

	free(A);
}

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


Measured memory_bytes: 2432
import sys
input = lambda: sys.stdin.readline().rstrip('\n')

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

r = 0
for rows in range(1<<H):
	for cols in range(1<<W):
		bl = 0
		for y, l in enumerate(C):
			if rows & (1<<y): continue

			for x, c in enumerate(l):
				if cols & (1<<x): continue

				if c == '#': bl += 1

		if bl == K:
			r += 1
print(r)


Measured memory_bytes: 68668
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,j,k;
    int num=0;
    vector<int> a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        a.push_back(k);
    }

    for(int i=0;i<n;i++){
        k=i;
        for(j=i+1;j<n;j++){
            k=a[k]<=a[j]?k:j;   //保证这个是稳定排序！
        }
        if(k!=i){
            num++;
            int temp=a[k];
            a[k]=a[i];
            a[i]=temp;
        }
    }
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        cout<<a[i];
    }
    cout<<endl<<num<<endl;
    return 0;
}



Measured memory_bytes: 3160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n, m;
char a[50][50], b[50][50];

int main(int argc, char **argv) {
	cin >> n >> m;
	REP(i, n) REP(j, n) cin >> a[i][j];
	REP(i, m) REP(j, m) cin >> b[i][j];
	REP(l, n - m + 1) REP(t, n - m + 1) {
		bool res = true;
		REP(i, m) REP(j, m) if (a[l + i][t + j] != b[i][j]) res = false;
		if (res) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;
int main()
{
  long long modV = 1000000007;
  int N, M;
  cin >> N >> M;
  vector<int> stop(N+1, 0);
  for (int i=0;i<M;i++) {
    int a;
    cin >> a;
    stop[a] = 1;
  }
  vector<long long> ans(N+1, 0);
  ans[0] = 1;
  for (int i=0;i<N;i++) {
    if (ans[i]>modV) ans[i] = ans[i] % modV;
    if (stop[i] == 1) continue;
    if (stop[i+1] == 0) {
      ans[i+1] += ans[i];
    }
    if (i+2 <= N && stop[i+2] == 0) {
      ans[i+2] += ans[i];
    }
  }
  cout << ans[N] % modV << endl;
  return 0;
}


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

int main(){
	int n;
	while( cin >> n ){
		if( n == 0 )
			break;
		int cnt[10] = {0};
		for(int i = 0;i < n;i++ ){
			int num;
			cin >> num;
			cnt[num]++;
		}
		for(int i = 0;i < 10;i++ ){
			if( cnt[i] == 0 ){
				cout << "-" << endl;
			}
			else{
				for(int j = 0;j < cnt[i];j++)
					cout << "*";
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;
    
    while (op != '\?') {
        scanf("%d %c %d", &a, &op, &b);
        switch (op) {
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
                break;
        }
    }
    
}


Measured memory_bytes: 1972
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
int main(){
	int x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
int m=Integer.parseInt(sc.next());
int f=Integer.parseInt(sc.next());
int r=Integer.parseInt(sc.next());
int score=m+f;
if(score+r==-3)break;
    if(m==-1||f==-1){
    System.out.println("F");
    }else if(score>=80){System.out.println("A");}else if(score>=65&&score<80){System.out.println("B");}
    else if(score>=50&&score<65){System.out.println("C");}else if(score<30){System.out.println("F");}
    else if(r>=50){System.out.println("C");}else{System.out.println("D");}
}
}
}


Measured memory_bytes: 26116
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,l = li()
a = list(li())

exist = False

for i, (ap, an) in enumerate(zip(a[:-1], a[1:])):
    if ap + an >= l:
        bef = [j+1 for j in range(i)]
        aft = [j+1 for j in range(n-2,i,-1)]
        ans = bef + aft + [i+1]
        exist = True
        break

if exist:
    print("Possible")
    for ai in ans:
        print(ai)

else:
    print("Impossible")

Measured memory_bytes: 14712
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt;
int fa[400010],F[400010],L[400010],N[400010],a[400010],Max[400010],size[400010],dfn[400010];
void add(int x,int y){
	a[++k]=y;
	if(!F[x])F[x]=k;
	else N[L[x]]=k;
	L[x]=k;
}
int ans[400010];bool vis[400010];
int calc(int x,int pre,int lim){
	int ret=!vis[x];vis[x]=1;
	for(rt i=F[x];i;i=N[i])if(a[i]!=pre&&a[i]<lim)ret+=calc(a[i],x,lim);
	return ret;
}

void dfs(int x,int pre){
	ans[x]=ans[pre];Max[x]=max(x,Max[pre]);fa[x]=pre;
	if(pre>Max[fa[pre]]||x>Max[fa[pre]]){
		if(!vis[x])ans[x]++,vis[x]=1;
		for(rt i=F[x];i;i=N[i])if(a[i]!=pre&&a[i]<Max[pre])ans[x]+=calc(a[i],x,Max[pre]);
	}
	for(rt i=F[x];i;i=N[i])if(a[i]!=pre)dfs(a[i],x);
}
int main(){
	//freopen("E.in","r",stdin);
	n=r;
	for(rt i=1;i<n;i++){
		x=r;y=r;
		add(x,y);
		add(y,x);
	}
	dfs(1,1);
	for(rt i=2;i<=n;i++)write(ans[i]),putchar(' ');
	return 0;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000000000000001
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n; cin>>n;
map<ll,ll>mp;
ll cnt = 0;
if(n%2==0)
{
    while(n%2==0)
    {
        n/=2;
        cnt++;
    }
    mp[2] = cnt;
}
for(ll i=3;i*i<=n;i+=2)
{
    while(n%i==0)
    {
        mp[i]++;
        n/=i;
    }
}
if(n>2)mp[n]++;
cnt = 0;
for(auto x:mp)
{
    ll ans = 0;
    ll l =0,r = 1e9;
    while(l<=r)
    {
        ll mid = l+(r-l)/2;
        ll val = (mid*(mid+1))/2;
        if(val<=x.se)
        {
            ans = mid;
            l = mid+1;
        }
        else r = mid-1;
    }
    cnt+=ans;
}
cout<<cnt<<endl;
return 0;
}
/*
5 10 10
22 23
17 19
13 17
8 12
2 6
*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
ll C[51][51];
void comb_table(int N){
	for(int i=0;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0 or j==i){
				C[i][j]=1LL;
			}else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			} 
		}
	}
}

ll COM(int n,int k){
	return C[n][k];
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,A,B;
	cin >> N >> A >> B;
	comb_table(N);
	vector<ll> v(N);
	rep(i,N)cin >> v[i];
	sort(v.rbegin(),v.rend());
	double ave = 0;
	rep(i,A)ave+=v[i];
	ave/=A;
	cout << fixed << setprecision(10) << ave << endl;
	if(v[0] != v[A-1]){
		int ic = 0;
		int sum= 0;
		rep(i,A)if(v[A-1]==v[i])ic++;
		rep(i,N)if(v[A-1]==v[i])sum++;
		cout << COM(sum,ic) << endl;
	}else{
		int sum = 0;
		rep(i,N)if(v[A-1]==v[i])sum++;
		long long ans = 0;
		for(int i=A;i<=min(sum,B);i++){
			ans += COM(sum,i);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 256