akhauriyash/Code-Regression huggingface dataset:
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)

Measured memory_bytes: 7864
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_set>

using namespace std;

int main() {
  cin.tie(0);
  char in[5];
  cin >> in;
  
  if (in[0] == in[1] && in[2] == in[3] && in[0] != in[2]) {
    cout << "Yes\n";
  } else if (in[0] == in[3] && in[1] == in[2] && in[0] != in[1]) {
    cout << "Yes\n";
  } else if (in[0] == in[2] && in[1] == in[3] && in[0] != in[1]) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

if min(a) > x:
    print(0)
    sys.exit()

if sum(a) == x:
    print(n)
    sys.exit()

a.sort()
l = 0
for i,s in enumerate(a):
  l += s
  if l > x:
    print(i)
    sys.exit()
print(n-1)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin>>s;
    rep(i,s.size()){
        if((i%2==0&&s[i]=='L')||(i%2!=0&&s[i]=='R')){ 
            out("No");
            return 0;
        }
    }
    out("Yes");
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            List<int> ls = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                ls.Add(int.Parse(ReadLine()));
            }
            int ans = 0;
            int min = 10;
            for (int i = 0; i < ls.Count(); i++)
            {
                if (ls[i] % 10 == 0)
                {
                    ans += (ls[i] / 10) * 10;
                }
                else
                {

                    if (ls[i] % 10 < min)
                    {
                        min = ls[i] % 10;
                    }
                    ans += (ls[i] / 10 + 1) * 10;
                }
            }
            WriteLine(ans - 10 + min);

        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = 0;
    res += a * (n / (a+b));
    auto m = n % (a+b);
    if (m >= a) {
        res += a;
    } else {
        res += m;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int a, b;
  scanf("%d %d" , &a,&b);
  if(a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  }  else  {
    printf("a == b\n");
  }
 
return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

// 置換行列P,Qの積。ただし、p,qは対応する順列で、P[i][j] == 1 <==> p[i] = j となっている。
// N次元行列の表現に、先頭が0のN+1要素ベクトルを利用している。
std::vector<int> perm_product(std::vector<int> p, std::vector<int> q) {
    assert(p.size() == q.size());
    std::vector<int> r;
    r.resize(p.size());
    int N = p.size() - 1;
    for (int i = 1; i <= N; i++) {
        r[i] = q[p[i]];
    }
    return r;
}

// 置換行列Pの転置。pは対応する順列。
std::vector<int> perm_trans(std::vector<int> p) {
    std::vector<int> r;
    r.resize(p.size());
    int N = p.size() - 1;
    for (int i = 1; i <= N; i++) {
        r[p[i]] = i;
    }
    return r;
}

// 置換行列Pの累乗。ただしpは対応する順列。
std::vector<int> perm_pow(std::vector<int> p, long long K) {
    std::vector<int> r;
    r.resize(p.size());
    int N = p.size() - 1;
    for (int i = 1; i <= N; i++) {
        r[i] = i;
    }

    while (K > 0) {
        if (K & 1) {
            r = perm_product(r, p);
        }
        p = perm_product(p, p);
        K = (K >> 1);
    }

    return r;
}

const int MAX_N = 100050;
int N;
int K;

std::vector<int> func(const std::vector<int>& p, const std::vector<int>& q) {
    assert(p.size() == q.size());
    std::vector<int> ret;
    ret.resize(p.size());

    for (int i = 1; i <= N; i++) {
        ret[p[i]] = q[i];
    }

    return ret;
}

std::vector<int> ret[7];

int main(int argc, char **argv) {
    std::cin >> N >> K;

    std::vector<int> p, q;
    p.resize(N+1);
    q.resize(N+1);

    for (int i = 1; i <= N; i++) {
        std::cin >> p[i];
    }

    for (int i = 1; i <= N; i++) {
        std::cin >> q[i];
    }

    int pow_num = (K - 1) / 6;
    std::vector<int> A = perm_product(perm_product(perm_trans(q), p), perm_product(q, perm_trans(p)));
    std::vector<int> A_pow = perm_pow(A, pow_num);

    ret[1] = perm_product(perm_product(A_pow, p), perm_trans(A_pow));
    ret[2] = perm_product(perm_product(A_pow, q), perm_trans(A_pow));

    for (int i = 3; i <= 6; i++) {
        ret[i] = perm_product(perm_trans(ret[i-2]), ret[i-1]);
    }

    int id = (K % 6 == 0) ? 6 : K % 6;

    for (int i = 1; i <= N; i++) {
        std::cout << ret[id][i] << " ";
    }
    std::cout << std::endl;

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))


