akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    ll n, m, Q, l, r, p, q, a[505][505];
    cin >> n >> m >> Q;
    for (int i = 0; i < n; i++) fill(a[i], a[i] + n, 0);
    for (int i = 0; i < m; i++) {
        cin >> l >> r;
        l--;  r--;
        a[l][r]++;
    }
    
    ll b[505][505], sum[505][505];
    for (int i = 0; i < n; i++) {
        fill(b[i], b[i] + n, 0);
        fill(sum[i], sum[i] + n, 0);
    }
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            b[0][0] = a[0][0];
            for (int j = 1; j < n; j++) {
                b[i][j] = b[i][j - 1] + a[i][j];
            }
        }
        else {
            b[i][0] = a[i][0] /*+ sum[i - 1][0]*/;
            for (int j = 1; j < n; j++) {
                b[i][j] = b[i][j - 1] + /*sum[i - 1][j] +*/ a[i][j];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            sum[0][0] = b[0][0];
            for (int j = 1; j < n; j++) {
                sum[j][i] = sum[j - 1][i] + b[j][i];
            }
        }
        else {
            sum[0][i] = b[0][i] /*+ sum[i - 1][0]*/;
            for (int j = 1; j < n; j++) {
                sum[j][i] = sum[j - 1][i] + /*sum[i - 1][j] +*/ b[j][i];
            }
        }
    }
    
    for (int i = 0; i <Q ;i++) {
        cin >> p >> q;
        p--;  q--;
        if (p == 0)cout << sum[q][q] << endl;
        else cout << sum[q][q] - sum[q][p - 1] - sum[p - 1][q] + sum[p - 1][p - 1] << endl;
    }
    /*
    for (int i = 0; i< n; i++) {
        for (int j = 0; j < n; j++) cout << a[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    for (int i = 0; i< n; i++) {
        for (int j = 0; j < n; j++) cout <<b[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    for (int i = 0; i< n; i++) {
        for (int j = 0; j < n; j++) cout << sum[i][j] << " ";
        cout << endl;
    }*/
}


Measured memory_bytes: 6912
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

bool is_valid(vector<bool>& enable, int n) {
	while(n > 0) {
		if(!enable[n % 10]) {
			return false;
		};
		n /= 10;
	}
	return true;
}

