akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
const LL INF = 1LL << 60;
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
LL dp[100010];
const LL N=100010;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int n, k;
    cin >> n >> k;
    VI h(n);
    REP(i,n){
      cin >> h[i];
    }
    REP(i,n) dp[i] = MOD;
    dp[0]=0;
    for(int i=1; i<n; i++){
      int tmp = min(k,i);
      for(int j=1; j<tmp+1; j++)
        chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n-1] << endl;
  }

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

int a[(int)1e5 + 10];
int n;

void solve() {
	cin >> n;
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (a[n - 1] - a[0] > 2) {
		cout << "No" << endl;
	} else if (a[n - 1] == a[0]) {
		if (a[0] + 1<= n && (2 * a[0] <= n || a[0] + 1 == n)) {
			cout << "Yes" << endl;
		} else cout << "No" << endl;
	} else if (a[n - 1] - a[0] == 1) {
		int k = upper_bound(a, a + n, a[0]) - lower_bound(a, a + n, a[0]);
		int k2 = upper_bound(a, a + n, a[n - 1]) - lower_bound(a, a + n, a[n -1]);
		if (a[n - 1] <= n + 1 && a[0] >= k && 2 * (a[0] - k + 1) <= k2) {
			cout << "Yes" << endl;
		} else cout << "No" << endl;
	} else cout << "No" << endl;
}

int main() {
	solve();
	//test();
	return 0;
}

Measured memory_bytes: 640
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;
typedef long long ll;

int n;
int a[100100], b[100100], c[100100];
int dp[100100][3];
int ans;

int rec(int x, int y)
{
  if (dp[x][y] >= 0)
  {
    return dp[x][y];
  }
  else
  if (x == n)
  {
    ans = 0;
  }
  else
  {
    if (y == 0)
    {
      ans = a[x] + max(rec(x + 1, 1), rec(x + 1, 2));
    }
    if (y == 1)
    {
      ans = b[x] + max(rec(x + 1, 0), rec(x + 1, 2));
    }
    if (y == 2)
    {
      ans = c[x] + max(rec(x + 1, 0), rec(x + 1, 1));
    }
  }
  return dp[x][y] = ans;
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      dp[i][j] = -1;
    }
  }
  cout << max({rec(0, 0), rec(0, 1), rec(0, 2)}) << "\n";
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {
  int n,wt ;cin >> n>> wt;
  vector<int>w(n+1),v(n+1) ;
  for(int i=1;i<=n;i++)
    cin >> w[i] >> v[i] ;
  vector<vector<int>>dp(n+1,vector<int>(wt+1));
  for(int i=1;i<=n;i++)
    for(int j=0;j<wt+1;j++)
      dp[i][j] =max(dp[i-1][j],(j>=w[i]?dp[i-1][j-w[i]]+v[i]:-1)) ;
  cout << dp[n][wt] ;
}


Measured memory_bytes: 83096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n,i,j,k; cin>>n>>k; int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    if(n==k) cout<<1;
    else
    {
        int res=1;n=n-k;
        res+=n/(k-1);
        if(n%(k-1)!=0) res++;
        cout<<res;
    }


}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		StringBuilder sb = new StringBuilder(s);
		String akb = "AKIHABARA";
		if(n > 9) {
			System.out.println("NO");
			return;
		}
		for(int i = 0 ; i < 9 ; i++) {
			if(sb.length() > i && sb.charAt(i) == akb.charAt(i)) continue;
			sb.insert(i, "A");
			if(sb.charAt(i) != akb.charAt(i)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 22996
def solve2():
    N = int(raw_input())
    s = [int(_) for _ in raw_input().split()]
    ans = 0
    pass_set = set()
    for C in range(1, N - 1):
        pass_set.clear()
        maxK = (N - 1) / C
        score = 0 # when k = 0: 0 -> (N - 1)
        for k in range(1, maxK+1):
            if N - 1 - k*C < C:
                break
            if (N-1-k*C) in pass_set or k*C in pass_set or (N-1-k*C) == k*C:
                break
            else:
                score += s[N-1-k*C] + s[k*C] # DP
                pass_set.add(N-1-k*C)
                pass_set.add(k*C)
            ans = max(ans, score)
    print ans

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 102340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  int M=N;
  int S=0;
  while(N>0){
    S+=N%10;
    N/=10;
  }
  cout<<(M%S==0 ? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

int n;
cin>>n;
int ans=0;
for1(i,n)
{
  int x;
  cin>>x;
  if(x%2&&i%2)ans++;
}
cout<<ans;

    return 0;
  }


Measured memory_bytes: 3604
I,O,T,J,L,S,Z=gets.split.map(&:to_i)

ans=2*(I/2)+2*(L/2)+2*(J/2)+O
temp=0
temp+=1 if I%2==1
temp+=1 if J%2==1
temp+=1 if L%2==1
ans+=3 if temp==3
ans+=1 if temp==2 && I>0 && J>0 && L>0
puts ans


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var count = Enumerable.Range(1, N).Where(n => n % 2 == 1).Where(n => Divisors(n).Count() == 8).Count();
            Console.WriteLine(count);
        }

        public static IEnumerable<int> Divisors(int n) => Enumerable.Range(1, n).Where(x => n % x == 0);
    }

