akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N;
	cin >> N;
	string A, B, C;
	cin >> A >> B;
	for (int i = 0; i < N; i++) {
		C += A.substr(i,1);
		C += B.substr(i,1);
	}
	cout << C << endl;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()
  ans=0

  for i in range(n):
    if (i+1)%2==1:
      if l[i]%2==1:
        ans+=1

  return ans

# main()
print(main())


Measured memory_bytes: 10748
#include <stdio.h>

#define N 8
#define FR -1
#define NFR 1

int m[N][N], r[N], c[N], dp[2*N-1], dn[2*N-1];

void print()
{
  int i, j;
  
  for (i = 0; i < N; i++)
    for ( j = 0; j < N; j++)
      if (m[i][j] == NFR)
	if (r[i] != j)
	  return;
  for (i = 0; i < N; i++){
    for (j = 0; j < N; j++){
      if (r[i] == j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
}

void recursive(int i)
{
  int j;
  
  if (i == N){
    print();
    return;
  }
  for (j = 0; j < N; j++){
    if (c[j] != FR || dp[i+j] != FR || dn[i-j+N-1] != FR)
      continue;
    r[i] = j;
    c[j] = dp[i+j] = dn[i-j+N-1] = NFR;
    recursive(i+1);
    r[i] = c[j] = dp[i+j] = dn[i-j+N-1] = FR;
  }
}

int main()
{
  int k, row, col, i, j;

  for (i = 0; i < N; i++)
    r[i] = c[i] = FR;
  for (i = 0; i < 2*N-1; i++)
    dp[i] = dn[i] = FR;
  for (i = 0; i < N; i++)
    for (j = 0; j < N; j++)
      m[i][j] = FR;
  scanf("%d",&k);
  for (i = 0; i < k; i++){
    scanf("%d%d",&row,&col);
    m[row][col]  = NFR;
  }
  recursive(0);
  
  return 0;
}



Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int w, h, n; cin >> w >> h >> n;
  vector<vector<bool> > white(h, vector<bool>(w, true));
  while (n--) {
    int x, y, a; cin >> x >> y >> a;
    if (a == 1) {
      REP(i, h) REP(j, x) white[i][j] = false;
    } else if (a == 2) {
      REP(i, h) FOR(j, x, w) white[i][j] = false;
    } else if (a == 3) {
      REP(i, y) REP(j, w) white[i][j] = false;
    } else if (a == 4) {
      FOR(i, y, h) REP(j, w) white[i][j] = false;
    }
  }
  int ans = 0;
  REP(i, h) REP(j, w) ans += white[i][j];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right

n,m=n1()
ab=n3(m)

node=defaultdict(list)
for a,b in ab:
    node[a].append(b)
    node[b].append(a)
    
p=deque([1])
d=[0]*(n+1)
while len(p)>0:
    c=p.popleft()
    for i in node[c]:
        if d[i]==0:
            d[i]=c
            p.append(i)
            
print("Yes")
for i in range(2,n+1):
    print(d[i])
    
    

Measured memory_bytes: 59080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;

void solve()
{
	int x;scd(x);
	int n=x/100;
	int ans=0;
	if(x%100<=n*5)ans=1;ac;
}
int main(){
    //IOS;
    solve();
    return 0;
}

Measured memory_bytes: 256
def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt

n = int(input())
a = list(map(int, input().split()))
sorted_a, num_swap = selection_sort(a)
print(' '.join(map(str, sorted_a)))
print(num_swap)

Measured memory_bytes: 7708
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	edges := make([][]int, M)
	for i := 0; i < M; i++ {
		edges[i] = []int{ReadInt() - 1, ReadInt() - 1}
	}
	ans := 0
	for i := 0; i < M; i++ {
		uf := MakeUnionFind(N)
		for j := 0; j < M; j++ {
			if j == i {
				continue
			}
			uf.Unite(edges[j][0], edges[j][1])
		}
		if uf.Size(0) != N {
			ans++
		}
	}
	fmt.Println(ans)
}

type UnionFind []int

func MakeUnionFind(size int) UnionFind {
	uf := make([]int, size)
	for i := 0; i < size; i++ {
		uf[i] = -1
	}
	return uf
}
func (uf UnionFind) Root(x int) int {
	if uf[x] < 0 {
		return x
	}
	uf[x] = uf.Root(uf[x])
	return uf[x]
}
func (uf UnionFind) Unite(x, y int) {
	x, y = uf.Root(x), uf.Root(y)
	if x == y {
		return
	}
	if uf[x] > uf[y] {
		x, y = y, x
	}
	uf[x] += uf[y]
	uf[y] = x
}
func (uf UnionFind) Connected(x, y int) bool { return uf.Root(x) == uf.Root(y) }
func (uf UnionFind) Size(x int) int          { return -uf[uf.Root(x)] }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo INT_MAX

const int N = 1e5 + 5;
int n , k;
int a[N];
int dp[N][3];
/// dp[i][j] là người nào sẽ thắng nếu người thứ j đi trước và số hòn đá còn lại là i -> n.

int main()
{
    //freopen("K.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        cin >> a[i];
    FORD(i , k , 1)
    {
        FOR(j , 0 , 1)
        {
            FOR(x , 1 , n)
            {
                if(i + a[x] <= k)
                {
                    if(dp[i + a[x]][j ^ 1] == j)
                    {
                        dp[i][j] = j;
                        goto l1;
                    }
                }
                else if(i + a[x] == k + 1)
                {
                    dp[i][j] = j;
                    goto l1;
                }
            }
            dp[i][j] = j ^ 1;
            l1:;
        }
    }
    if(dp[1][0] == 1)
        cout << "Second";
    else
        cout << "First";
}


Measured memory_bytes: 1408
//#include "stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define int long long
int dp[402][402];
int32_t main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");/*
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<402;i++)
        for(int j=0;j<402;j++)
            dp[i][j]=LL_INF;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i][i]=0;
    }
    int sm[n];
    sm[0]=a[0];
    for(int i=1;i<n;i++)
        sm[i]=a[i]+sm[i-1];
    int j;
    for(int l=2;l<=n;l++)
    {
        for(int i=0;i<=n-l;i++)
        {
            j=i+l-1;
            for(int k=j-1;k>=i;k--)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
                
            }
            dp[i][j]+=(sm[j]-(i>=1?sm[i-1]:0));
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1536
from collections import Counter

N, K, *AB = map(int, open(0).read().split())

C = Counter()
for a, b in zip(*[iter(AB)] * 2):
    C[a] += b

ma = sum(v for k, v in C.items() if k | K == K)

S = list(bin(K)[2:])
i = -1
for _ in range(S.count('1')):
    T = S[:]
    i = T.index('1', i + 1)
    T[i:] = "0" + "1" * (len(T) - i - 1)

    T = int("".join(T), 2)
    ma = max(ma, sum(v for k, v in C.items() if k | T == T))

print(ma)

Measured memory_bytes: 27084
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    string S;
    cin >> S;
    
    int ans[50] = { 0 }, len = S.length();
    for( int i = 0; i < len; ++i ){
        ++ans[(int)(S.c_str()[i]-'a')];
        if( 1 < ans[(int)(S.c_str()[i]-'a')] ){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=5005;const ll inf=0x3f3f3f3f3f3f3f3f;
int a[N],b[N],c[N],id[N],n;ll mn[N];
inline bool cmp(const int &x,const int &y){return c[x]==c[y]?b[x]<b[y]:c[x]<c[y];}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d%d",&a[i],&b[i]),c[i]=a[i]+b[i],id[i]=i;
	sort(id+1,id+1+n,cmp);
	memset(mn,0x3f,sizeof(mn));
	mn[0]=0;
	fp(i,1,n){
		R int t=n-1;
		while(mn[t]==inf)--t;
		fd(j,t,0)if(mn[j]<=a[id[i]])cmin(mn[j+1],mn[j]+b[id[i]]);
	}
	fd(i,n,0)if(mn[i]!=inf)return printf("%d\n",i),0;
	return 0;
}

Measured memory_bytes: 512
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<numeric>
#include<cstdint>
#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n,k;
cin >> n >> k;
vector<i32> a(n);
i32 ma = 0;
rep(i,n){
    cin >>a[i];
    ma = max(a[i],ma);
}
i32 rec = a[0];
rep(i,n)rec = gcd(rec,a[i]);
cout << (k <= ma && k % rec == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 3992
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 

void solve(){   
    //clock_t time;
    ll n, w; cin>>n>>w;
    vector<pll> v(n);
    for(auto &i: v) cin>>i.F>>i.S;
    //asc(v);
    vvll dp(n+1, vll(w+1));
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=w; j++){
            if(j-v[i-1].F<0){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=max(v[i-1].S+dp[i-1][j-v[i-1].F], dp[i-1][j]);
            }
        }
    }
    cout<<dp[n][w];

}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(9);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

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

using namespace std;

typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    if (a == 1 || b == 1) cout << 1, exit(0);
    cout << (a * b + 1) / 2;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  string str;
  cin >> str;
  ll resulta = 0;
  ll resultb = 0;
  for(i = 0; i < str.size(); i++)
    if(i % 2 != str[i] - '0')
      resulta++;
    
  for(i = 0; i < str.size(); i++)
    if(i % 2 == str[i] - '0')
      resultb++;
    
      
    
  
  cout << min(resulta, resultb) << endl;

  return 0;
}

