akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
  string s;
  cin>>s;
  if(s=="Sunny"){
      cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
      cout<<"Rainy"<<endl;
  }
  else{
      cout<<"Sunny"<<endl;
  }
}


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

using namespace std;

struct node {
	long long key;
	int left;
	int right;
};

vector<node> tree;

void preorder_walk(int ind) {
	if (ind < 0) {
		return;
	}
	cout << " " << tree[ind].key;
	preorder_walk(tree[ind].left);
	preorder_walk(tree[ind].right);
	return;
}

void inorder_walk(int ind) {
	if (ind < 0) {
		return;
	}
	inorder_walk(tree[ind].left);
	cout << " " << tree[ind].key;
	inorder_walk(tree[ind].right);
	return;
}

void insert(int ind) {
	if (ind == 0) {
		return;
	}
	bool find = false;
	int now = 0;
	while (!find) {
		if (tree[now].key < tree[ind].key) {
			if (tree[now].right == -1) {
				tree[now].right = ind;
				find = true;
			}
			else {
				now = tree[now].right;
			}
		}
		else {
			if (tree[now].left == -1) {
				tree[now].left = ind;
				find = true;
			}
			else {
				now = tree[now].left;
			}
		}
	}
	return;
}

int main(void) {
	int nop;
	cin >> nop;

	string ope;
	int ind = 0;
	long long num;
	tree = vector<node>(nop,{-1,-1,-1});
	for (int q = 0; q < nop; ++q) {
		cin >> ope;
		if (ope == "insert") {
			cin >> tree[ind].key;
			insert(ind);
			++ind;
		}
		else {
			inorder_walk(0);
			cout << endl;
			preorder_walk(0);
			cout << endl;
		}
	}
	return 0;
}



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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	int N, x;
	cin >> N >> x;
	
	if(x == 1 || x == 2*N-1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;;
		int y = x - N;
		if(y < 0) y += 2*N-1;
		reppp(i, y, 2*(N-1)+y){
			cout << i % (2*N-1) + 1 << endl;
		}
	}
}


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

int main(){
	string S;
	cin >> S;
	int num=0;
	int dmin=-1;
	for(const char& c : S){
		num=(num*10)%1000;
		num+=c-'0';
		int dist=abs(num-753);
		if(dmin==-1 || dist<dmin){
			dmin=dist;
		}
	}
	cout << dmin << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        k: i32,
        a: i32,
        b: i32,
    }

    for i in 1..=1000 {
        if k * i >= a && k * i <= b {
            println!("OK");
            return;
        }
    }

    println!("NG");
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int L;
string S,T;
int a,b;

