akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
constexpr int MOD = 1000000007;
constexpr int DEBUG = 0;
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> v;
  v.push_back(0);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<')
      v.push_back(v[i]+1);
    if (s[i] == '>') {
      v.push_back(v[i]-1);
    }
  }

  int min = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] < min)
      min = v[i];
  }

  for (int i = 0; i < v.size(); i++)
    v[i] -= min;

  if (s[0] == '<')
    v[0] = 0;
  if (s.back() == '>')
    v.back() = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '>' && s[i+1] == '<')
      v[i+1] = 0;
  }
  
  if (DEBUG >= 2) {
    for (int i = 0; i < v.size(); i++)
      cout << v[i] << " ";
    cout << endl;
  }
  
  int l = 0, r = -1;
  bool flag = false;
  for (int i = 1; i < v.size(); i++) {
    if (v[i] == 0 || i  == v.size() - 1) {
      r = (i == v.size() - 1 && v.back() != 0) ? v.size() : i;
      flag = true;
      if (flag) {
        if (DEBUG >= 2) {
       	 cout << "L:" << l << " R:" << r << endl;
        }
        if (l + 2 == r && l != 0) {
          v[l+1] = 1;
      	  l = r;
      	  r = -1;
          continue;
        }
        int sl = (l == 0 && v[0] != 0) ? l : l + 1, sr = sl;
        char sign = s[sr];
        while (1) {
          while (sr <= v.size() && v[sr + 1] != 0 && s[++sr] == sign) {}
          if (DEBUG >= 2) {
            cout << "v[" << sl << "] = " << v[sl] << " " << sign << " v[" << sr << "] = " << v[sr] << endl;
            for (int k = sl; k <= sr; k++)
              cout << v[k] << " ";
            cout << endl;
          }
          int d;
          if (sign == '<') {
            if (sr + 1 != r)
              sr--;
          	d = v[sl] - 1;
          }
          else {
            if (sl != 0)
          	  sl++;
            d = v[sr] - 1;
          }
          d = std::max(0, d);
          if (DEBUG >= 2) {
            cout << "d = " << d << endl;
          }
          for (int j = sl; j <= sr; j++)
            v[j] -= d;
          if (sign == '<') {
            sign = '>';
            sl = sr + 1;
            sr = sl;
          }
          else {
            sign = '<';
            sl = l == sl ? sr + 1 : sr;
            sr = sl;
          }
          if (sr + 1 >= r)
        	  break;
        }
        l = r;
        r = -1;
        flag = false;
      }
    }
  }
  
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == '<' && s[i+1] == '>') {
      v[i+1] = std::max(v[i], v[i+2]) + 1;
    }
  }
  
  if (DEBUG >= 1) {
    for (int i = 0; i < s.size(); i++)
      cout << v[i] << " " << s[i] << " ";
    cout << v.back() << endl;
  }
  
  ll total = 0;
  for (int i = 0; i < v.size(); i++)
    total += v[i];
  
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main() {
    
    int n = 0, m = 0, l = 0;
    
    int i, tmp;
    for (i = 1; i <= 10; i++) {
      
        scanf("%d", &tmp);
        if (n < tmp) { l = m; m = n; n = tmp;}
        else if (m < tmp) { l = m; m = tmp; }
        else if (l < tmp) { l = tmp; }
        
    }
    
    printf("%d\n%d\n%d\n", n, m, l);
    
    return 0;
}

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<array<int, 2>> a(n);
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < 2; ++ j){
			cin >> a[i][j];
		}
	}
	for(auto i = 1; i < n - 1; ++ i){
		if(a[i - 1][0] == a[i - 1][1] && a[i][0] == a[i][1] && a[i + 1][0] == a[i + 1][1]){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
ll ans;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='9')s[i]='1';
		else if(s[i]=='1')s[i]='9';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<queue>
using namespace std;
typedef long long ll;
#define N 100005
int main()
{
    int n,m,i,j,k,l;
    int T,unit;
    int x,z,y,x1,y1;
    ll ans1=0,ans2=0;
    int n1,n2;
    int a[100005]={0};
    priority_queue<int> q;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        q.push(x);
    }
    for(i=0;i<m;i++)
    {
        y=q.top();
        q.pop();
        q.push(y/2);
    }
    while(!q.empty())
    {
        ans1+=q.top();
        q.pop();
    }
    printf("%lld\n",ans1);
    return 0;
}


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

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 16MB stack
        Thread thread = new Thread(null, new Main(), "", 16 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int N = a[0], K = a[1];
        String S = scanner.nextLine();
        if (!S.contains("0") || !S.contains("1")) {
            System.out.println(N);
            return;
        }

        S = "1".concat(S).concat("1");
        List<Integer> starts = new ArrayList<>();
        List<Integer> ends = new ArrayList<>();
        boolean one = false;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '1') {
                if (!one) {
                    one = true;
                    starts.add(i);
                }
            } else {
                if (one) {
                    ends.add(i - 1);
                    one = false;
                }
            }
        }
        if (one) {
            ends.add(S.length() - 1);
        }

        int max = 0;
        for (int i = 0; i < starts.size(); i++) {
            int endIdx = Math.min(i + K, ends.size() - 1);
            int ans = ends.get(endIdx) - starts.get(i) + 1;
            if (i == 0) {
                ans--;
            }
            if (endIdx == ends.size() - 1) {
                ans--;
            }
            max = Math.max(max, ans);
        }

        System.out.println(max);
    }

}


