akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while(cin >> xa1 >> ya1 >>xa2 >>ya2 >>xb1 >>yb1 >>xb2 >>yb2){
		if(xb2 < xa1 || ya2 < yb1 || xa2 < xb1 || yb2 < ya1) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}

Measured memory_bytes: 1220
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();

		int rgb = R*100+G*10+B;
		int B1;
		int C1;

		int A2;
		int B2;
		int C2;

		int tmp = 0;

		if(rgb % 4 ==0){
			System.out.println("YES");
			return;
		}else{
			System.out.println("NO");
			return;
		}

	}

}


Measured memory_bytes: 23892
n, m = map(int, input().split())
X = list(map(int, input().split()))

if(n >= m):
    print('0')
    exit()

X.sort()
diff = []
for i in range(1, len(X)):
    diff.append(X[i]-X[i-1])

diff.sort()

ans = 0
for i in range(m-n):
    ans += diff[i]

print(ans)


Measured memory_bytes: 13968
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> Min(26,50), cnt(26);
    rep(i,n) {
        cin >> s[i];
        rep(j,s[i].size()) {
            cnt[s[i][j]-(int)'a']++;
        }
        rep(j,26) {
            Min[j] = min(Min[j], cnt[j]);
            cnt[j] = 0;
        }
    }
    rep(i,26) {
        rep(j,Min[i]) {
            cout << (char)('a'+i);
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
int n,m,l;
int dist[350][350];
void warshall_floyd(int t[350][350]){
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
            }
        }
    }
}
signed main(){
    int r[350][350];
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)r[i][j]=0;
            else r[i][j]=INF;
        }
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        r[a-1][b-1]=c;
        r[b-1][a-1]=c;
    }
    warshall_floyd(r);
    int u[350][350];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)u[i][j]=0;
            else if(r[i][j]<=l)u[i][j]=1;
            else u[i][j]=INF;
        }
    }
    warshall_floyd(u);
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int s,t;
        cin>>s>>t;
        if(u[s-1][t-1]==INF)cout<<-1<<endl;
        else cout<<u[s-1][t-1]-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
s = input()
i = 0
while True:
	if i == len(s):
		print('YES')
		break
	if len(s) - i < 5:
		print('NO')
		break
	if s[i] == 'd':
		if s[i:i+5] != 'dream':
			print('NO')
			break
		if len(s) - i < 7:
			i += 5
			continue
		if s[i:i+7] != 'dreamer':
			i += 5
			continue
		if len(s) - i == 7 or s[i+7] != 'a':
			i += 7
			continue
		i += 5
		continue
	if s[i] == 'e':
		if s[i:i+5] != 'erase':
			print('NO')
			break
		if len(s) - i < 6:
			i += 5
			continue
		if s[i:i+6] != 'eraser':
			i += 5
			continue
		if len(s) - i == 6 or s[i+6] != 'a':
			i += 6
			continue
		i += 5
		continue
	print('NO')
	break


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef unsigned long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, a, b;
    cin >> n >> a >> b;
    
    if (a==0)
    {
        cout << a << endl;
        return 0;
    }

    if (a>=n)
    {
        cout << n << endl;
        return 0;
    }

    ll d = n / (a+b);
    ll r = n % (a+b);
    ll apd = (r>a) ? a : r;

    ll ans(0);
    if (r==0)
        cout << d*a << endl;
    else
        cout << d*a+apd << endl;

    return 0;
}


Measured memory_bytes: 256
# ABC 131 anti division

a, b, c, d = [int(el) for el in input().split(' ')]

def gcd(x, y):
    while(y):
        x, y = y, x % y
    return x

def lcm(x, y):
    return(x*y // gcd(x, y))

def g(x, y):
    return(x // y + 1)

def f(x, y, z):
    return(x+1 - g(x, y) - g(x, z) + g(x, lcm(y, z)))

print(f(b, c, d) - f(a-1, c, d))


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

int main() {
  string s;
  cin >> s;
  int ans = 0;

  if (s[0] == 'R') ans++;
  if (s[1] == 'R') ans++;
  if (s[2] == 'R') ans++;

  if (ans > 0 && s[1] == 'S') ans=1;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

bool check(int a,int b,int c){
    int maxi=max(a,max(b,c));
    if((a+b+c)-max(a,max(b,c))>max(a,max(b,c))){
        return true;
    }
    return false;
}

int main(){
    int n;cin>>n;
    int niz[n],rj=0;
    for(auto& a:niz)
        cin >>a;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(niz[i]!=niz[j] && niz[j]!=niz[k] && niz[i]!=niz[k] && check(niz[i],niz[j],niz[k])){
                    rj++;
                }
            }
        }
    }
    cout <<rj<<endl;
}