int main(){
	cin >> L;
	cin >> S >> T;
	if(S+T > T+S) swap(S,T);
	a = S.size();
	b = T.size();
	repm(i,L/a,-1){
		if((L-a*i)%b == 0){
			repp(k,0,i) cout << S;
			repp(k,0,(L-a*i)/b) cout << T;
			cout << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1544
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    forn(i, n) cin >> s[i], sum += s[i];
    if (sum % 10 != 0)
        cout << sum << endl;
    else {
        sort(all(s));
        forn(i, n) {
            if ((sum - s[i]) % 10 != 0) {
                sum -= s[i];
                break;
            }
        }
        if (sum % 10 != 0)
            cout << sum << endl;
        else
            cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int H,W,i,a;
	while(1) {
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		if(3 <= H && H <=300 && 3 <= W && W <= 300) {
			for(i=0;i<H;i++) {
				printf("#");
				for(a=1;a<W-1;a++) {
					if(i==0 || i==H-1) {
						printf("#");
					} else if(i!=0 && i!=H-1) {
						printf(".");
					}
				}
				printf("#");
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1756
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <map>
using namespace std;
#define maxn 100005
char s[maxn];


int main()
{
	scanf("%s", s);
	int n = strlen(s);
	int w=0;
	int flag = 1;
	if (s[0] == 'W')
		flag = 1;
	else
		flag = 0;
	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'W' && flag == 0)
		{
			w++;
			flag = 1;
		}
		if (s[i] == 'B'&& flag == 1)
		{
			w++;
			flag = 0;
		}
	}

	cout << w << endl;

	
	
	
	
	return 0;
}


Measured memory_bytes: 384
n,a,b = list(map(int, input().split()))
ans = 0

for i in range(n+1):
    str_i = str(i)
    s_sum = 0
    for j in range(len(str_i)):
        s_sum += int(str_i[j])
    if(s_sum >= a and b >= s_sum):
        ans += i
print(ans)

Measured memory_bytes: 3060
#include <iostream>

#include <string>
#include <unordered_map>

int main(void) {
	std::unordered_map<std::string, int> mymap;
	std::unordered_map<std::string, int>::iterator it;
	int N, M;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::string temp;
		std::cin >> temp;
		if ((it = mymap.find(temp)) != mymap.end()) {
			mymap[temp] = it->second + 1;
		} else {
			mymap[temp] = 1;
		}
	}
	std::cin >> M;
	for (int i = 0; i < M; i++) {
		std::string temp;
		std::cin >> temp;
		if ((it = mymap.find(temp)) != mymap.end()) {
			mymap[temp] = it->second - 1;
		} else {
			mymap[temp] = -1;
		}
	}
	int max = 0;
	for (auto it = mymap.begin(); it != mymap.end(); ++it) {
		if (it->second > max) {
			max = it->second;
		}
	}
	std::cout << max;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		boolean ok=false; 
		for(int i = 0; i <= x; i++) {
			int ans = 2*i+4*(x-i);
			if(ans == y) {
				ok = true;
				break;
			}
		}
		if(ok) System.out.println("Yes");
		else System.out.println("No");
	 }
}


Measured memory_bytes: 35764
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int magic[][] = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                magic[j][i] = sc.nextInt();
            }
        }

        int mins[] = new int[10];
        boolean fix[] = new boolean[10];
        Arrays.fill(mins, 114514);
        mins[1] = 0;

        int cnt = 1;
        int nowp = 1;
        while (cnt < 10) {
            fix[nowp] = true;
            int minc = 114514;
            int nextp = 0;
            for (int i = 0; i < 10; i++) {
                if (!fix[i]) {
                    mins[i] = Math.min(mins[i], mins[nowp] + magic[nowp][i]);
                    if (mins[i] <= minc) {
                        minc = mins[i];
                        nextp = i;
                    }
                }
            }

            nowp = nextp;
            cnt++;
        }

        int sum = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int a = sc.nextInt();
                if (a != -1) {
                    sum += mins[a];
                }
            }
        }

        System.out.println(sum);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main(){
  long long l, r;
  long long ans = 2019;
  cin >> l >> r;
  
  for (long long tsumugi = l; tsumugi < r; tsumugi++){
    for (long long matsuri = tsumugi + 1;matsuri <= r; matsuri++){
      ans = min(ans, (tsumugi * matsuri) % 2019);
      if (ans == 0)
        break;
    }
    if (ans == 0)
      break;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, x, a, ans=0, m;
    cin >> n >> x;
    a=x;
    for(int i=0; i<n; i++)
    {
        cin >> m;
        ans+=m;
        a=min(a,m);
    }
    x-=ans;
    int s=x/a+n;
    cout << s << '\n';
}

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

const ll mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	vector<ll> a(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	vector<vector<ll>> dp(N + 1, vector<ll> (K + 1, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		vector<ll> pref(K + 1);
		pref[0] = dp[i - 1][0];
		for (int j = 1; j <= K; j++) {
			pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
		}
		for (int j = 0; j <= K; j++) {
			dp[i][j] = pref[j];
			int val = j - a[i] - 1;
			if (val >= 0) {
				dp[i][j] -= pref[val];
			}
			if (dp[i][j] < 0)
				dp[i][j] += mod;
		}
	}
	cout << dp[N][K];

	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;
    for(int x=0; x<=N; x++){
        for(int y=0; y<=N - x; y++){
            int z = N - x - y;
            if(10000 * x + 5000 * y + 1000 * z == Y){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }    
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3592
N, K = list(map(int, input().split()))
S = input()

repulsion_end = 0
if S[ 0]=='L': repulsion_end+=1
if S[-1]=='R': repulsion_end+=1

repulsion = 0
back2back = 0
for i in range(N-1):
    if S[i]=='R' and S[i+1]=='L': repulsion+=1
    if S[i]=='L' and S[i+1]=='R': back2back+=1

remove_repulsion = min(K, back2back, repulsion)
back2back -= remove_repulsion
K -= remove_repulsion
repulsion -= remove_repulsion

if K>0 and back2back>0:
    unhappy=1
elif K>0 and repulsion>0 and repulsion_end<2:
    repulsion_end += 1
    repulsion -=1
    unhappy=repulsion*2+repulsion_end
else:
    unhappy=repulsion*2+repulsion_end

print(N-unhappy)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin >> n;
  	double ans = 0;
	for(int i = 0 ; i < n ; i++){
		double x;
      	cin >> x;
      	ans += (1/x);    	
    }
  	cout << (1 / ans ) << 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);
        int n = sc.nextInt();
        int[] l = new int[n];
        for(int i=0; i<n; i++){
            l[i] = sc.nextInt();
        }
        int argmax = 0;
        int max = l[0];
        for(int i=1; i<n; i++){
            if(l[i] > max){
                argmax = i;
                max = l[i];
            }
        }
        int sum = 0;
        for(int i=0; i<n; i++){
            sum += l[i];
        }
        if(max < sum - max){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

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

int main()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << max((H2 - H1) * 60 + (M2 - M1) - K, 0) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  double a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    double x = (e*c-b*f)/(a*e-b*d);
    double y = (-d*c+a*f)/(a*e-b*d);
    printf("%.3f %.3f\n",x+EPS,y+EPS);
  }
  return 0;
}

Measured memory_bytes: 0
str = input()

flag = 0
for i in range(len(str)):
  if i % 2 == 0:
    if str[i] == "L":
      flag = 1
      break
  else:
    if str[i] == "R":
      flag = 1
      break
if flag == 1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

int main()
{
	vector<ll> pl(100001);
	rep(i, 100001) {
		if (IsPrime(i)) {
			pl[i] = 1;
		}
	}
	vector<ll> al(100001);
	rep(i, 100001) {
		if (i % 2 == 1) {
			if (pl[(i + 1) / 2] == 1 && pl[i] == 1)
			{
				al[i] = 1;
			}
		}
		if (i - 1 > 0) {
			al[i] += al[i - 1];
		}
	}
	ll n;
	cin >> n;
	vector<ll> ansl;
	rep(i, n) {
		ll l, r;
		cin >> l >> r;
		ansl.push_back(al[r] - al[max(l - 1, (ll)0)]);
	}
	rep(i, n) {
		cout << ansl[i] << endl;
	}
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 5800
#include <bits/stdc++.h>
using namespace std;
int n;
int a[15],x[15][15],y[15][15];

int func(int state){
    int t = 0;
    for(int i=0; i<n; i++){
        int h = (state >> i) % 2;
        if(h){
            for(int j=0; j<a[i]; j++){
                if(y[i][j] != (state >> (x[i][j])-1) %2) return 0;
            }
            t++;
        }
    }
    return t;
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        for(int j=0; j<a[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<pow(2,n); i++){
        ans = max(ans,func(i));
    }
    cout << ans << endl;
    return 0;
}


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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    long long N, K;
    long long current;
    cin >> N >> K;
    N = abs(N - K * (N / K));
    while(true) {
        long long temp;
        temp = abs(N - K);
        if(temp >= N) break;
        N = temp;
    }
    printf("%lld\n", N);
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int N; ll W;
	cin >>N >>W;
	vector<ll> w(N), v(N);
	rep(i, N) cin >>w[i] >>v[i];
	
	ll kjw = *min_element(all(w));
	vector<vector<ll>> dp(N+1, vector<ll>(3*N+30, 0));
	rep(i, N){
		vector<vector<ll>> np(N+1, vector<ll>(3*N+30, 0));
		rep(j, N) rep(k, 3*N+10){
			amax(np[j][k] , dp[j][k]);
			if(kjw * j + w[i] <=W)
				amax(np[j+1][k+w[i]-kjw], dp[j][k] + v[i]);
		}
		swap(dp, np);
	}
	ll ans = 0;
	rep(j, N+1) rep(k, 3*N+10){
		if(j * kjw + k <= W) amax(ans, dp[j][k]);
	}
	cout << ans <<"\n";

	return 0;
}

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

template <typename T>
void prime_factorization(T& result, int x)
{
  for (int i = 1; i*i <= x; i++) {
    if (x % i == 0) {
      result.insert(i);
      result.insert(x/i);
    }
  }
}

bool verify(const vector<int>& a, int k, int block_size, int block_num)
{
  priority_queue<int> pq;
  for (int x : a) {
    pq.push(x);
  }
  while (0 < block_num) {
    int x = pq.top();
    pq.pop();
    int block_use = min(block_num, max(1, x / block_size));
    pq.push(x - block_size * block_use);
    block_num -= block_use;
  }
  int diff = 0;
  while (!pq.empty()) {
    int x = pq.top();
    pq.pop();
    if (0 < x) {
      diff += x;
    }
  }
  return diff <= k;
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int sum = accumulate(a.begin(), a.end(), 0);
  unordered_set<int> s;
  prime_factorization(s, sum);
  int result = 0;
  for (int block_num : s) {
    int block_size = sum / block_num;
    if (result < block_size && verify(a, k, block_size, block_num)) {
      result = block_size;
    }
  }
  cout << result << '\n';
  return 0;
}


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

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

int main() {
   int N;
   cin >> N;
   vector<int> a(N);
   for (int i = 0; i < N; i++) {
      cin >> a.at(i);
   }
   
   sort(a.rbegin(), a.rend());
   int total_a = 0;
   int total_b = 0;
   for (int i = 0; i < N; i++) {
      if (i % 2 == 0) {
         total_a += a.at(i);
      } else total_b += a.at(i);
   }

   cout << total_a - total_b << endl;
   
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, L: int, T: int, X: "List[int]", W: "List[int]"):
    

    nxtX = [0] * N
    r = 0
 
    
    #基準より前にいるやつで逆のやつがいたら遠さからrをカウント
    for i in range(N):
        if W[i]==1:
            nxtX[i]=(X[i]+T)%L
            r+=(X[i]+T)//L      
        else:
            nxtX[i]=(X[i]-T)%L
            r+=(X[i]-T)//L

    nxtX.sort()


    r%=N
    
    
    ans=nxtX[r:]+nxtX[:r]
    print("\n".join(map(str,ans)))
    return
    

                



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    W = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        W[i] = int(next(tokens))
    solve(N, L, T, X, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20552
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }

    if s == "SSS" {
        println!("0");
    } else if s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR" {
        println!("1");
    } else if s == "RRS" || s == "SRR" {
        println!("2");
    } else {
        println!("3");
    }
}


Measured memory_bytes: 2172
#include<stdio.h>
int main()
{
    int m,d,date,count=0,done,dten;
    scanf("%d %d",&m,&d);
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=d;j++)
        {
            if(j<=9)
            continue;
                done = j%10;
                dten = j/10;
                if(done*dten==i && done>=2 && dten>=2)
                    count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M=1e9+7;
const ll inf=1e18+5;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){ 
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}


void solve(){
	string s;
	cin>>s;
	for(ll i=0;i<(int)s.length();i++) if(s[i]=='?') s[i]='D';
	cout<<s<<"\n";
 }
int main(){
	fast();
	solve();
	return 0;
}



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

void output(vector<int> x){
    int y = x.size();
    for(int i=0;i<y-1;i++){
        cout << x[i] << " ";
    }
    cout << x[y-1] << endl;;
}

void bubblesort(vector<int> x){
    int n = x.size();
    bool flag = true;
    int cnt = 0;
    while(flag){
        flag = false;
        for(int j = n-1;j>=1;j--){
            if(x[j] < x[j-1]){
                swap(x[j],x[j-1]);
                flag = 1;
                cnt ++ ;
            }
        }
    }
    output(x);
    cout << cnt << endl;
}

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


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
struct UnionFind{
    vector<int> d;
    UnionFind(int n) : d(n,-1) {}
    //根なら、-サイズを格納それ以外は、親を格納
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]); //経路縮約
    }
    bool unite(int x,int y){
        //二つ頂点を持ってくる
        x = find(x);
        y = find(y);
        if(x == y) return false;//根が一致するなら何もしない
        if(d[x] > d[y]) swap(x,y);
        //ex:d[x]=-5,d[y]=-2
        //小さい方が、大きい方に引っ付く
        d[x] += d[y];//この場合、yがxにくっつく
        d[y] = x;
        return true;
    }
    bool same(int x,int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};