int N,M;
multiset<int> E[101010];
vector<pair<int,int>> V;

int dfs(int cur,int pre) {
	int lef=-1;
	while(E[cur].size()) {
		int x=*E[cur].begin();
		E[cur].erase(x);
		E[x].erase(cur);
		int y=dfs(x,cur);
		
		if(y!=-1) {
			if(lef==-1) lef=y;
			else {
				V.push_back({cur,lef});
				V.push_back({cur,y});
				lef=-1;
			}
		}
	}
	
	if(lef!=-1) {
		if(pre!=-1) {
			V.push_back({cur,pre});
			V.push_back({cur,lef});
			return -1;
		}
	}
	return cur;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x].insert(y);
		E[y].insert(x);
	}
	if(M%2) return _P("-1\n");
	
	dfs(1,-1);
	FORR(v,V) cout<<v.first<<" "<<v.second<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{
    if(a%b==0)
    {
        return b;
    }
    else
        return gcd(b,a%b);
}
int main()
{
    int x;
    cin>>x;
    int a[x+5],b[x+5],c[x+5];
    int ans=0;
    for(int i=1; i<=x; i++)
    {
        for(int j=1; j<=x; j++)
        {
            for(int k=1; k<=x; k++)
            {
                int x=gcd(i,j);
                ans+=gcd(x,k);
                //cout<<x<<endl;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

struct Node {
  ll key;
  Node *parent, *left, *right;
};
Node *root, *NIL;

void insert(ll k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  ll n; cin >> n;
  string com;
  REP(i, n) {
    cin >> com;
    if (com == "insert") {
      ll x; cin >> x;
      insert(x);
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 26624
#include <iostream>
#include <string>
#include <set>
using namespace std;
 
int main() {
	int k;
	string s;
	set<string> a;
 
	cin >> s >> k;
	for(int i = 0; i < s.size(); i++)
		for(int j = 1; j <= k && i + j <= s.size(); j++)
			a.insert(s.substr(i, j));
 
	auto it = a.begin();
	advance(it, k - 1);
	cout << *it << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());
	int res = 0;
	rep(i, n - 1) res += l[i];
	if (l[n - 1] < res) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=3002;
const ll mod=998244353;
ll dp[M][M];
ll a,b,c,d;
ll solve(ll x,ll y)
{
	if(x==a && y==b)
		return 1;
	if(x<a || y<b)
		return 0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	ll z = y*solve(x-1,y)+x*solve(x,y-1)-(x-1)*(y-1)*solve(x-1,y-1);
	z=(z%mod+mod)%mod;
	return dp[x][y]=z;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>a>>b>>c>>d;
	memset(dp,-1,sizeof(dp));
	cout<<solve(c,d)<<"\n";
	return 0;
}

Measured memory_bytes: 74408
const md = 1000000007;
type ary=array[0..2010] of int64;
var n,k,i,j,ans,save,count1,count2,sum1,sum2,save1,save2:int64;
    a:ary;
    

begin
read(n,k);
ans:=0;
sum2:=((k+1)*k div 2) mod md;
sum1:=((k-1)*k div 2) mod md;
for i := 0 to n-1 do read(a[i]);
for i := 0 to n-1 do
begin
 count1:=0;count2:=0;
 for j := 0 to i-1 do
 if a[i]>a[j] then inc(count1);
 for j := i+1 to n-1 do
 if a[i]>a[j] then inc(count2);
 if (count1=0)and(count2=0) then continue;
 save1:=sum1*count1 mod md;
 save2:=sum2*count2 mod md;
 ans:=(ans+save1) mod md;
 ans:=(ans+save2) mod md;
end;


write(ans)
end.

Measured memory_bytes: 128
n,x = map(int,input().split())
cnt = [0]*(n+1)
pcnt = [0]*(n+1)
cnt[0] = pcnt[0] = 1
for i in range(n):
    cnt[i+1] = cnt[i]*2+3
    pcnt[i+1] = pcnt[i]*2+1

def f(lv,x):
    if lv == 0: return 1
    elif x <= 1: return 0
    elif x <= cnt[lv-1] + 1: return f(lv-1,x-1)
    elif x == cnt[lv-1] + 2: return pcnt[lv-1]+1
    elif x <= 2*cnt[lv-1] + 2: return pcnt[lv-1]+1+f(lv-1,x-cnt[lv-1]-2)
    else: return pcnt[lv]

print(f(n,x))

Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int main(){
  int n,cnt=0;
  int a[101]={};
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int flag=1;
  while(flag){
    flag=0;
    for(int i=n-1;i>=1;i--)
      if(a[i]<a[i-1]){
	int temp=a[i];
	a[i]=a[i-1];
	a[i-1]=temp;
	flag=1;
	cnt++;
    }
  }
    for(int i=0;i<n-1;i++)
      cout<<a[i]<<' ';
    cout<<a[n-1]<<endl<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3096
def abs(a):
    if a < 0:
        return -a
    return a

def main():
    n, k = map(int, input().split())
    n = n % k

    if n < k:
        if n > abs(n-k): 
            print(abs(n-k))
        else:
            print(n)
    else:
        print(n)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    final int A,B,C;
    int ans=0;
    A = sc.nextInt();B=sc.nextInt();C=sc.nextInt();
    if(A+B >= C){
      ans = B+C;
    }
    else{
      if(A >= B ){
        ans = A + B +Math.min(C-A,B)+1;
      }
      else {
        ans =A + B + Math.min(C-A,B)+1;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){

    int k, x;
    cin >> k >> x;

    int l,r;
    l = x - (k - 1);
    r = x + (k - 1);

    for (int i=l; i<=r; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
g = [0]*(10**6+1)
s = [1]*(10**6+1)
for x in a:
  g[x] += 1
for i in range(1, 10**6+1):
  if g[i] and s[i]:
    for j in range(2*i, 10**6+1, i):
      s[j] = 0
print(sum(1 for i in range(10**6+1) if g[i] == s[i] == 1))

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

int main() {
  int n,t,a;
  cin>>n>>t>>a;
  int b,e=0;//eに０を代入
  double d=650.0;//a=t,a=10^5でmax差６５０
  vector<double> c(n,0);
  for (int i=0;i<n;i++){
    cin>>b; 
    if(t-b*0.006>=a) c[i]=t-b*0.006-a;
    else c[i]=a-t+b*0.006;
    if(d>c[i]) {e=i+1;d=c[i];}
    }
  cout<<e<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  long double ans = 0;
  rep(i, n) {
    long double x;
    string u;
    cin >> x >> u;
    if (u == "BTC") x *= 380000;
    ans += x;
  }
  cout << ans << endl;
}

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





int main() {
			int n; cin >> n;
			vector<int> vec;
			for(int i = 0; i < n; i++) {
				int x; cin >> x; vec.push_back(x);
			}
			int res = 0;	
			for(int i = 0; i < n;i++) {
				for(int j = i+1; j < n; j++) {
					res += vec[i]*vec[j];
				}
			}
			cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;

bool is_prime(int p) {
	for (int i = 2; i*i <= p; i++) {
		if (p%i == 0) {
			return false;
		}
	}

	return true;
}


int main() {
	int N;

	cin >> N;
	int p = 11;

	/*1の位が1であるような素数を探す*/
	for (int i = 0; i < N; i++) {
		while (!is_prime(p)) {
			p += 10;
		}
		cout << p << ' ';
		p += 10;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<cctype>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

  string S;
  ll ans = 0;

  cin >> S;

  ll count = std::count(S.begin(), S.end(), 'S');

  if(count == 3) cout << "0" << endl;
  else if(count == 2) cout << "1" << endl;
  else if(count == 1){

   for(ll i = 0;i < S.length();++i){

     if(i == 1 && 'S' == S[i]){

       cout << '1' << endl;
       return 0;

     }if((i == 0 || i == 2) && 'S' == S[i]){

       cout << '2' << endl;
       return 0;

     }

    }

  }
  else if(count == 0) cout << "3" << endl;

  return 0;

}   


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

#define sq(a) ((a) * (a))

int n;
int x[24], y[24], r[24], c[24];
int s[24];
char dp[1 << 24];

int calc(int bit)
{
	if (~dp[bit]) return dp[bit];
	int res = 0;
	for (int i = 0; i < n; i++){
		if (bit & (1 << i)) continue;
		if (s[i] & ~bit) continue;
		for (int j = 0; j < i; j++){
			if (bit & (1 << j)) continue;
			if (c[i] != c[j]) continue;
			if (s[j] & ~bit) continue;
			res = max(res, 2 + calc(bit | (1 << i) | (1 << j)));
		}
	}
	return dp[bit] = res;
}

int main()
{
	while (cin >> n, n){
		memset(s, 0, sizeof(s));
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < n; i++){
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < i; j++){
				if (sq(x[i] - x[j]) + sq(y[i] - y[j]) < sq(r[i] + r[j])){
					s[i] |= 1 << j;
				}
			}
		}
		cout << calc(0) << endl;
	}
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;


string s[1111];

int main(void)
{
	li n, l;
	cin >> n >> l;
	rep(i, n) {
		cin >> s[i];
	}
	sort(s, s + n);
	rep(i, n) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int l, r, d, a1, a2, ans;
	cin >> l >> r >> d;
	a1 = (l - 1) / d;
	a2 = r / d;
	ans = a2 - a1;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

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

#define mp       make_pair
#define mt	 make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,K;
set<char> set_bad;
int main(){
  cin >> N >> K;
  for (int i = 0; i < K; i++){
    char c;
    cin >> c;
    set_bad.insert(c);
  }
  for (int i = N; ; i++){
    string tmp = to_string(i);
    bool ok = true;
    for (int j = 0; j < tmp.size(); j++){
      if (set_bad.count(tmp[j]) > 0){
	ok = false;
	break;
      }
    }
    if (ok){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ios_base::sync_with_stdio(false);
#define MAXN 500005          // cin.tie(NULL);
#define di pair<int, int>
#define tri pair<int, di>
#define bi pair<bool, int>
using namespace std;
void swap(int ar[],int  i,int j)
    {int aux = ar[j]; ar[j] = ar[i]; ar[i] = ar[j];}

vector<di> m[MAXN];
int seen[MAXN];

void dfs(int v){
    
    for(int k = 0 ;  k < m[v].size(); k++){
        di at = m[v][k];
        if (seen[at.first] == 5){
            if(at.second % 2 == 0 ){
                seen[at.first] = seen[v];
                dfs(at.first);
            }
            else{
                if(seen[v] == 0)
                    seen[at.first] = 1; 
                else
                    seen[at.first] = 0;
                dfs(at.first);
            }
        }
    }
}




int main(){
    
    int n;
    cin >> n;
    int v, u, s ;
    for(int i = 1; i <= n;i++){
        seen[i] = 5;
    }

    for(int i =0; i < n-1; i++){
        cin >> v >> u >> s;
        m[u].push_back({v, s});
        m[v].push_back({u, s});
    }

    seen[1] = 0;
    dfs(1);
    for(int i = 1; i <= n;i++){
        cout << seen[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
int prime(long long n)
{

	if(n<=2) return 1;
	if(n%2==0) return 0;

	for(long long i=3;i*i<=n;i++)
    {
        if(n%i==0)
        return 0;
    }

    return 1;
}
void solve()
{
   ll x;
   cin>>x;
   while(prime(x) !=1)
   {
       x++;
   }
   cout<<x<<endl;
}

int main()
{
#ifndef oj
    // freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
    // system("cls");
    //getchar();

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



}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


int f(int h, int w, int d) {
  const int mod = 2*d;
  h = (h % mod + mod) % mod;
  w = (w % mod + mod) % mod;

  int res = 0;
  if (h >= d) res += 1;
  if (w >= d) res += 2;
  return res;
}

char t[510][510];

bool check(int H, int W, int d) {
  REP(i1, H) REP(j1, W) {
    REP(i2, H) REP(j2, W) {
      if (abs(i1 - i2) + abs(j1 - j2) == d) {
        if (t[i1][j1] == t[i2][j2]) {
          return false;
        }
      }
    }
  }
  return true;
}

int main2() {
  int H = nextLong();
  int W = nextLong();
  int d = nextLong();

  REP(i, H) {
    REP(j, W) {
      t[i][j] = "RGBY"[f(i+j, i-j, d)];
    }
  }

  REP(i, H) {
    REP(j, W) cout << t[i][j];
    cout << '\n';
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
string a[101];
int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

int main(){

    int N, a;
    cin >> N;
    vector<int> As;
    vector<long long> table(N+10, 0);
    for(int i=0;i<N;++i){
        cin >> a;
        As.push_back(a);
        ++table.at(a);
    }

    long long all_c = 0;
    for(long long e: table){
        all_c += e*(e-1)/2;
    }

    for(int a:As){
        cout << all_c - table[a]*(table[a]-1)/2 + (table[a]-1)*(table[a]-2)/2 << endl;
    }
                                     
    return 0;
}


Measured memory_bytes: 5108
import collections
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
a = collections.Counter(A)
a = a.most_common()[::-1]

if N % 2 == 0:
    for i in range(len(a)):
        if a[i][0] % 2 == 1 and a[i][1] == 2:
            pass
        else:
            print(0)
            exit()
    ans = (2 ** (N // 2)) % mod

else:
    for i in range(len(a)):
        if a[i][0] == 0:
            if a[i][1] == 1:
                pass
            else:
                print(0)
                exit()
        else:
            if a[i][0] % 2 == 0 and a[i][1] == 2:
                pass
            else:
                print(0)
                exit()
    ans = (2 ** (N // 2)) % mod 
print(ans)

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

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

LL area2(
    const LL ax, const LL ay,
    const LL bx, const LL by,
    const LL cx, const LL cy)
{
    const LL A = ax*(by-cy)+bx*(cy-ay)+cx*(ay-by);
    return abs(A);
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    LL S;
    while (cin >> S) {
        const LL a = 1;
        const LL b = 1e9;
        const LL c = S + a*b;
        const LL x0 = 1, y0 = 0;
        const LL x1 = x0*c;
        const LL y1 = y0*c;
        LL lo = 0, hi = 1e9;
        while (lo < hi) {
            const LL mid = lo + (hi-lo)/2;
            const LL x = x1 - mid*b;
            const LL y = y1 + mid*a;
            if (x < 1e9)
                hi = mid;
            else
                lo = mid+1;                    
        }
        const int cx = y1 + lo*a;
        const int cy = x1 - lo*b;
        const int ax = 1, ay = 0;
        const int bx = 0, by = b;
        printf("%d %d %d %d %d %d\n",ax,ay,bx,by,cx,cy);
        const LL A = area2(ax,ay,bx,by,cx,cy);
        int ans[] = { ax,ay,bx,by,cx,cy };
        FOR(i,0,SZ(ans)) if (!(0 <= ans[i] && ans[i] <= 1e9))
            printf("error: %d %d %d %d %d %d\n",ax,ay,bx,by,cx,cy);
        if (A != S) {
            printf("error: %lld %lld\n",A,S);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
//map<string,bool> mp;
string s,str1,str2;
int m,n=1,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>s;
//	mp[" "]=1;
	if(s.size()==1){
		cout<<1;
		return 0;
	}
	str2=s[0];
	while(n<s.size()){
		str1=s[n];
		m=1;
		while(str1==str2&&n+m<s.size()){
			str1+=s[n+m];
			m++;
		}
		if(n+m>=s.size()&&str1==str2) ans--;
//		mp[str]=1;
		str2=str1;
		ans++;
//		cout<<str1<<" ";
		n+=m;
	}
	cout<<ans+1;
	return 0;
}


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

int main() {
	string S, T, U;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	cin >> U;
	cout << (S == U ? A - 1 : A) << " " << (T == U ? B - 1 : B) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        string str;
        cin>>str;
        if(str=="0"){
            break;
        }
        int sum=0;
        for(int i=0;i<(int)str.size();i++){
            sum+=str[i]-'0';
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
signed main(){
	int n,l[210];
	cin>>n;
	for(int i=0;i<2*n;i++)cin>>l[i];
	sort(l,l+2*n);
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans=ans+l[i];
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define BUF (1000)

int N;
long long T[BUF];
void input(void){
	cin >> N;
	for(int i=1;i<=N;i++) cin >> T[i];
}

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

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

int main(void){
	input();

	long long  ans=1;
	for(int i=1;i<=N;i++){
		ans = lcm(ans,T[i]);
	}
	cout << ans << endl;
/*	sort(T+1,T+N+1);

	long long b = T[N];
	long long cnt = 1;
	while(1){
		int f=1;
		for(int i=N-1;i>0;i--){
			if(((long long)cnt*b)%T[i]!=0){
				f=0;
				break;
			}			
		}
		if(f==1) break;
		cnt++;
	}
	cout << (long long)cnt*b << endl;
*/
	return 0;
}


Measured memory_bytes: 256
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))
T = list(input())

ans = 0
flag = []
for i in range(N):
    if i < K:
        if T[i] == 'r':
            ans += P
            flag.append('p')
        elif T[i] == 's':
            ans += R
            flag.append('r')
        elif T[i] == 'p':
            ans += S
            flag.append('s')
    else:
        if T[i] == 'r' and flag[i-K] != 'p':
            ans += P
            flag.append('p')
        elif T[i] == 's'  and flag[i-K] != 'r':
            ans += R
            flag.append('r')
        elif T[i] == 'p'  and flag[i-K] != 's':
            ans += S
            flag.append('s')
        else:
            flag.append(0)
print(ans)

Measured memory_bytes: 53516
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans=0,a;
    for(ll i=0;i<3;i++){
        cin>>a;
        ans^=a;
    }
    cout<<ans;


    return 0;
}



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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	set<char> s;
	REP(i, n){
		char c;
		cin >> c;
		s.insert(c);
	}
	cout << (s.size() == 4 ? "Four" : "Three") << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {
double x1, y1, x2, y2, x3, y3, xp ,yp,ss,s1,s2,s3;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
ss=fabs((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1));
s1=fabs((x3-xp)*(y2-yp)-(x2-xp)*(y3-yp));
s2=fabs((x3-xp)*(y1-yp)-(x1-xp)*(y3-yp));
s3=fabs((x2-xp)*(y1-yp)-(x1-xp)*(y2-yp));

if(fabs(s1+s2+s3-ss)<0.001){
	cout<<"YES"<<endl;
}
else{
	cout<<"NO"<<endl;
}}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string W,T;
  cin >> W;
  int i,j = 0;
  for(i = 0; i < W. size( ); i++) {
    if('A' <= W[i] && W[i] <= 'Z') W[i] += 'a'-'A';
  }
  cin >> T;
  while(T != "END_OF_TEXT"){
    for(i = 0; i < T. size( ); i++) {
      if('A' <= T[i] && T[i] <= 'Z') T[i] += 'a'-'A';
    }
    if(W == T) j++;
    cin >> T;
  }
  cout << j << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <unordered_set>


using namespace std;


int main()
{
    int X, A;
    cin >> X >> A;
    if(X<A)
        cout<<0<<endl;
    else
        cout<<10<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n,k;
	cin>>n;
	k=2;
	vll a(n);
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	vll dp(n, INF);
	dp[0]=0;
	for(ll i=1; i<n; i++){
		for(ll j=max(0ll, i-k); j<i; j++){
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4764
N = int(input())

def it(remain,n):
    if remain == 0:
        yield tuple()
    else:
        for x in range(n):
            for d in it(remain-1,n):
                yield (x,)+d
        for d in it(remain-1,n+1):
            yield (n,)+d


print(*(''.join(chr(x+ord('a')) for x in d) for d in it(N,0)), sep='\n')



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  for(int i=0; i<m; i++){
    cin >> b.at(i);
  }
  
  for(int i=0; i<n-m+1; i++){
    for(int j=0; j<n-m+1; j++){
      if (a.at(i).at(j) != b.at(0).at(0)) continue;
      bool c0 = true;
      int cnt = 0;
      for(int k1=0; k1<m; k1++){
        for(int k2=0; k2<m; k2++){
          if(a.at(i+k1).at(j+k2) != b.at(k1).at(k2)){
            c0=false;
            break;
          }
          cnt++;
        }
        if(c0 == false) break;
      }
      if (cnt == m * m) {
        cout << "Yes" << endl;
        return 0;
      }
    }

  }
  
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007




ll n, a, b, k, ans = 0, f[310000];

ll kn(ll aa, ll bb) {
	aa %= 998244353;
	ll res = 1;
	while (bb > 0) {
		if (bb % 2 == 1)res *= aa;
		aa *= aa;
		bb /= 2;
		aa %= 998244353;
		res %= 998244353;
	}
	return res;
}

ll com(ll aa, ll bb) {
	return f[aa] * kn(f[aa - bb] * f[bb], 998244351) % 998244353;
}

int main() {
	f[0] = 1;
	REPO(i, 300000)f[i] = f[i - 1] * i % 998244353;
	cin >> n >> a >> b >> k;
	REP(i, n + 1) {
		ll now = k - a * i;
		if (now % b == 0 and now / b >= 0 and now / b <= n) {
			ans += com(n, i) * com(n, now / b);
			ans %= 998244353;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
import sys
import collections

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

Edge = collections.namedtuple('Edge', ['s', 't', 'cost'])
    
V, E = map(int, sys.stdin.readline().split())
edges = sorted([Edge(*map(int, line.split())) for line in sys.stdin], key=lambda e: e.cost)
uf = UnionFind(V)
min_cost = 0
for edge in edges:
    if not uf.are_same(edge.s, edge.t):
        uf.union(edge.s, edge.t)
        min_cost += edge.cost
print(min_cost)


Measured memory_bytes: 26428
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
prev = 0
count = 0
for i, a in enumerate(A):
  if i >= N:
    if A[i] < prev:
      count += A[i]
      continue
    else:
      count += prev
      continue

  if prev >= a:
    count += a
    prev = B[i]
    continue
  
  if prev + B[i] >= a:
    count += a
    temp_a = a - prev
    prev = B[i] - temp_a
    continue
  else:
    count += B[i]+prev
    prev =0
  
print(count)

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    string X; cin >> X;
    int ans = 0;
    int len = X.size();

    int r = 0;
    rep(i,len) {
        if(X[i] == 'T') {
            if(r == 0) ans++;
            r = max(0, r-1);
        } else r++;
    }

    ans += r;
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int ans = 1;
    int asc = 0;
    REP(i, n - 1) {
        if (asc == 0) {
            if (a[i] < a[i + 1]) {
                asc = 1;
            } else if (a[i] > a[i + 1]) {
                asc = -1;
            }
        } else if (asc == 1) {
            if (a[i] > a[i + 1]) {
                asc = 0;
                ans++;
            }
        } else {
            if (a[i] < a[i + 1]) {
                asc = 0;
                ans++;
            }

        }
    }
    cout << ans << EOL;
}


Measured memory_bytes: 640
import Control.Monad
import Control.Applicative
import Data.List

solve :: [Int] -> String
solve ns =
            unwords . map show $ sort ns

main =      
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
        where
            takeInputs :: [String] -> [[Int]]
            takeInputs = takeWhile (not . all (== 0)) . map (map read . words)



Measured memory_bytes: 4576
X,N=map(int,input().split())
if N==0:
	print(X)
	exit()
p=list(map(int,input().split()))
if X not in p:
	print(X)
	exit()
tmp=101
for i in range(200):
	if i not in p:
		if tmp>abs(X-i):
			ans=i
			tmp=abs(X-i)
print(ans)


Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;
typedef pair<lld,lld> node;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	vector<node> p(n);

	for(int i = 0; i < n; i++)
	{
		cin >> p[i].first >> p[i].second;
	}
	unsigned long long  sol = 4*1e18;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			for(int k = 0; k < n; k++)
			{
				for(int l = 0; l < n; l++)
				{
					lld x_min = min(min(p[i].first,p[j].first),min(p[k].first,p[l].first));
					lld x_max = max(max(p[i].first,p[j].first),max(p[k].first,p[l].first));
					lld y_min = min(min(p[i].second,p[j].second),min(p[k].second,p[l].second));
					lld y_max = max(max(p[i].second,p[j].second),max(p[k].second,p[l].second));

					lld cnt = 0;

					for(int q = 0; q < n; q++)
					{
						if (x_min <= p[q].first && p[q].first <= x_max && y_min <= p[q].second && p[q].second <= y_max )
						{
							cnt++;
						}
					}

					if (cnt >= K)
					{
						unsigned long long s = abs(x_max-x_min) * abs(y_max-y_min);
						if (s < sol)
						{
							sol = s;
						}
					}
				}
			}
		}
	}

	cout << sol << endl;

	return 0;
}

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

int result = INT_MAX;
int D;
long int G;

int addd(vector<int> t)
{
    int k=0;
    for(int i=0;i<t.size();i++)
    {
        k += t[i];
    }
    return k;
}

void check(vector<int> &data, vector<int> &comp,vector<int> &ans, int i, long int temp)
{
    if(i == D)
    {
        for(int j=D-1;j>=0;j--)
        {
            if(ans[j] == 0)
            {
                for(int k = 0; k <= data[j]; k++)
                {
                    if(temp + k*(j+1)*100 >= G)
                    {
                        result = min(result,addd(ans) + k);
                        break;
                    }
                }
                break;
            }
        }
    }
    else
    {
        check(data,comp,ans,i+1, temp);
        ans[i] = data[i];
        temp += ans[i] * (i+1) * 100 + comp[i];
        if(temp >= G)
        {
            result = min(result,addd(ans));
        }
        else
        {
            check(data,comp,ans,i+1, temp);
        }
        ans[i] = 0;
    }
    
    return;
}

int main()
{
    
    cin >> D >> G;
    
    vector<int> data(D),comp(D);
    
    for(int i=0;i<D;i++)
    {
        cin >> data[i] >> comp[i];
    }
    vector<int> ans(D,0);
    
    check(data,comp,ans,0,0);
    
    cout << result << endl;
    
    
    //cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*; 
import java.util.*; 
public class Main {
    static long dp[][],mod=1000000007L;
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int m=input.nextInt();
        dp=new long[n][m];
        for(int i=0;i<n;i++) {
            String str=input.next();
            for(int j=0;j<m;j++) {
                if(str.charAt(j)=='#') {
                    dp[i][j]=-1;
                }
            }
        }
        System.out.println(solve(n,m));
    }
    public static long solve(int n, int m) {
        for(int i=1;i<n;i++) {
            if(dp[i][0]==-1) {
                break;
            }
            else {
                dp[i][0]=1;
            }
        }
        for(int i=1;i<m;i++) {
            if(dp[0][i]==-1) {
                break;
            }
            else {
                dp[0][i]=1;
            }
        }
        for(int i=1;i<n;i++) {
            for(int j=1;j<m;j++) {
                if(dp[i][j]==-1) {
                    continue;
                }
                if(dp[i-1][j]==-1 && dp[i][j-1]==-1) {
                    dp[i][j]=0;
                }
                else if(dp[i-1][j]==-1) {
                    dp[i][j]=dp[i][j-1];
                }
                else if(dp[i][j-1]==-1) {
                    dp[i][j]=dp[i-1][j];
                }
                else {
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                }
            }
        }
        return dp[n-1][m-1];
    }
}


Measured memory_bytes: 37204