akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string S;
  cin >> S;
  vector<int> a(S.size());
  rep(i, S.size()-1) {
    if(S[i] == 'R' && S[i+1] == 'L') {
      a[i]++;
      for(int j=i+2; j<S.size(); j+=2) {
        if(S[j-1] == 'L' && S[j] == 'L')
          a[i]++;
        else
          break;
      }
      for(int j=i-2; j>=0; j-=2) {
        if(S[j+1] == 'R' && S[j] == 'R')
          a[i]++;
        else
          break;
      }
      a[i+1]++;
      for(int j=i+3; j<S.size(); j+=2) {
        if(S[j-1] == 'L' && S[j] == 'L')
          a[i+1]++;
        else
          break;
      }
      for(int j=i-1; j>=0; j-=2) {
        if(S[j+1] == 'R' && S[j] == 'R')
          a[i+1]++;
        else
          break;
      }
    }
  }
  rep(i, S.size()) printf("%d%c", a[i], i < S.size()-1 ? ' ' : '\n');
  return 0;
}

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

int main(){
  int N;
  string str;
  cin>>N;
  cin>>str;
  vector<int> de(N-1);
  vector<int> dw(N-1);
  dw.at(0)=(str.at(0)=='W'?1:0);
  de.at(0)=(str.at(N-1)=='E'?1:0);
  for(int i=1;i<N-1;i++){
    dw.at(i)=dw.at(i-1)+(str.at(i)=='W'?1:0);
    de.at(i)=de.at(i-1)+(str.at(N-1-i)=='E'?1:0);
  }
  int cnt=de.at(N-2);
  for(int i=1;i<N-1;i++){
    int tmp=de.at(N-2-i)+dw.at(i-1);
    cnt=min(cnt,tmp);
  }
  cnt=min(cnt,dw.at(N-2));
  cout<<cnt<<endl;
}