Measured memory_bytes: 28364
#include<algorithm>
#include<iostream>

using namespace std;

const long long int N = 200005;
const long long int MOD = 998244353;
long long int x[N], y[N];
long long int power[N];
int tree[N][2];
int revert[N];

struct block{
  long long int value;
  int index;
};

bool compare(block Block1, block Block2){
  return Block1.value < Block2.value;
}

block x_block[N], y_block[N];

void update(int val, int index, int k, int n){
  while(index <=n){
    tree[index][k] += val;
    index += index & (-index);
  }
}

int query(int index, int k){
  int sum = 0;
  while(index > 0){
    sum += tree[index][k];
    index -= index & (-index);
  }

  return sum;
}

int main(){
  int n;
  long long int sum = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i){
    cin >> x[i] >> y[i];
    x_block[i].value = x[i];
    x_block[i].index = i;
    y_block[i].value = y[i];
    y_block[i].index = i;
  }

  sort(x_block + 1, x_block + n + 1, compare);
  sort(y_block + 1, y_block + n + 1, compare);

  for (int i = 1; i <= n; ++i){
      revert[y_block[i].index] = i;
  }


  power[0] = 1;
  for (int i = 1; i <=n; ++i){
    update(1, i, 1, n);
    power[i] = power[i - 1] * 2 % MOD;
  }

  for (int i = 1; i <=n; ++i){
    int index = revert[x_block[i].index];
    update(-1, index, 1, n);
    int zone3 = query(index, 0);
    int zone2 = i - 1 - zone3;

    int zone4 = query(index, 1);
    int zone1 = n - i - zone4;
    update(1, index, 0, n);

    sum = (sum + power[n - 1]) % MOD;
    sum = (sum + (((power[zone1] - 1) * (power[zone3] - 1) % MOD) * power[zone2] % MOD) * power[zone4] % MOD) % MOD;
    sum = (sum + (((power[zone2] - 1) * (power[zone4] - 1) % MOD) * power[zone1] % MOD) * power[zone3] % MOD) % MOD;
    sum = (sum + MOD - (((power[zone1] - 1) * (power[zone3] - 1) % MOD) * (power[zone2] - 1) % MOD) * (power[zone4] - 1) % MOD) % MOD;
  }

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


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    bool r = false;
    string S;
    cin >> S;
    i32 ans = 0;
    for (i32 i = 0; i < S.size(); i++) {
        if (S[i] == 'R') {
            if (r) ans++;
            else ans = 1, r = true;;
        } else r = false;
    }
    cout << ans << endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, d; cin >> N >> d;
    int work = d;
    int ans = 1;
    while(work <= N){
        work *= d;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
dic=dict()
for i in range(n):
  if d[i] not in dic:
    dic[d[i]]=1
  else:
    dic[d[i]]+=1
if d[0]!=0 or dic[0]>1:
  print(0)
else:
  l=list(dic.items())
  l.sort()
  ans=1
  for i in range(len(l)-1):
    if l[i][0]+1==l[i+1][0]:
      ans*=l[i][1]**l[i+1][1]
    else:
      print(0)
      exit()
  print(ans%998244353)

Measured memory_bytes: 20208
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
// #define max_n 

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll max_n=n+1;
	vector<ll> ans(max_n,1);
	vector<bool> prime(max_n,true);
	for (int i = 2; i < max_n; ++i)
	{
		if(prime[i]==true)
		{
			// deb(i)
			for (int j = 2*i; j < max_n; j+=i)
			{
				ll c=0;
				ll temp=j;
				while(temp%i==0)
				{
					c++;
					temp/=i;
				}
				ans[j]*=(c+1);
				prime[j]=false;
			}
			ans[i]=2;
		}
	}
	ll fans=0;
	for (int i = 1; i <= n; ++i)
	{
		// cout<<ans[i]<<endl;
		fans+=(i*ans[i]);
	}
	cout<<fans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 82656
class BIT:
  
  def __init__(self, N):
    self.n = N
    self.tree = [0]*(self.n+1)
    
  def bsum(self, i):
    s = 0
    while i:
      s += self.tree[i]
      i -= i&(-i)
    return s
  
  def badd(self, i, x):
    while i<=self.n:
      self.tree[i] += x
      i += i&(-i)
  
  def bsearch(self, x):
    i = 0
    s = 0
    step = 1<<(self.n.bit_length()-1)
    while step:
      if i+step<=self.n and s+self.tree[i+step]<x:
        i += step
        s += self.tree[i]
      step >>= 1
    return i+1

      
N = int(input())
P = [0]+[int(c) for c in input().split()]

ntoi = [0]*(N+1)
for i in range(N+1):
  ntoi[P[i]] = i

bit = BIT(N)

ans = 0
for m in range(N, 0, -1):
  I = ntoi[m]
  L = bit.bsum(I)
  bit.badd(I,1)
  R = N-L-m
  a = bit.bsearch(L-1) if L>1 else 0
  b = bit.bsearch(L) if L>0 else 0
  c = bit.bsearch(L+2) if R>0 else N+1
  d = bit.bsearch(L+3) if R>1 else N+1
  coef = 0
  if b!=0:
    coef += (b-a)*(c-I)
  if c!=0:
    coef += (I-b)*(d-c)
  ans += m*coef

print(ans)

Measured memory_bytes: 58860
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,R = MI()
	if(N <10):
		print(R + 100 * (10-N))
	else:
		print(R)

if __name__ == '__main__':
	main()

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in();
	int B=ceil(A/1.08);
	int C=int(B*1.08);
	if(A!=C) out(":(");
	else out(B);
	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	double sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end());
	double border = sum / (4 * m);
	if (a[n-m] >= border)print("Yes");
	else print("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (x < a[i - 1] + a[i]) {
            int t = a[i - 1] + a[i] - x;
            ans += t;
            if (t > a[i]) a[i] = 0;
            else a[i] -= t;
        }
    }
    cout << ans << endl;
}

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