int main(){
    cout << fixed << setprecision(10);
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    int cnt = 0;
    rep(i,n){
        if(uf.same(i,v[i]-1)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

    long long n, k;
    cin >> n >> k;

    double ans = 0.0;
    for(int i = 1; i <= n; i++){
        double tmp = 1.0;
        long long a = i;
        while(a < k){
            a *= 2;
            tmp /= 2.0;
        }
        ans = ans + tmp / n;
    }

    cout << setprecision(10) << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;


int main() {

	long N, M;
	cin >> N >> M;

	vector<long> ans(M, 0);
	long A, K;

	for (long i = 0; i < N; i++) {
		cin >> K;
		for (long j = 0; j < K; j++) {
			cin >> A;
			ans[A - 1] += 1;
		}
	}

	cout << count(ans.begin(), ans.end(), N) << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
 int main(){ 
   string s,t;
   cin>>s>>t;
   int flag=0;
   for(int i=0;i<s.size();i++){
      char u=s[s.size()-1];
      s=u+s;
      s.pop_back();
      if(s==t) flag=1;
	}
   (flag==1)? cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll a,b;
    cin >> a >> b;
    ll x = max(a,b),y=min(a,b);
    while(1){
        if(x < y)swap(x,y);
        if(y<=0)break;
        x %= y;
    }
    //cout << x << endl;
    ll ans = 1;
    for(ll i = 2;i<=sqrt(x)+2;i++){
        ll c = x;
        bool ok = false;
        while(x%i==0){
            ok = true;
            x/=i;
        }
        if(ok){
            ans++;
            //cout << i << "i" << endl;
        }
        //cout << i << "ii" << endl;
    }
    //cout << x << "x" << endl;
    if(x!=1)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void) {
	int n;
	int cnt = 0;

	scanf("%d", &n);

	int d1, d2;

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &d1, &d2);

		if (cnt < 3) {
			if (d1 == d2)
				cnt++;
			else
				cnt = 0;
		}
	}

	if (cnt >= 3)
		printf("Yes");
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 1728
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> list = new ArrayList<>();
		long[] ans = new long[n];
		for(int i = 0; i < n; i++) {
			long tmp = sc.nextLong();
			list.add(tmp);
			ans[i] = tmp;
		}
		Collections.sort(list);
		long a1 = list.get(n / 2);
		long a2 = list.get(n / 2 - 1);
		for(int i = 0; i < n; i++) {
			if(ans[i] < a1) {
				System.out.println(a1);
			} else {
				System.out.println(a2);
			}
		}
	}

}


Measured memory_bytes: 100452
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#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()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
	string s,t;
    int n,a,b,c,d,e,x,y,k;
	vi v(5);
    rep(i,5)cin >> v[i];
	rep(i,5)if(v[i] == 0){
		cout << i+1 << endl;
		return 0;
	}

}