Measured memory_bytes: 32916
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    int cnt = 0;
    
    REP(i, n + 1)
    {
        cin >> a[i];
        cnt += a[i];
    }
    if (n == 0)
    {
        if (a[0] == 1)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << -1 << endl;
        }
        return 0;
    }
    int c = (a[0]==0);
    int ans = 0;
    //cはその高さの個数
    for (int i = 0; i <= n; i++)
    {
       // cerr << c << endl;
        ans += c;
        c -= a[i];
        cnt -= a[i];
        int x = cnt - c;
        x = min(x, c);
       // cerr << "x" << x << endl;
        if (x < 0)
        {
            cout << -1 << endl;
            return 0;
        }
        c = x + c;

        
    }
    cout << ans  << endl;

    return 0;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std ;

const int N=1e5+10 ;

struct Line
{
	int A , B ;
	bool operator < ( const Line x ) const { return A^x.A?A<x.A:B<x.B; }
};
Line a[N] ;
priority_queue<int,deque<int>,greater<int> > Q ;
int n , m ;
int main ()
{
	int i ;
	scanf("%d%d",&n,&m);
	for ( i=1 ; i<=n ; i++ ) scanf("%d%d",&a[i].A,&a[i].B),a[i].A=m-a[i].A+1;
	sort(a+1,a+n+1);
	for ( i=1 ; i<=n ; i++ )
	{
		if ( a[i].A<1 ) continue;
		Q.push(a[i].B);
		while ( Q.size()>a[i].A ) Q.pop();
	}
	int res=0 ;
	while ( !Q.empty() ) res+=Q.top(),Q.pop();
	printf("%d\n",res);
	return 0 ;
}


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


int students[10001][800] = {};
int numlogin[10001] = {};
int sum[10001][800]={};

int main(){

  while(1){
    int N,M,r;
    cin >> N >> M;
    if(!N and !M) break;

    cin >> r;

    memset(students,0,sizeof(students));
    memset(numlogin,0,sizeof(numlogin));
    memset(sum,0,sizeof(sum));

    // ?¨????
    for(int i=0; i<r; i++){ // 1000
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      t -= 540;
      if(s == 0) { // ?????°??¢??????
	numlogin[m]--;
	if(numlogin[m] == 0){
	  for(int i=t-1; students[m][i] != 1 and t>=0; i--){ // 1000
	    students[m][i] = 1;
	  }
	}
      }
      else{ // ?????°??????
	numlogin[m]++;
	if(numlogin[m] == 1)
	  students[m][t] = 1;
      }
    }

    // ?´???????

    for(int i=1; i<=M; i++){ // 100000
      for(int j=1; j<=720; j++){ // 1000
	sum[i][j] = sum[i][j-1] + students[i][j]; 
	//	students[i][j] += students[i][j-1];
      }
    }

    // ??????
    int  q;
    cin >> q;
    for(int i=0; i<q; i++){
      int ts,te,id;
      cin >> ts >> te >> id;
      ts -= 540;
      te -= 540;
      cout << sum[id][te-1] - sum[id][ts] + students[id][ts] << endl;
      //      cout << students[id][te] - students[id][ts] << endl;
      //cout << students[id][te] - students[id][ts] << endl;
    }
  }
}

Measured memory_bytes: 63712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);

ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
 /*struct cmp{ bool operator() ( const, const )const{}};
  use as set<ll> ,cmp> a*/
int main()
{
  Summon_Tourist;
  //freopen("input.txt" , "r" , stdin );
  ll n,k;
  cin>>n>>k;
  vector<ll> snukes(n+1,0);
  for( ll i = 0 ; i<k ; i++)
  {
      ll x;
      cin>>x;
      for( ll i = 0 ; i<x ; i++)
      {
          ll inp;
          cin>>inp;
          snukes[inp] = 1;
      }

  }
  ll ans = 0;
  for( ll i = 1 ; i<=n ; i++)
 {
     if(snukes[i]==0)
        ans++;
 }
 cout<<ans;
  return 0;

}



Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr int MAXN = (1 << 20) + 5;
constexpr int MOD = 1e9 + 7;
constexpr double eps = 1e-6;
constexpr int INF = 1e9 + 7;
int dir[4][2] = { { -1,0 },{ 0,1 },{ 1,0 },{ 0,-1 } };