Measured memory_bytes: 6136
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    char p = '+';
    char m = '-';
    for(int i = 0; i < 4; i++)
    {
        if (S[i] == p)
        {
            ++ans;
        }
        else if (S[i] == m)
        {
            --ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
let to_array s =
  Str.split (Str.regexp_string " ") s
  |> List.map int_of_string
  |> Array.of_list;;

let binary_search l value =
  let rec loop left right =
    let mid = (left+right)/2 in
    if mid = left then
      if l.(left) = value then 1
      else if l.(right) = value then 1
      else 0
    else
      let (left_new, right_new) =
        if l.(mid) > value then (left,mid-1)
        else if l.(mid) < value then (mid+1, right)
        else (left, mid)
      in
      loop left_new right_new
  in loop 0 ((Array.length l)-1)
;;

let _ = read_int () and
    s = read_line () |> to_array and
    _ = read_int () and
    t = read_line () |> to_array  in
    let count = Array.fold_left (fun x y -> x + (binary_search s y)) 0 t in
    Printf.printf "%d\n" count
;;

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int N;
    scanf("%lld",&N);
    int sum=0;
    rep(i,N){
        int a;scanf("%lld",&a);sum+=a;
    }
    if(sum&1)puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int main()
{
	string s; cin >> s;

	int sum_0_start = 0;
	int sum_1_start = 0;
	FOR_LT(i, 0, s.size()) {
		bool is_0 = (s[i] == '0');

		if (is_0 && (i & 1)) {
			sum_0_start++;
		}
		if (is_0 && (!(i & 1))) {
			sum_1_start++;
		}
		if (!is_0 && (i & 1)) {
			sum_1_start++;
		}
		if (!is_0 && (!(i & 1))) {
			sum_0_start++;
		}
	}

	cout << min(sum_0_start, sum_1_start) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
int main(void) {
	double a, b, degree, s, L, h;

	scanf("%lf %lf %lf", &a, &b, &degree);
	h = b * sin(degree * M_PI / 180.0);
	s = a * h / 2.0;
	L = sqrt(a*a + b*b - 2.0*a*b*cos(degree * M_PI / 180.0)) + a + b;
	printf("%.4lf\n%.4lf\n%.4lf\n", s, L, h);
	return 0;
}

Measured memory_bytes: 652
N, X, M = map(int, input().split())
loop = [X]
appeared = set(loop)
while True:
  n = loop[-1] ** 2 % M
  if n in appeared:
    break
  else:
    loop.append(n)
    appeared.add(n)
if N <= len(loop):
  print(sum(loop[:N]))
  exit()
  
i = loop.index(n)
preloop = loop[:i]
loop = loop[i:]

total = sum(preloop)
N -= len(preloop)
#print(total, N)
total += sum(loop) * (N // len(loop))
for l, _ in zip(loop, range(N % len(loop))):
  total += l
print(total)


Measured memory_bytes: 77740
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int n,a[202020];
map<int,int> num;
bool check(int x)
{
	num.clear();
	for(int i=1;i<=n;i++)
	if(a[i]<=a[i-1])
	{
		while(num.size()&&(*(--num.end())).first>a[i]) num.erase(--num.end());
		int an=a[i];
		while(an>=1&&num.size()&&num[an]==x-1) num.erase(--num.end()),an--;
		if(!an) return 0;
		num[an]++;
	}
	return 1;
}
			
int main()
{
	scanf("%d",&n);
	int fl=0;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]),fl|=(a[i]<=a[i-1]);
	if(!fl) puts("1");
	else
	{
		int l=2,r=n,mid;
		while(l<r)
		{
			mid=(l+r)/2;
		//	cout<<l<<" "<<r<<" "<<mid<<endl;
			if(check(mid)) r=mid;
			else l=mid+1;
		}
		printf("%d\n",l);
	}
	return 0;
}

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

typedef long long lli;

const int MAX_N = 20001;
const int MAX_M = 16;
const int MAX_V = 256;
const lli INF = 1LL<<60;

lli T[MAX_N][MAX_V];
int N, M;
lli C[MAX_M];
lli x[MAX_N];

lli solve() {
  fill(T[0], T[N+1], INF);
  T[0][128] = 0LL;
  for(int i = 1; i <= N; ++i) {
    for(int j = 0; j <= 255; ++j) {
      for(int k = 0; k < M; ++k) {
	lli value = j + C[k];
	if(value < 0LL) value = 0LL;
	if(value > 255LL) value = 255LL;
	T[i][value] = min(T[i][value], T[i-1][j] + (x[i]-value)*(x[i]-value));
      }
    }
  }
  lli res = INF;
  for(int i = 0; i <= 255; ++i) {
    res = min(res, T[N][i]);
  }
  return res;
}

int main() {
  while(cin >> N >> M && (N || M)) {
    for(int i = 0; i < M; ++i) {
      cin >> C[i];
    }
    for(int i = 1; i <= N; ++i) {
      cin >> x[i];
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
n, p = map(int, input().split())

def calc(p):
    for i in range(2, int(p ** 0.5) + 1):
        if p % i == 0:
            return calc(p // i) + [i]
    return [p]

prims = sorted(calc(p))
result = 1
now_target = -1
cnt = 0
for i in prims:
    if i != now_target:
        cnt = 1
        now_target = i
    else:
        cnt += 1
    if cnt >= n:
        now_target = -1
        result *= i
print(result)


Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = if (1..10).find(|&i| (1..10).find(|&j| i * j == N) != None) != None { "Yes" } else { "No" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>

int main() {
    long long a, b;
    int result;
    scanf("%lld %lld", &a, &b);
    if (a <= 0 && b >= 0)
        puts("Zero");
    else if (a > 0)
        puts("Positive");
    else {
        if ((b - a + 1) % 2LL == 0)
            puts("Positive");
        else
            puts("Negative");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int calc(string S) {
	int res = (S[0] - '0') * 10 + (S[1] - '0');
	res *= 60;
	res += (S[4] - '0');
	res += (S[3] - '0') * 10;
	cout << res << endl;
	return res % 1440;
}

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


	int D, G; cin >> D >> G;
	VI P(D), C(D);
	REP(i, D)cin >> P[i] >> C[i];
	int ans = INF;
	REP(i, 1 << D) {
		int cnt = 0;
		int score = 0;
		REP(j, D) {
			if (i&(1 << j)) {
				cnt += P[j];
				score += 100 * (j + 1)*P[j];
				score += C[j];
			}
		}
		//cout << cnt << " " << i << " " << score << endl;
		
		for (int j = D - 1; j >= 0; j--) {
			if (score >= G)break;
			if (i&(1 << j)) {

			}
			else {
				REP(k, P[j] - 1) {
					//cout << k << endl;
					score += 100 * (j + 1);
					cnt++;
					if (score >= G)break;
				}
			}
			if (score >= G)break;
		}
		

		if (score >= G)chmin(ans, cnt);
		//cout << cnt << " " << i << " " << score << endl;
	}

	/*
	int N; cin >> N;
	int cnt[20][1510] = { 0 };
	REP(i, N) {
		string s, t;
		cin >> s >> t;
		int a = calc(s);
		int b = calc(t);
		if (a > b) {
			FOR(j, a, 1440)cnt[i][j]++;
			REP(j, b)cnt[i][j]++;
		}
		else FOR(j, a, b)cnt[i][j]++;
	}
	*/
	cout << ans << endl;
	return 0;
}



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

using namespace std;


int a,b;
int main(){
    cin >> a >> b;
    if(b%a==0){
        cout << b+a << endl;
    }else{
        cout << b-a << endl;
    }
    return 0;
}


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

int main() {
    const int MAX = 1300000;
    bool isPrime[MAX];
    fill_n(isPrime, MAX, true);
    for (int i = 4; i < MAX; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX; i += 2) {
        if (isPrime[i]) {
            for (int j = i * 2; j < MAX; j += i) {
                isPrime[j] = false;
            }
        }
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int gap = 0;
        if (isPrime[n] == false) {
            int min = n, max = n;
            do {
                min--;
            } while (isPrime[min] == false);
            do {
                max++;
            } while (isPrime[max] == false);
            gap = max - min;
        }
        cout << gap << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
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++)


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

  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ans++;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 3612
N = gets.to_i
fs = N.times.map { gets.split.map(&:to_i) }
ps = N.times.map { gets.split.map(&:to_i) }

ans = -(1 << 60)
(1...(1 << 10)).each do |b|
  sum = 0
  fs.each.with_index do |f, i|
    c = 0
    f.each.with_index do |n, j|
      c += 1 if n == 1 && b[j] == 1
    end
    sum += ps[i][c]
  end
  ans = sum if sum > ans
end
puts ans


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int m;
vector< P > u;
lint memo[(int)2e5 + 10];

lint solve(int k){
    if(k == m){
        return 1LL;
    }
    if(memo[k] >= 0){
        return memo[k];
    }

    lint res = 0;
    res += solve(k + 1);
    res %= MOD;

    int j = lower_bound(u.begin(), u.end(), make_pair(u[k].second, -1)) - u.begin();
    res += solve(j);
    res %= MOD;

    return memo[k] = res;
}

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

    int n;
    cin >> n;

    vector<int> c(n);
    int input = 0, prev = -1;
    while(input < n){
        cin >> c[input];
        --c[input];
        if(c[input] == prev){
            c.pop_back();
            --n;
            continue;
        }
        prev = c[input];
        ++input;
    }

    vector< vector<int> > v(2e5);
    rep(i, n){
        v[c[i]].emplace_back(i);
    }

    rep(i, 2e5){
        rep(j, (int)v[i].size() - 1){
            u.emplace_back(v[i][j], v[i][j + 1]);
        }
    }
    SORT(u);
    m = u.size();
    fill(memo, memo + m + 1, -1);

    lint ans = solve(0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16248
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    cout<<x*x*x<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

bool f(const string &s){
    for (int i = 0; i < s.size() / 2;i++){
        if (s[i] != s[i + s.size() / 2]) return false;
    }
    return true;
}

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

    ll ans = 100100100;
    for (int i = 2; i < S.size(); i += 2) {
        if(f(S.substr(0, S.size()-i))){
            ans = S.size() - i;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
using System;

namespace Atc_0017
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            var str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);
            int B = int.Parse(str.Split(' ')[1]);

            for (int i = A; i <= B; i++)
            {
                if (i % K == 0)
                {
                    Console.WriteLine("OK");

                    return;
                }
            }
            Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n+2];a[0]=0;a[n+1]=0;
	for(int i=1;i<n+1;i++) cin>>a[i];

	ll sum=0;
	rep(i,n+1) sum+=abs(a[i]-a[i+1]);

	for(int i=1;i<n+1;i++){
		ll d=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
		d+=abs(a[i-1]-a[i+1]);
		cout<<d<<"\n";
	}
}

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

using namespace std;

int main() {
	int n; cin >> n;
	for (int j = 0; j < n; ++j){
	int edges[3];
	for (int i = 0; i < 3; ++i)
		cin >> edges[i];
	sort(edges, edges+3);

	if (edges[0]*edges[0] + edges[1]*edges[1] == edges[2]*edges[2])
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
	}

	return 0;
}

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

using namespace std;

int N = 100;
int a, b, m[102][102];

int main()
{
  cin >> a >> b;
  for (int i = 1; i <= N / 2; i++)
    for (int j = 1; j <= N; j++)
      m[i][j] = 1;
  a--; b--;
  for (int i = 2; i <= N / 2 && a; i += 2)
    for (int j = 2; j <= N && a; j += 2) {
      m[i][j] = 0;
      a--;
    }
  for (int i = N / 2 + 2; i <= N  && b; i += 2)
    for (int j = 2; j <= N && b; j += 2) {
      m[i][j] = 1;
      b--;
    }
  cout << 100 << " " << 100 << "\n";
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      if (m[i][j])
        cout << "#";
      else
        cout << ".";
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100000

typedef struct{
  int num;
  char mark;
  int no;
}Card;

void quickSort(Card *A,int p, int r){
  int q;
  
  if(p < r){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }

}

int partition(Card *A,int p, int r){
  int i, j;
  Card x, buf;
  x = A[r];
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j].num <= x.num){
      i = i + 1;
      buf = A[i];
      A[i] = A[j];
      A[j] = buf;
    }
  }
  buf = A[i + 1];
  A[i + 1] = A[r];
  A[r] = buf;
  return i + 1;
}

int main(){
  int n, i;
  Card c[N];
  Card d[N];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf(" %c%d",&c[i].mark,&c[i].num);
    c[i].no = i;
  }
  
  quickSort(c,0,n-1);
  
  for(i = 1; i < n; i++){
    if((c[i-1].num == c[i].num) && (c[i-1].no > c[i].no)){
      break;
    }
  }
  if(i == n) printf("Stable\n");
  else printf("Not stable\n");
  
  for(i = 0; i < n; i++)
    printf("%c %d\n",c[i].mark,c[i].num);
  
  
  return 0;
}



Measured memory_bytes: 2872
#include <iostream>
#include <string>

using namespace std;

string cda[4] = {"dream","dreamer","erase","eraser"};

int main() {
	string s;
	cin >> s;

	int pre_size = -1;
	while(pre_size!=s.size()) {
		pre_size = s.size();
		for(string str : cda) {
			int pos = s.rfind(str);
			if(pos==string::npos) continue;
			if(s.size()==pos+str.size()) {
				s = s.substr(0,s.size()-str.size());
				break;
			}
		}
	}

	cout << ((s.size()==0)?"YES":"NO") << endl;

	return 0;
}


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

int main(){
	int i, j;
	
	for(i = 1;i <= 9; i++)
	{
		for(j = 1;j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
	return 0;
}

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


int main(){
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy";
	}
	else if (s=="Cloudy"){
		cout<<"Rainy";
	} 
	else{
		cout<<"Sunny";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b[1000],i;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&b[i]);
    }
    for(i=a-1;i>=0;i--){
        printf("%d",b[i]);
        if(i==0){
            printf("\n");
        }
        else printf(" ");
    }
    return 0;
}


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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

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

    string s;
    cin >> s;
    for (ll i = 0; i < s.size(); i++) {
        if ((i + 1) % 2 == 0) {
            if (s[i] == 'R') {
                cout << "No";
                return 0;
            }
        } else {
            if (s[i] == 'L') {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	s = list(str(input()))
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)
	avoid = 0
	ans = 0
	ans_rec = []
	for i in range(len(s)):
		if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
			# print("when i = {} is true".format(i))
			ans += 1
		else:
			ans_rec.append(ans)
			ans = 0
	ans_rec.append(ans)
			
	print(max(ans_rec))

 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
# F - Sugoroku
import sys
sys.setrecursionlimit(10 ** 9)

n,m = map(int,input().split())
s = input()

# r[i]:sを後ろから見ていって、iから最小何手でゴールするかを求める。
INF = float('inf')
r = [INF for _ in range(n+1)]
r[n] = 0
idx = n
for i in range(n-1,-1,-1):
  while(idx-i > m or r[idx] == INF):
    idx -= 1
  if idx <= i:
    print(-1)
    exit()
  if s[i] == '0':
    r[i] = r[idx]+1
    p = r[i]
#print(r)

# rを先頭から見ていき、rの数字が変わる直前まで進むようにすれば
# 最短で辞書順最小なルートが求まる。
ans = []
c = 0
for i in range(n+1):
  if r[i] != INF and r[i] != p:
    p = r[i]
    ans.append(c)
    c = 1
  else:
    c += 1
print(*ans)

# mnr = [m for _ in range(n+1)]
# mnl = n+1
# def dfs(x,c):
#   global mnr,mnl
#   #print(x,c)
#   if x == n:
#     #print(r)
#     if len(r) < mnl or (len(r) == mnl and r < mnr):
#       mnr = r[:]
#       mnl = len(r)
#     return True
#   if c >= mnl or x > n or s[x] == '1':
#     return False
#   for i in range(m,0,-1):
#     r.append(i)
#     dfs(x+i,c+1)
#     r.pop()
# dfs(0,0)
# if mnl < n+1:
#   print(*mnr)
# else:
#   print(-1)

Measured memory_bytes: 91376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1024);
		int number = Integer.parseInt(br.readLine());
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18536
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    vector<int> a(3);
    int sum = 0;
    rep(i, 3){
        cin >> a[i];
        sum += a[i];
    }
    if(sum >=22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 888
import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))
    
event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop
        
print('\n'.join(map(str, ans)))

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

using namespace std;

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

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

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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    ll t = 1;
    ll ans = 0;
    vector<ll> v;
    while (true) {
        if (A % t == 0 && B % t == 0) {
            v.push_back(t);
        }
        t++;
        if (t > A || t > B)
            break;
    }

    cout << v[v.size() - K] << endl;
    return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N == 105)
            {
                Console.WriteLine(1);
                return;
            }
            else if (N < 105)
            {
                Console.WriteLine(0);
                return;
            }

            int ret = 1;
            for (int i = 106; i <= N; i++)
            {
                if (i % 2 == 0)
                {
                    continue;
                }
                int tmpRet = 0;
                for (int j = 1; j <= N; j++)
                {
                    if (i % j == 0)
                    {
                        tmpRet++;
                    }
                }

                if (tmpRet == 8)
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

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

int main(){
  int x, y, z;
  cin >> x >> y >> z;

  for(int i = 0; ; i++){
    if((z*(i+1) + y*i) > x){
      cout << i-1 << endl;
      break;
    }
  }

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <deque>
#include <bitset>
#include <string>
#include <limits.h>
#include <stdint.h>
#include <algorithm>
#include <tuple>
#include <iomanip>
#include <set>
#include <assert.h>
using namespace std;

int main(int argc, char* argv[])
{
	if (argc >= 2) {
		FILE* fp = freopen(argv[1], "r", stdin);
	}

	int N, K;
	cin >> N >> K;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		v.push_back(l);
	}
	sort(v.begin(), v.end());
	int len = 0;
	for (int i = 0, j = N - 1; i < K; i++, j--) {
		len += v[j];
	}
	cout << len;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	ans := k
	for i := 0; i < n-1; i++ {
		ans *= k - 1
	}
	fmt.Fprintln(wr, ans)
}


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

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

  for (int i = 0; i < S.size(); i++) {
    if ((S.at(i) == 'L'  && i % 2 == 0) || (S.at(i) == 'R'  && i % 2 == 1)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
def main():
    n, *x = map(int, open(0).read().split())

    a = sum([i < 400 for i in x])
    b = sum([i < 800 for i in x])
    c = sum([i < 1200 for i in x])
    d = sum([i < 1600 for i in x])
    e = sum([i < 2000 for i in x])
    f = sum([i < 2400 for i in x])
    g = sum([i < 2800 for i in x])
    h = sum([i < 3200 for i in x])
    xxx = sum([i >= 3200 for i in x])

    i = [a, (b - a), (c - b), (d - c), (e - d), (f - e), (g - f), (h - g)]
    ans = sum([j >= 1 for j in i])
    print(max(ans, 1), ans + xxx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cassert>
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int h,w;
char cmap[110][110];
P pos[110];
int index,matrix[110][110];
int imap[110][110];
static const int dx[4] = {0,1,0,-1};
static const int dy[4] = {1,0,-1,0};
static const int dx8[8] = {0,1,1,1,0,-1,-1,-1};
static const int dy8[8] = {-1,-1,0,1,1,1,0,-1};
static const int dx16[16] = {0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1};
static const int dy16[16] = {-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2};
 
int D[110][110];

 
void bfs(P s,P g){
  rep(i,h)rep(j,w){
    D[i][j] = INF;
  }
  queue<P> que;
  que.push(s);
  D[s.S][s.F] = 0;

 
  while(!que.empty()){
    P p = que.front(); que.pop();
 
    for(int i=0;i<4;i++){
      int nx = p.F+dx[i],ny = p.S+dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h && cmap[ny][nx] != '#' && D[ny][nx] > D[p.S][p.F] +imap[ny][nx]){
    D[ny][nx] = min(D[p.S][p.F] + imap[ny][nx],D[ny][nx]);
 
    que.push(P(nx,ny));
      }
    }
  }
}
 
int main(){
 
  scanf("%d %d",&w,&h);
    int sindex,lim = 1;
    index = 1;
   
    rep(i,h)rep(j,w)imap[i][j] = 1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    
	cin >> cmap[i][j];
    matrix[i][j] = INF;
    if(cmap[i][j] == 'S'){
      lim++;
    }
    else if(cmap[i][j] == 'M')lim++;
    else if(cmap[i][j] == 'G'){
      pos[0] = P(j,i);
    }
      }
    }
  
    rep(i,h){
      rep(j,w){
       
    if(cmap[i][j] == 'S'){
      pos[lim-1] = P(j,i);
    }
    else if(cmap[i][j] == 'M'){
      assert(index != lim-1);
      pos[index++] = P(j,i);
    }
    else if(cmap[i][j] == '#'){
      for(int k=0;k<8;k++){
       
        int nx = j+dx8[k],ny = i+dy8[k];
        if(0<=nx && nx<w && 0<=ny && ny <h && cmap[ny][nx] != '#'){
          imap[ny][nx] = 3;
        }
      }
      for(int k=0;k<16;k++){
        int nx = j+dx16[k],ny = i+dy16[k];
        if(0<=nx && nx<w && 0<=ny && ny <h && cmap[ny][nx] != '#'){
          imap[ny][nx] = max(imap[ny][nx],2);
        }
      }
    }
      }
    }
 
 
    index = lim;
 
    for(int i=0;i<index;i++){
      rep(j,index){
     
    if(i == j){
      matrix[i][j] = 0;
      continue;
    }
    bfs(pos[i],pos[j]);
    matrix[i][j] = D[pos[j].S][pos[j].F];
      }
    }
    int per[110];
    rep(i,index-1)per[i] = i+1;
 
    int sum;
    int ans=INF;
    do{
      sum=0;
      sum+=matrix[0][per[0]];
 
      int posi=-1;    
      for(int i=1;i<index-1;i++){
    if(i == index-2)posi = per[i];
    sum+=matrix[per[i-1]][per[i]];
      }
     
      if(posi != -1 && posi != lim-1)sum += matrix[posi][lim-1];
     
      ans=min(ans,sum);
    }while(next_permutation(per,per+(index-1)));
    printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, ans=0;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d.at(i);
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j < n; j++){
            ans += d.at(i) * d.at(j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <memory.h>
#include <string>
#include <fstream>
#include <queue>
#include <random>
#include <ctime>
#include <array>

using namespace std;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (auto& el : v) {
        cin >> el;
    }
    int cnt = 1;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (v[i] == v[i - 1]) {
            cnt++;
            continue;
        } else {
            ans += (cnt / 2);
            cnt = 1;
        }
    }
    if (cnt) {
        ans += (cnt / 2);
        cnt = 1;
    }
    cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 100005
int n;
LL A[M],B[M];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%lld",A+i);
		if(i&1)B[1]+=A[i];
		else B[1]-=A[i];
	}
	printf("%lld",B[1]);
	for(int i=2; i<=n; i++) {
		B[i]=A[i-1]*2-B[i-1];
		printf(" %lld",B[i]);
	}
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int[][] c = new int[3][3];
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        c[i][j] = scanner.nextInt();
      }
    }
    int[] total = new int[6];
    total[0] = c[0][0] + c[1][1] + c[2][2];
    total[1] = c[0][0] + c[1][2] + c[2][1];
    total[2] = c[0][1] + c[1][0] + c[2][2];
    total[3] = c[0][1] + c[2][0] + c[1][2];
    total[4] = c[0][2] + c[1][1] + c[2][0];
    total[5] = c[0][2] + c[1][0] + c[2][1];
    if (total[0] == total[1] && total[1] == total[2] && total[2] == total[3]
    && total[3] == total[4] && total[4] == total[5]){
      System.out.println("Yes");
    } else {System.out.println("No");}
    }
}


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

int main(){
  
  int a, b, c, d, e, f;

  cin>>a>>b>>c>>d>>e>>f;

  if(a+b*5+c*10+d*50+e*100+f*500>=1000) cout<<1<<endl;
  else cout<<0<<endl;
  
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >> t;
	int ans = s[0] == t[0];
	ans += s[1] == t[1];
	ans += s[2] == t[2];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll A, B;
	cin >> A >> B;

	if (B < A) {
		ll C = A;
		A = B;
		B = C;
	}

	while (1) {
		ll C = B % A;
		if (C == 0) break;

		B = A;
		A = C;
	}
	ll ko = A;

	ll x = ko;
	ll count = 1;
	for (ll i = 2; i <= 1000001; i++) {
		if (x == 1) break;

		if (i * i > x) {
			count++;
			break;
		}

		if (x % i != 0) continue;
		count++;

		while (x%i == 0) {
			x /= i;
		}
	}

	cout << count << '\n';

	return 0;
}



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

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

int main() {
    int n; cin >> n;
    vector<double> v(n); rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i=1; i<n; i++){
        ans = (ans + v[i])/2.0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
sub = []
ans = 0
for i in range(N):
	sub.append(V[i] - C[i])

for j in range(N):
	if sub[j] > 0:
		ans += sub[j]
print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}


int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        a[i]--;
    }
    // print(a);
    vector<ll> sum(n+1);
    rep(i,n) {
        sum[i+1] = sum[i]+a[i];
        sum[i+1] %= k;
    }

    map<ll,ll> mp;
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (i>=k) {
            mp[sum[i-k]]--;
        }
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    // print(sum);
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    long int N;
    long int K;
    cin >> N;
    cin >> K;
    vector<long double> A(N);
    long int i;
    for (i = (long int)0; i < N; i++)
    {
        cin >> A[i];
    }
    long int d = (long int)0;
    long int l = (long int)*max_element(A.begin(), A.end());
    long int count;
    long double ans;
    long int dist;
    while (d + (long int)1 < l)
    {
        count = (long int)0;
        dist = (d + l) / (long int)2;
        for (i = (long int)0; i < N; i++)
        {
            ans = A[i] / (long double)dist;
            if (ans == (long double)(long int)ans)
            {
                count += (long int)ans - (long int)1;
            }
            else
            {
                count += (long int)ans;
            }
        }
        if (count <= K)
        {
            l = dist;
        }
        else
        {
            d = dist;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 6348
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          Dictionary<char,Player> Players = new Dictionary<char,Player>();
          Players.Add('a',new Player(Input.ScanStr()));
          Players.Add('b',new Player(Input.ScanStr()));
          Players.Add('c',new Player(Input.ScanStr()));
          
          char turn = 'a';
          char res='a';
          while(true){
            res = Players[turn].Play();
            if(res == ' ') break;
            turn = res;
          }
          
          Console.WriteLine(new string(new char[]{turn}).ToUpper());
        }
    }
  
  class Player{
    char[] Hand;
    int HandNum;
    
    public char Play(){
      if(HandNum==0) return ' ';
      return Hand[--HandNum];
    }
    
    public Player(string hand){
      Hand = hand.ToCharArray();
      Array.Reverse(Hand);
      HandNum = Hand.Length;
    }
  }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	double d;
	double EPS = 1e-10;
	while(scanf("%lf", &d) != EOF) {
		double x[4], y[4];
		x[0] = d;
		rep(i,7) {
			if(i % 2) cin >> x[i / 2 + 1];
			else cin >> y[i / 2];
		}
		if(abs((x[1] - x[0]) * (x[3] - x[2]) + (y[1] - y[0]) * (y[3] - y[2])) < EPS) {
			cout << "YES" << endl;
		} else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
N,Y = map(int,input().split())
x,y,z = 0,0,0

for x in range(N,-1,-1):
  for y in range(N-x,-1,-1):
    z = N-(x+y)
    if 10000*x+5000*y+1000*z == Y and x+y+z ==N:
      print(x,y,z);exit()
print(-1,-1,-1)

Measured memory_bytes: 40428
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,a,b,i,j,ans,mod=1e9+7,fac[200005];
long long qp(long long x,long long y)
{
	if (y==0) return 1;
	if (y==1) return x;
	long long z=qp(x,y/2);
	z*=z;
	z%=mod;
	if (y&1) z*=x;
	z%=mod;
	return z;
}
long long inv(long long x)
{
	return qp(x,mod-2);
}
long long c(long long x,long long y)
{
	return fac[x]*inv(fac[y])%mod*inv(fac[x-y])%mod;
}
int main()
{
	cin>>n>>m>>a>>b;
	fac[0]=1;
	for (i=1;i<=200000;i++) fac[i]=fac[i-1]*i%mod;
	for (i=1;i<=n-a;i++)
	{
		ans+=c(i+b-2,b-1)*c(m+n-i-b-1,n-i);
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
main(void){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int a[n], b[m];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<m;i++) cin>>b[i];
    sort(b,b+m);
    for(int z=x+1;z<=y;z++){
        if(a[n-1]<z && b[0]>=z){
            cout<<"No War";
            return 0;
        }
    }
    cout<<"War";
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n;
	cin >> n;
	vector<long long int>p(n);

	for (int i = 0; i < n; i++)cin >> p[i];
	long long int x = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2)x -= p[i];
		else x += p[i];
	}
	vector<int>t(n);
	t[0] = x / 2;

	for (int i = 0; i < n - 1; i++) {
		t[i + 1] = p[i] - t[i];
	}
	for (int i = 0; i < n; i++)t[i]*= 2;
	for (int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << t[i];
	}
	cout << endl;


	return 0;

}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int A = sc.nextInt();
		
		if(X<A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
		
	}
}



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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans = a.Select(x => x-1).Sum();
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    vector<int>x;
    int X;
    int m=INT_MAX;
    for(int i=0;i<N;i++){
        cin>>X;
        x.push_back(X);
    }
    for(int i=0;i<N-K+1;i++){
        if(x[i]>0){m=min({m,x[i+K-1]});}
        else if(x[i+K-1]<0){m=min({m,-x[i]});}
        else{
            m=min({m,-x[i]*2+x[i+K-1],-x[i]+x[i+K-1]*2});
        }
    }
    cout<<m<<endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main()
{
    int n,q;
    cin>>n>>q;
    vector<int> a(n-1);
    vector<int> b(n-1);
    int i;
    for(i=0;i<n-1;i++)cin>>a.at(i)>>b.at(i);
    vector<int> p(q);
    vector<int> x(q);
    for(i=0;i<q;i++)cin>>p.at(i)>>x.at(i);
    vector<int> ans(n+1);
    for(i=0;i<q;i++)ans.at(p.at(i))+=x.at(i);
    vector<vector<int>> t(n+1,vector<int>(0));
    for(i=0;i<n-1;i++)
    {
        t.at(a.at(i)).push_back(b.at(i));
        t.at(b.at(i)).push_back(a.at(i));
    }
    vector<bool> check(n+1,false);
    check.at(1)=true;
    queue<int> que;
    for(i=0;i<t.at(1).size();i++)
    {
        que.push(t.at(1).at(i));
    }
    while(!que.empty())
    {
        for(i=0;i<t.at(que.front()).size();i++)
        {
            if(check.at(t.at(que.front()).at(i)))
            {
                ans.at(que.front())+=ans.at(t.at(que.front()).at(i));
            }
            else
            {
                que.push(t.at(que.front()).at(i));
            }
        }
        check.at(que.front()) = true;
        que.pop();
    }
    for(i=1;i<=n;i++)
    {
        if(i==1)cout<<ans.at(i);
        else cout<<' '<<ans.at(i);
    }
    cout<<endl;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  
  vector<bool> seen(n, 0);
  int s = 1;
  int ans = 0;
  bool exist = false;
  while (seen[s-1] == false) {
    ans++;
    seen[s-1] = true;
    s = a[s-1];
    
    if (s == 2) {
      exist = true;
      break;
    }
  }
  if (exist) cout << ans << endl;
  else cout << -1 << endl;  
}

Measured memory_bytes: 640
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
S = [(i, 1) for i in range(N)]
par = [-1] * N
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

r = 0
def union(x, y):
    global r
    x = find(x)
    y = find(y)
    if x != y:
        if par[x] > par[y]:
            x, y = y, x
        r += par[x] * par[y]
        par[x] += par[y]
        par[y] = x
    return r

D = [union(a-1, b-1) for a, b in AB[::-1]][::-1] + [0]
for d in D[1:]:
    print(D[0] - d)

Measured memory_bytes: 34920