int N;
vector<int> A;

int main(){
  cin >> N;
  A.resize(N);
  int m = 0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[m] < A[i])
      m = i;
  }
  int cur = 0;
  for(int i=0; i<N; i++){
    if(i != m && abs(A[m]/2.0 - A[i]) <= abs(A[m]/2.0 - A[cur])){
      cur = i;
    }
  }

  cout << A[m] << " " << A[cur] << endl;

  return 0;
}

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

int main() {
	int h, w;
	int i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int L[200];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&L[i]);
	sort(L,L+n);
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(L[i]==L[j])continue;
			for(int k=j+1;k<n;k++){
				if(L[j]==L[k])continue;
				if(L[i]+L[j]>L[k])cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;

int b[1000], n;

int main(){
	scanf("%d", &n);
	for(int i=1;i<n;++i) scanf("%d", b+i);
	int ans = 0;
	for(int i=1;i<=n;++i){
		if(i==1) ans += b[i];
		else if(i==n) ans += b[n-1];
		else ans += min(b[i], b[i-1]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int H, W;
char a[10][10];

int main () {
  cin >> H >> W;

  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }

  int cx = 1;
  int cy = 1;

  while (cx != W || cy != H) {
    //cout << cy << " " << cx << "\n";
    a[cy][cx] = '.';

    if (cx >= 2) {
      if (a[cy][cx-1] == '#') {
        cout << "Impossible\n";
        return 0;
      }
    }

    if (cy >= 2) {
      if (a[cy-1][cx] == '#') {
        cout << "Impossible\n";
        return 0;
      }
    }

    if (cx == W) {
      char q = a[cy+1][W];
      if (q == '.') {
        cout << "Impossible\n";
        return 0;
      } else {
        cy++;
      }
    } else if (cy == H) {
      char p = a[H][cx+1];
      if (p == '.') {
        cout << "Impossible\n";
        return 0; 
      } else {
        cx++;
      }
    } else {
      char p = a[cy][cx+1];
      char q = a[cy+1][cx];

      if (p == '.' && q == '.') {
        cout << "Impossible\n";
        return 0;
      } else if (p == '#' && q == '#') {
        cout << "Impossible\n";
        return 0;
      } else if (p == '.') {
        cy++;
      } else {
        cx++;
      }
    }

  }

  if (cx >= 2) {
    if (a[cy][cx-1] == '#') {
      cout << "Impossible\n";
      return 0;
    }
  }

  if (cy >= 2) {
    if (a[cy-1][cx] == '#') {
      cout << "Impossible\n";
      return 0;
    }
  }

  cout << "Possible\n";
}

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

struct Point{
	double x;
	double y;
};

Point roll(Point div1,Point div2){
	Point tmp_start = { div2.x-div1.x,div2.y-div1.y };
	Point tmp_end = { tmp_start.x*cos(M_PI/3) -tmp_start.y*sin(M_PI/3),
			tmp_start.x*sin(M_PI/3) + tmp_start.y*cos(M_PI/3) };
	Point ret = { tmp_end.x + div1.x,tmp_end.y + div1.y };
	return ret;
}

void outPut(Point point){
	printf("%.8f %.8f\n",point.x,point.y);
}

void calc(Point left,Point right,int count){
	Point div1 = {	(2*left.x + right.x)/3,(2*left.y + right.y)/3 };
	Point div2 = {(2*right.x + left.x)/3,(2*right.y + left.y)/3	};
	Point peek = roll(div1,div2);

	if(count > 1){
		calc(left,div1,count-1);
		calc(div1,peek,count-1);
		calc(peek,div2,count-1);
		calc(div2,right,count-1);
	}else{
		outPut(left);
		outPut(div1);
		outPut(peek);
		outPut(div2);
	}
}

int main(){
	int n;
	Point left = {0,0},right = {100,0};
	scanf("%d",&n);
	if(n == 0){
		outPut(left);
		outPut(right);
	}else{
		calc(left,right,n);
		outPut(right);
	}
}



Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}

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

int main(void) {
    int x, y;
    cin >> x >> y;
    for (int c = 0; c <= x ;c++) {
        int t = x - c;
        int legs = c*2 + t*4;
        if (legs == y) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
    return 0;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    string tmp;
    cin >> tmp;
    deque<char> S;
    REP(i, tmp.length()) {
        S.push_back(tmp[i]);
    }
    int Q;
    cin >> Q;
    vector<pair<int, int>> D(Q);
    vector<char> C(Q);
    REP(i, Q) {
        int option;
        cin >> option;
        if (option == 1) {
            D[i] = make_pair(option, -1);
            C[i] = '-';
        } else {
            int f;
            char c;
            cin >> f >> c;
            D[i] = make_pair(option, f);
            C[i] = c;
        }
    }
    
    bool trans = false;
    int num = 0;
    for (int i = 0; i < Q; i++) {
        if (D[i].first == 1) {
            trans = !trans;
            num++;
        } else {
            if (D[i].second == 1) {
                if (trans) {
                    //S = S + C[i];
                    S.push_back(C[i]);
                } else {
                    //S = C[i] + S;
                    S.push_front(C[i]);
                }
            } else {
                if (trans) {
                    //S = C[i] + S;
                    S.push_front(C[i]);
                } else {
                    //S = S + C[i];
                    S.push_back(C[i]);
                }
            }
        }
    }

    string out = "";
    while (!S.empty()) {
        char curr = S.front();
        S.pop_front();
        out += curr;
    }
    if (num % 2 != 0) {
        reverse(out.begin(), out.end());
    }
    print(out);

}

signed main() {
    solve();
}


Measured memory_bytes: 3200
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace AOJ2
{
    class Program
    {
        static void Main()
        {
            var scoreA = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Sum();
            var scoreB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Sum();
            Console.WriteLine(Math.Max(scoreA, scoreB));
        }
    }
}

Measured memory_bytes: 5856
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s[1] == 'S') {
        ans = (s[0] == 'R') || (s[2] == 'R');
    } else {
        ans = 1;   
        ans += (s[0] == 'R') + (s[2] == 'R');
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int x;
    cin>>x;
    for(int i=1;i<=x;i++){
        if(i%3==0){
            cout<<" "<<i;
            continue;
          }int y=i;
        while(y){
            if(y%10==3){
                cout<<" "<<i;
                break;
            }y/=10;
        }
    }cout<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int N;
	int score[101];
	vector<int> res;
	int A, B, C, D;
	int rank[101];
	int n, r;
	
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		score[i] = 0;
	}
	for(int i = 0; i < N * (N - 1) / 2; i++){
		scanf("%d%d%d%d", &A, &B, &C, &D);
		
		if(C > D) score[A] += 3;
		else if(C < D) score[B] += 3;
		else{
			score[A]++; score[B]++;
		}
	}
	
	for(int i = 1; i <= N; i++){
		res.push_back(score[i]);
	}
	sort(res.begin(), res.end(), greater<int>());
	res.erase(unique(res.begin(), res.end()), res.end());
	n = 0;
	for(int i = 0; i < res.size(); i++){
		r = n + 1;
		for(int j = 1; j <= N; j++){
			if(res[i] == score[j]){
				rank[j] = r;
				n++;
			}
		}
	}
	
	for(int i = 1; i <= N; i++){
		printf("%d\n", rank[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1056
def mod_inv(n: int, mod: int)->int:
    b, u, v = mod, 1, 0
    while b > 0:
        t = n // b

        n -= t * b
        u -= t * v

        n, b = b, n
        u, v = v, u

    return (u+mod) % mod


def comb(r: int, c: int, mod: int) -> int:
    if c < 0 or r < c:
        raise Exception('invalid r={}, c={}'.format(r, c))
    if c == 0 or c == r:
        return 1
    return (comb(r-1, c-1, mod) + comb(r-1, c, mod)) % mod


# n+1Cr = (n+1)*n!/((n+1-r)!r!) = ((n+1)/(n+1-r)) * (n!/((n-r)!r!))
def iroha_and_grid(H: int, W: int, A: int, B: int) -> int:
    MOD = 10 ** 9 + 7

    c1, c2 = 1, 1

    uH, uW = H - A, B - 1
    r = uH - 1
    for n in range(r, (uH - 1) + (uW - 1) + 1):
        c1 = (c1 * (n + 1) * mod_inv(n + 1 - r, MOD)) % MOD

    lH, lW = A, W - B
    r = lH - 1
    for n in range(r, (lH - 1) + (lW - 1) + 1):
        c2 = (c2 * (n + 1) * mod_inv(n + 1 - r, MOD)) % MOD

    ret = 0
    for w in range(B, W):
        # 上の領域の高さと幅
        uH, uW = H - A, w - 1
        n = (uH - 1) + (uW - 1) + 1
        r = uH - 1
        c1 = (c1 * (n + 1) * mod_inv(n + 1 - r, MOD)) % MOD

        # 下の領域の高さと幅
        lH, lW = A, W - w
        n = (lH - 1) + (lW - 1)
        r = lH - 1
        c2 = (c2 * (n + 1 - r) * mod_inv(n + 1, MOD)) % MOD

        ret = (ret + c1 * c2) % MOD

    return ret


if __name__ == "__main__":
    H, W, A, B = map(int, input().split())
    ans = iroha_and_grid(H, W, A, B)
    print(ans)


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, k;
		
		n = sc.nextInt();
		k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			x = Math.min(x, n - x + 1);
			y = Math.min(y, n - y + 1);
			System.out.println((Math.min(x, y) - 1) % 3 + 1);
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,k;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>k;
    ll ans = 0;
    
    if(k!=0)repi(i,k+1,n+1){
        ans += (i-k)*(n/i);
        ans += max(0LL,n%i-k+1);
       // princ(ans);
    }
    if(k==0)ans = n*n;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    ret = 700
    for c in S:
        if c == 'o':
            ret += 100
    print(ret)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,d;
  cin >> n >> d;
  
  vec x(n),y(n);
  for(ll i=0;i<n;i++)cin >> x[i] >> y[i];

  two_sat ts(n);

  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      if (abs(x[i] - x[j]) < d) {
        // cannot use both of x[i] and x[j]
        ts.add_clause(i, false, j, false);
      }
      if (abs(x[i] - y[j]) < d) {
        ts.add_clause(i, false, j, true);
      }
      if (abs(y[i] - x[j]) < d) {
        ts.add_clause(i, true, j, false);
      }
      if (abs(y[i] - y[j]) < d) {
        ts.add_clause(i, true, j, true); 
      }     
    }
  }

  if (!ts.satisfiable()) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  auto answer = ts.answer();
  for (int i = 0; i < n; i++) {
    if (answer[i])
      cout << x[i] << endl;
    else
      cout << y[i] << endl;
  }



}

Measured memory_bytes: 3728
#include <cmath>
#include <string>
#include <iostream>
using namespace std;
string s;
bool check() {
	for(int i = 1; i < s.size(); i++) {
		if(!(abs(s[i] - s[i - 1]) == 1 && (s[i] + s[i - 1] - 130) % 6 != 5) && abs(s[i] - s[i - 1]) != 3) return false;
	}
	return true;
}
int main() {
	for(int i = 0; i < 1000; i++) {
		cin >> s;
		if(check()) cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  }
  COUT(ans);
}

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

int main(){
    string s;
    while(cin >> s, s != "."){
        string t;
        cin >> t;

        vector<string> v, w;
        v.push_back("");
        for(int i = 0 ; i < s.size() ; ++i){
            if(s[i] == '"'){
                v.push_back("");
            }else{
                v.back().push_back(s[i]);
            }
        }

        w.push_back("");
        for(int i = 0 ; i < t.size() ; ++i){
            if(t[i] == '"'){
                w.push_back("");
            }else{
                w.back().push_back(t[i]);
            }
        }

        string ans = "IDENTICAL";

        int cnt = 0;
        for(int i = 1 ; i < min(v.size(), w.size())  ; i += 2){
            if(v[i] != w[i]){
                ++cnt;
            }
        }

        if(cnt == 1){
            ans = "CLOSE";
        }else if(cnt > 1){
            ans = "DIFFERENT";
        }

        for(int i = 0 ; i < min(v.size(), w.size()) ; i += 2){
            if(v[i] != w[i]){
                ans = "DIFFERENT";
            }
        }

        if(v.size() != w.size()){
            ans = "DIFFERENT";
        }

        cout << ans << endl;
    }

    return 0;
}


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

using ll = long long int;
using P = std::pair<int, int>;

constexpr ll mod = 1e9 + 7;

class mint
{
    ll num = 0;

public:
    mint(ll x = 0) : num(x) {}

    mint operator+(const mint &rhs) const
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs) const
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs) const
    {
        return (num + rhs.num + mod) % mod;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

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

int main()
{
    int n, K;

    std::cin >> n >> K;

    std::vector<std::vector<std::vector<mint>>> dp(n + 1, std::vector<std::vector<mint>>(n + 1, std::vector<mint>(K + 1)));

    dp[1][0][0] = 1;

    if (K >= 2)
        dp[1][1][2] = 1;

    for (int i = 2; i <= n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            for (int k = 2 * j; k <= K; ++k)
            {
                dp[i][j][k] = mint((j + 1) * (j + 1)) * dp[i - 1][j + 1][k - 2 * j] + mint(2 * j + 1) * dp[i - 1][j][k - 2 * j];

                if (j >= 1)
                    dp[i][j][k] = dp[i][j][k] + dp[i - 1][j - 1][k - 2 * j];
            }
        }
    }

    std::cout << dp[n][0][K] << std::endl;

    return 0;
}

Measured memory_bytes: 52224
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0;
int32_t main()
{
	IOS
	int a,b,c;cin>>a>>b>>c;
	cout<<min(b/a,c)<<endl;
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 256
#include <cinttypes>
#include <cstdint>
#include <cstdio>

const int kMaxN = 200000;
const int kMaxAi = 1000000000;
const int kSentinel = kMaxAi + 1;

void Merge(int A[], int left, int mid, int right,
           int L[], int R[], std::int64_t *cnt) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i = 0; i < n1; ++i) { L[i] = A[left + i]; }
  for (i = 0; i < n2; ++i) { R[i] = A[mid + i]; }
  L[n1] = R[n2] = kSentinel;
  i = j = 0;
  for (k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      *cnt += n1 - i;
    }
  }
}