int a[105];
int main()
{
	//freopen("in.in", "r", stdin);&
	//freopen("out.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	
	int n, d, x;
	scanf("%d%d%d", &n, &d, &x);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);

	int ans = x;
	for (int i = 0; i < n; i++)
	{
		ans += d / a[i] + 1;
		if (d%a[i] == 0)
			ans--;
	}

	printf("%d\n", ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if (S == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if( S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll A,B,K; cin >> A >> B >> K;
  ll p=A-K;
  if(p>=0){
    cout << p << ' ' << B;
    return 0;
  }
  ll q=B+p;
  if(q>=0){
    cout << 0 << ' ' << q;
    return 0;
  }
  cout << 0 << ' ' << 0;

}


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

int64_t dp[101][100001];

int main(){
    int N, W, w[100], v[100];
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];

    for(int i=0; i<=N; i++) for(int j=0; j<=100000; j++) dp[i][j] = W+1;
    dp[0][0] = 0;

    for(int i=0; i<N; i++){
        for(int j=0; j<=100000; j++){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j+v[i] <= 100000) dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
        }
    }
    for(int j=100000; j>=0; j--) if(dp[N][j] <= W){
        cout << j << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 79104
import java.util.Stack

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
  val t = Array<MutableList<Int>>(n+1) { mutableListOf<Int>() }
  repeat(n-1) {
    val (u, v) = readLine()!!.split(" ").map { it.toInt() }
    t[u].add(v)
    t[v].add(u)
  }
  val stack = Stack<Int>()
  stack.push(1)
  var size = 0
  val pop = BooleanArray(n+1)
  val las = IntArray(n+1)
  val pos = IntArray(n+1)
  val par = IntArray(n+1)
  val lis = IntArray(n+1)
  val ans = IntArray(n+1)
  while (stack.isNotEmpty()) {
    val u = stack.pop()
    if (u > 0) {
      pos[u] = lis.lowerBound(a[u-1], 0, size)
      if (pos[u] == size) {
        pop[u] = true
        size++
      }
      las[u] = lis[pos[u]]
      lis[pos[u]] = a[u-1]
      stack.push(-u)
      ans[u] = size
      for (v in t[u]) {
        if (v == par[u]) continue
        par[v] = u
        stack.push(v)
      }
    } else {
      val v = -u
      if (pop[v]) size-- else lis[pos[v]] = las[v]
    }
  }
  println(ans.drop(1).joinToString("\n"))
}
fun IntArray.lowerBound(element: Int, fromIndex: Int, toIndex: Int): Int {
  val index = this.binarySearch(element, fromIndex, toIndex)
  return if (index < 0) -index-1 else index
}

Measured memory_bytes: 114864
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << ” ” << xxx.second << “\n”;}}

using LL = long long;

int main() {

    string S;
    long long K;
    cin >> S >> K;

    for (int i = 0; i < K; i++) {
        if (S[i] != '1') {
            cout << S[i];
            return 0;
        }
    }

    cout << S[K - 1] << endl;

    return 0;
}































Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class ABC121_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);

        if(A==B)
        {
            Console.WriteLine(A);
            return;
        }

        int[] A2 = BitCountXOR(A-1);
        int[] B2 = BitCountXOR(B);

        long sum = 0;
        long exponential = 1;
        for (int i = 0; i < B2.Length; i++)
        {
            long a = i < A2.Length ? A2[i] : 0;
            long b = B2[i];

            if ((a+b) % 2 == 1)
            {
                sum += exponential;
            }
            exponential *= 2;
        }

        Console.WriteLine(sum);
    }

    static int[] BitCountXOR(long num)
    {
        List<int> digit = new List<int>();

        long quotient = num + 1;
        long exponential = 1;
        while (num > exponential/2)
        {
            long q = quotient / (exponential*2);
            long r = quotient % (exponential*2);
            long bit = r >= exponential ? r - exponential : 0;
            bit += q * exponential;
            exponential *= 2;
            digit.Add((int)(bit%2));
        }

        return digit.ToArray();
    }
}


Measured memory_bytes: 13140
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 1e9+7;
const ll INF = 1e18;
ll fib[105], l;
ll m, T, n;