Measured memory_bytes: 3540
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>

using namespace std;

int main() {
	int n;
	auto ma=0;
	int f;
	string tmp;
	vector <string> v;
	vector <string> ans;
	map<string, int> vote;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		v.push_back(tmp);
		vote[tmp]++;
		
	}
	//map<string, int>::iterator itr;
	for (auto itr = vote.begin(); itr != vote.end(); itr++) {
		f = itr->second;
		ma = max(f, ma);
		
	}
	

	for (auto itr = vote.begin(); itr != vote.end(); itr++) {
		if(ma==itr->second)
			cout << itr->first<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 23468
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    int n = 5;
    VI a(n+1);
    FOR (i, 1, n+1)
        cin >> a[i];

    int i = 1;
    GFOR(i, 1, 5) {
        if (a[i] == 0)
            break;
    }
    cout << i << "\n";
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  ll cnt = 0;
  int sum = 0;
  int right = 0;
  for (int left = 0; left < n; ++left)
  {
    while (right < n && (sum ^ a[right]) == (sum + a[right]))
      sum += a[right++];
    cnt += right - left;
    if (left == right)
      right++;
    else
    {
      sum -= a[left];
    }
  }
  cout << cnt << endl;

  return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];v[i]--;
  }
  int res=0;
  int t = 0;
  while(1){
    if(res > n)break;
    if(t==v[t])break;
    t = v[t];
    res++;
    if(t==1){
      cout<<res<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (ans == "") {
        continue;
      } else {
        ans.resize(ans.size() - 1);
      }
    } else {
      ans += s[i];
    }
  }
  D(ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

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

signed main(){
	int n;cin>>n;
	cout<<n*(n+1)/2<<endl;
	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    if (a > b)
        cout << "a > b\n";
    else if (a < b)
        cout << "a < b\n";
    else 
        cout << "a == b\n";
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int dp[101][4][4][4];

int main() {
    const int mod = 1000000007;
    int n;
    cin >> n;

    dp[0][3][3][3] = 1;

    rep(len, n) {
        rep(c1, 4) {
            rep(c2, 4) {
                rep(c3, 4) {
                    if(dp[len][c1][c2][c3] == 0) {
                        continue;
                    }
                    rep(a, 4) {
                        if(a == 2 && c1 == 1 && c2 == 0) {
                            continue;
                        }
                        if(a == 2 && c1 == 0 && c2 == 1) {
                            continue;
                        }
                        if(a == 1 && c1 == 2 && c2 == 0) {
                            continue;
                        }
                        if(a == 2 && c1 == 1 && c3 == 0) {
                            continue;
                        }
                        if(a == 2 && c2 == 1 && c3 == 0) {
                            continue;
                        }
                        dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len+1][a][c1][c2] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }

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

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

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

signed main(void)
{
  string s = "CODEFESTIVAL2016";
  string t;
  cin >> t;
  int ret = 0;
  REP(i, t.size()) {
    if(t[i] != s[i]) ret++;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <vector>

struct Spell
{
  char name;
  int direction;
};

int final_index(
    const std::string& board,
    const std::vector<Spell>& spells,
    int index)
{
  const int n = static_cast<int>(board.size());
  for (const auto& s : spells) {
    if (board[index] == s.name) {
      index += s.direction;
      if (index < 0 || index >= n) break;
    }
  }
  return index;
}

int solve(const std::string& board, const std::vector<Spell>& spells)
{
  std::vector<int> indexes(board.size());
  std::iota(indexes.begin(), indexes.end(), 0);

  return std::distance(
      std::partition_point( indexes.begin(),
        indexes.end(),
        [&board, &spells](int i) {
          return final_index(board, spells, i) < 0;
        }),
      std::partition_point(
        indexes.begin(),
        indexes.end(),
        [&board, &spells](int i) {
          return final_index(board, spells, i) < static_cast<int>(board.size());
        }));
}

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

  std::vector<Spell> spells(q);
  char d;
  for (int i = 0; i < q; ++i) {
    std::cin >> spells[i].name >> d;
    spells[i].direction = d == 'L' ? -1 : 1;
  }

  std::cout << solve(s, spells) << std::endl;
}


Measured memory_bytes: 2948
z = [input() for i in range(4)]
a = z[0]+1
b = z[1]+1
c = z[2]+1
x = z[3]
p = 0
for i in range(a):
    for j in range(b):
        for k in range(c):
            total = (500*i) + (100*j) + (50*k)
            if total == x: p+=1
print p

Measured memory_bytes: 2568
n, k = list(map(int, input().split()))
P = list(map(int, input().split()))

P_ave_sum = []
ave = 0
for p in P:
    ave += (p + 1) / 2
    P_ave_sum.append(ave)



max = -1
if n == k:
    max = P_ave_sum[n - 1]
else:
    for j in range(n - k):
        sum_k = P_ave_sum[j + k] - P_ave_sum[j]
        if sum_k > max:
            max = sum_k

print(max)

Measured memory_bytes: 25060
#include <cstdio>

int ask(int y1, int x1, int y2, int x2)
{
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if (y2 - y1 > x2 - x1) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}
	printf("! %d\n", ret);
	return 0;
}


Measured memory_bytes: 596
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;

const ll INF = 100100100100100;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll dp[n][n];
  rep(i, n) rep(j, n) dp[i][j] = 0;
  REP(len, 1, n) {
    rep(i, n - len) {
      ll mn = INF;
      REP(m, i, i + len) {
        mn = min(dp[i][m] + dp[m + 1][i + len], mn);
        dp[i][i + len] += a[m];
      }
      dp[i][i + len] += a[i + len];
      dp[i][i + len] += mn;
    }
  }
  cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 1536
N = int(input())
H = list(map(int, input().split()))

cnt = 1

for i in range (1, N):
  mieru = True
  for j in range (i):
    
    if H[i] < H[j]:
      mieru = False
      break
      
  if mieru == True:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
N,M = map(int,input().split())
a = list(map(int,input().split()))
num = a.index(1)
n = M-1
left1= (num)//(M-1)
left2 = n-(num)%(M-1)
right = (N-num-1-left2)//(M-1)
right2 = (N-num-1-left2)%(M-1)
#print(left1,left2,right,right2)
if left2 !=0:
  left1 += 1
if right2 !=0:
  right += 1
print(left1+right)



Measured memory_bytes: 20560
n = io.read('*n')
_, str = io.read('*l'), io.read('*l')

function b2i(b) if b then return 1 else return 0 end end
function check(s1, s2)
    local s = { s1, s2 }
    for i = 3, n do
        s[i] = s[i - 1] ~ s[i - 2] ~ b2i(str:sub(i - 1, i - 1) == 'x')
    end
    if s1 == (s[n] ~ s[n - 1] ~ b2i(str:sub(n, n) == 'x')) and
        s2 == (s[1] ~ s[n] ~ b2i(str:sub(1, 1) == 'x'))
    then
        return s
    end
end
function print_tab(t)
    for i = 1, #t do if t[i] == 0 then io.write('S') else io.write('W') end end
    io.write('\n')
end

s = check(0, 0); if s ~= nil then print_tab(s) return end
s = check(0, 1); if s ~= nil then print_tab(s) return end
s = check(1, 0); if s ~= nil then print_tab(s) return end
s = check(1, 1); if s ~= nil then print_tab(s) return end
print('-1')


Measured memory_bytes: 6672
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> G[100005];
ll a[100005];
ll cnt[100005];
ll val[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
		cnt[a]++;
		cnt[b]++;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	queue<int> que;
	for(int i=0;i<n;i++){
		if(cnt[i]==1)que.push(i);
	}
	ll ans=0;
	int cur=0;
	while(que.size()){
		int v=que.front();
		que.pop();
		val[v]=a[cur];
		ans+=cnt[v]*a[cur++];
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			cnt[nv]--;
			if(cnt[nv]==1){
				que.push(nv);
			}
		}
	}
	printf("%lld\n",ans);
	for(int i=0;i<n;i++){
		printf("%lld%c",val[i],i+1==n?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::string s;
  Solver() {
    S002 r;
    r >= s;
  }
  void solve() {
    char c = s[0];
    puts(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o' ? "vowel" : "consonant");

  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;
void hh(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}
void zz(int A[],int n){
    for(int h=1;;){
        if(h>n)break;
        G.push_back(h);
        h=3*h+1;
    }
    for(int i=G.size()-1;i>=0;i--){
        hh(A,n,G[i]);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
        cnt=0;
        zz(A,n);
        printf("%d\n",G.size());
        for(int i=G.size()-1;i>=0;i--){
            printf("%d",G[i]);
            if(i)printf(" ");
        }
        printf("\n");
        printf("%d\n",cnt);
        for(int i=0;i<n;i++){
            printf("%d\n",A[i]);
        }

    return 0;
}

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


void solve(std::string S){

    replace(S.begin(), S.end(), 'A', '+');
    replace(S.begin(), S.end(), 'T', '+');
    replace(S.begin(), S.end(), 'G', '+');
    replace(S.begin(), S.end(), 'C', '+');

    // count max continuous "+"
    int smax=0;
    int count1=0;
    for(int i=0; i<S.size(); i++) {
        if (S.at(i) == '+') {
            count1++;
        } else {
            if (count1 > 0) {
                smax = max(smax, count1);
            }
            count1=0;
        }
    }
    if (count1 > 0) smax = max(smax, count1);
    cout << smax << endl;
}


// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> oks(N+1,true);
    for(int i=0; i<M; i++){
        int a; cin >> a;
        oks[a] = false;
    }
    vector<long long int> dp(N+1);
    dp[0] = 1;
    for(int now=0; now<N; now++){
        for(int next=now+1; next<=min(N,now+2); next++){
            if(oks[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string str1,str2;
  int cnt1=0, cnt2=0;
  for(int i=0; i<n; i++){
      cin >> str1 >> str2;
      if(str1 == str2){
          cnt1++;
          cnt2++;
      }
      else if(str1 > str2) cnt1+=3;
      else cnt2+=3;
  }
  cout << cnt1 << " " << cnt2 << endl; 
  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 200005;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
	x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

void solve(){
	int n, k, has = 0;
	cin >> n >> k;
	vector<ii> v;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		v.pb({abs(x), x});
		has |= (x>0);
	}
	sort(v.rbegin(), v.rend());
	ll ans = 1;
	if(!has and (k%2) == 1){
		for(int i = n-1; k > 0; i--, k--)
			ans = (ans * v[i].snd + mod)%mod;
		cout << ans << endl;
		return ;
	}
	ll cnt = 0, nu = mod, nn = mod, pu = mod, pn = mod;
	for(int i = 0; i < k; i++){
		ans = (ans * v[i].fst)%mod;
		if(v[i].snd < 0)
			cnt++, nu = v[i].snd; // maior negativo usado
		else
			pu = v[i].snd; // menor positivo usado
	}
	for(int i = k; i < n; i++){
		if(v[i].snd < 0 and nn == mod)
			nn = v[i].snd;	// maior neg n usado
		if(v[i].snd > 0 and pn == mod)
			pn = v[i].snd; // maior pos n usado
	}
	if((cnt % 2) == 1){ // the ans is < 0
		nu = abs(nu), nn = abs(nn);
		ll ans1 = (divll(ans, nu) * pn) % mod;
	 	ll ans2 = (divll(ans, pu) * nn) % mod;
		bool a = ((nu != mod) and (pn != mod));
		bool b = ((pu != mod) and (nn != mod));
		if(a and b){
			if(pn*pu > nn*nu)ans = ans1;
			else ans = ans2;
		}else if(a){
			ans = ans1;
		}else if(b){
			ans = ans2;
		}else{
			cout << (mod-ans)%mod << endl;
			return ;
		}
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 7336
#include<stdio.h>
int main(void)
{
    int n, x, y, b, p, i, wa1, wa2;
    scanf("%d",&n);
    for (i = 1; i <= n; i++) {
        scanf("%d %d %d %d", &x, &y, &b, &p);
        wa1 = x*b + y*p;
        if (b >= 5 && p >= 2) {
            wa1 =4*wa1/5;
        }
        else {
            if (b < 5) {
                b = 5;
            }
            if (p < 2) {
                p = 2;
            }
            wa2 = 4*(x*b + y*p)/5;
        	if (wa1 > wa2) {
            wa1 = wa2;
            
       	 	}	
        }
        	printf("%d\n", wa1);
    	
    }
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
            int n,a;
            cin >> n>>a;
            int fact = n%500;
            if(a>=fact)
            {
                    cout << "Yes" << endl;
            }
            else if(a< fact)
            {
                    cout << "No" << endl;
            }
            
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    vector<ll> h(n);
    for(int i=0; i<n; ++i) {
        cin>>h[i];
    }
    sort(h.begin(), h.end());
    ll ans = 0;
    for(int i=0; i < n-k; ++i)
        ans += h[i];
    cout<<ans;
}

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

LL Q, A, B, T, ans, p, q;

int main() {
	scanf("%lld", &Q);
	while (Q--) {
		scanf("%lld%lld", &A, &B);
		if (A > B) swap(A, B);
		if (A == B) { printf("%lld\n", 2 * A - 2); continue; }
		ans = 2 * A - 2;
		if (B - A <= 100000) {
			p = A; q = B - 1;
			while (p < B && q > A) {
				while (p * q >= A * B) q--;
				if (p < B && q > A && p * q < A * B) ans++;
				p++; q--;
			}
			printf("%lld\n", ans);
			continue;
		}
		T = sqrt(A * B + 0.5);
		while (T * T >= A * B) T--;
		if (T * (T + 1) < A * B)
			ans += 2 * (T - A) + 1;
		else
			ans += 2 * (T - A);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll total = 1000;
  for (int i = 0; i + 1 < n; ++i) {
    if (a[i] < a[i + 1]) {
      ll t = total / a[i];
      total -= a[i] * t;
      total += a[i + 1] * t;
    }
  }
  cout << total << endl;
  return 0;
}

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

using namespace std;

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

    vector <vector<int>> adj_matrix;
    adj_matrix.resize(N);

    vector<int> in_edge(N);

    int vertex_1, vertex_2;
    for (int edge = 1; edge <= M; edge++) {
        cin >> vertex_1 >> vertex_2;
        adj_matrix[vertex_1 - 1].push_back(vertex_2 - 1);

        in_edge[vertex_2 - 1]++;
    }

    queue<int> top_logic_sort;
    for (int index = 0; index < N; index++) if (in_edge[index] == 0) top_logic_sort.push(index);

    vector<int> path_length(N);

    while (!top_logic_sort.empty()){
        int node = top_logic_sort.front();
        top_logic_sort.pop();

        for(int index = 0; index < adj_matrix[node].size(); index++){
            in_edge[adj_matrix[node][index]]--;
            path_length[adj_matrix[node][index]] = max(path_length[adj_matrix[node][index]], path_length[node] + 1);
            if(in_edge[adj_matrix[node][index]] == 0) top_logic_sort.push(adj_matrix[node][index]);
        }
    }

    cout << *max_element(path_length.begin(), path_length.end());
  
    return 0;
}

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

int main(){
  int N,Y,i,j,k;
  bool flag = false;
  cin >> N >> Y;
  
  for(i = 0;i <= N;i++){
    for(j = 0;i + j <= N;j++){
      k = N - (i + j);
      if(i * 10000 + j * 5000 + k * 1000 == Y){
        flag = true;
        break;
      }
    }
    
    if(flag){
      break;
    }
  }
  
  if(flag){
    cout << i << " " << j << " " << k << endl;
  }else{
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,L;
    cin>>N>>L;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<ll> S(N+1);
    REP(i,N) S[i+1]=S[i]+a[i];
    vector<int> ans1,ans2;
    REP(i,N-1){
        if(a[i]+a[i+1]>=L){
            cout<<"Possible"<<endl;
            REP(j,i) cout<<j+1<<endl;
            for(int j=N-1;j>i;--j) cout<<j<<endl;
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
}


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

int main() {
	int n;
	string s, ans = "";
	cin >> n >> s;
	for(int i=0;i<s.size();i++) {
		int tmp = s[i] - 'A';
		tmp += n;
		tmp %= 26;
		ans += char('A' + tmp);
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int x = 100001;
  vector<int> v(x);
  int sum=0;
 
  sort(a.begin(),a.end());
  vector<int> b(100000); 
  for(int i=0; i<n; i++){
    b[a[i]]++;
  }
  
  
  for(int i=0; i<=100001; i++){
    if(i == 0){
      sum = b[i] + b[i+1];
    }
    else{
      sum = b[i-1] + b[i] + b[i+1];
    }
   
    v[i] = sum;
    sum=0;
   
  }
  
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  
  cout << v[0] << endl;
	return 0;
}


Measured memory_bytes: 1408
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		String[] S = sc.next().split("");
		String[] T = sc.next().split("");

		int cnt = 0;
		for (int i = 0; i < 3; i++) {
			if (S[i].equals(T[i])) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    lint a, b;
    cin >> a >> b;
    lint g = __gcd(a, b);
    vector<lint> divisors;
    for (lint i = 2; i*i <= g; ++i) 
    	if (g % i == 0) {
			int exp = 0;
			while (g % i == 0) {
				g /= i; exp += 1;
			}
    		divisors.push_back(i);
    	}
	if (g != 1) divisors.push_back(g);
    cout << divisors.size() + 1 << '\n';
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define dupl(s) s.erase(unique(s.begin(), s.end()), s.end());//重複取り除き
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
  long long n, a, b;
  cin >> n >> a >> b;
  if (a > b) cout << 0;
  else if (n == 1){
    if (a != b) cout << 0;
    else cout << 1;
  }
  else cout << (b * (n - 1) + a) - (a * (n - 1) + b) + 1;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int a , b , c , d ;
scanf ("%d%d%d%d " , &a , &b , &c , &d ) ;
int x = c - a , y = d - b ;
printf ("%d %d %d %d\n " , c - y , d + x , a - y , b + x ) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 3752
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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 <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0


int main(){
	int n,w,h,s,t,x,y;
	int field[128][128];
	while(scanf("%d",&n),n){
		memset(field,0,sizeof(field));
		scanf("%d%d",&w,&h);
		rep(i,n){
			scanf("%d%d",&x,&y);
			field[y][x] = 1;
		}
		scanf("%d%d",&s,&t);

#if DEB
		rep(i,7){
			rep(j,7){
				printf("%d ",field[i][j]);
			}
			puts("");
		}
#endif		

		int ans = 0;
		for(int i=0; i+t<=h+1; i++){
			for(int j=0; j+s<=w+1; j++){
				int cnt = 0;
				rep(k,t)rep(l,s)if( field[i+k][j+l]==1 )cnt++;
#if DEB
				if( j==4 && i==1 ){
					printf("%d %d  cnt:%d\n",j,i,cnt);
				}
#endif 				
				ans = max(ans,cnt);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int n, m, q; 
vector<int> a, b, c, d;
int ans;


void dfs(vector<int> A){
    if(A.size() == n+1){
        int now = 0;
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));//1-indexedになる
    cout << ans << endl;
    return 0;
}


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

iStock = 0
iMoney = 1000

for i in range(N-1):
    if A[i] < A[i + 1]:
        # A[i]Day 株購入 & a[i+1]Day 株売却
        iStock = iMoney // A[i]
        iMoney %= A[i]
        iMoney += iStock * A[i+1]
print(iMoney)


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

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

    int n; cin >> n;
    cout << n*n << endl;

    return 0;
}

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int m=in.nextInt();
		long [] vis=new long [n+1];
		vis[0]=1;
		for(int i=0;i<m;i++)
		{
			int k=in.nextInt();
			vis[k]=-1;
		}
		if(vis[1]!=-1)
			vis[1]=1;
		for(int i=2;i<=n;i++)
		{
			if(vis[i]!=-1)
			{
				if(vis[i-1]==-1)
					vis[i]=vis[i-2];
				else if(vis[i-2]==-1)
					vis[i]=vis[i-1];
				else
				    vis[i]=(vis[i-1]+vis[i-2])%1000000007;
			}
		}
		if(vis[n]==-1)
			vis[n]=0;
		System.out.println(vis[n]);
	}
}
	

Measured memory_bytes: 48748
#include <iostream>

using namespace std;

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'R') {
            ans = 1;
            break;
        }
    }
    for(int i = 0; i < 2; i++) {
        if(s[i] == 'R' && s[i+1] == 'R') {
            ans = 2;
            break;
        }
    }
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        ans = 3;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
import sys
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()))

n = Ii()
a = Li()
b = 0
for i in range(n):
  b ^= a[i]
ans = []
for i in range(n):
  print(b^a[i],end=' ') 

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

const int INF = 1 << 30;

int a[50], b[50], c[50], d[50];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)
		scanf("%d%d", &a[i], &b[i]);
	for(int i = 0; i < m; i++)
		scanf("%d%d", &c[i], &d[i]);
	for(int i = 0; i < n; i++) {
		int ans = -1;
		int dist = INF;
		for(int j = 0; j < m; j++) {
			int dst = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if(dist > dst) {
				dist = dst;
				ans = j + 1;
			}
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
bitset<2005> a[2005],dpr[2005],dpl[2005],tmp;
int N;
char s[2005][2005];
void Solve() {
    read(N);
    for(int i = 2 ; i <= N ; ++i) {
        scanf("%s",s[i] + 1);
        for(int j = 1 ; j < i ; ++j) {
            if(s[i][j] == '1') a[i][j] = 1;
            else a[j][i] = 1;
        }
    }
    for(int i = 1 ; i <= N ; ++i) dpr[i][i] = 1,dpl[i][i] = 1;
    for(int d = 2 ; d <= N ; ++d) {
        for(int l = 1 ; l <= N ; ++l) {
            int r = l + d - 1;
            if(r > N) break;
            if((dpr[l] & dpl[r - 1] & a[r]).any()) {
                dpr[l][r] = 1;
            }
            if((dpl[r] & dpr[l + 1] & a[l]).any()) {
                dpl[r][l] = 1;
            }
        }
    }
    out((dpr[1] & dpl[N]).count());enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 5632
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z'){
                System.out.print((char)(s.charAt(i)-'a'+'A'));
            }
            else if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z'){
                System.out.print((char)(s.charAt(i)+'a'-'A'));
            }
            else System.out.print(s.charAt(i));
        }
        System.out.println("");
    }
}



Measured memory_bytes: 26888
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXF = 3000 + 10;

int A, B, C, D, E, F;
int S[MAXF], W[MAXF];

void Work()
{
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	W[0] = 1;
	for (int i = 0; i + A * 100 <= F; i ++)
		if (W[i])
			W[i + A * 100] = 1;
	for (int i = 0; i + B * 100 <= F; i ++)
		if (W[i])
			W[i + B * 100] = 1;

	S[0] = 1;
	for (int i = 0; i + C <= F; i ++)
		if (S[i])
			S[i + C] = 1;
	for (int i = 0; i + D <= F; i ++)
		if (S[i])
			S[i + D] = 1;

	int Anss = 0, Answ = A * 100;
	for (int w = 100; w <= F; w += 100)
	{
		if (W[w])
			for (int s = 0; s + w <= F; s ++)
				if (S[s])
				{
					if (100 * s <= E * w && s * (Answ + Anss) > (w + s) * Anss)
					{
						Answ = w;
						Anss = s;
					}
				}
	}
	printf("%d %d\n", Answ + Anss, Anss);
}

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

Measured memory_bytes: 128
usrInput = input()
splitedInput = usrInput.split()
clearFlag = []

for i in range(2):
    if int(splitedInput[i]) < 10:
        clearFlag.append(True)
    else:
        clearFlag.append(False)

if bool(clearFlag[0]) == True and bool(clearFlag[1]) == True:
    print(int(splitedInput[0]) * int(splitedInput[1]))
else:
    print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[200010];
int ans[200010];
vector<int>v[200010];
int dp[200010];
void dfs(int x){
    ans[x]=lower_bound(dp,dp+n+1,INF)-dp-1;
    for(int i:v[x]){
        if(ans[i]==0){
            int it=lower_bound(dp,dp+n+1,a[i])-dp;
            int num=dp[it];
            dp[it]=a[i];
            dfs(i);
            dp[it]=num;
        }
    }
}
int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        int A,b;
        cin>>A>>b;
        A--,b--;
        v[A].pb(b);
        v[b].pb(A);
    }
    fill(dp,dp+n+1,INF);
    dp[0]=0,dp[1]=a[0];
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 31224
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
    string S, T;
    cin >> S >> T;


    int ans = T.length();
    for(int i = 0; i <= S.length()-T.length(); i++){
        int a = 0;
        for(int j = 0; j<T.length(); j++){
            if(S[i+j] != T[j])a ++;
        }
        ans = min(ans,a);

    }

    cout << ans << endl;

}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int interest(int);

int main(void){
	int loan=100000,week;

	cin >> week;
	for(int i=0;i<week;i++)
		loan+=interest(loan);

	cout << loan << endl;

	return 0;
}

int interest(int loan){
	float tmp=loan*0.05;

	if(tmp>(int)tmp/1000*1000)
		tmp=((int)tmp/1000+1)*1000;

	return (int)tmp;
}

Measured memory_bytes: 1160