Measured memory_bytes: 512
# D - RGB Triplets
	
N = int(input())
S = input()
	
r, g, b = 0, 0, 0
	
for s in S:
	if s == 'R':
		r += 1
	elif s == 'G':
		g += 1
	else:
		b += 1
	
ans = r * g * b
	
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		k = j * 2 - i
			
		if k < N:
			if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
				if j -i == k -j:
					ans -= 1
	
print(ans)

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int sum = 0;
    for (int j = 1; j <= N; j++){
        int num[5];
        num[4] = j / 10000;
        num[3] = (j % 10000) / 1000;
        num[2] = (j % 1000) / 100;
        num[1] = (j % 100) / 10;
        num[0] = (j % 10) / 1;
        // for (int i = 0; i < 5; i++) printf("%d",num[i]);
        int total = 0;
        for (int i = 0; i < 5; i++) total += num[i];
        if (total >= A && total <= B) {
            sum += j;
            // printf("current value = %d and current sum = %d\r\n",j,sum);
            // cout << sum << endl;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <list>
#include <utility>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define MAX 100000
typedef long long LL;
typedef unsigned long long ULL;
int main(void){	
    int n; scanf("%d", &n);
    int cmp = 0, tmp = n;
    while(tmp != 0){
    	cmp += tmp % 10;
    	tmp /= 10;
    }
    if(n % cmp == 0) printf("Yes");
    else printf("No");
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, T;
llint a[100005];

int main(void)
{
	cin >> n >> T;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	llint ans = 1;
	for(int i = n; i >= 1; i--){
		llint x = upper_bound(a+i+1, a+n+1, a[i]+T) - lower_bound(a+i+1, a+n+1, a[i]) + 1;
		ans *= x, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3932
n = gets.chomp("").to_i

p = gets.split.map(&:to_i)

count = 0
(n-2).times do |i|
  if p[i] < p[i+1] && p[i+1] < p[i+2] or p[i+2] < p[i+1] && p[i+1] < p[i]
    count += 1
  end
end

puts count


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

using namespace std;
typedef long long ll;

queue<pair<ll,ll> > q;
ll current_order = 0;


bool isLunLun(ll k) {
    string s = to_string(k);

    for(int i = 1; i < s.size(); i++) {
        if(abs(s[i] - s[i-1]) > 1) return false;
    }
    return true;
    
}
void push_digit(ll number) {
    for(int i = 0; i <= 9; i++) {
        ll temp = number * 10 + i;
        if(isLunLun(temp)) q.push(make_pair(temp, current_order++));
    }
}


int main() {
    int K;

    cin >> K;

    push_digit(0);
    while(q.size() >= 1) {
        pair<ll, ll> p = q.front(); q.pop();
        ll num = get<0>(p);
        ll order = get<1>(p);
        if(num == 0) continue;
        //cout << order << "th: " << num << endl;
        if(order == K) {
            cout << num << endl;
            return 0;
        }
        push_digit(num);

    }

    return 0;
}

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

const int N = 3000 + 7, mod = 1e9 + 7;

int c[N], l[N], r[N], n, m, dp[N][N];

string str;


int f(int idx, int one) {
	if(idx > n) {
		return 1;
	}
	if(~dp[idx][one]) {
		return dp[idx][one];
	}
	int res = 0;
	if(r[idx] - idx >= one) {
		if(l[idx + 1] != l[idx]) { 
			res += f(idx + 1, one + c[r[idx + 1]] - c[r[idx]]); 
			res %= mod;
		} else {
			res += f(idx + 1, one);
			res %= mod;
		}
	}

	if(one) {
		if(l[idx + 1] != l[idx]) {
			res += f(idx + 1, one - 1 + c[r[idx + 1]] - c[r[idx]]);
			res %= mod;
		} else {
			res += f(idx + 1, one - 1);
			res %= mod;
		}
	}
	
	return dp[idx][one] = res;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m >> str;
	for(int i = 1; i <= m; i++) {
		int lx, rx; cin >> lx >> rx;
		r[lx] = max(rx, r[lx]);
	}

	for(int i = 1; i <= n; i++) {
		r[i] = max(i, r[i]);
		l[i] = r[l[i - 1]] >= r[i] ? l[i - 1] : i;
		r[i] = r[l[i]];
		c[i] = c[i - 1] + (str[i - 1] == '1');
	}

	c[n + 1] = c[n];

	l[n + 1] = r[n + 1] = n + 1;

	memset(dp, -1, sizeof dp);
	cout << f(1, c[r[1]]) << endl;
}

Measured memory_bytes: 74516
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long


const int INF = 1e9 + 5;
int main()
{
	load;
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i=0; i<n;i++){
		cin >> v[i];
	}
	vector<int> dp(n, INF); //cost to reach certain index
	dp[0] = 0;
	for (int i=0; i<n;i++){
		for (int j :{i+1, i+2}){
			if(j<n){
				dp[j] = min(dp[j], dp[i]+ abs(v[i]- v[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
char s[4];
int main(){
	scanf("%s",s);
	int cnta=0,cntb=0,cntc=0;
	for(int i = 0; i < 3;i++){
		if (s[i]=='a') cnta++;
		if (s[i]=='b') cntb++;
		if (s[i]=='c') cntc++;
	}
	if(cnta == 1&& cntb==1&& cntc==1) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

long long calc(vector<long long> &x, long long l, long long n) {
    vector<long long> y(n);
    for (int i = 0; i < n; i++)
        y[i] = l - x[n - i - 1];

    vector<long long> ll(n + 1), rr(n + 1);
    for (int i = 1; i <= n; i++) {
        rr[i] = rr[i - 1] + x[i - 1];
        ll[i] = ll[i - 1] + y[i - 1];
    }

    long long maxx = 0;
    for (int i = 1; i <= n; i++) {
        // left
        long long res = 0;
        int num_left = i + (n - i) / 2;
        int num_right = (n - i + 1) / 2;
        if ((n - i) % 2 == 0) {
            res = 2 * (ll[num_left - 1] - ll[i - 1]) + y[num_left - 1] +
                  2 * rr[num_right];

        } else {

            res = 2 * (ll[num_left] - ll[i - 1]) + 2 * rr[num_right - 1] +
                  x[num_right - 1];
        }
        maxx = max(maxx, res);
    }

    return maxx;
}
int main() {
    long long l, n;
    cin >> l >> n;
    vector<long long> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    long long maxx = 0;
    maxx = max(maxx, calc(x, l, n));

    vector<long long> rev(n);
    for (int i = 0; i < n; i++) {
        rev[i] = l - x[n - i - 1];
    }
    maxx = max(maxx, calc(rev, l, n));

    cout << maxx << endl;

    return 0;
}


Measured memory_bytes: 8108
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = float("inf")
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    H = H_temp
                    
print("{0} {1} {2}".format(Cx, Cy, H))


Measured memory_bytes: 3064
N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]

s=0
flag=False
for k in range(N):
      if x[k]==y[k]:
         s=s+1
         if s==3:
          flag=True
          break
      else:
         s=0
 
if flag==True:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main() {
    string a,b;
    cin >> a >> b;
    int x = stoi(a+b);
    REP1(i, 1000) {
        if (i*i == x) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll ret = 0;
    rep1(i,N){
        ll ct = 0;
        ll tp = i;
        while(tp % 2 == 0){
            tp /= 2;
            ct++;
        }
        if(ct >= ans) ret = i, ans = max(ans,ct);
    }
    print(ret);
    return 0;
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
d = []
n.times {d<<gets.chomp}
p d.uniq.size

Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int dp[3100][3100] = {0};

int main(){
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < (int)s.size(); i++) {
        for(int j = 0; j < (int)t.size(); j++) {
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }

    int i = s.size();
    int j = t.size();
    string res = "";
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            res = s[i-1] + res;
            i--, j--;
        }
    }

    cout << res << endl;
    
}

Measured memory_bytes: 37120
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

int Max(const vector<int>& v, const vector<int>& w, int W) {
    assert(v.size() == w.size());
    vector<int> dp(W + 1, 0);
    for (int i = 0; i < v.size(); i++) {
        for (int j = w[i]; j <= W; j++) {
            dp[j] = max(dp[j], dp[j - 1]);
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    return dp[W];
}

int main() {
    int N, W; cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
    cout << Max(v, w, W) << endl;
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l=-1;
  for(int i=1;i<s.length();i++)
  {
    if(s[i]==s[i-1])
    {
      l=0;
      cout<<"Bad";
      break;
    }
  }
  if(l==-1)
  {
    cout<<"Good";
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1000010
#define inf 2147483647
using namespace std;
struct data{int x, y;}d[N];
int n, m, k, map[810][810], S, op, cl, h[810][810], ans, x, y, dis;
char s[810];
int main(){
	scanf("%d%d%d", &n, &m, &k);
	for(int i=1; i<=n; i++){
		scanf("%s", s+1);
		for(int j=1; j<=m; j++){
			if(s[j]=='#')map[i][j]=1;
			if(s[j]=='.')map[i][j]=0;
			if(s[j]=='S'){map[i][j]=0; x=i; y=j;}
		}
	}
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)h[i][j]=inf;
	h[x][y]=0;
	op=0; cl=1; d[1].x=x; d[1].y=y;
	while(op<cl){
		op++; x=d[op].x; y=d[op].y;
		if(h[x][y]==k)continue;
		if(x>1&&!map[x-1][y]&&h[x-1][y]>h[x][y]+1){h[x-1][y]=h[x][y]+1; cl++; d[cl].x=x-1; d[cl].y=y;}
		if(x<n&&!map[x+1][y]&&h[x+1][y]>h[x][y]+1){h[x+1][y]=h[x][y]+1; cl++; d[cl].x=x+1; d[cl].y=y;}
		if(y>1&&!map[x][y-1]&&h[x][y-1]>h[x][y]+1){h[x][y-1]=h[x][y]+1; cl++; d[cl].x=x; d[cl].y=y-1;}
		if(y<m&&!map[x][y+1]&&h[x][y+1]>h[x][y]+1){h[x][y+1]=h[x][y]+1; cl++; d[cl].x=x; d[cl].y=y+1;}
	}
	ans=inf;
	for(int i=1; i<=cl; i++){
		x=d[i].x; y=d[i].y;
		dis=min(min(x-1, n-x), min(y-1, m-y));
		if(!dis){ans=min(ans, h[x][y]?1:0); continue;}
		ans=min(ans, (dis-1)/k+2);
	}
	printf("%d", ans);
	return 0;
}

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

typedef long long i64;
typedef pair<int, int> ii;
typedef pair<i64, i64> ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9;
const int maxn = 3e3+5;
const int mod = 2019;

string s;
int cur, ans, x, base, n;
int f[maxn], pot[200005];

int main() {
    fastIO();
    cin >> s;
    n = s.size();
    pot[n-1] = 1;
    for (int i = n-2; i >= 0; --i) pot[i] = (pot[i+1] * 10) % mod;
    f[0] = 1;
    for (int i = 0; i < n; ++i) {
    	cur = (cur + (pot[i] * (s[i]-'0')) % mod) % mod;
    	ans += f[cur];
    	++f[cur];
    }
    cout << ans << '\n';
    return 0;
}


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

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

using namespace std;
int N,AB[18][2];
int dp[1<<18][51];
//dp[msk][lst] := 既に整列済みの集合がmskで、最後の値がlstであるときの操作の最小値

// 参考にしたサイト: https://www.hamayanhamayan.com/entry/2020/01/18/233933

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

    cin >> N;
    rep(i,N)cin >> AB[i][0]; // i番目のカードの表がAB[i][0];
    rep(i,N)cin >> AB[i][1]; // i番目のカードの裏がAB[i][1];

    for(int mask = 0;mask< (1<<N) ;mask++){
        for(int list = 0;list<51;list++)dp[mask][list] = inf; // inf で初期化することで不可能な遷移を防げる
    }
    dp[0][0] = 0;// 0枚で最後の値を0にするのに必要な操作回数は0
    for(int mask = 0;mask < (1<<N);mask++){
        for(int list = 0;list <51;list++){
            // maskの置き方をすでにしており
            // 最後においた数値がlistのときについて考える

            if(dp[mask][list]==inf)continue;
            int done = 0;//すでに置かれているカードの枚数

            for(int i=0;i<N;i++)if(mask&(1<<i))done++; // maskのiビット目が1だったらカードが置かれている
            
            for(int i=0;i<N;i++){ // i番目のカードを集合maskの末尾に追加することを考える
                if(mask&(1<<N))continue; //既に集合に追加されていたら遷移を考えない

                int p = abs(done-i)%2; // 現在位置からカードの末尾までの移動距離が abs(done-i) で
                // p は表か裏かを決める　偶数枚置かれていて iが偶数のときは p は0で表面を使う
                // 奇数枚置かれていて iが偶数だったら p は 1で裏面を使う
                if(AB[i][p]<list)continue; // もしも新しく追加する数が末尾の数よりも小さかったら追加できない

                int c = 0; // これは多分操作回数なんだけど
                for(int j=0;j<i;j++)if(!(mask& (1<<j)))c++; // ここの操作よくわからない たすけて

                dp[mask|(1<<i)][AB[i][p]] = min(dp[mask|(1<<i)][AB[i][p]],dp[mask][list]+c);
            }
        }
    }
    int ans = inf;
    for(int i=0;i<51;i++)ans = min(ans,dp[(1<<N)-1][i]);
    if(ans==inf)ans = -1;
    cout << ans << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s;
    cin>>s;
    
    ll ans=0;
    if(s[0]=='R' && s[1]=='R'&& s[2]=='R')
    {
        ans=3;
    }
    else if(s[0]=='R'&& s[1]=='R')
    {
        ans=2;
    }
    else if(s[2]=='R'&& s[1]=='R')
    {
        ans=2;
    }
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
    {
        ans=1;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#define LiangJiaJun main
using namespace std;
int a,b,c;
int LiangJiaJun(){
    cin>>a>>b>>c;
    cout<<min(a+b,min(a+c,b+c))<<endl;
    return 0;
}



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

using namespace std;

const int NS = (int)1e5 + 4;
int N;
char s[NS];
int l[NS], r[NS], ans[NS];

int main(){
    scanf("%s", s + 1); N = strlen(s + 1);
    int cnt = 0;
    for(int i = 1; i <= N; ++i){
        if(s[i] == 'L') ++cnt;
        else cnt = 0;
        l[i] = cnt;
    }
    cnt = 0;
    for(int i = N; i >= 1; --i){
        if(s[i] == 'R') ++cnt;
        else cnt = 0;
        r[i] = cnt;
    }
    for(int i = 1; i <= N; ++i){
        if(s[i] == 'L'){
            if(l[i] % 2 == 0) ++ans[i - l[i]];
            else ++ans[i - l[i] + 1];
        }
        else{
            if(r[i] % 2 == 0) ++ans[i + r[i]];
            else ++ans[i + r[i] - 1];
        }
    }
    for(int i = 1; i <= N; ++i){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

char str[200000+5];
int n;

signed main()
{
	long long rec=0;
	scanf("%s",str);
	n=strlen(str);
	for(int i=0;i<n;++i)	rec+=str[i]-'0';
	puts(rec%9==0?"Yes":"No");
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int answer = 0;
  for (int i = 1; i < n - 1; i++) {
    if (a[i] >= a[i - 1] && a[i] <= a[i + 1] || a[i] <= a[i - 1] && a[i] >= a[i + 1]) {
      answer++;
    }
  }
  cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int combination(int n, int x){
    int count = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            for(int k = j+1; k <= n; k++){
                if(i+j+k == x){
                    count++;
                }
            }
        }
    }
    return count;
}

void solve(){
    int n, x;
    while(cin >> n >> x){
        if(n == 0 && x == 0){
            return;
        }
        cout << combination(n, x) << endl;
    }
}

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

Measured memory_bytes: 3036
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
AA = []
BA = []
BZ = []

AZ = []

count = 0
l = 0
AAc = 0
BAc = 0
BZc = 0
for i in range(n):
    t = input()
    count += t.count('AB')
    ss = list(t)
    if ss[0] == 'B' and ss[-1] == 'A':
        BA.append(1)
        BAc += 1
        l += 1
    elif ss[0] != 'B' and ss[-1] == 'A':
        AA.append(1)
        AAc += 1
        l += 1
    elif ss[0] == 'B' and ss[-1] != 'A':
        BZ.append(1)
        BZc += 1
        l += 1
if AAc != 0 and BAc != 0:
    count += BAc
    AAc -= 1
    if BZc != 0:
        BZc -= 1
        count += 1
    if AAc != 0 and BZc !=0:
        count += min(AAc,BZc)
elif AAc == 0 and BAc != 0:
    if BAc >= 2:
        count += BAc - 1
    if BZc > 0:
        count += 1
elif AAc != 0 and BAc ==0:
    count += min(AAc, BZc)
print(count)

Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;cin >> N;
    vector<pair<ll,ll>> X;
    rep(i,N){
        ll x,l;cin >> x >> l;
        X.emplace_back(x+l,x-l);
    }
    sort(ALL(X));
    ll cnt = 0,e = X[0].first;
    rep(i,N){
        if(X[i].second < e){
            cnt++;
        }else{
            e = X[i].first;
        }
    }
    cout << N - cnt + 1 << endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      sc.nextLine();
      	String line = sc.nextLine();
    
      	if(line.substring(0, n/2).equals(line.substring(n/2, line.length())))
           System.out.println("Yes");
        else
           System.out.println("No");
      
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

#define fs first
#define sc second 
#define mp make_pair
#define pii pair<int,int>
#define pip pair<int,pii>

using namespace std;

int n, vis[100005];
long long ans;
pip list[100005];
vector <pii> v[100005];
priority_queue <pii> pq;

bool cmpa(pip a, pip b) {
	return a.sc < b.sc;
}

bool cmpb(pip a, pip b) {
	return a.sc.sc < b.sc.sc;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d%d", &list[i].sc.fs, &list[i].sc.sc);
		list[i].fs = i;
		vis[i] = 0;
	}
	sort(list + 1, list + 1 + n, cmpa);
	for(int i = 1; i < n; i++) {
		v[list[i].fs].push_back(mp(list[i + 1].fs, list[i + 1].sc.fs - list[i].sc.fs));
		v[list[i + 1].fs].push_back(mp(list[i].fs, list[i + 1].sc.fs - list[i].sc.fs));
	}
	sort(list + 1, list + 1 + n, cmpb);
	for(int i = 1; i < n; i++) {
		v[list[i].fs].push_back(mp(list[i + 1].fs, list[i + 1].sc.sc - list[i].sc.sc));
		v[list[i + 1].fs].push_back(mp(list[i].fs, list[i + 1].sc.sc - list[i].sc.sc));
	}
	pq.push(mp(0, 1));
	ans = 0;
	while(pq.size()) {
		int skrg, jrk;
		jrk = -pq.top().fs;
		skrg = pq.top().sc;
		pq.pop();
		if(vis[skrg] == 1) {
			continue;
		} else {
			vis[skrg] = 1;
			ans += jrk;
			for(int i = 0; i < v[skrg].size(); i++) {
				if(vis[v[skrg][i].fs] == 0) {
					pq.push(mp(-v[skrg][i].sc, v[skrg][i].fs));
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12020
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
char S[112345];

int main() {

	scanf("%d%s", &N,S);

	int ans = 1;

	rep(i, N - 1) {
		if (S[i] != S[i + 1]) ++ans;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A):
    swap_num = 0
    while True:
        swapped = False
        for i in range(N - 1):
            if A[i] > A[i + 1]:
                A[i], A[i + 1] = A[i + 1], A[i]
                swap_num += 1
                swapped = True
        if not swapped:
            return A, swap_num

A, num = bubble_sort(A)
print(*A)
print(num)

Measured memory_bytes: 7812
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d, lsum, rsum;
    cin >> a >> b >> c >> d;
    lsum = a + b;
    rsum = c + d;
    if(lsum > rsum){
        printf("Left\n");
    }
    else if(lsum == rsum){
        printf("Balanced\n");
    }
    else if(lsum < rsum){
        printf("Right\n");
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

int n, t, res;
int mi = INT_MAX;

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

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    if (t <= mi) {
      ++res;
      mi = t;
    }
  }
  cout << res << endl;
  
  return 0;
}


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

// author: Seong Yong-ju ( @sei40kr )

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

using namespace std;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = MIN(b, d) - MAX(a, c);
  cout << (MAX(0, ans)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;string s;cin>>n>>s>>k;
    for (int i = 0; i < n; i++)
    {
        /* code */
        if (s[i]!=s[k-1])
        {
            /* code */
            s[i]='*';
        }
        
    }
    cout<<s<<endl;
}

Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline

    N, R, L = map(int, input().split())
    P = list(map(int, input().split()))

    val2idx = [0] * (N+1)
    for i, p in enumerate(P):
        val2idx[p] = i + 1
    bigger = [[0] * (N+1) for _ in range(N+1)]
    for p in range(1, N+1):
        for j in range(N):
            if P[j] > p:
                bigger[p][j+1] = bigger[p][j] + 1
            else:
                bigger[p][j + 1] = bigger[p][j]
    #print(bigger)
    inf = 10**14
    dp = [[inf] * (N+1) for _ in range(N+1)]
    dp[0][0] = 0

    for p in range(1, N+1):
        i = val2idx[p]
        for j in range(N+1):
            if i > j:
                dp[p][j] = min(dp[p][j], dp[p-1][j] + L)
                dp[p][i] = min(dp[p][i], dp[p-1][j] + R * (bigger[p][i] - bigger[p][j]))
            else:
                dp[p][j] = min(dp[p][j], dp[p - 1][j])
    print(min(dp[-1]))
    #[print(i, dp[i]) for i in range(N+1)]


if __name__ == '__main__':
    main()


Measured memory_bytes: 428296
#include<iostream>
#include<string>
#include<vector>
 
struct Stack{
    std::vector<int> nums;
    int stack_ptr,ptr_max;
};
 
void push(int x,Stack &s){
    if(s.stack_ptr<=s.ptr_max){
        s.nums[s.stack_ptr++]=x;
    }else{
        s.nums.push_back(x);
        s.stack_ptr++;
        s.ptr_max++;
    }
}
 
int pop(Stack &s){
    s.stack_ptr--;
    return s.nums[s.stack_ptr];
}
 
int main(){
    Stack s;
    s.stack_ptr=0;
    s.ptr_max=-1;
    std::string ch;
    while(std::cin>>ch){
        if(ch=="+"){
            push(pop(s)+pop(s),s);
        }else if(ch=="-"){
            int a=-pop(s),b=pop(s);
            push(a+b,s);
        }else if(ch=="*"){
            push(pop(s)*pop(s),s);
        }else{
            int x=0,size=ch.size();
            for(int i=0;i<size;i++){
                x*=10;
                x+=ch[i]-'0';
            }
            push(x,s);
        }
    }
    std::cout<<s.nums[s.stack_ptr-1]<<'\n';
    return 0;
     
}


Measured memory_bytes: 3168
#include<stdio.h>

int solve(int ,int);
int A[20],n;

int main(){
  int i,q,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1){
      printf("yes\n");
    }else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res;
  if( m == 0) return 1;
  if(i >= n)return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}




Measured memory_bytes: 2108