akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}
int gcd(int p,int q)
{
  if(p>q)swap(p,q);
  if(p==0)return q;
  else return gcd(q/p,p);
}

int main()
{
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  std::vector<int> h(N);
  std::vector<int> dp(N);
  for (size_t i = 0; i < N; i++) {
    /* code */
    cin>>h[i];
  }
  dp[0]=0;dp[1]=abs(h[1]-h[0]);
  for (int i = 2; i < N; i++) {
    dp[i]=INFINITY;
    for (int j = 0; j < K; j++) {
      if(i-j-1>=0){
        dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
      }
    }
  }
  cout<<dp[N-1];
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  int ans = 0;
  for (int x:a) {
    ans += x;
  }
  if (N >= ans) {
    cout << N-ans <<endl;
  }
  else {
    cout << -1 <<endl;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define ll long long
int main(){
  ll N,X;
  cin>>N>>X;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  ll ans=0;
  rep(i,N){
    X-=A[i];
    if(i!=N-1&&X>0||!X) ans++;
    else break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from math import ceil

N = int(input())
prv_t, prv_a = 1, 1
for _ in range(N):
  t,a = map(int,input().split())
  x = max(-(-prv_t//t), -(-prv_a//a))
  prv_t, prv_a = t*x, a*x
print(prv_t+prv_a)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[1005];
int main()
{
	string s;
	cin>>s;
	int a[256]={0};
	int f=1;
	for(int i=0;i<s.length();i++)
	{
		if(a[s[i]]>=1)
		{
			f=0;break;
		}
		else a[s[i]]++;
	}
	if(f)cout<<"yes";
	else cout<<"no";

}

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


int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a.at(i);
		--a.at(i);
	}
	int j = 0;
	rep(i,n){
		int k = a.at(j);
		j = k;
		if(k==1){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 640
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,m = I()
num = [l() for i in range(m)]
a = [-1]*n
for i in num:
    if a[i[0]-1] != -1:
        if a[i[0]-1] == i[1]:
            pass
        else:
            print(-1)
            sys.exit()
    else:
        a[i[0]-1] = i[1]

if n == 1:
    if a[0] == -1:
        print(0)
        sys.exit()
    else:
        print(a[0])
        sys.exit()

if a[0] == 0:
    print(-1)
else:
    a = [0 if i == -1 else i for i in a]
    if a[0] == 0:
        a[0] =1
    print("".join(map(str,a)))


Measured memory_bytes: 10516
#include <iostream>

using namespace std;

int main() {
    int i = 1, n;
    cin >> n;
    do {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x);
        }
    } while (++i <= n);
    cout << endl;
    return 0;
}



Measured memory_bytes: 3096
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let s = get!(i32);
    let l = s%100;
    let b = (s-l)/100;


    match b{
        1...12 => match l{
                        1...12 => println!("AMBIGUOUS"),
                            _  => println!("MMYY"),
        },
            _  => match l{
                        1...12 => println!("YYMM"),
                            _  => println!("NA"),
            },
    }

                    
}


Measured memory_bytes: 4352
import java.util.*;
import java.util.stream.Collectors;

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();
        int result = 0;

        for (int i = a; i <= b; i++) {
            for (int j = c; j <= d; j++) {
                if (i == j) {
                    result++;
                    break;
                }
            }
        }

        if (result > 0) {
            result--;
        }

        System.out.println(result);
    }
}

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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll num;
    for(int i=0;i < (1<<(s.size() - 1));i++){
        num = 0;
        rep(j,s.size() - 1){
            num += s.at(j) - '0';
            if(i & (1 << j)){
                ans += num;
                num = 0;
            }else{
                num *= 10;
            }
        }
        num += s.at(s.size() - 1) - '0';
        ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mod=1e9+7;
int n;
int a[100005];
using namespace std;
int main(){
	cin>>n;int x,ans=1;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	if(n%2)
	{
		if(a[0]!=1){cout<<0;return 0;
		}
		for(int i=2;i<=n-1;i+=2)
		   if(a[i]!=2){cout<<0;return 0;
		}
	}
	else
	   for(int i=1;i<=n-1;i+=2)
		   if(a[i]!=2){cout<<0;return 0;
		}
	for(int i=1;i<=n/2;i++)
	   ans=(ans*2)%mod;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c , k;
  cin >> a >> b >> c >> k;
  cout << max({a * pow(2, k) + b + c, b * pow(2, k) + a + c, c * pow(2, k) + b + a}) << endl;
}

Measured memory_bytes: 256
def solve():
    W, H, N = map(int,input().split())
    area = [[True] * W for i in range(H)]
    for i in range(N):
        x,y,a = map(int,input().split())
        x -= 1
        y -= 1

        if a == 1:
            for h in range(H):
                for w in range(W):
                    if w > x:
                        continue
                    area[h][w] = False
        elif a == 2:
            for h in range(H):
                for w in range(W):
                    if w <= x:
                        continue
                    area[h][w] = False
        elif a == 3:
            for h in range(H):
                if h > y:
                    continue
                for w in range(W):
                    area[h][w] = False
        else:
            for h in range(H):
                if h <= y:
                    continue
                for w in range(W):
                    area[h][w] = False
        

    cnt = 0
    for h in range(H):
        for w in range(W):
            if area[h][w]:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    solve()

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

int main()
{
    int a, b;
    cin >> a >> b;
    bool fin = false;
    int i = 0;
    if (b == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        while (!fin)
        {
            i++;
            if (i * a - i + 1 >= b)
            {
                cout << i << endl;
                fin = true;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

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

ll even_count(ll x){
  ll count = 0;
  while(x % 2 == 0){
    count++;
    x /= 2;
  }
  return count;
}

int main(){
  ll n, m;
  cin >> n >> m;
  ll x = 1;
  ll a;
  bool flag = false;
  ll count;
  ll prev = -1;
  rep(i, n){
    cin >> a;
    a /= 2;
    x = lcm(x, a);
    if (a == 1) continue;
    else if (prev == -1){
      prev = even_count(a);
      continue;
    }
    else{
      count = even_count(a);
      if (prev != count){
        flag = true;
        break;
      }
    }
  }
  if (flag)
    cout << 0 << endl;
  else{
    ll ans = (m + x) / (2 * x);
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())
Ans=[0 for i in range(1,N)]
X-=1;Y-=1
for i in range(N-1):
  for j in range(i+1,N):
    if i<=X:
      if j<=X:
        d=j-i
      elif X<j<Y:
        d=min(j-i,X-i+1+Y-j)
      else:
        d=X-i+1+j-Y
    elif X<i<Y:
      if X<j<Y:
        d=min(j-i,i-X+1+Y-j)
      else:
        d=min(j-i,i-X+1+j-Y)
    else:
      d=j-i
    #print(i,j,d)
    Ans[d-1]+=1
for a in Ans:
  print(a)

Measured memory_bytes: 47196
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	if (c>=d&&c>=e)  cout<<c;
	else if (d>=c&&d>=e)  cout<<d;
		 else if (e>=c&&e>=d)  cout<<e;
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//std out
template<typename T>
void print_container(const vector<T> vals) {
    REPinit(i, 0, vals.size() - 1) cout << vals.at(i) << " ";
    cout << vals.back();
}


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    int K, X;
    cin >> K >> X;

    vector<int> ans;
    REPinit(i, X - K + 1, X + K) {
        ans.push_back(i);
    }
    print_container(ans);


    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N, M;
    std::cin >> N >> M;
    string ans(N, 'x');
    REP(i, M) {
        int s, c;
        std::cin >> s >> c;
        auto cc = '0' + c;
        if(ans[s - 1] == 'x') {
            ans[s - 1] = cc;
        }
        else if(ans[s - 1] != cc) {
            ans = "-1";
            break;
        }
    }

    if((ans.front() == '0' && ans.size() != 1) || ans == "-1") {
        std::cout << -1 << std::endl;
    }
    else {
        if(ans.front() == 'x') {
            ans.front() = ans.size() == 1 ? '0' : '1';
        }
        for(auto& v : ans) {
            if(v == 'x') v = '0';
        }
        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
from itertools import combinations


def main():
    n = int(input())
    L = [int(e) for e in input().split()]

    ans = 0
    for t in combinations(range(n), 3):
        i, j, k = t
        if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[i] + L[j] \
                and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68224
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
const int mxn=1000;
int n,m;
vector<string> mat;
const int mod=1e9+7;
int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		cin>>n>>m;
		for(int i=0;i<n;i++)
		{
			string s;
			cin>>s;
			mat.push_back(s);
		}
		ll dp[n][m];
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(mat[i][j]=='.')
				{
					if(j-1>=0&&mat[i][j-1]=='.')
					{
						dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
					}
					if(i-1>=0&&mat[i-1][j]=='.')
					{
						dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
					}
				}
			}
		}
		cout<<dp[n-1][m-1]<<'\n';
		
	}
		
}


Measured memory_bytes: 12408
#include<stdio.h>

int main(){
    int m,f,r;

    while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1 && f==-1 && r==-1)
        break;
    else if(m==-1 || f==-1)
        printf("F\n");
    else if(80<=(m+f))
        printf("A\n");
    else if(65<=(m+f) && (m+f)<80)
        printf("B\n");
    else if(50<=(m+f) && (m+f)<65)
        printf("C\n");
    else if(30<=(m+f) && (m+f)<50){
        if(50<=r)
            printf("C\n");
        else
            printf("D\n");
    }
    else if((m+f)<30)
        printf("F\n");
    }
return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c;
    int num[12];
 while(cin>>a>>b>>c&&a&&b&&c)
 {
     memset(num,0,sizeof(num));
     num[a]++;
     num[b]++;
     num[c]++;
     if(num[5]==2&&num[7]==1)
        cout<<"YES"<<endl;
     else
        cout<<"NO"<<endl;



 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO
    // L(T)
    {
        lli a, b, c, k;
        cin >> a >> b >> c >> k;
        if (k <= (a))
        {
            cout << k;
            return 0;
        }
        if (k <= (a + b))
            cout << a;
        else
        {
            cout << a * 2 + b - k;
        }
    }
    return 0;
}

Measured memory_bytes: 3692
import sys
import itertools
import bisect
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K,N = IL()
a = IL()

num = K+a[0] - a[-1]
for i in range(N-1):
  num = max(num, a[i+1]-a[i])
print(K-num)

Measured memory_bytes: 77388
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int A=nextInt();
		int B=nextInt();
		int C=nextInt();
		int D=nextInt();
		int E=nextInt();

		int[] x = {A,B,C,D,E};
		int max = 0;
		long ans = 0;
		for(int i=0;i<x.length;i++){
			ans+=((x[i]+9)/10)*10 ;
			max = Math.max(max, ((x[i]+9)/10)*10 - x[i]);
		}
		System.out.println(ans-max);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x/gcd(x,y)*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


string L;
int dp[100010][2];


signed main(){
    cin >> L;

    dp[0][1] = 1;
    rep(i, 0, SZ(L)) rep(j, 0, 2){
        if(L[i] == '1' && j) CHADD(dp[i+1][0], dp[i][j]), CHADD(dp[i+1][1], MUL(2, dp[i][j]));
        else if(L[i] == '1') CHADD(dp[i+1][0], dp[i][j]), CHADD(dp[i+1][0], MUL(2, dp[i][j]));
        else if(j) CHADD(dp[i+1][1], dp[i][j]);
        else CHADD(dp[i+1][0], dp[i][j]), CHADD(dp[i+1][0], MUL(2, dp[i][j]));
    }

    cout << ADD(dp[SZ(L)][0], dp[SZ(L)][1]) << endl;

    return 0;
}

Measured memory_bytes: 2048
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll n, ans = 0;
	string s, x = "", y = "ABC";
	cin >> n >> s;
	for(int i=0;i<n;i++) {
		x = "";
		x+=s[i];
		x+=s[i+1];
		x+=s[i+2];
		if(x==y) ans++;
	}
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    //cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define kosu 100000
int main() {
    string isi;
    cin>>isi;

    int ans=0;
    for(int i=1;i<isi.size();i++){
        if(isi[i]!=isi[i-1]){
            ans++;
        }
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> p(n); for (auto&& e : p) cin >> e;
  int res = 0;
  for (int i = 1; i + 1 < n; ++i) {
    V<> v{p[i - 1], p[i], p[i + 1]};
    sort(begin(v), end(v));
    res += p[i] == v[1];
  }
  cout << res << '\n';
}

Measured memory_bytes: 892
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;
ll cal(int wt,vi &w,vi &v,vector<vector<ll>> &dp,int n){
	if(n==0 || wt==0)return 0LL;

	if(dp[n][wt]!=-1){
		return dp[n][wt];
	}

	dp[n][wt]=cal(wt,w,v,dp,n-1);
	if(w[n-1]<=wt){
		dp[n][wt]=max(dp[n][wt],v[n-1]+cal(wt-w[n-1],w,v,dp,n-1));
	}

	return dp[n][wt];
}
void solve(){
	int i,j;
	int n,wt;
	cin >> n >> wt;
	vector<int> w(n),v(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n+1,vector<ll>(wt+1,-1));

	printf("%lld\n",cal(wt,w,v,dp,n));
	
}


int main(){
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 83076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod =1000000007;
ll fun(int n)
{
	ll ans=1;
	while(n)
	{
		ans*=n;
		ans%=mod;
		n--;
	}
	return ans;
}
int main()
{
	ll ans=0;
	int n,m;
	scanf("%d%d",&n,&m);
	if(n<m)
		swap(n,m);
	if(n-m>1)
		ans=0;
	else 
	{
		ans+=(fun(n)*fun(m))%mod;
		if(n-m+1==1)
			ans=(ans*2)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>

using namespace std;

#define ZZZ -1000000007

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

	int a[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	sort(a, a + m);

	int sum = 0;
	int sa[m-1];

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

	sort(sa, sa + m - 1);

	long long int ans = 0;

	for (int i = 0; i < m  - n; i++) {
		ans += sa[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

void solve() {
	ll k, x;
	cin >> k >> x;
	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.nextInt());
        }
        out.println(set.size() == n ? "YES" : "NO");
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 59156
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int tt;
    tt = 1;
    while (tt--)
    {
        string s, t; cin >> s; cin >> t;
        int i, j, count = 0;
        vector<int> v;
        //cout << s.length() - t.length() << " " << endl;
        for (i = 0; i <= (s.length() - t.length()); i++)
        {
            count = 0;
            for (j = i; j < i + t.length(); j++)
            {
                if (s[j] != t[j - i])
                {
                    count++;
                }
            }
            //cout << count << " " << endl;
            v.push_back(count);
        }
        sort(v.begin(), v.end());
        cout << v[0] << " " << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
// Accepted.
#include <iostream>
#include <list>
#include <vector>
using namespace std;

struct Point {
  int x,y,top;
  Point(int x, int y): x(x),y(y),top(0) {}
};
ostream& operator<<(ostream& s, const Point& x) {
  return s<< "(" << x.x << "," << x.y << ")";
}

struct Data {
  int x,y,h;
  Data(): x(0),y(0),h(0) {}
  Data(int x, int y, int h): x(x),y(y),h(h) {}
};
ostream& operator<<(ostream& s, const Data& x) {
  return s<< "(" << x.x << "," << x.y << "," << x.h << ")";
}
void p(const vector<Data>& xs) {
  cout<< xs.size() << ": ";
  for (const auto& x:xs) cout<< x <<",";
  cout<<endl;
}

int N;
list<Point> pyramids;
vector<Data> datas;
int main() {
  for(int y=0;y<=100;y++) for(int x=0;x<=100;x++) pyramids.push_back(Point(x,y));
  scanf("%d", &N);
  Data t;
  for(int n=0;n<N;n++) {
    int x,y,h; scanf("%d%d%d",&x,&y,&h); datas.push_back(Data(x,y,h));
    if(h>=1) t=datas.back();
  }
  for(auto it = pyramids.begin(); it != pyramids.end(); ++it) {
    Point& pyramid=*it;
    pyramid.top = t.h + abs(pyramid.x-t.x) + abs(pyramid.y-t.y);
    for(const auto& data:datas) {
      const int h = max(pyramid.top - abs(data.x - pyramid.x)
                                    - abs(data.y - pyramid.y),
                        0);
      if (h != data.h) {
        it = pyramids.erase(it);
        --it;
        break;
      }
    }
  }
  Point pyramid = pyramids.front();
  printf("%d %d %d\n", pyramid.x, pyramid.y, pyramid.top);
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<string,string> pcc;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(i%2&&x%2)
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
t = gets.strip
s = gets.strip

s = s.split

for n in 0...s.length
    s[n] = s[n].to_i
end


while s.length > 1
    s = s.sort
    b = (s[0] + s[1])/2.to_f
    s.shift(2)
    s.push(b)
end


print s[0]

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        cout << (N / 2) * (N - N / 2) << endl;

        return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// vector<int>を渡してあげると、それを元に遅延セグメント木を構築する。
// 区間加算です。いじれそうだったらいじって。

struct LazySegmentTree {
 private:
  int n;  // 最下段のノード数
  vector<ll> node, lazy;

 public:
  LazySegmentTree(vector<ll> v) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;  // 元のサイズ以上の最小の2冪
    node.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);

    // 最下段に突っ込む
    for (int i = 0; i < sz; i++) node[(n - 1) + i] = v[i];

    // 最下段以外を更新していく(下から上に)
    for (int i = n - 2; i >= 0; i--) {
      node[i] = node[i * 2 + 1] + node[i * 2 + 2];
    }
  }

  // 遅延評価をk番目について行う
  void eval(int k, int l, int r) {
    // 遅延配列が空でないなら、自ノード及び子ノードに伝搬する
    if (lazy[k]) {
      node[k] += lazy[k];

      // 最下段ならここは実行されません
      if (r - l > 1) {
        lazy[k * 2 + 1] += lazy[k] / 2;
        lazy[k * 2 + 2] += lazy[k] / 2;
      }
      lazy[k] = 0;  // 自分のぶんは役目を果たしたので
    }
  }

  // [a,b)に遅延評価をする。[l,r)は今呼ばれている区間。上から降りていく。
  void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
    // 右端を要素の長さに
    if (r < 0) r = n;
    // まず呼ばれたので自分の所に遅延評価を施す
    eval(k, l, r);
    // 俺は関係ない
    if (r <= a || b <= l) return;
    // 完全に範囲に入っているので
    if (a <= l && r <= b) {
      lazy[k] += (r - l) * x;  // 横幅ぶん掛けたのを足す
      eval(k, l, r);
    } else {  // 部分的に重なっているので子ノードに投げる
      add(a, b, x, k * 2 + 1, l, (l + r) / 2);
      add(a, b, x, k * 2 + 2, (l + r) / 2, r);
      node[k] = node[k * 2 + 1] + node[k * 2 + 2];
    }
  }

  // [a,b) 中の結果を返す。[l,r)は対象区間の左端と右端。
  ll getsum(int a, int b, int now = 0, int l = 0, int r = -1) {
    // 右端を初期化
    if (r < 0) r = n;

    // 俺は関係ないとき -> 答えの邪魔にならない値を返す
    if (r <= a || b <= l) return 0;

    // ここまで来た時点で少なくとも重なっているので、遅延評価
    eval(now, l, r);

    // 要求区間の中にノードがすっぽり入ってる → 計算候補として返す
    if (a <= l && r <= b) return node[now];

    // ノードの一部分だけ要求区間に入ってる → 子を再帰的に探索する
    ll vl = getsum(a, b, 2 * now + 1, l, (l + r) / 2);  // 子(左)
    ll vr = getsum(a, b, 2 * now + 2, (l + r) / 2, r);  // 子(右)
    return vl + vr;
  }
};

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

int main() {
  int n, q, c, s, t, x;
  cin >> n >> q;
  vector<ll> v(n, 0);
  LazySegmentTree seg(v);
  for (int i = 0; i < q; i++) {
    cin >> c >> s >> t;
    s--;  // tは半開区間なので引かない
    if (c == 0) {
      cin >> x;
      seg.add(s, t, x);
    } else {
      cout << seg.getsum(s, t) << endl;
    }
  }
}



Measured memory_bytes: 8360
#include<bits/stdc++.h>
using namespace std;
int n, num[20];
long long dfs(int l, int r, int x, int y)
{
	if (l + 1 >= r)return 0;
	long long res = 1e18;
	for (int i = l + 1; i <= r - 1; i++)
		res = min(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + 1LL * (x + y) * num[i]);
	return res;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> num[i];
	cout << num[1] + num[n] + dfs(1, n, 1, 1) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
string m[21][21];

vector<vector<int>> dxy = {{1,0},{-1,0},{0,-1},{0,1}};
deque<pair<int,int>> dq;

int main() {
  priority_queue<int,vector<int>,greater<int> > pq;
  int n ;
  cin >> n;
  int p[n];
  for(int i = 0;i<n;i++){
    cin >> p[i];
  }
  int res = 1;
  pq.push(p[0]);
  for(int i = 1 ; i< n; i++){
    if(p[i] <= pq.top()){ res++;}
    pq.push(p[i]);
  }
  
  cout << res << endl;
 }

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

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

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

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

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


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

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

  int N; cin >> N;
  string S; cin >> S;

  string ws = "WS";
  string ans(N, '0');
  REP(x0,2) REP(x1,2){
	ans[0] = ws[x0];
	ans[1] = ws[x1];
	
	for(int i=1;i+1<N;++i){
	  if(ans[i] == 'S'){
		if(S[i] == 'o'){
		  ans[i+1] = ans[i-1];
		}
		else{
		  ans[i+1] = (ans[i-1]=='S'?'W':'S');
		}
	  }
	  else{
		if(S[i] == 'x'){
		  ans[i+1] = ans[i-1];
		}
		else{
		  ans[i+1] = (ans[i-1]=='S'?'W':'S');
		}
	  }
	}
	bool ok = true;
	if(ans.back() == 'S'){
	  if(S.back() == 'o')
		ok = ok && ans[N-2] == ans[0];
	  else
		ok = ok && ans[N-2] != ans[0];
	}
	else{
	  if(S.back() == 'x')
		ok = ok && ans[N-2] == ans[0];
	  else
		ok = ok && ans[N-2] != ans[0];
	}
	if(ans[0] == 'S'){
	  if(S[0] == 'o')
		ok = ok && ans[N-1] == ans[1];
	  else
		ok = ok && ans[N-1] != ans[1];
	}
	else{
	  if(S[0] == 'x')
		ok = ok && ans[N-1] == ans[1];
	  else
		ok = ok && ans[N-1] != ans[1];
	}

	if(ok){
	  cout << ans << endl;
	  return 0;
	}
  }
  cout << -1 << endl;

  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,s,c=0,o;
	scanf("%d%d",&k,&s);
		for(int x=0;x<=k;x++)
		{
            for(int y=0;y<=k;y++)
            {
                int o=s-(x+y);
                if(o>=0&&o<=k)
                    c++;
            }
	   }
	   printf("%d",c);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<int> m(26, 0);
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] == 'C') m[s[i]-'A']++;
        else if (s[i] == 'F') {
            if (m['C'-'A']) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
CSF=[list(map(int,input().split())) for _ in range(N-1)]
INF=10**9+7

for i in range(N):
    t=0
    for j in range(i,N-1):
        c,s,f=CSF[j]
        t=max(s, t if t%f==0 else t+f-t%f)
        t+=c
    print(t)

Measured memory_bytes: 43116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        if(a[i]==i+1){
            if(i!=n-1) swap(a[i],a[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    vec C(N, 0);
    ll cnt = 1;
    if(A[0] == 0) ++C[0];
    else cnt = 0;
    REP(i,1,N) {
        if(C[A[i]] >= 3) {
            cnt = 0;
            break;
        }
        else {
            if(A[i] >= 1) cnt = cnt * (C[A[i]-1] - C[A[i]]) % MOD;
            ++C[A[i]];
        }
    }
    if(C[0] == 1) cnt = (cnt * 3) % MOD;
    else cnt = (cnt * 6) % MOD;
    PR(cnt);


    return 0;
}

/*



*/

Measured memory_bytes: 4812
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    ll buf=n;
    ll m=0;
    while(buf>0){
        m+=buf%10;
        buf/=10;
    }
    if(n%m==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

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



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

    int h, r;
	cin >> h >> r;
	if (h + r < 0) cout << -1 << endl;
	else if (h + r == 0) cout << 0 << endl;
	else cout << 1 << endl;

    return 0;
}





Measured memory_bytes: 3168
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
    fmt.Scan(&s)

	n := len(s)
	rs := []rune(s)
	dp := make([][]int,n+1)
	for i := range(dp) {
		dp[i] = make([]int,13)
	}
	dp[0][0] = 1
	for i:=0; i<len(s); i++ {
		if rs[i] != '?' {
			j,_ := strconv.Atoi(string(rs[i]))
			for k := 0; k < 13; k++ {
				dp[i+1][(k*10+j)%13] += dp[i][k]
			}
		} else {
			for j := 0; j < 10; j++ {
				for k:= 0; k < 13; k++ {
					dp[i+1][(k*10+j)%13] += dp[i][k]
				}
			}
		}
		for j := 0; j <13; j++ {
			dp[i+1][j] %= 1e9+7
		}
	}
	fmt.Println(dp[n][5])
}

Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
string s;
int ans = 1;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N >> s;
    rep1(i, N-1) {
        if (s[i-1] != s[i]) ans++;
    }

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

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

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

    int ans;
    if (N % (2 * D + 1) == 0) {
        ans = N / (2 * D + 1);
    } else {
        ans = N / (2 * D + 1) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
while line = gets
  h, w = line.chomp.split(" ").map(&:to_i)
  break if h == 0 && w == 0
  puts '#' * w
  (h - 2).times do
    print '#', '.' * (w - 2), '#', "\n"
  end
  puts '#' * w
  puts "\n"
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define N 100005
typedef long long ll; 
using namespace std;
int main()
{
    int n,a,b;scanf("%d%d%d",&n,&a,&b);
    if((a-b)&1)puts("Borys");
    else puts("Alice");
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int mod=1e9+7,N=200005,inf=0x3f3f3f3f;
vector<int> orz[N];
int mi=inf,mic,mii,X,Y,ans,js,n,a[N],fac[N],ni[N];
int ksm(int x,int y) {
	int re=1;
	for(;y;y>>=1,x=1LL*x*x%mod) if(y&1) re=1LL*re*x%mod;
	return re;
}
int main()
{
	int c,w;
	n=read(),X=read(),Y=read();
	for(RI i=1;i<=n;++i) {
		c=read(),w=read(),orz[c].push_back(w);
		if(w<=mi) mii=mi,mi=w,mic=c;
		else if(w<mii) mii=w;
	}
	for(RI i=1;i<=n;++i) sort(orz[i].begin(),orz[i].end());
	for(RI i=1;i<=n;++i) {
		if(!(int)(orz[i].size())) continue;
		if(i==mic) {
			a[i]=1,++js;
			for(RI j=1;j<orz[i].size();++j)
				if(orz[i][j]+mii<=Y||orz[i][j]+orz[i][0]<=X) ++a[i],++js;
		}
		else {
			if(orz[i][0]+mi>Y) continue;
			a[i]=1,++js;
			for(RI j=1;j<orz[i].size();++j)
				if(orz[i][j]+mi<=Y||orz[i][j]+orz[i][0]<=X) ++a[i],++js;
		}
	}
	fac[0]=1;for(RI i=1;i<=n;++i) fac[i]=1LL*fac[i-1]*i%mod;
	ni[n]=ksm(fac[n],mod-2);
	for(RI i=n-1;i>=0;--i) ni[i]=1LL*ni[i+1]*(i+1)%mod;
	ans=fac[js];
	for(RI i=1;i<=n;++i) ans=1LL*ans*ni[a[i]]%mod;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 11648