vector<pair<ll, ll> > res[100];
int main() {
	for (fib[0] = fib[1] = l = 1; fib[l] <= INF; l++)
		fib[l+1] = fib[l] + fib[l-1];
		
	res[1].push_back(MP(1, 2));
	res[1].push_back(MP(1, 3));
	res[1].push_back(MP(1, 4));
	for (int i = 1;i < l - 2; i++) {
		for (auto j: res[i]) {
			ll x = j.fi, y = j.se;
			x += y;
			while (x <= fib[i+3] + fib[i]) {
				res[i+1].push_back(MP(y, x));
				x += y;
			}
		}
	}
	
	for (read(T); T; T--) {
		read(n), read(m);
		n > m && (swap(n, m), 0);
		int k = 1;
		while (fib[k+1] <= n && fib[k+2] <= m) ++k;
		printf ("%d ", k);
		if (k == 1) {
			printf ("%lld\n", n * m % P);
			continue;
		}
		ll ans = 0;
		for (auto j: res[k-1]) {
			ll x = j.fi, y = j.se;
			if (y <= n) ans += (m - x) / y;
			if (y <= m) ans += (n - x) / y;
			ans %= P;
		}
		printf ("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4456
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,k;
int main(){
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    int ans=0; 
    for(int i=0; i<k; i++) ans+=v[i];
    cout << ans << "\n";
}

Measured memory_bytes: 3612
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int a;
		int b;
		HashSet<Integer> hashFirstTo = new HashSet<Integer>();
		HashSet<Integer> hashSecondFrom = new HashSet<Integer>();
		boolean possible = false;
		for (int i=0; i<M; i++){
			a = sc.nextInt();
			b = sc.nextInt();
			if (a == 1){
				hashFirstTo.add(b);
			} else if (b == N){
				hashSecondFrom.add(a);
			}
		}
		for (int firstTo:hashFirstTo){
			if (hashSecondFrom.contains(firstTo)){
				possible = true;
				break;
			}
		}

		if (possible == true){
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}

}


Measured memory_bytes: 102900
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner scanner = new Scanner(System.in);
    		int n = scanner.nextInt();
    		int a = scanner.nextInt();
    		int b = scanner.nextInt();
    		int ta = 0, tb = 0;
    		String string = scanner.next();
    		for (int i = 0; i < n; i++) {
    			switch (string.charAt(i)) {
    			case 'a':
    				if (ta + tb < a + b) {
    					ta++;
    					System.out.println("Yes");
    					break;
    				}
    				System.out.println("No");
    				break;
     
    			case 'b':
    				if (ta + tb < a + b && tb < b) {
    					tb++;
    					System.out.println("Yes");
    					break;
    				}
    				System.out.println("No");
    				break;
     
    			case 'c':
    				System.out.println("No");
    				break;
    			}
    		}
    	}
    }

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

int main()
{
  	int x[5], n=5;
  	cin>>x[1]>>x[2]>>x[3]>>x[4]>>x[5];
  	if(x[1]==0)
      	cout<<1;
  	if(x[2]==0)
      	cout<<2;
  	if(x[3]==0)
      	cout<<3;
  	if(x[4]==0)
      	cout<<4;
  	if(x[5]==0)
      	cout<<5;
  	return 0;
}

Measured memory_bytes: 3624
/***
    BISMILLAH
    @Author : Arham
**/
#include <bits/stdc++.h>
#define endl "\n"
#define found true
#define infinity 1e+9+10
#define not_found false
#define FOR(limit) for(int i = 0; i < limit; i++)
#define __FOR(limit) for(int j = 0; j < limit; j++)
#define __FOR__(limit) for(int k = 1; k <= limit; k++)
#define hello(a) a ? "Yes" : "No"
#define HELLO(a) a ? "YES" : "NO"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pof pop_front
#define pob pop_back
#define I insert
#define fr front
#define B back
#define P push
#define pp pop
#define T top
#define F first
#define S second
/// getline (cin, string);
/// find (lower_bound(inclusive), upper_bound(exclusive), value);
/// set.find (value):
typedef long long lld;
using namespace std;

void solving_f() {
    int count = not_found, temp;
    string s;
    cin >> s;
    for(int i = not_found; i < s.size(); i++) {
        temp = not_found;
        if(s[i] == 'R') {
            for(int j = i; j < s.size(); j++) {
                if(s[i] == s[j])
                    temp++;
                else
                    break;
            }
        }
        count = max(count, temp);
    }
    cout << count << endl;
}

