akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    int ans = 700;
    rep(i,3) if(s[i] == 'o') ans += 100;
    ANS;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - B +/- A
	var A, B int
	fmt.Scanf("%d %d", &A, &B)
	if B%A == 0 {
		fmt.Println(A + B)
	} else {
		fmt.Println(B - A)
	}
}


Measured memory_bytes: 1832
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}



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

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

    map<char, int> m;
    REP(i, N) {
        m[S[i]]++;
    }

    ll ans = 1;
    for (auto&& s : m) {
        ans *= (s.second + 1);
        ans %= mod;
    }

    cout << ans - 1 << endl;
    return 0;

}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,k;
signed main(){
  cin>>n>>k;
  int ans = 0;
  repd(i,k,n+2){
    int s = i*(2*n-i+1)/2%MOD-i*(i-1)/2%MOD+1;
    add(ans, s);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3556
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 21:48:49 2020

@author: liang
"""
def min_search(a,b,c):
    if a < b:
        if a < c:
            return a
        else:
            return c
    else:
        if b < c:
            return b
        else:
            return c
        
        
X, Y, A, B, C = map(int,input().split())
red_apples = list(map(int,input().split()))
green_apples = list(map(int,input().split()))
colorless_apples = list(map(int,input().split()))

red_apples.sort(reverse=True)
green_apples.sort(reverse=True)
colorless_apples.sort(reverse=True)

#print(red_apples)
#print(green_apples)
#print(colorless_apples)

result_red = red_apples[0:X]
result_green = green_apples[0:Y]

#print(result_red)
#print(result_green)

i = X - 1
j = Y - 1
k = 0

while k <= C-1:
    if i < 0 :
        i = 0
    if j < 0 :
        j = 0
    mini = min_search(result_red[i], result_green[j], colorless_apples[k])
    if mini == colorless_apples[k]:
        break
    elif mini == result_red[i]:
        result_red[i] = colorless_apples[k]
        i -= 1
        k += 1
    else:
        result_green[j] = colorless_apples[k]
        j -= 1
        k += 1


score = sum(result_red) + sum(result_green)

print(score)

Measured memory_bytes: 22720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = Integer.parseInt(scan.next());
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        scan.close();

        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}

Measured memory_bytes: 35696
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;

int main(){
  int n;
  int maxN=0;
  vector<int> vec(100001, 0);
  vector<int> part(100001, 0);
  vector<int> ans;
  cin >> n;
  rep(i, 0, n){
    int tmp;
    cin >> tmp;
    vec[tmp]++;
    maxN = maxN<tmp ? tmp : maxN;
  }
  maxN++;
  part[0] += vec[0];
  rep(i, 1, maxN){
    part[i] += part[i-1] + vec[i];
  }
  rep(i, 0, 3){
    ans.push_back(part[i]);
  }
  rep(i, 3, maxN){
    ans.push_back(part[i]-part[i-3]);
  }
  sort(ans.begin(), ans.end());
  cout << ans.back() << endl;
  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<stack>
#include<queue>
using namespace std;

int main() {
  stack<int> c;
  queue<int> q;

  int n;
  while(cin >> n) {
    if(n == 0) {
      int s = c.top();
      q.push(s);
      c.pop();
    }else {
      c.push(n);
    }
  }

  while(!q.empty()) {
    cout << q.front() << endl;
    q.pop();
  }

  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll a, b, k;
  cin >> a >> b >> k;
  
  rep(i, 0, k) {
    if(i%2==0) {
      if(a%2==1) a--;
      b += a/2;
      a /= 2;
    }
    else {
      if(b%2==1) b--;
      a += b/2;
      b /= 2;
    }
  }    
  
  cout << a << " " << b << "\n";
}

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


int main()
{
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    for(ll i = 0; i < n; i++){
        ll temp;
        cin >> temp;
        a.push(temp);
    }
    for(ll i = 0; i < m; i++){
        ll temp = a.top();
        a.pop();
        temp /= 2;
        a.push(temp);
    }

    ll ans = 0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;


}

Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,K;
    cin >>N >> K;
    vector<int> val;

    for(int i=0;i<N;++i){
        int temp;
        cin >> temp;
        val.push_back(temp);
    }
    sort(val.begin(),val.end());

    int64_t sum =0;
    for(int i=0;i<K;++i){
        sum+= val[i];
    }

    cout<<sum <<endl;

}



Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int a, b, c;

int main() {
  cin >> a >> b >> c;

  if (c <= a + b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;

    int ret = 0;
    for (int start = 0; start < n; start++) {
        int size = n - start;
        std::vector<int> a(size);
        a[0] = size;
        int i = 1, j  =0;
        while (i < size) {
            while (i + j < size && s[start + j] == s[start + i + j]) ++j;
            a[i] = j;
            if (!j) {
                ++i;
                continue;
            }
            int k = 1;
            while (i + k < size && k + a[k] < j) {
                a[i + k] = a[k];
                ++k;
            }
            i += k;
            j -= k;
        }

        for (int i = 0; i < size; i++) {
            ret = std::max(ret, std::min(a[i], i));
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    string s;
    cin>>s;

    int count=0;
    int counts=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            count++;
        }
       else
       {
           count=0;
       }
       counts=max(counts,count);
    }
    // cout<<counts<<endl;
    cout<<counts<<endl;
    return 0;
}


Measured memory_bytes: 3612
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()

from collections import defaultdict
node = defaultdict(set)  # キーで指定したノードが隣接するノードを記録しておく。
for _ in range(N-1):
    u, v, w = read_ints()
    if w % 2:
        # wが奇数だったらTrue
        w = True
    else:
        w = False
    node[v-1].add((u-1, w))
    node[u-1].add((v-1, w))


# 0番目から探索していく
import numpy as np
ans = np.full(N, -1, dtype='int16')
# -1は未探索、1は黒、0は白、奇数の重みに当たるたびに反転
visited = np.full(N, False, dtype=bool)
from collections import deque
# 幅優先探索で白黒を記録していく
que = deque([(0, 0)])  # (nodeidx, 現在の色)
ans[0] = 0
visited[0] = True
while que:
    n, c = que.popleft()
    ans[n] = c

    for nex in node[n]:
        nex_node, nex_w = nex
        nex_color = c
        if visited[nex_node]:
            continue
        # 重みが奇数なら色を反転して探索に追加
        if nex_w:
            nex_color = 1-nex_color

        que.append((nex_node, nex_color))
        visited[nex_node] = True

print(*ans, sep='\n')


Measured memory_bytes: 69064
#include <iostream>
using namespace std;
const int N = 200010;
int array[N];

int main(){
    int len;
    cin >> len;
    int cnt = 0;
    for(int i = 0; i < len; i ++)
    {
        cin >> array[i];
    }
    int curr = 1;
    for(int i = 0; i < len; i ++){
        if(array[i] == curr) {
            cnt ++;
            curr ++;
        }
    }
    if(cnt == 0) cout << -1 << endl;
    else cout << len - cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * |-|-|-|-|-|-|    |-|-|-|-|-|-|-|
 * |1|2|3|4|5|6|  |0|1|2|3|4|5|6|7|8|9|0|
 *    |     |      |     |
 *    k     i      k     i
 */

int main()
{
    int n,k;
    while (cin >> n >> k) {
        LL ans = 0;
        FOR(i,k+1,n+1) {
            const int x = n/i;
            ans += 1LL*x*(i-k);
            const int r = n%i;
            if (r && r >= k) {
                /* if k=0, need to avoid double count */
                if (k)
                    ans += r-k+1;
                else
                    ans += r;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())

for j in range(n):
    nums = list(map(int, input().split()))

    b = [0]
    c = []
    ans = "YES"

    for i in range(10):
        if nums[i] > b[-1]:
            b.append(nums[i])
        else:
            c.append(nums[i])

    if len(c) > 1:
        x = c[0]
        for i in range(1, len(c)):
            if x > c[i]:
                ans = "NO"
            else:
                x = c[i]
    print(ans)






Measured memory_bytes: 5596
#include<bits/stdc++.h>
//#define m 1000000007
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;

int main()
{
	ll n;
	cin>>n;
	ll h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	ll cnt=0,max1=0;
	for (int i = 0; i < n-1; ++i)
	{
		if(h[i]>=h[i+1])
		{
			cnt++;
		}
		else
		{
			max1=max(max1,cnt);
			cnt=0;
		}
		//cout<<cnt;
	}
	max1=max(max1,cnt);
	cout<<max1<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=100005;
struct coord
{
    int val,ind;
}x[nmax],y[nmax];
bool comp(coord unu,coord doi)
{
    return unu.val<doi.val;
}
struct muchie
{
    int a,b,c;
}v[2*nmax];
int tt[nmax],rg[nmax];
int n,m,i,j;
long long cost;
bool comp_m(muchie unu,muchie doi)
{
    return unu.c<doi.c;
}
int finds(int x)
{
    int y=x,aux=0;
    while(x!=tt[x])
        x=tt[x];
    while(y!=x)
    {
        aux=tt[y];
        tt[y]=x;
        y=aux;
    }
    return x;
}
void unite(int A,int B)
{
    if(rg[A]>rg[B]) tt[B]=A;
    else tt[A]=B;
    if(rg[A]==rg[B]) rg[B]++;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x[i].val>>y[i].val;
        x[i].ind=i;y[i].ind=i;
    }
    sort(x+1,x+n+1,comp);
    sort(y+1,y+n+1,comp);
    for(i=1;i<n;i++)
    {
        m++;
        v[m].a=x[i].ind;
        v[m].b=x[i+1].ind;
        v[m].c=x[i+1].val-x[i].val;
        m++;
        v[m].a=y[i].ind;
        v[m].b=y[i+1].ind;
        v[m].c=y[i+1].val-y[i].val;
    }
    sort(v+1,v+m+1,comp_m);
    for(i=1;i<=n;i++)
        tt[i]=i;
    for(i=1;i<=m;i++)
    {
        if(finds(v[i].a)!=finds(v[i].b))
        {
            unite(finds(v[i].a),finds(v[i].b));
            cost+=1LL*v[i].c;
        }
    }
    cout<<cost;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int>P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/

const int MAX_N = 100000+10;

vec memo(MAX_N,-1); // memo[i] が i についての答え
int rec(int n){
    if(n==0)return memo[n]=0;
    if(memo[n]>=0) return memo[n];
    int res=INF;
    for(int pow6=1;pow6<=n;pow6*=6)res=min(res,rec(n-pow6)+1);
    for(int pow9=1;pow9<=n;pow9*=9)res=min(res,rec(n-pow9)+1);
    return memo[n]=res;
}

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

    cout << rec(n) << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int y[] = { -1, 0, 1, -1, 1, -1, 0, -1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

ll arr[N];
int main()
{
	assem99;

	ll n; cin >> n;
	ll cntr = 0;
	f(i, 0, n) cin >> arr[i];
	f(i, 0, n)
	{
		if (arr[i] < 0)cntr++;
	}
	ll ans = 0;
	if (cntr % 2)
	{
		ll mn = 1e9;
		f(i, 0, n)
		{
			ans += abs(arr[i]);
			mn = min(mn, abs(arr[i]));
		}
		cout << ans - 2 * mn;
	}
	else
	{
		f(i, 0, n) ans += abs(arr[i]);
		cout << ans;
	}


	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		int H = readInt(), W = readInt(), D = readInt(); int board[][] = new int[H+1][W+1]; int X[] = new int[H*W+1], Y[] = new int[H*W+1];
		for(int i = 1; i<=H; i++) for(int j = 1; j<=W; j++) {
			board[i][j] = readInt(); X[board[i][j]] = i; Y[board[i][j]] = j;
		}
		int prefixboard[][] = new int[D+1][H*W/D+4];
		for(int i = 1; i<=D; i++) {
			int crntX = X[i], crntY = Y[i]; 
			for(int j = i, k = 1; j<=H*W; j += D, k++) {
				prefixboard[i%D][k] = prefixboard[i%D][k-1] + Math.abs(crntX-X[j])+Math.abs(crntY-Y[j]);
				crntX = X[j]; crntY = Y[j];
			}
		}
		int Q = readInt(); for(int q = 0; q < Q; q++) {
			int L = readInt(), R = readInt(); 
			if(L%D==0)println(prefixboard[L%D][R/D]-prefixboard[L%D][L/D]);
			else println(prefixboard[L%D][R/D+1]-prefixboard[L%D][L/D+1]);
//			println(prefixboard[L%D][R/D] + " " + (R/D) + " " + prefixboard[L%D][L/D] + " " + (L/D));
		}
//		for(int i = 0; i<=D; i++) {for(int j = 1; j<=9; j++) print(prefixboard[i][j] + " "); println();}
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 47708
N,M = map(int,input().split())
R,A = [0]*N,[1]*N
R[0] = 1
for i in range(M):
    x,y = map(int,input().split())
    x,y = x-1,y-1
    if A[x] > 1 and R[x] == 1:
        R[y] = 1
    elif A[x] ==  R[x] == 1:
        R[x] = 0
        R[y] = 1
    A[x] -= 1
    A[y] += 1
print(sum(R))

Measured memory_bytes: 10292
#include <iostream>

int main()
{
	int N,M,C;
	std::cin >> N>>M>>C;
	int B[22];
	int A[22][22];
	for (int i = 0; i < M;i++)std::cin >> B[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			std::cin >> A[i][j];
		}
	}
	int counter = 0;
	for (int i = 0; i < N; i++) {
		int check = 0;
		for (int j = 0; j < M; j++) {
			check += A[i][j] * B[j];
		}
		check += C;
		if (check > 0)counter++;
	}

	std::cout << counter;
   return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()

	n, x := io.Int(), io.Int()

	ll := []int{}
	for i := 0; i < n; i++ {
		ll = append(ll, io.Int())
	}

	ans := 1

	sum := 0
	for i := 0; i < n; i++ {
		if i == 0 {
			sum = ll[i]
		} else {
			sum += ll[i]
		}

		if sum <= x {
			ans++
		}
	}
	fmt.Println(ans)
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) Int() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Float() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

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

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

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

int main() {
  int N, ans=0;
  cin >> N;
  
  VI a(N);
  
  REP(i,N){
   cin >> a.at(i);
  }
  
  int t=0;
  
  REP(i,N){
    if(a.at(i) == t+1) t++;
  }
  
  if(!t) ans = -1;
  else ans = N-t;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);

	sort(a.begin(), a.end());
	int mx = 0;
	rep(i, n-1){
		int dif = a.at(i+1) - a.at(i);
		mx = max(mx, dif);
	}
	int lr = k - a.at(n-1);
	lr += a.at(0);
	mx = max(mx, lr);
	cout << k - mx << endl;
	return 0;
}

Measured memory_bytes: 1024
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b, c) = (line[0], line[1], line[2]);

    if c <= a+b{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    multiset<int> st;
    int ans = 0;
    rep(i, n) {
        auto it = st.lower_bound(a[i]);
        if(it == st.begin()) ++ans;
        else {
            --it;
            st.erase(it);
        }
        st.insert(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#include <limits>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    ll h,n;
    cin>>h>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        h-=a[i];
    }
    if(h<=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
std::vector<char> a;
int main(void)
{
	std::string s;
	std::cin >> s;
	for (auto c : s)
		if (c == 'B' && a.size())
			a.pop_back();
		else if (c ^ 'B')
			a.push_back(c);
	for (auto c : a)
		std::cout << c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(3*N);
	priority_queue<int,vector<int>,greater<int>> Q1;
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q2;
	
	long long S1=0,S2=0;
	
	for(int i=0;i<3*N;i++){
		cin>>a[i];
		if(i<N){
			Q1.push(a[i]);
			S1 += (long long)a[i];
		}
		else{
			Q2.push(make_pair(a[i],i));
		}
	}
	
	set<pair<int,int>> s;
	
	for(int i=0;i<N;i++){
		pair<int,int> P = Q2.top();
		Q2.pop();
		S2 += (long long)P.first;
		s.insert(P);
	}
	
	vector<bool> used(3*N,false);
	
	long long ans = S1-S2;
	for(int i=0;i<N;i++){
		Q1.push(a[N+i]);
		S1+=a[N+i];
		S1 -= Q1.top();
		Q1.pop();
		used[N+i]=true;
		if(s.count(make_pair(a[N+i],N+i))){
			s.erase(make_pair(a[N+i],N+i));
			S2 -= a[N+i];
			while(true){
				pair<int,int> P = Q2.top();
				Q2.pop();
				if(used[P.second])continue;
				s.insert(P);
				S2 += P.first;
				break;
			}
		}
		//cout<<','<<S1<<','<<S2<<endl;
		ans = max(ans,S1-S2);
		
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 8048
#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;

const int MAX = 500005;


void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

struct Query
{
  int l, r, idx;
};

bool cmp(Query x, Query y)
{
  return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
  for (; idx <= n; idx += idx & -idx)
    bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
  int sum = 0;
  for (; idx > 0; idx -= idx & -idx)
    sum += bit[idx];
  return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
  int bit[n + 1];
  memset(bit, 0, sizeof(bit));

  int last_visit[MAX];
  memset(last_visit, -1, sizeof(last_visit));

  int ans[q];
  int query_counter = 0;
  for (int i = 0; i < n; i++)
  {
    if (last_visit[arr[i]] != -1)
      update (last_visit[arr[i]] + 1, -1, bit, n);

    last_visit[arr[i]] = i;
    update(i + 1, 1, bit, n);

    while (query_counter < q && queries[query_counter].r == i)
    {
      ans[queries[query_counter].idx] =
        query(queries[query_counter].r + 1, bit, n) -
        query(queries[query_counter].l, bit, n);
      query_counter++;
    }
  }

  for (int i = 0; i < q; i++)
    cout << ans[i] << endl;
}


void solve()
{

  int n, q;
  cin >> n >> q;

  int a[n];

  fo(i, 0, n - 1) cin >> a[i];

  Query queries[q];

  fo(i, 0, q - 1)
  {
    cin >> queries[i].l >> queries[i].r;
    queries[i].l--;
    queries[i].r--;
    queries[i].idx = i;
  }

  sort(queries, queries + q, cmp);
  answeringQueries(a, n, queries, q);

}


int main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 17424
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return (a*b//gcd(a,b))
#####segfunc######
def segfunc(x,y):
    return gcd(x,y)

def init(init_val): #渡されたリストでsegを初期化
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x): #segの要素kをxに変更(セグ木全体の更新)
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q): #区間[p,q)での、segfuncに準じた値を返す
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
"""
最小値のセグ木 → 10**9　(最小値の更新に影響しないため)
　　和のセグ木 → 0　(上の単位元の説明を参照)
　　積のセグ木 → 1　(上の単位元の説明を参照)
　　gcdのセグ木 → 0　(gcdを更新しない値は0)
"""
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num #単位元の配列(計算結果に影響を及ぼさない配列)
init(lst1)
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans,query(1,n))
    elif i == n-1:
        ans = max(ans,query(0,n-1))
    else:
        ans = max(ans,gcd(query(0,i),query(i+1,n)))

print(ans)

Measured memory_bytes: 87812
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
void func(int,int);
int a,b,n,k[17][17],cnt;
int main(void)
{
	int i,j,x,y;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		scanf("%d",&n);
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++) k[i][j]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			k[y][x]=1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int yy,int xx){
	if(yy==b&&xx==a) cnt++;
	else{
		if(xx+1<=a&&k[yy][xx+1]==0) func(yy,xx+1);
		if(yy+1<=b&&k[yy+1][xx]==0) func(yy+1,xx);
	}
}

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

int main() {
  int n, x; cin >> n >> x;
  vector<int> vec(n+1);
  vec[0]= 0;
  for(int i=0; i<n; i++) {
    int l; cin >> l;
    vec[i+1] = vec[i] + l;
  }
 
  int ans=0;
  for(int i=0;i<=n;++i) if (vec[i] <= x) ans++;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int maxi(int a,int b)
{
  if(a>b) return a;
  else return b;
}

int main()
{
  int n,k,ans;
  cin>>n>>k;
  string s;
  cin>>s;
  //ある範囲をk回1に変える
  //0が終わるとこをinsertする
  vector<int> end,start;
  rep(i,n)
  {
    if(i<n-1)
    {
      if(s.at(i)=='0' && s.at(i+1)=='1') end.push_back(i+1);
    }
    else
    {
      if(s.at(i)=='0') end.push_back(i+1);
    }
  }
  rep(i,n)
  {
    if(i>0)
    {
      if(s.at(i)=='0' && s.at(i-1)=='1') start.push_back(i+1);
    }
    else
    {
      if(s.at(i)=='0') start.push_back(i+1);
    }
  }

  if(end.size()<=k) ans=n;
  else if(end.size()-1>=k)
  {
      ans=start[k]-1;
      for(int i=1;i<=start.size()-k-1;i++)
      {
        ans=maxi(ans,start[i+k]-1-(end[i-1]));
      }
      ans=maxi(ans,n-(end[end.size()-1-k]));
  }
  else
  {
    ans=maxi(n-end.at(0),start.at(end.size()-1)-1);
  }


  cout<<ans<<endl;

}

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

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

    map<long,bool> m;
    for(int i = 0; i < n; i++)
    {  
        int a;
        cin >> a;

        if(m.find(a) == m.end()){
            m[a] = true;
        }else{
            m.erase(a);
        }
    }
    cout << m.size() << endl;

}
 


Measured memory_bytes: 6528
package main

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

//StrStdin Read standard input data
func StrStdin(line int) [][]string {
	var stringInput [][]string
	scanner := bufio.NewScanner(os.Stdin)

	for i := 0; i < line; i++ {
		scanner.Scan()
		if s := scanner.Text(); s != "" {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((scanner.Text())), " "))
		} else {
			break
		}
	}

	return stringInput
}

//rLine Read standard input data
func rLine(line int) [][]string {
	var rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	var buf = make([]byte, 0, 1000000)
	var stringInput [][]string

	for i := 0; i < line; {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((string(buf))), " "))
			buf = []byte{}
			i++
		}
	}
	return stringInput
}

func irLine(i int) [][]int {
	return alitoas(rLine(i))
}

//itoa converts string to integer
func itoa(s string) int {
	var i, _ = strconv.Atoi(s)
	return i
}

func itoas(S []string) []int {
	var result = make([]int, len(S))
	for i, s := range S {
		result[i] = itoa(s)
	}
	return result
}

func alitoas(S [][]string) [][]int {
	var result = make([][]int, len(S))
	for i, s := range S {
		result[i] = itoas(s)
	}
	return result
}

func main() {
	var lists [][]int = irLine(2)
	N := lists[0][0]
	A := lists[1]
	var result int
	sort.Ints(A)
	for i := 0; i < N-1; i++ {
		if A[i] == A[i+1] {
			result = 0
			break
		}
		result = 1
	}
	if result == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  long long N;
  string S;
  cin >> S;
  N = S.size();
  vector<long long> left(N+1);
  vector<long long> right(N+1);
  long long ans = 0;

  for(long long i = 0;i<N;i++){
    if(S.at(i)=='<'){
      left.at(i+1) = left.at(i)+1;
    }
    else{
      left.at(i+1) = 0;
    }
  }

  for(long long j = N-1;j>=0;--j){
    if(S.at(j)=='>'){
      right.at(j) =right.at(j+1)+1;
    }
    else{
      right.at(j) = 0;
    }
  }

  for(long long k=0;k<=N;k++){
    ans = ans + max(left.at(k),right.at(k));
  }
  cout << ans << endl;
}


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

int nt(int n){
  if(n%2==0)return n/2;
  else return 3*n+1;
}

int main(){
  int s,i,j;
  cin>>s;
  int a[1000000];
  
  a[0]=s;
  for(i=1;i<1000000;i++){
    a[i]=nt(a[i-1]);
    for(j=0;j<i;j++){
      if(a[i]==a[j]){
        cout<<i+1;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  char s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (s1 + s2 + s3) - (3 * '0') << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=4e5+7;
int a[17][17],b[17][17];
int main()
{
    int n;
    scanf("%d",&n);
    bool ff=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i][0]);
        int s=a[i][0];
        for(int j=1;j<=s;j++){
            scanf("%d%d",&a[i][j],&b[i][j]);
        }
    }
    int sum=1<<n;
    //printf("sum==%d\n",sum);
    int cmax=0;
    for(int i=0;i<sum;i++){
        int t=0,g=i;
        bool flag=0;
        while(g){if(g&1)t++;g>>=1;}
        //printf("t==%d\n",t);
        for(int j=0;j<n;j++){
            if((i&(1<<j))==0) continue;
            int u=a[j][0];
            for(int k=1;k<=u;k++){
                if(b[j][k]!=((i>>(a[j][k]-1))&1)){
                    flag=1;
                    //printf("i==%d j==%d k==%d   ss=%d\n",i,j,k,(i>>(a[j][k]-1)));
                }

            }
        }
        if(flag) continue;
        cmax=max(cmax,t);
        //printf("i==%d\n",i);
    }
    printf("%d\n",cmax);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    int ans=0;
    int premax=0;
    rep(i,n){
        int a;
        cin>>a;
        if(i==0){
            ans++;premax=a;
        }else{
            if(premax<=a){ans++;premax=a;}
        }


    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256