void MergeSort(int A[], int left, int right,
               int L[], int R[], std::int64_t *cnt) {
  int mid;
  if (left + 1 < right) {
    mid = (left + right) / 2;
    MergeSort(A, left, mid, L, R, cnt);
    MergeSort(A, mid, right, L, R, cnt);
    Merge(A, left, mid, right, L, R, cnt);
  }
}

int main() {
  int n, i;
  std::scanf("%d", &n);
  int A[n];
  for (i = 0; i < n; ++i) { std::scanf("%d", &A[i]); }
  int L[n/2 + 1], R[n/2 + 1];
  std::int64_t cnt = 0;
  MergeSort(A, 0, n, L, R, &cnt);
  std::printf("%" PRId64 "\n", cnt);
}

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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

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

  ll cnt1 = 0;
  char first;
  for(char c : S){
    if(c == '1') cnt1++;
    else{
      first = c;
      break;
    }
  }
  if(K <= cnt1) cout << 1 << endl;
  else cout << first << endl;
  return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)


int main(){
    int h,w;
    string s;
    cin>>h>>w;
    REP(i,h){
        cin>>s;
        cout<<s<<endl;
        cout<<s<<endl;
    }
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s[100010];
    int ans = 0;
    cin >> s;
    rep(i, 100000) {
        if ((s[i] == 'B' && s[i+1] == 'W') || (s[i] == 'W' && s[i+1] == 'B')){
            ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3736
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }

        long cost_1 = 0L;
        long cost_2 = 0L;
        long sum_1 = 0L;
        long sum_2 = 0L;
        for (int i=0;i<n;i++) {
            sum_1 += a[i];
            sum_2 += a[i];
            if (i%2==0) {
                if (sum_1<=0) {
                    cost_1 += 1-sum_1;
                    sum_1 += 1-sum_1;
                }
                if (sum_2>=0) {
                    cost_2 += sum_2-(-1);
                    sum_2 -= sum_2-(-1);
                }
            } else { // i%2==1
                if (sum_1>=0) {
                    cost_1 += sum_1-(-1);
                    sum_1 -= sum_1-(-1);
                }
                if (sum_2<=0) {
                    cost_2 += 1-sum_2;
                    sum_2 += 1-sum_2;
                }
            }
        }
        System.out.println(Math.min(cost_1, cost_2));
    }
}