int main() {
	int n, k;
	cin >> n >> k;
	VI d(k);
	REP(i, k) { cin >> d[i]; }
	vector<bool> enable(10, true);
	REP(i, k) { enable[d[i]] = false; }
	RANGE(i, n, 100000) {
		if(is_valid(enable, i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3568
var
  a,b,c,i:longint;
  f:array[-100..100] of longint;
begin
  readln(a,b,c);
  inc(f[a]);inc(f[b]);inc(f[c]);
  for i:=-100 to 100 do if f[i]=1 then begin writeln(i);exit;end;
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
	ll x;
	cin>>x;
	return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <vector <int> > g;
vector <int> val;
vector <int> a;
 int dfs(vector <bool> &visited,int s);
 vector <int> test;
  vector <int> ans;
  void rerooting(int s,vector <bool> &visited);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r=nxtl(),c=nxtl();
    if(r==1||c==1)
    {
        cout<<"1\n";
        return 0;
    }
    ll test;
    if(r*c%2==0)
        cout<<(r*c)/2<<endl;
    else{
         test=((r*(c-1))/2)+r/2+r%2;
         cout<<test<<endl;
    }

    return 0;   
}


 
 


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

int main() {
    int n, m;
    cin >> n >> m;
    int l, r;
    int max_l, min_r;
    max_l = 0;
    min_r = n;
    for (int i = 0; i < m; i++) {
        cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }
    if (min_r - max_l < 0) {
        cout << 0 << endl;
    }
    else {
        cout << min_r - max_l + 1 << endl;
    }
    return 0;
}

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

int x;

void func(int p2, int y, int first)
{
	int flag = 0;
	
	if (y == 0) {
		return;
	}
	
	if (y >= p2) {
		func(p2 / 2, y - p2, 0);
		flag = 1;
	}
	else {
		func(p2 / 2, y, first);
	}
	
	if (flag == 1) {
		cout << p2;
		if (first) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

int main()
{
	while (cin >> x) {
		func(512, x, 1);
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 500
#define MAX_h 500
int N;
double h[MAX_N];
double dp[MAX_N + 1][MAX_h + 1];

void DP() {
    rep(i, MAX_N + 1) rep(k, MAX_h + 1) dp[i][k] = INF;
    dp[0][1] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= MAX_h; j++) {
            for (int k = 1; k <= MAX_h; k++) {
                if ((j <= h[i - 1] && k <= h[i - 1]) ||
                    (j >= h[i - 1] && k >= h[i - 1])) {
                    // 交差しないとき
                    dp[i][k] =
                        min(dp[i][k],
                            dp[i - 1][j] + (double)((double)abs(j - h[i - 1]) +
                                                    (double)abs(k - h[i - 1])) *
                                               1 / 2);
                } else {
                    double point = (double)abs(j - h[i - 1]) /
                                   (double)((double)abs(j - h[i - 1]) +
                                            (double)abs(k - h[i - 1]));
                    dp[i][k] =
                        min(dp[i][k],
                            dp[i - 1][j] +
                                ((double)abs(j - h[i - 1]) * point +
                                 (double)abs(k - h[i - 1]) * (1 - point)) /
                                    2);
                }
            }
        }
    }
}
int main() {
    cin >> N;
    rep(i, N) cin >> h[i];
    DP();
    double ans = INF;
    rep(i, MAX_h + 1) ans = min(ans, dp[N][i]);
    cout << setprecision(9);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
bool isKaibun(string s)
{
    string r = s;
    reverse(r.begin(), r.end());
    return r == s;
}
int main()
{
    string s;
    cin >> s;

    cout << (isKaibun(s) && isKaibun(s.substr(0, s.length() / 2)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys

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

def main():
	N = II()
	S = LII(N)

	total_S = sum(S)
	S.sort()
	if(total_S % 10 == 0):
		i = 0
		for i in range(N):
			f = False
			if(S[i]%10!=0): 
				print(total_S-S[i])
				f=True
				break
		if(f==False):print(0)
	else:
		print(total_S)

main()

Measured memory_bytes: 3064
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 x              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF b < a
      MOVE a TO x
      MOVE b TO a
      MOVE x TO b
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL b < i
      MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans.
  STOP RUN.


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL n;
    cin >> n;
    LL ans = n - 1;
    for (LL i = 1; i * i <= n; ++i)
        if (n % i == 0)
            ans = min(ans, i + n / i - 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	char x, y;
	cin >> x >> y;
	if (x < y) {
		cout << "<" << endl;
	}
	else if (x == y) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}
}

Measured memory_bytes: 3636
#include<stdio.h>

void selection_sort(int *number,int array_num){
	int flag;
	int p;
	int i,j;
	int temp=0;
	int c=0;
	for(i=0;i<array_num-1;i++){
		flag=0;
		p=i;
		for(j=i+1;j<array_num;j++){
			if(number[p]>number[j]){
				p=j;
				flag=1;
			}
		}
		if(flag){
			temp=number[i];
			number[i]=number[p];
			number[p]=temp;
			c++;
		}
	}
	for(int k=0;k<array_num;k++){
			if(k!=array_num-1){printf("%d ",number[k]);}
			else{printf("%d\n",number[k]);}
	}
	printf("%d\n",c);
}

int main(void){
	int n;
	scanf("%d",&n);
	int A[n];
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	selection_sort(A,n);
	return 0;
	
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int a[20];
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1] == a[2] && a[1] != a[3]){
        cout<<"Yes\n";
    }
    else if(a[2] == a[3] && a[1] != a[2]) cout<<"Yes\n";
    else cout<<"No\n";
}


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

flag = 1
i = 0
a = []
a.append(s)

while flag == 1 : 
    i += 1
    
    if a[i-1] % 2 == 0 : 
        if int(a[i-1]/2) in a : 
            flag = 0
        else : 
            a.append(int(a[i-1]/2))
    else : 
        if int(3*a[i-1]+1) in a : 
            flag = 0
        else : 
            a.append(int(3*a[i-1]+1))
    
print(i+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3){
    if(s[i]==t[i]) ans++;
  }
  cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        for (int j = i + 1; j < s.size(); j++) {
            string ss = "";
            ss += s[i];
            ss += s[j];
            if (ss== "CF") {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    w,d = map(int,input().split())
    if w == 0 and d == 0:
        break

    h = list(map(int,input().split()))
    m = list(map(int,input().split()))

    hl = [0] * 30
    ml = [0] * 30

    for i in h:
        hl[i] += 1
    for i in m:
        ml[i] += 1

    ans = 0
    for i in range(30):

        ans += i * max(hl[i],ml[i])

    print (ans)

   



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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<ll> a(3 * N, 0LL);
	rep (i, 3 * N){
		cin >> a[i];
	} // end rep

	priority_queue<ll, vector<ll>, greater<ll> > p;
	priority_queue<ll> q;
	
	ll psum = 0LL, qsum = 0LL;
	rep (i, 3 * N){
		if (i < N){
			p.push(a[i]);
			psum += a[i];
		} // end if
		if (i >= 2 * N){
			q.push(a[i]);
			qsum += a[i];
		} // end if
	} // end rep

	vector<ll> pm(N + 1, 0LL), qm(N + 1, 0LL);
	pm[0] = psum, qm[0] = qsum;

	rep (i, N){
		p.push(a[N + i]); psum += a[N + i];
		psum -= p.top(); p.pop();
		pm[i + 1] = psum;

		q.push(a[2 * N  - 1 - i]); qsum += a[2 * N - 1 - i];
		qsum -= q.top(); q.pop();
		qm[i + 1] = qsum;
	} // end rep

	ll res = -INF;
	rep (i, N + 1){
		ll curr = pm[i] - qm[N - i];
		res = max(res, curr);
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5876
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String text = sc.next();

        long ans = 0;

        for (int i = 0; i < 10; i++) {
            int iIndex = text.indexOf(String.valueOf(i));
            if (iIndex < 0) {
                continue;
            }
            for (int j = 0; j < 10; j++) {
                int jIndex = text.indexOf(String.valueOf(j), iIndex + 1);
                if (jIndex < 0) {
                    continue;
                }
                for (int k = 0; k < 10; k++) {
                    int kIndex = text.indexOf(String.valueOf(k), jIndex + 1);
                    if (kIndex >= 0) {
                        ans++;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

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

using namespace std;
string a,b;
int len_a,len_b;
int main()
{
	cin>>a>>b;
	len_a=a.size(),len_b=b.size();
	for(int i=0;i<len_b;i++)
	cout<<a[i]<<b[i];
	if(len_a>len_b)cout<<a[len_b];
	cout<<"\n";
    
    return 0;
}

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

signed main() {
  int N;
  cin>>N;
  int c;
  for(int i=0;i<sqrt((double)N);i++){
    if(N%(i+1)!=0)continue;
    c=0;
    for(int j=1;N/(i+1)/j>0;j*=10) c++;
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
long long int m=1000000007;
long long int power(long long int p,long long int k)
{
long long int a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
int main()
{
string s,t;
cin>>s;
cin>>t;
ll ans=0,i;
for(i=0;i<3;i++)
if(s[i]==t[i])
ans++;
cout<<ans;
return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1) {
    c -= b;
    if(c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3584
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e6+7;


ll ME(ll x,ll n)
{
    ll res=1;
    
    while(n)
    {
        if(n&1)
        res=(res*x)%M;
        
        n/=2;
        
        x=(x*x)%M;
    }
    
    return res;

    
}



void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{

    string s;
    cin>>s;
    
    int ctr=0,mx=0;
    
    rep(i,0,3)
    {   if(s[i]=='R')
        ctr++;
        
        else
        mx=max(ctr,mx),ctr=0;
    
    }
    
    mx=max(ctr,mx);
    
    prin(mx);
    
    
    
        
    
            
}

Measured memory_bytes: 3688
#include <cstdio>
#include <algorithm>
using namespace std;

inline int max (const int p, const int q) {return p > q ? p : q;}

const int N = 2003;
int n, a[N], ans;

int main () {
	scanf ("%d", &n);
	int i, j; for (i = 1; i <= n; ++i) scanf ("%d", &a[i]);
	sort (a + 1, a + n + 1);
	for (i = 1; i < n - 1; ++i) {
		for (j = i + 1; j < n; ++j) {
			if (a[n] < a[i] + a[j]) {
				ans += n - j;
				continue;
			}
			int x = lower_bound (a + j + 1, a + n + 1, a[i] + a[j]) - a;
			ans += x - j - 1;
		}
	}
	printf ("%d\n", ans);
	return 0;
}

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

int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
 int k;
  cin >> k;
  cout << ans[k - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int POW[6];
ll num[26];
char buf[11];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 6; i++){

		POW[i] = POW[i-1]*2;
	}

	for(int i = 0; i < 26; i++){

		num[i] = 0;
	}

	scanf("%d",&N);

	for(int loop = 0; loop < N; loop++){

		scanf("%s",buf);

		if(buf[0] != 'M' && buf[0] != 'A' && buf[0] != 'R' && buf[0] != 'C' && buf[0] != 'H')continue;

		num[buf[0]-'A']++;
	}

	vector<ll> V;

	V.push_back(num['M'-'A']);
	V.push_back(num['A'-'A']);
	V.push_back(num['R'-'A']);
	V.push_back(num['C'-'A']);
	V.push_back(num['H'-'A']);

	ll ans = 0,tmp;
	int count;

	for(int state = 0; state < POW[5]; state++){

		count = 0;
		tmp = 1;

		for(int loop = 0; loop < 5; loop++){
			if(state & (1 << loop)){

				tmp *= V[loop];
				count++;

			}
		}
		if(count != 3)continue;

		ans += tmp;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char ch; cin>>ch; cout<<char(ch+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<Integer>();
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x[] = new int[n+1];
    int y[] = new int[m+1];
    x[0] = sc.nextInt();
    y[0] = sc.nextInt();

    for(int i=1;i<=n;i++){
      x[i] = sc.nextInt();
    }
    for(int i=1;i<=m;i++){
      y[i] = sc.nextInt();
    }
    Arrays.sort(x);
    Arrays.sort(y);
    if(x[x.length-1]<y[0])
      System.out.println("No War");
    else
      System.out.println("War");
  }
}

Measured memory_bytes: 23892
N = int(input())
A = list(map(int, input().split()))

cnt = 0
flg = True
while True:
    for a in A:
        if a % 2 != 0:
            flg = False
    if flg == False:
        break
    A = list(map(lambda x: x/2, A))
    cnt += 1
print(cnt)


Measured memory_bytes: 38768
import sys
def input(): return sys.stdin.readline().strip()

def main():
    W, a, b = map(int, input().split())
    if a + W < b:
        print(b - a - W)
    elif a < b + W:
        print(0)
    else:
        print(a - b - W)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61556
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-8;
#define MAX_N 10
#define MAX_M 1000

double Sqrt(double x){
  if(x<0)return 0;
  return sqrt(x);
}

int n,m;
double dx[MAX_N],dy[MAX_N],dv[MAX_N];
double fpx[MAX_M],fpy[MAX_M],fvx[MAX_M],fvy[MAX_M];

double ddx[MAX_N],ddy[MAX_N];
double gett[MAX_N];

double calcdir(int id){
  double res=1e20;
  
  for(int i=0;i<n;i++){
    ddx[i]=ddy[i]=0;
    gett[i]=1e20;
    
    double cx = fpx[id]-dx[i];
    double cy = fpy[id]-dy[i];
    double A=fvx[id]*fvx[id]+fvy[id]*fvy[id]-dv[i]*dv[i];
    double B=2.0*(fvx[id]*cx+fvy[id]*cy);
    double C=cx*cx+cy*cy;
    if( B*B-4.0*A*C < -eps )continue;
    double t0 = ( -B + Sqrt(B*B-4.0*A*C) ) / ( 2.0*A );
    double t1 = ( -B - Sqrt(B*B-4.0*A*C) ) / ( 2.0*A );
    double mini=1e20;
    if( -eps < t0 )mini=min(mini,t0);
    if( -eps < t1 )mini=min(mini,t1);
    if(mini==1e20)continue;
    res=min(res,mini);
    gett[i]=mini;
    
    double nfx = fpx[id]+fvx[id]*mini;
    double nfy = fpy[id]+fvy[id]*mini;
    ddx[i] = nfx - dx[i];
    ddy[i] = nfy - dy[i];

    double len= Sqrt(ddx[i]*ddx[i] + ddy[i]*ddy[i]);
    if(len>eps){
      ddx[i]/=len;
      ddy[i]/=len;
    }

  }
  return res;
}

int ans[MAX_N];

void solve(){
  memset( ans , 0 , sizeof(ans) );
  for(int i=0;i<m;i++){
    double t=calcdir(i);
    for(int j=0;j<n;j++){
      if( gett[j] == t )ans[j]++;
      dx[j]=dx[j]+t*ddx[j]*dv[j];
      dy[j]=dy[j]+t*ddy[j]*dv[j];
    }
  }

  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
      cin>>dx[i]>>dy[i]>>dv[i];
    }
    for(int i=0;i<m;i++){
      cin>>fpx[i]>>fpy[i]>>fvx[i]>>fvy[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3228
package main

import(
    "fmt"
)



func main() {
    var x,y int
    fmt.Scan(&x,&y)
    a := [7]int{1,3,5,7,8,10,12}
    b := [4]int{4,6,9,11}
    c := 0
    d := 0
    for _,i := range a{
        if x==i{
            c=1
        }
        if y==i{
            d=1
        }
    }
    for _,i := range b{
        if x==i{
            c=2
        }
        if y==i{
            d=2
        }
    }
    ans := "No"
    if c==d{
        ans = "Yes"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


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


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

void solve() {
    ll H, W; cin >> H >> W;
    
    if(H == 1){
        cout << 1 << endl;
        return;
    }

    if(W == 1){
        cout << 1 << endl;
        return;
    }

    if(W % 2 != 0 ){
        //  kisu
        cout << (H * (W-1))/2 + (H + 1)/2 << endl;
        return;
    }else{
        // gu
        cout << (H * W)/2 << endl;
        return;
    }

}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const ll MAX = 3234566667;

void dfs(vector<string> &v, string s) {
    if (MAX < stoll(s)) return;
    v.push_back(s);
    if (s.back() != '0') dfs(v, s + char(s.back() - 1));
    dfs(v, s + s.back());
    if (s.back() != '9') dfs(v, s + char(s.back() + 1));
}

int main() {
    ll K;
    cin >> K;
    
    vector<string> all;
    for (int i=1; i<=9; ++i) {
        dfs(all, to_string(i));
    }
    
    // to long
    vector<ll> v;
    for (string s: all) {
        v.push_back(stoll(s));
    }
    sort(v.begin(), v.end());

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

    return 0;
}

Measured memory_bytes: 8280
from itertools import permutations
stdin = open(0).read().split('\n')
N = int(stdin[0])

P=int("".join(list(stdin[1].split())))
Q=int("".join(list(stdin[2].split())))

l = []
for pp in permutations(range(1, N+1)):
    ll = []
    for _p in pp:
        ll.append(str(_p))
    l.append(int("".join(ll)))
a = l.index(P)
b = l.index(Q)
print(abs(a - b))

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

public class Main {
    static long get(long limit,long a,long b){
        ArrayList<Long>pows= new ArrayList<>();
        long x=0;
        for (int i =60;i>=0;i--){
            if ((1l<<i&a)!=(1l<<i&b)){
                pows.add(1l<<i);
            }
            else x|=(1l<<i &a);
        }
        for (long c:pows){
            if (c+x<=limit){
                x+=c;
            }
        }
        return x;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n= sc.nextInt();
        long[]a = new long[n];
        for (int i =0; i<n;i++)a[i]=sc.nextLong();
        long sum = a[0]+a[1];
        long xor=0;
        for (int i =2;i<n;i++)xor^=a[i];
        if (sum%2!=xor%2||sum<xor){
            pw.println(-1);
        }
        else {
            long s1=xor;
            long s2=sum-xor;
            s2/=2;
            s1+=s2;
            if ((s1^s2)==xor&&s1+s2==sum){
                long ans=get(a[0],s1,s2);
                if (ans<=a[0]&&ans>0){
                    pw.println(a[0]-ans);
                }
                else pw.println(-1);
            }
            else {
                pw.println(-1);
            }
        }
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++)
                arr[i] = nextInt();
            return arr;
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 32868
#include<iostream>
#include<string>
#include<algorithm>
#include<stdbool.h>
using namespace std;

int main(void) {
	char a;
	cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  vector<int> s(n);
  for(int i = 0;i<n;i++){
    int m;
    cin >>m;
    s.at(i)=m;
  }
  sort(s.begin(),s.end());
  int now = s.at(0);
  int ans =1;
  for(int i =0;i<n;i++){
    if(now <s.at(i)){
      now = s.at(i);
      ans++;
    }
  }
  cout << ans;
}

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

typedef long long int lli;
typedef pair<int,int> pii;

lli binSearch(vector<lli> arr,lli s,lli e,lli t){
    lli low = s;
    lli high = e;
    while(low<=high){
        lli mid = low + (high - low)/2;
        if(arr[mid] == t){
            return mid;
        } else if(arr[mid]>t){
            high = mid-1;
        } else {
            low = mid+1;
        }
    }
    return -1;
}

lli greatSearch(vector<lli> arr, int vis[], lli t){
    lli l = 0;
    lli h = arr.size()-1;
    while(l<h){
        lli mid = l + (h-l)/2;
        if(vis[mid] == 0 ){
            
            if(arr[mid] == t || ((mid+1)<arr.size() && arr[mid]<t && arr[mid+1]>=t)){
                return mid;
            } else if( arr[mid]>t ){
                h = mid - 1; 
            } else {
                l = mid + 1;
            }
        }
    }
    return -1;
}

int main(){

    lli a;//b,count=0;
    cin>>a;//>>b;
    // string s;
    // cin>>s;
    // vector<lli> arr;
    if(a%1000 == 0){
        cout<<0;
    } else {
        cout<<1000 - a%1000;
    }
    // vector<lli> arr1;
    //unordered_map<lli,lli> ans;
    //vector<int> vis;
    // while(a--){
    //     lli temp;
    //     cin>>temp;
    //     if(temp==1){
    //         cout<<1<<endl;
    //     } else if(temp&1) {
    //         cout<< 1 + (temp - 1)/2 <<endl;
    //     } else {
    //         cout<< temp/2 << endl; 
    //     }
    // }

    // while(n--){
        
        // lli x,y,ans;
        // cin>>y>>x;
        // cout<<ans<<endl;

    //}
    return 0;
}   

Measured memory_bytes: 3620
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0&&0<=b)printf("Zero\n");
	else if(0<a)printf("Positive\n");
	else if((b-a)%2==0)printf("Negative\n");
	else printf("Positive\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0, j = s.size() - 1; i < j; i++, j--) cnt += (s[i] != s[j]);
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>x>>y;
	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){cout<<"Yes\n";return 0;}
	}
	cout<<"No\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int r,c,t;
    cin >> r >> c;
    vector<vector<int>> v(r, vector<int>(c));
    for(auto& v1 : v) for(auto& d : v1) cin >> d;
    for (int i=0; i<r; i++) {
        t = 0;
        for (int j=0; j<c; j++) {
            t += v[i][j];
            cout << v[i][j] << " ";
        }
        cout << t << endl;
    }
    for (int i=0; i<c; i++) {
        t = 0;
        for (int j=0; j<r; j++) {
            t += v[j][i];
        }
        cout << t << " ";
    }
    t = 0;
    for (int i=0; i<r; i++) {
        for (int j=0; j<c; j++) {
            t += v[i][j];
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3188
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e18;
const ll MAXN=1e7;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
//vector<ll> v(MAXN);
ll n;
cin>>n;
string s;
cin>>s;
ll w=0;
for(ll i=0;i<n;i++)
{
   if(s[i]=='W')
        w++;
}
ll cnt=0;
for(ll i=n-1;i>=0;i--)
{
   if(s[i]=='W' && w>0)
        w--;
   else
    if(s[i]=='R' && w>0)
   {
      cnt++;
   w--;
   }
   else
    break;
}
   cout<<cnt;
return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
int main(){
        string s1, s2;
        cin >> s1 >> s2;
        int n = s1.size();
        int m = s2.size();
        for(int i = 0 ; i < n  ; i++){
            for(int j = 0 ; j < m ; j++){
                if(s1[i] == s2[j])
                    dp[i+1][j+1] = 1 + dp[i][j];
                else
                    dp[i+1][j+1] = max(dp[i][j+1] , dp[i+1][j]);
            }
        }
        int c = 0;
        int r = 1;
        string res = "";
        int i = n-1 , j = m-1;
        while(i >= 0 && j >= 0){
            if(s1[i] == s2[j]){
                res += s1[i];
                i--;
                j--;
                continue;
            }
            if(dp[i+1][j] < dp[i][j+1])
                i--;
            else
                j--;
        }
        reverse(res.begin() , res.end());
        cout<<res<<"\n";
        //cout<<dp[n][m];
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 26;

ll C[30];
ll S[400][30];
ll T[400];
ll Last[30];
ll score = 0;

ll calc(ll t, ll d) {
    score += S[d][t];
    Last[t] = d;
    REP(i, MAX) {
        score -= C[i] * (d - Last[i]);
    }
    return score;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    REP(i, MAX) {
        cin >> C[i];
    }
    REP(i, D) {
        REP(j, MAX) {
            cin >> S[i][j];
        }
    }
    REP(i, D) {
        cin >> T[i];
        T[i]--;
    }
    memset(Last, -1, sizeof(Last));
    REP(i, D) {
        cout << calc(T[i], i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3696
# 高橋君の夏休みは N 日間
# 夏休みの宿題が M 個
# 遊ぶことができる日数は？
# ただし、夏休み中に全ての宿題を終わらせることができないときは、-1 を出力

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-1')

Measured memory_bytes: 10052
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
ll a[MAX], b[MAX];
int N, M, K, ans;

int main(int argc, char** argv) {
	scanf("%d%d%d", &N, &M, &K);
	REP(i, 1, N) scanf("%lld", a+i);
	REP(i, 1, M) scanf("%lld", b+i);
	REP(i, 1, N) a[i] += a[i-1];
	REP(i, 1, M) b[i] += b[i-1];
	int j = M;
	REP(i, 1, N) {
		if(a[i] > K) break;
		while(a[i]+b[j] > K) j--;
		ans = max(ans, i+j);
	}
	j = N;
	REP(i, 1, M) {
		if(b[i] > K) break;
		while(b[i]+a[j] > K) j--;
		ans = max(ans, i+j);
	}
	printf("%d\n", ans);
	return 0;
}


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

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n), ys(n);
    for (auto& x : xs) std::cin >> x;
    for (auto& y : ys) std::cin >> y;

    std::vector<int> xr(n + 1, -1), yl(n + 1, -1);
    for (int i = 0; i < n; ++i) xr[xs[i]] = i;
    for (int i = n - 1; i >= 0; --i) yl[ys[i]] = i;

    int d = 0;
    for (int i = 1; i <= n; ++i) {
        if (xr[i] == -1 || yl[i] == -1) continue;
        d = std::max(d, xr[i] - yl[i] + 1);
    }

    std::rotate(ys.begin(), ys.begin() + n - d, ys.end());

    for (int i = 0; i < n; ++i) {
        if (xs[i] == ys[i]) {
            std::cout << "No\n";
            return;
        }
    }

    std::cout << "Yes\n";
    for (auto y : ys) std::cout << y << " ";
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 6344
import std.stdio;
import std.c.stdio;
import std.string;
import std.array;
import std.conv;

void Sort(ref int[] a,int n){

    int key,j;
    for(int i=1;i<n;i++){

	writef("%d",a[0]);
	for(int k=1;k<n;k++){
	    writef(" %d",a[k]);
	}
	writeln();

	key = a[i];
	j = i - 1;
	while(j >= 0 && key < a[j]){
	    a[j+1] = a[j];
	    a[j] = key;
	    j--;
	}
    }

}

void main(){

    int n;
    int[] a;
    string[] s;
    scanf("%d\n",&n);
    a = new int[n];
    s = split(readln());
    for(int i=0;i<n;i++){
	a[i] = to!int(s[i]);
    }
    Sort(a,n);
    writef("%d",a[0]);
    for(int i=1;i<n;i++){
	writef(" %d",a[i]);
    }
    writeln();

}

Measured memory_bytes: 2508
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

int dfs(int a, int b, int t) {
  if (a < 2 && b < 2)return 1 - t;
  rep(i, (a + 2) / 2)rep(j, (b + 2) / 2) {
    if (i != 0 && t == dfs(a - i * 2, b + i, 1 - t))return t;
    if (j != 0 && t == dfs(a + j, b - j * 2, 1 - t))return t;
  }
  return 1 - t;
}

void Calc() {
  /*ofstream ifs("ba.txt");
  rep(i, 6)rep(j, 6) {
    ifs << i << ' ' << j << ' ' << dfs(i, j, 0) << ' ' << (abs(i - j) < 2) << endl;
  }*/
  var(ll, x, y);

  cout << (abs(x - y) >= 2 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = [0]*(n+1)
if n == 0:  
    x = a[0]
    if x == 1:
        print(1)
    else:
        print(-1)
    exit()
nows = sum(a)
s = nows
for i in range(n+1):
    if i == 0:
        b[i] = 1 - a[i]
    else:
        nows -= a[i]
        b[i] = min(nows, 2*b[i-1]-a[i])
        if b[i] < 0:  
            print(-1)
            exit()

print(sum(b)+s)  


Measured memory_bytes: 20108
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int, string> P;
bool comp(const P& a, const P& b) {
    if (a.first!=b.first) return a.first<b.first;
    return a.second<b.second;
}
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        vector<string> cnt[31];
        map<string, int> mp;
        P po[n];
        for (int i=0; i<n; i++) {
            string name; cin>>name;
            po[i]=P(0,name);
            mp[name]=i;
            int m; scanf("%d",&m);
            for (int j=0; j<m; j++) {
                int d; scanf("%d",&d);
                cnt[d].push_back(name);
            }
        }
        for (int i=0; i<31; i++) {
            int sz=cnt[i].size();
            int x=n-sz+1;
            for (int j=0; j<sz; j++) {
                po[mp[cnt[i][j]]].first+=x;
            }
        }
        sort(po, po+n, comp);
        cout<<po[0].first<<" "<<po[0].second<<endl;
    }
}

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

int main(){
int K,S;
  cin>>K>>S;
  int ans=0;
  for(int x=0; x<=K; x++){
   for(int y=0; y<=K; y++){
    int z=S-x-y;
     if(0<=z && z<=K){ans+=1;} //zの数ansが割り当ての個数になるように変換した
   }}
  cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> Words(N);
    for(int i = 0; i < N; i++){
        cin >> Words.at(i);
    }

    bool ok = true;
    for(int i = 0; i < N - 1; i++){
        if(Words.at(i).back() != Words.at(i + 1).at(0)) ok = false;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            if(Words.at(i) == Words.at(j)) ok = false;
        }
    }

    if(ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = np.array(A[::-1])
B = np.array(B[::-1])

ans = 0

# print(A, B)

for i in range(N):
    m = A[i] % B[i]
    if m == 0:
        continue
    else:
        if i != N - 1:
            A[i + 1 :] += B[i] - m
        # print(i, B[i] - m)
        ans += B[i] - m


print(ans)



Measured memory_bytes: 36412
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int h,w,n,sr,sc;
char s1[N],s2[N];
bool judge(char opt)
{
    int x=sr,y=sc;
    for(int i=1;i<=n;i++)
    {
        if(s1[i]==opt)
        {
            if(opt=='U') x--;
            else if(opt=='D') x++;
            else if(opt=='L') y--;
            else y++;
        }
        if(x<1||x>h||y<1||y>w) return true;
        if(opt=='U')
        {
            if(s2[i]=='D'&&x+1<=h) x++;
        }
        else if(opt=='D')
        {
            if(s2[i]=='U'&&x-1>=1) x--;
        }
        else if(opt=='L')
        {
            if(s2[i]=='R'&&y+1<=w) y++;
        }
        else
        {
            if(s2[i]=='L'&&y-1>=1) y--;
        }
    }
    return false;
}
int main()
{
    scanf("%d%d%d",&h,&w,&n);
    scanf("%d%d",&sr,&sc);
    scanf("%s%s",s1+1,s2+1);
    if(judge('U')||judge('D')||judge('L')||judge('R'))
        printf("NO\n");
    else printf("YES\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a;
  cin>>a;
  string b;
  cin>>b;
  rep(i,b.size()){
    int c=b.at(i)-'A';
    c+=a;
    c%=26;
    char d=c+'A';
    cout<<d;
  }
}

Measured memory_bytes: 256