int main(string hello_world) {
    ios_base :: sync_with_stdio(not_found);
    cin.tie(NULL);
//    cout.tie(0);

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    solving_f();

    return not_found;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int calc(int p, int x){
    return p * (100 + x) / 100;
}

int main(){

    for(int x, y, s; cin >> x >> y >> s, x;){
        int ans = 0;
        for(int a = 1; a <= 1000; a++){
            for(int b = 1; b <= 1000; b++){
                if(calc(a, x) + calc(b, x) == s){
                    ans = max(ans, calc(a, y) + calc(b, y));
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;

int n,ret,mx;
vpi ans;
vi mm,pm;

int main(){
    I(n);
    vector<long long> a(n);
    REP(i,n) cin >> a[i];
    if (*(max_element(a.begin(),a.end())) >= (-1) * *(min_element(a.begin(),a.end()))) {
        mx = distance(a.begin(),max_element(a.begin(),a.end()));
        REP(i,n){
            if(i==mx) continue;
            ans.pb(mp(mx,i));
            ret++;
        }
        REP(i,n-1){
        //    if( a[i] > a[i+1] ){
                ans.pb(mp(i,i+1));
                ret++;
            //}
        }
        cout << ret << endl;
        for(auto i : ans) cout << i.first+1 << " " << i.second+1 << endl;
    } else {
        mx = distance(a.begin(),min_element(a.begin(),a.end()));
        REP(i,n){
            if(i==mx) continue;
            ans.pb(mp(mx,i));
            ret++;
        }
        REPN(i,n-2){
            //if( a[i] > a[i+1] ){
                ans.pb(mp(i+1,i));
                ret++;
            //}
        }
        cout << ret << endl;
        for(auto i : ans) cout << i.first+1 << " " << i.second+1 << endl;
    }


}


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

class unionfind{
    long *tree, *cnt;
    size_t length;
public:
    unionfind(size_t n, int *state): length(n){
        tree = new long[n];
        cnt = new long[n];
        for(size_t i=0;i<n;++i) tree[i] = -1;
        for(size_t i=0;i<n;++i) cnt[i] = state[i];
    }
    size_t root(size_t pos){
        if(tree[pos] < 0) return pos;
        else return tree[pos] = root(tree[pos]);
    }
    bool is_same(size_t x, size_t y){
        return root(x) == root(y);
    }
    bool merge(size_t x, size_t y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(tree[x] > tree[y]) swap(x, y);
        tree[x] += tree[y];
        tree[y] = x;
        cnt[x] += cnt[y];
        cnt[y] = cnt[x];
        return true;
    }
    size_t size(size_t pos){
        return -tree[root(pos)];
    }
    size_t count(size_t pos){
        return cnt[root(pos)];
    }
};

int main(){
    int n, m;
    static int pos[100002], state[100002];
    static pair<int, int> parent[100002];
    static int ans[200001];
    map<int, int> mp;
    static vector<pair<int,int>> edges[100002];
    cin >> n >> m;

    mp[0] = 0;
    mp[1'000'000'001] = 0;
    for(int i=0;i<n;++i){
        int a, b;
        cin >> a >> b;
        mp[a] = b;
    }
    auto it = mp.begin();
    for(int i=0;it!=mp.end();++i, ++it){
        pos[i] = it->first;
        state[i] = it->second;
    }
    for(int i=1;i<n+2;++i){
        if(state[i]) state[i-1] ^= 1;
    }

    unionfind uf(n+2, state);
    for(int i=0;i<m;++i){
        int l, r;
        cin >> l >> r;
        int lp = lower_bound(pos, pos + n + 2, l) - pos - 1;
        int rp = upper_bound(pos, pos + n + 2, r) - pos - 1;
        if(uf.merge(lp, rp)){
            edges[lp].emplace_back(rp, i + 1);
            edges[rp].emplace_back(lp, i + 1);
        }
    }
    set<int> roots;
    for(int i=0;i<n+2;++i){
        if(uf.count(i) & 1){ cout << -1 << endl; return 0; }
        roots.insert(uf.root(i));
    }
    queue<int> q;
    for(int r: roots){
        parent[r] = {-1, -1};
        q.push(r);
    }
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto to: edges[v]){
            if(to.first != parent[v].first){
                q.push(to.first);
                parent[to.first] = {v, to.second};
            }
        }
    }
    for(int i=0;i<n+2;++i){
        if(state[i] == 0) continue;
        auto p = parent[i];
        state[i] = 0;
        while(p.first >= 0){
            ans[p.second] ^= 1;
            if(state[p.first]){
                state[p.first] = 0;
                break;
            }
            p = parent[p.first];
        }
    }

    int k = 0;
    for(int i=1;i<=m;++i) if(ans[i]) ++k;
    cout << k << endl;
    int flg = 0;
    for(int i=1;i<=m;++i){
        if(ans[i] == 0) continue;
        if(flg != 0) cout << " ";
        else flg = 1;
        cout << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 14848
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

W, H, x, y = LI()

print((W*H)/2, 1 if x*2 == W and y*2 == H else 0)


Measured memory_bytes: 38384
n=int(input())
l=list(map(int,input().split()))
e=[]
sx=0
for i in l:
    sx^=i
for i in l:
    i&=(~sx)
    for j in e:
        i=min(i,i^j)
    if i:
        e.append(i)
t=0
for i in e:
    t=max(t,t^i)
print((t^sx)+t)

Measured memory_bytes: 16052
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("fft.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
}
const int N=5e5+5;
int n,m;
void input()
{
	n=read<int>(),m=read<int>();
	if(n<m)swap(n,m);
}
const int mo=998244353;
const int inv2=(mo+1)>>1;
int power(int x,int y)
{
	int res=1;
	for(;y;x=1ll*x*x%mo,y>>=1)if(y&1)res=1ll*res*x%mo;
	return res;
}
int inv[N<<1],mc[N<<1];
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
int Mod(int x){return x>=mo?x-mo:x;}
int C(int n,int m){return 1ll*mc[n]*inv[m]%mo*inv[n-m]%mo;}
void work()
{
	mc[0]=inv[0]=1;
	For(i,1,n+m)mc[i]=1ll*mc[i-1]*i%mo;
	inv[n+m]=power(mc[n+m],mo-2);
	Fordown(i,n+m,1)inv[i-1]=1ll*inv[i]*i%mo;
	
	int ans=0;
	For(i,1,m)
	{
		//cerr<<1ll*C(i*2,i)<<' '<<C(n-i+m-i,n-i)<<endl;
		add(ans,1ll*C(i*2,i)*C(n-i+m-i,n-i)%mo*inv2%mo);
	}
	ans=1ll*ans*power(C(n+m,n),mo-2)%mo;
	ans=(ans+n)%mo;
	//ans=(m-ans+mo)%mo;
	write(ans,'\n');
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 8064
#include <stdio.h>
#include <math.h>
 
int main(void){
  int n,d,x[10][10];
  int i,j,k;
  int dist,count;
  double sq;
  if(scanf("%d %d",&n,&d)==1);
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      if(scanf("%d",&x[i][j])==1);
    }
  }
  
  count = 0;
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      dist = 0;
      for(k=0;k<d;k++){
        dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      sq = sqrt((double)dist);
      if(ceil(sq)==floor(sq)){
        count += 1;
      }
    }
  }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
//ABC074C
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    double A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    double MAX = -1,Sugar,Water;
    int  Sugar_Water,Sugar_ans;

    for(int a=0;a<31;++a){
        for(int b=0;b<31;++b){
            Water = 100*a*A+100*b*B;
            for(int c=0;C*c<=F;++c){
                for(int d=0;D*d<=F;++d){
                    Sugar = C*c+D*d;
                    if(Sugar > Water/100*E) continue;
                    if(Water+Sugar>F) continue;
                    if(MAX < 100*Sugar/(Water+Sugar)){
                        Sugar_Water = Water+Sugar;
                        Sugar_ans = Sugar;
                        MAX = 100*Sugar/Sugar_Water;
                    }
                }
            }
        }
    }

    cout<<Sugar_Water<<" "<<Sugar_ans<<endl;
}

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

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

int main(){
 int H,W,N; cin >> H >> W >> N;
  
 vector<vector<char>> S(H,vector<char>(W));
  
  deque<tuple<int,int,int>> starts;
 
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){ 
      cin >> S[i][j];  char c = S[i][j];
      if( c == 'S'){ starts.push_back(make_tuple(0,i,j));}
      else if( 1<= c-'0' && c-'0'<= 9){
        starts.push_back(make_tuple(c-'0',i,j));}
    }
  }
  
  sort(starts.begin(),starts.end());
  
  //BFS
  int length = 0;
  
  for(int i = 0; i < starts.size()-1; i++){
    queue<tuple<int,int,int>> Q;
    
    Q.push(make_tuple(get<1>(starts[i]),get<2>(starts[i]),0));
    // selecting the new start 
    pair<int,int> goal = make_pair(get<1>(starts[i+1]),get<2>(starts[i+1]));
    
    vector<vector<int>> visited(H,vector<int>(W,-1));
    
    visited[get<1>(starts[i])][get<2>(starts[i])] = 0;
    // -1 means this point has not been visited
    while(!Q.empty()){
      tuple<int,int,int> p = Q.front(); Q.pop();
      int x = get<0>(p); int y = get<1>(p);  int L = get<2>(p);
      visited[x][y] = L;
      
      for(int k = 0; k < 4; k++){
        int a = x+dx[k]; int b = y+dy[k];
        if( a < 0 || a >= H || b < 0 || b >= W){ continue;}
        if( visited[a][b] != -1){ continue;}
        if( S[a][b] == 'X' ){ continue;}
        
        visited[a][b] = L+1; Q.push(make_tuple(a,b,L+1));
      }
    }
      length += visited[goal.first][goal.second];
  }
    
    cout << length << endl; return 0;}


Measured memory_bytes: 7780
#include <stdio.h>

int main(void){

  int x, y;

  while(1){

    scanf("%d %d",&x, &y);
    if (0==x && 0==y) break;
    if (x<=y){
    printf("%d %d\n",x ,y );
    }
    else{
      printf("%d %d\n",y ,x );
    }
    
  }
  return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
///-------------------------


int main()
{
    Phuong_; /// <3333
    int n,k;
    cin >> n >> k;
    vector<int> d(n+1,false);
    while (k--){
        int m;
        cin >> m;
        while (m--){
            int u;
            cin >> u;
            d[u]=true;
        }
    }
    int ans=0;
    for(int i=1; i<=n; ++i) if (!d[i]) ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>

using namespace std;

int main(){

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

    long long dp[105][25];// [sequence][sum]:=
    fill(dp[0], dp[105], 0);// 

    dp[0][a[0]]=1;
    for(int i=1; i<n; i++){
        for(int j=0; j<=20; j++){
            if(j+a[i]<=20){
                dp[i][j+a[i]]+=dp[i-1][j];
            }
            if(j-a[i]>=0){
                dp[i][j-a[i]]+=dp[i-1][j];
            }

        }
    }

    cout<< dp[n-2][a[n-1]]<< endl;

    return 0;
}

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

int main(){
	int n,k,x,y;
	int ans;
	cin>>n>>k>>x>>y;
	if(n>k){
		ans=x*k;
		ans+=y*(n-k);
	}else{
		ans=x*n;
	}
	cout<<ans<<endl;
	return 0;
}
		

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

int main(){
  int N, M;
  cin >> N >> M;
  int L = 0, R = N;
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    L = max(L, l);
    R = min(R, r);
  }
  if (R - L < 0) {
    cout << 0 << endl;
  }
  else {
    cout << R - L + 1 << endl;
  }
}

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

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

  int cont = 0;
  bool result = false;
  for (int n = 0; n < N; n++){
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 != d2){
      cont = 0;
    }else if (++cont >= 3){
      result = true;
    }
  }

  cout << (result ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+200;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 0x3f3f3f;
int main(){
	int n;
	int a1,b;
	cin>>a1>>b;
	if(a1 < b){
		cout<<0<<endl;
	}else{
		cout<<10<<endl;
	}
	vector<int> a(n);

}


Measured memory_bytes: 256
def solve():
    N, *a_l = map(int, open(0).read().split())
    x_l = [0] * N

    x_l[0] = sum(a_l) - 2*(sum(a_l[1::2]))
    for i in range(1, N):
        x_l[i] = 2*a_l[i-1] - x_l[i-1]

    print(' '.join(map(str, x_l)))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 19164
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    for(char i='a'; i <= 'z'; i++){
        for(int j=0; j<s.length(); j++){
            if(s[j] == i) break;
            if(j==s.length()-1 && s[j] != i){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << "None" << endl;
    /*
    sort(s.begin(), s.end());


    for(int i=0; i<s.length()-1; i++){
        if(i < s.length() -1 && (s[i+1] - s[i]) > 1) {
            cout << (char)(s[i] + 1) << endl;
            return 0;
        }
    }

    if(s[s.length()-1] != 'z') cout << (char)(s[s.length()-1] + 1) << endl;
    else cout <<  "None" << endl;
    */
}


Measured memory_bytes: 760
using System;
using System.Linq;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int sum = 0,pred=-2;
            for(int i =0;i<N;i++)
            {
                if (A[i]-1 == pred+1) sum += C[pred];
                sum += B[A[i]-1];
                pred = A[i]-1 ;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13268
//2018.12.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=2e5+10;
namespace MAIN{
    int a[N],n,maxa;
    map<int,int> M;
    int ans;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read(),M[a[i]]++,maxa=_max(maxa,a[i]);
        sort(a+1,a+n+1);
        for(res i=n;i;i--){
            if(!M[a[i]])continue;
            M[a[i]]--;
            res j=1;
            for(;j<=a[i];j<<=1);
            res x=((j-1)^a[i])+1;
            if(M[x])ans++,M[x]--;
        }
        printf("%d\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<40-1)
#define mod 1000000007
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; }

vector<ll> suma,sumb;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}

int main(){
    ll n,m,k;cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    pre_process(a,suma);
    pre_process(b,sumb);

    ll ans=0,B=m;
    for(ll A=0;A<=n;A++){
        if(suma[A]>k) break;

        while(sumb[B]>k-suma[A]){
            B--;
        }

        chmax(ans,A+B);
    }


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

Measured memory_bytes: 9568
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)


int main(){
    long long int a,c,d=0;
    cin>>a;
    if(a<1200)cout<<"ABC";
    else cout<<"ARC";
}


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

int main(){

  char s[256];
  scanf("%s", s);

  int len = strlen(s);
  for(int i = len - 2; i > 0; i -= 2){
    if(strncmp(s, s + i / 2, i / 2) == 0){
      printf("%d\n", i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  
  int atk = 0;
  for (;;) {
    int natk = atk;
    for (int i = 0; i < N; i++) {
      if (i == atk) continue;
      if (A[i] <= A[atk]) A[i] = 0;
      else {
        A[i] %= A[atk];
        if ((A[i] > 0) && (A[i] < A[natk])) {
          natk = i;
        }
      }
    }
    if (atk == natk) break;
    else atk = natk;    
  }
  cout << A[atk] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

long long modpow(long long a, long long n) {
  long long atai = 1;
  while (n > 0) {
    if (n % 2) {
      atai *= a;
	  atai%=MOD;
      n-=1;
    } 
    a *= a;
    a%=MOD;
    n /= 2;
  }
  return atai;
}
int main(){
	ll n;
    cin>>n;
    ll ans=modpow(10,n)-modpow(9,n)*2+modpow(8,n);
    if(ans<0){
        while(ans<0){
            ans+=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

long long N, k, a[5] = {0,0,1,2,1};

int main() {
  cin>>N>>k;
  long long num=0;
  REP(i,0,N-1){
    if(a[0]*k-a[1] > num || num > a[2]*k-a[3]){
      long long inc = (k*a[0]-a[1]-num)/(1-k);
      REP(j,0,5) a[j] += inc;
    }
    num += a[4];
  }
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 3092
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

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

minas=[]
plus=[]
zero=[]
for a in A:
    if a<0:
        minas.append(-a)
    else:
        plus.append(a)
minas.sort()
plus.sort()

st=-(10**18)-1
ed=10**18+1
len_minas=len(minas)
len_plus=len(plus)
len_zero=len(zero)
zero1=len_plus*len_minas
zero2=len_zero*(len_minas+len_plus)+len_zero*(len_zero-1)//2



while ed-st>1:
    mid=(st+ed)//2
    if mid<0:
        j=0
        i=0
        for m in range(len(minas)-1,-1,-1):
            while i<len(plus) and plus[i]*minas[m]<-mid:
                i+=1
            j+=len(plus)-i
    else:
        j=zero1
        i=len(minas)-1
        for m in range(len(minas)-1):
            while m<i and minas[i]*minas[m]>mid:
                i-=1
            j+=max(i-m,0)


        i=len(plus)-1
        for m in range(len(plus)-1):
            while m<i and plus[i]*plus[m]>mid:
                i-=1
            j+=max(i-m,0)
    if j<K:
        st=mid
    else:
        ed=mid

print(ed)


Measured memory_bytes: 119424
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main()
{
     ll n,i,j,m=0,c,T,s=0,r,k=0,p=0,q,x,y,l;
     cin>>n;
     ll a[n];
     f(i,n){
          cin>>a[i];
          s+=a[i];
     }
     f(i,n-1)
     {
         s-=a[i];
         c=((a[i]%mod)*(s%mod))%mod;
         m=((m%mod)+(c%mod))%mod;
     }
     cout<<m<<endl;
}







Measured memory_bytes: 5144
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct edges
{
	int to,next;
}edge[101010];
int first[101010],now;
void adde(int x,int y)
{
	now++;
	edge[now].to=y;
	edge[now].next=first[x];
	first[x]=now;
}
int a[101010];
int h[101010];
int dfn[101010],dd;
void dfs(int p)
{
	dfn[++dd]=p;
	for(int e=first[p];e;e=edge[e].next)
		dfs(edge[e].to);
}
int main()
{
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(first,0,sizeof(first));
	now=0;
	if(a[1]!=1)
		ans++;
	for(int i=2;i<=n;i++)
		adde(a[i],i);
	dd=0;
	dfs(1);
	memset(h,0,sizeof(h));
	for(int i=1;i<=n;i++)
		h[i]=1;
	for(int i=dd;i>1;i--)
	{
		if(h[dfn[i]]==k&&a[dfn[i]]!=1)
			ans++;
		else
			h[a[dfn[i]]]=max(h[a[dfn[i]]],h[dfn[i]]+1);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4224
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

ans = 0
m = A[0]  # 最大
for i in range(1,N):
    if m <= A[i]:
        m = A[i]
    else:
        ans += m-A[i]

print(ans)


Measured memory_bytes: 94092
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextInt();
	        if(N==0) {
	        	System.out.println(0);
	        	return;
	        }
        	int cnt=0;
        	char[] c = new char[10000];
	        while(N!=0) {
	        	if(N%2==1||N%2==-1) {
        			c[cnt]='1';
	        		if(cnt%2==0) {
	        			N=N-1;
	        		} else {
	        			N=N+1;
	        		}
	        	} else {
	        		c[cnt]='0';
	        	}
        		N=N/2;
        		cnt++;
	        }
	        
	        StringBuffer ans = new StringBuffer();
	        for(int i=cnt-1;i>=0;i--) {
	        	ans.append(c[i]);
	        }
	        
	        System.out.println(ans);
	    }
	}

Measured memory_bytes: 21844