Measured memory_bytes: 49412
N = gets.to_i
H = gets.split.map(&:to_i)

h = H[0]
c = 1
1.upto(H.size-1) do |i|
  	if h <= H[i]
      c += 1 if H[i-1] <= H[i]
      h = H[i]
    end
end
puts c


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int MAXQ = 1e7 + 5;
const int MAXN = 1e3 + 5;
const int MAXP = 5e3 + 5;
const int INF = 1e9;
const long long INFLL = 1e18;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
struct edge {int dest, flow, pos, cost; };
vector <edge> a[MAXP];
int s, t, tot, flow; ll cost;
ll dist[MAXP]; int path[MAXP], home[MAXP];
void FlowPath() {
	int p = t, ans = INF;
	while (p != s) {
		ans = min(ans, a[path[p]][home[p]].flow);
		p = path[p];
	}
	flow += ans;
	cost += ans * dist[t];
	p = t;
	while (p != s) {
		a[path[p]][home[p]].flow -= ans;
		a[p][a[path[p]][home[p]].pos].flow += ans;
		p = path[p];
	}
}
bool spfa() {
	static int q[MAXQ];
	static bool inq[MAXP];
	static int l = 0, r = 0;
	for (int i = 0; i <= r; i++)
		dist[q[i]] = INFLL;
	q[l = r = 0] = s, dist[s] = 0, inq[s] = true;
	while (l <= r) {
		int tmp = q[l];
		for (unsigned i = 0; i < a[tmp].size(); i++)
			if (a[tmp][i].flow != 0 && dist[tmp] + a[tmp][i].cost < dist[a[tmp][i].dest]) {
				dist[a[tmp][i].dest] = dist[tmp] + a[tmp][i].cost;
				path[a[tmp][i].dest] = tmp;
				home[a[tmp][i].dest] = i;
				if (!inq[a[tmp][i].dest]) {
					q[++r] = a[tmp][i].dest;
					inq[q[r]] = true;
				}
			}
		l++, inq[tmp] = false;
	}
	return dist[t] != INFLL;
}
void addedge(int x, int y, int z, int c) {
	a[x].push_back((edge){y, z, a[y].size(), c});
	a[y].push_back((edge){x, 0, a[x].size() - 1, -c});
}
int n, mid[4], cntx[MAXN], cnty[MAXN];
pair <int, int> posx[MAXN], posy[MAXN];
int main() {
	read(n), tot = 2 * n;
	s = ++tot, t = ++tot;
	for (int i = 0; i <= 3; i++)
		mid[i] = ++tot;
	for (int i = 1; i <= n; i++) {
		read(posx[i].first), read(posx[i].second), read(cntx[i]);
		addedge(s, i, cntx[i], 0);
		addedge(i, mid[0], INF, -posx[i].first - posx[i].second);
		addedge(i, mid[1], INF, posx[i].first - posx[i].second);
		addedge(i, mid[2], INF, -posx[i].first + posx[i].second);
		addedge(i, mid[3], INF, posx[i].first + posx[i].second);
	}
	for (int i = 1; i <= n; i++) {
		read(posy[i].first), read(posy[i].second), read(cnty[i]);
		addedge(n + i, t, cnty[i], 0);
		addedge(mid[0], n + i, INF, posy[i].first + posy[i].second);
		addedge(mid[1], n + i, INF, -posy[i].first + posy[i].second);
		addedge(mid[2], n + i, INF, posy[i].first - posy[i].second);
		addedge(mid[3], n + i, INF, -posy[i].first - posy[i].second);
	}
	for (int i = 1; i <= tot; i++)
		dist[i] = INFLL;
	while (spfa()) FlowPath();
	writeln(-cost);
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int a, b; cin >> a >> b;
  if(a != 1 && b != 1) cout << 1 << endl;
  else if(a != 2 && b != 2) cout << 2 << endl;
  else cout << 3 << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>


struct point {double x,y;};

void koch(int n,point a,point b){
  if(n == 0) return;
  point s,t,u;
  double th = M_PI * 60.0/180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  point a,b;
  int n;
  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}



Measured memory_bytes: 2756
n = int(input())
h = list(map(int, input().split(' ')))

current = 0
max_len = 0
length = 0

while current < n - 1:
    if h[current] < h[current + 1]:
        max_len = max(length, max_len)
        length = 0
    else:
        length += 1
    current += 1


print(max(max_len, length))


Measured memory_bytes: 14252