Measured memory_bytes: 3544
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()

    ans = []
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if N % 2 == 0:
                if i + j != N + 1:
                    ans.append((i, j))
            else:
                if i + j != N:
                    ans.append((i, j))

    print(len(ans))
    print('\n'.join(map(lambda a: '{} {}'.format(a[0], a[1]), ans)))


if __name__ == '__main__':
    main()


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


using namespace std;

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


int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int same = 0;
	if (a == b) same++;
	if (b == c) same++;
	if (a == c) same++;

	if (same == 1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

// ll gcd(ll a,ll b)  {
// 	if (a%b==0)  return(b);
// 	else return(gcd(b,a%b));
// }
//
// ll lcm(ll number1,ll number2){
// 	return number1 * number2 / gcd(number1,number2);
// }



int main(){
	int N; cin >> N;
	vector<int> P;
	rep(i,N){
		int p; cin >> p;
		P.push_back(p);
	}
	int ans = 0;
	// rep(i,N){
	// 	cout << P[i] << ' ';
	// }
	// cout << endl;
	reps(i,N-2){
		if((P[i-1] < P[i])&&(P[i] < P[i+1])){
				// cout << P[i] << endl;
				ans++;
		}
		if((P[i-1] > P[i])&&(P[i] > P[i+1])){
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bitset<100000> l;

ll a[100001];
int main(){
	cin>>l;
	a[0]=1;
	for(int i=1;i<100001;i++){
		a[i]=a[i-1]*3%MOD;
	}
	ll ans=0;
	ll cou=1;
	for(int i=99999;i>=0;i--){
		if(l[i]){
			ll as=(a[i]+1)*cou;
			ans=ans+as;
			ans%=MOD;
			cou*=2;
			cou%=MOD;
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,M;cin>>N>>M;
  vector<int> vec(M);
  for(int i=0;i<M;i++){
    cin>>vec[i];
  }
  
  int sum=0;
  for(int i=0;i<M;i++){
    sum+=vec[i];
  }
  
  if(sum<=N){
    cout<<N-sum<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
}

Measured memory_bytes: 3628
unittest
{
	assert( [ "5 3", "0 2 1 4 3" ].parse.expand.solve == 2 );
	assert( [ "4 4", "0 1 2 3" ].parse.expand.solve == 1 );
	assert( [ "10 4", "2 0 1 3 7 5 4 6 8 9" ].parse.expand.solve == 6 );
	
	assert( [ "10 4", "2 0 1 3 5 7 4 6 8 9" ].parse.expand.solve == 5 );		// 追加ケース
}



import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], ps );
}

auto solve( long k, long[] ps )
{
	auto ans = 1L;
	
	// 一つ前の順列と一致するか判定
	auto rbt = redBlackTree( ps[ 0 .. k ] );
	foreach( i; 0L .. ps.length.signed - k )
	{
		ans += !( ps[ i ] == rbt.front && rbt.back < ps[ i + k ] );
		rbt.removeKey( ps[ i ] );
		rbt.insert( ps[ i + k ] );
	}
	
	// 最初から昇順の区間の重複カウントを除外
	auto t = 0L;
	auto c = 0L;
	foreach( i; 0L .. ps.length.signed - 1 )
	{
		if( ps[ i ] < ps[ i + 1 ] ) c++;
		else                        c = 0;
		if( c == k - 1 ) t++;
	}
	if( 2 <= t ) ans -= t - 1;
	
	return ans;
}


Measured memory_bytes: 25872
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G

#BFS
from collections import deque
def bfs(G, v, p):
    point = [0] * n
    q=deque()
    q.append((v, p))
    point[0] = c.pop(0)

    score = 0
    while q:
        #qの先頭を取り出す
        V, P = q.popleft()
        for next_v in G[V - 1]:
            if next_v == P:continue
            q.append((next_v, V))
            temp = c.pop(0)
            score += temp
            point[next_v - 1] = temp

    return point, score

n = int(input())
ab = [list(map(int,input().split())) for i in range(n - 1)]
c = list(map(int,input().split()))
c = sorted(c, reverse=True)
G = Graph(ab)

point, score = bfs(G, 1, -1)
print(score)
print(*point)

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

int main(){
	while(1){
		int H,W;
		cin >> H >> W;
		if(H== 0 && W == 0)break;
		for(int i=0;i<H;++i){
			if(i==0 || i==H-1){
				for(int j=0;j<W;++j){
				cout << "#";
			     }
			}
			else{
				cout << "#";
				for(int k=0;k<W-2;k++){
					cout << ".";
				}
				cout <<"#";
			}
		cout << endl;
		}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b;

	if ((a + b) % 2== 0) {
		cout << (a + b) / 2;
	}
	else {
		c = (a + b) / 2;
		c = c + 1;
		cout << c;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll N, M;
ll A[112345], sum[112345];

int main() {
	cin >> N >> M;
	REP(i, N) scanf("%lld", A + i);
	sort(A, A + N);
	REP(i, N) sum[i + 1] = sum[i] + A[i];
	
	ll l = 0, r = longINF;
	ll ans = 0;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		
		ll cur = 0, curcnt = 0, curcnt2 = 0;
		REP(i, N) {
			ll fin = m - A[i];
			int pos = lower_bound(A, A + N, fin) - A;
			int pos2 = upper_bound(A, A + N, fin) - A;
			curcnt2 += pos2 - pos;
			curcnt += N - pos;
			cur += sum[N] - sum[pos];
			cur += A[i] * (N - pos);
			
		}
		if (curcnt >= M) {
			l = m;
			if (curcnt - M <= curcnt2) {
				ll d = curcnt - M;
				chmax(ans, cur - d * m);
			}
		}
		else {
			r = m;
		}
	}
	cout << ans << endl;
	
	return 0;
}

/*
5 3
10 14 19 33 34
*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    if (x > K-x)
      sum += 2*(K-x);
    else    
      sum += 2*x;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {

  int A;
  int B;
  int T;

  std::cin >> A >> B >> T;

  if (T + 0.5 < B) {
    std::cout << 0 << std::endl;
  } else if (T % A == 0) {
    std::cout << int(T / A) * B << std::endl;
  } else if (T % A != 0) {
    std::cout << int(T / A) * B << std::endl;
  }
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;

bool is_prime(int n) {
	if (n < 2) {
			return false;
	}
	if (n==2||n==3) {
		return true;
	}
	for (int i = 3; i < n; i = i+2) {
		if (n%i==0) {
			return false;
		}
	}
	return true;
}

int check_ind(std::vector<int> v, int n) {
	int ind = 0;
	for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
		if (*itr > n) {
			return ind;
		}
		ind++;
	}
	return 0;
}

int main(void) {
	int n = 101000;
	std::vector<bool> prime(n);
	std::vector<int> p;
	for (int i = 0; i < n+2; i++) {
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i <= sqrt(n); i++) {
		if (is_prime(i)) {
			for (int j = 2; i*j < n+2; j++) {
				prime[i*j] = false;
			}
		}
	}
	for (int i = 2; i < n+2; i++) {
		if (prime[i]) {
			p.push_back(i);
		}
	}

	int N,P;
	cin >> N;
	cin >> P;

	while (N != -1 || P != -1) {
		int ind = check_ind(p, N);
		std::vector<int> sum;

		for (int i = ind; i < ind+(2*sqrt(P))+10; i++) {
			for (int j = i; j < i+(2*sqrt(P))+10; j++) {
				sum.push_back(p[i]+p[j]);
			}
		}

		std::sort(sum.begin(), sum.end());

		cout << sum[P-1] << endl;

		cin >> N;
		cin >> P;
	}

	return 0;
}

Measured memory_bytes: 3216
X, Y, A, B, C = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
p.reverse()
q.sort()
q.reverse()

d = []

for i in range(X):
    d.append(p[i])
for i in range(Y):
    d.append(q[i])
for i in range(len(r)):
    d.append(r[i])

d.sort()
d.reverse()
result = 0
for i in range(X + Y):
    result += d[i]

print(result)

Measured memory_bytes: 23328
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    for(int i=0; i<k; i++){
      if(i%2==0){
        if(a%2==1){
          a--;
        }
        a /= 2;
        b += a;
      }else{
        if(b%2==1){
          b--;
        }
        b /= 2;
        a += b;
      }
    }
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int ans = 1;
	for(int i = 1; i <= n; i++){
		ans = (ans * i) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
a=list(map(int,input().split()))
A=[0]
for i in range(N):
    A.append((A[-1]+a[i]-1))
for i in range(len(A)):
    A[i]%=K
#print(A)

D={}
D[0]=1
ans=0

for i in range(1,N+1):
    if A[i] in D:
        ans+=D[A[i]]
        D[A[i]]+=1
    else:
        D[A[i]]=1
    if i-K+1>=0:
        D[A[i-K+1]]-=1
#print(D)
if K==1:
    print(0)
else:
    print(ans)
        

Measured memory_bytes: 112836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll x;
  cin >> x;
  ll sum = 0;
  ll count = 0;
  for (ll i = 1; sum < x; i++){
    sum += i;
    count++;
  }
  print(count);
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] count = new int[26];
        for (int i = 0; i < count.length; i++) {
            count[i] = 0;
        }
        while (scanner.hasNext()) {
            String s = scanner.next().toUpperCase();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if ('A' <= c && c <= 'Z') {
                    count[c - 'A']++;
                }
            }
        }
        for (int i = 0; i < count.length; i++) {
            char c = (char)('a' + i);
            System.out.println(""+c+" : "+count[i]);
        }
    }
}


Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],ans=0;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		a[x]++;a[x+1]++;a[x+2]++;
	}
	for(int i=0;i<=100005;i++)ans=max(ans,a[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main()
{
        int n,l,sum = 0,minFlavor,minIndex;
        cin >> n >> l;
        vector<int> apple(n);
        vector<int> flavor(n);
        for (int i = 0; i < n; i++)
        {   
                apple[i] = i + l;
                flavor[i] = abs(apple[i]);
                sum += apple[i];
        }   
        minFlavor = flavor[0];
        minIndex = 0;
        for (int i = 0; i < n; i++)
                if (flavor[i] < minFlavor)
                {   
                        minFlavor = flavor[i];
                        minIndex = i;
                }   
        cout << (sum - apple[minIndex]) << endl;
        return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	for (int i=1; i<=1000; i++) {
		if (floor(i*0.08) == a && floor(i*0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

	return 0;

}

Measured memory_bytes: 256
a,b,k = map(int,input().split())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math
print(sorted(make_divisors(math.gcd(a,b)),reverse=True)[k-1])

Measured memory_bytes: 9200
use std::io;
fn main() {
    let mut buf = String::new();

        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let a: i32 = iter.next().unwrap().parse().unwrap();
        let op: String = iter.next().unwrap().parse().unwrap();
        let b: i32 = iter.next().unwrap().parse().unwrap();

    let ans = if  op == "+" { a+b } else { a-b };
    println!("{}",ans);
}

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

#define __INIT_CC__ ios::sync_with_stdio(false); \
	cin.tie(0);

#ifdef __WIN32__
	char getchar_unlocked() {return getchar();}
#endif

#define FOR(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<(_t);++(_i))
#define FORN(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<=(_t);++(_i))
#define FORD(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i>=(_t);--(_i))
#define RESET(_a,_value) memset(_a,_value,sizeof(_a))
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define mp make_pair
#define SIZE(_a) (int)_a.size()
#define VSORT(_a) sort(_a.begin(),_a.end())
#define SSORT(_a,_val) sort(_a,_a+(_val))
#define ALL(_a) _a.begin(),_a.end()
#define mt make_tuple
#define _get(_tuple,_i) get<_i>(_tuple)
#define eb emplace_back
 
using namespace std;

using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<ii>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vll = vector<ll>;
using pdd = pair<double,double>;
using vpdd = vector<pdd>;
template <typename T> using uset = unordered_set<T>;
template <typename T> using umultiset = unordered_multiset<T>;
template <typename K, typename V> using umap = unordered_map<K, V>;
template <typename K, typename V> using umultimap = unordered_multimap<K, V>;

const int dr[] = { 1, 0,-1, 0, 1, 1,-1,-1};
const int dc[] = { 0, 1, 0,-1, 1,-1,-1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const ll INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);

template <typename T> T take(queue<T> &O) {T tmp=O.front();O.pop();return tmp;}
template <typename T> T take(stack<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T> T take(priority_queue<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T>
inline bool inRange(const T& z, const T& a, const T& b){return a <= z && z <= b;}

void OPEN(const string& in = "input.txt", const string& out = "output.txt")
{
	freopen(in.c_str(), "r", stdin);
	freopen(out.c_str(), "w", stdout);
	return ;
}

//using sokokaleb's template v4.0

const int N = 100005;
int ans;
int cnt[N];
int n;
int removed;

int main(int argc, char** argv) {
	__INIT_CC__
	cin >> n;
	ans = n;
	FOR (i, 0, n) {
		int a;
		cin >> a;
		if (a < N) {
			++cnt[a];
		} else {
			++removed;
		}
	}

	int tmpans = removed;
	FOR (i, 1, N) {
		if (cnt[i] >= i) {
			tmpans += cnt[i] - i;
		} else {
			tmpans += cnt[i];
		}
	}
	cout << min(ans, tmpans) << "\n";
}


Measured memory_bytes: 384
# coding: utf-8

num_array = [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]

k = int(input())

print("{}".format(num_array[k-1]))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
    int s;
    cin >> s;
    int y[2];
    y[0] = s / 100;
    y[1] = s % 100;
    bool mm[2];
    for (int i = 0; i < 2; i++)
        mm[i] = (y[i] >= 1) && (y[i] <= 12);
    if (!mm[0] && !mm[1])
        cout << "NA";
    else if (!mm[0] && mm[1])
        cout << "YYMM";
    else if (mm[0] && !mm[1])
        cout << "MMYY";
    else
        cout << "AMBIGUOUS";
}

Measured memory_bytes: 256