akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,c[maxn],v[maxn],d[maxn],cl[maxn];
bool vis[maxn][11];
vi e[maxn];
void bfs(int x,int y,int z)
{
    queue<pii>p;
    p.push(mp(x,y));
    while(!p.empty())
    {
        pii q=p.front();
        p.pop();
        if(q.se==-1)continue;
        vis[q.fi][q.se]=true;
        if(!c[q.fi])c[q.fi]=z;
        for(int t:e[q.fi])
        {
            int i;
            for(i=q.se-1;i<=10;i++)
            {
                if(vis[t][i])break;
            }
            if(i==11)p.push(mp(t,q.se-1));
        }
    }
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    rep(i,1,m)scanf("%d%d",&j,&k),e[j].pb(k),e[k].pb(j);
    int q;
    scanf("%d",&q);
    rep(i,1,q)
    {
        scanf("%d%d%d",&v[i],&d[i],&cl[i]);
    }
    for(i=q;i>=1;i--)
    {
        bfs(v[i],d[i],cl[i]);
    }
    rep(i,1,n)printf("%d\n",c[i]);
    return 0;
}


Measured memory_bytes: 9608
#include <bits/stdc++.h>
#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(){
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll a = 100;
    int year = 0;
    while(a < x) {
        a *= 1.01;
        year++;
    }
    cout << year << endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <stack>
using namespace std;
int main()
{
	stack<int>s;
	int n;
	while (cin >> n)
	{
		if (n!= 0)
		{
			s.push(n);
		}
		else
		{
			cout << s.top() << endl;
			s.pop();
		}
	}
};


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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int fun[1000000];
int n;
int h[1000000+2];
int main ()
{
    int k;
    cin >> n >> k;

    h[n+1]=MAX;
    for(int i=1;i<=n;i++)
        cin >> h[i];
    fun[n-1]=abs(h[n]-h[n-1]);
    int tot,p;
    for(int i=n-2;i>=1;i--)
    {
        tot= MAX;
        for(int j=i+1,p=1;j<=n && p<=k;j++,p++)
        tot= min(tot,abs(h[i]-h[j])+fun[j]);
        fun[i]=tot;
    }
    //cout << fun[1]<<endl;
//    for(int i=n;i>=1;i--)
//        cout << i << " th value is "<<fun[i]<<endl;
cout << fun[1]<<endl;
    return 0;
}



Measured memory_bytes: 4736
N, K = map(int, input().split())
a = list(map(int, input().split()))

sa = [0]
sb = [0]
for i in range(N):
    sa.append(sa[-1] + a[i])
    sb.append(sb[-1] + max(0, a[i]))

ans = 0
for i in range(N - K + 1):
    a = sa[i + K] - sa[i]
    b = sb[i + K] - sb[i]
    ans = max(ans, sb[N] - b + max(a, 0))
print(ans)


Measured memory_bytes: 76960
#include<stdio.h>
int a[1000006], b[1000006];
int h[1000006], ll;
int comp_h(int x, int y)
{
	if (a[h[x]] > 0 && a[h[y]] <= 0)return -1;
	if (a[h[x]] <= 0 && a[h[y]] > 0)return 1;
	if (a[h[x]] >= 0)
	{
		if (b[h[x]] < b[h[y]])return 1;
		return -1;
	}
	else
	{
		if (b[h[x]] > b[h[y]])return 1;
		return -1;
	}
}
void swap_h(int x, int y)
{
	int f = h[x];
	h[x] = h[y];
	h[y] = f;
	return;
}
void f1(int ne)
{
	h[ll] = ne;
	int p = ll;
	ll++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2()
{
	ll--;
	swap_h(0, ll);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < ll)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < ll)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[ll];
}
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	char s[1000006], t[1000006];
	int l[1000006];
	l[0] = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%s", t);
		for (j = 0; t[j] != '\0'; j++)
			s[l[i] + j] = t[j];
		l[i + 1] = l[i] + j;
	}
	for (i = 0; i < n; i++)
	{
		a[i] = b[i] = 0;
		for (j = l[i]; j < l[i + 1]; j++)
		{
			if (s[j] == '(')
				a[i]++;
			else
				a[i]--;
			if (b[i] > a[i])
				b[i] = a[i];
		}
	}
	ll = 0;
	for (i = 0; i < n; i++)
		ll += a[i];
	if (ll != 0)
	{
		printf("No\n");
		return 0;
	}
	ll = 0;
	for (i = 0; i < n; i++)
		if (a[i] >= 0)
			f1(i);
	int now = 0;
	while (ll > 0)
	{
		j = f2();
		if (now + b[j] < 0)
		{
			printf("No\n");
			return 0;
		}
		now += a[j];
		if (now < 0)
		{
			printf("No\n");
			return 0;
		}
	}
	ll = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] < 0)
		{
			a[i] = b[i] = 0;
			for (j = l[i + 1] - 1; j >= l[i]; j--)
			{
				if (s[j] == '(')
					a[i]--;
				else
					a[i]++;
				if (b[i] > a[i])
					b[i] = a[i];
			}
			f1(i);
		}
	}
	int now2 = 0;
	while (ll > 0)
	{
		j = f2();
		if (now2 + b[j] < 0)
		{
			printf("No\n");
			return 0;
		}
		now2 += a[j];
		if (now2 < 0)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    set<string> ans;
    vector<int> A;
    function<void(int)> recur = [&](int rest) {
        if (rest == 0) {
            string S(N, 'a');
            for (int i = 0; i < A.size(); i++) {
                for (int j = 0; j < N; j++) {
                    if (A[i] & (1 << j)) {
                        S[j] = 'a' + i;
                    }
                }
            }
            ans.insert(S);
            return;
        }
        int f;
        for (int i = 0; i < N; i++) if (rest & (1 << i)) { f = (1 << i); break; }
        A.push_back(f);
        recur(rest ^ f);
        A.pop_back();
        for (int b = 1; b < (1 << N) - 1; b++) {
            if (((rest ^ f) & b) != b) continue;
            A.push_back(f | b);
            recur(rest ^ f ^ b);
            A.pop_back();
        }
    };
    recur((1 << N) - 1);
    for (auto s : ans) cout << s << '\n';
    return 0;
}


Measured memory_bytes: 12416
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define inf 0x7fffffff
const int maxx=15;
int ans=0;
bool a[maxx][maxx];
vector <pair<int,int> > s;

void printgraph(){
	int sum=0;
	for(int i=0;i<s.size();i++){
		int x=s[i].first,y=s[i].second;
		if(a[x][y]!=1) return;
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			if(a[i][j]==1) cout<<"Q";
			else cout<<".";
		}
		cout<<endl;
	}
	
	return ;
}

bool check(int row,int col){
	for(int i=0;i<8;i++){
		if(a[row][i]==1 || a[i][col]==1 ) return false;
	}
	for(int i=1;i<row+1;i++){
		if(a[row-i][col-i]==1 || a[row-i][col+i]==1 ) return false;
	}
	for(int i=1;i<8-col;i++){
		if(a[row+i][col-i]==1 || a[row+i][col+i]==1 ) return false;
	}
	return true;
}

void solve(int row){
	int col;
	if(row==8) {
		printgraph();return;
	}
	for(col=0;col<8;col++){
		if(check(row,col)==false ) continue;
		a[row][col]=1;
//		for(int i=0;i<8;i++){
//			for(int j=0;j<8;j++){
//				cout<<a[i][j]<<" ";
//			}
//			cout<<endl;
//		}
		solve(row+1);
		a[row][col]=0;
	}
}

int main() {
	int n,x,y;
	cin>>n;
	ans+=n;
	memset(a, 0,sizeof(a));
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		s.push_back(make_pair(x,y));
	}
	solve(0);
	return 0;
}


Measured memory_bytes: 3072
n = int(input())
kousya =[[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]]]

for i in range(n):
    b,f,r,v = map(int,input().split())
    kousya[b-1][f-1][r-1] = kousya[b-1][f-1][r-1] + v
    if kousya[b-1][f-1][r-1] < 0:
        kousya[b-1][f-1][r-1] = 0

for a in range(4):
    for b in range(3):
        for c in range(10):
            print(" " + str(kousya[a][b][c]),end="")
        print()
    if a < 3:
        print("#"*20)



Measured memory_bytes: 5636
/**
 * @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;
ll atacks(ll x) {
    if (x == 1) return 1;
    ll ans = 0;
    ans += atacks(x / 2) + atacks(x / 2) + 1;
    return ans;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll h;
    cin >> h;
    ll x = 0;
    while (h - (1ll << x) >= 0) {
        x++;
    }
    cout << (1ll << (x)) - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main ( String[] args ) {
 
    Scanner sc = new Scanner ( System.in );
    
    int N = sc.nextInt();
    
    int x = 800 * N;
    int y = 200 * (N / 15);
  
    System.out.println(x-y);   
  }
}

Measured memory_bytes: 22740
import scala.math.abs

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val s = sc.next().toList
  val part = s.slice(2, s.length - 1)
  val cIndex = part.indexOf('C') + 2
  val map = part.groupMapReduce(identity)(_ => 1)(_ + _)
  if (s.head == 'A' && map.getOrElse('C', 0) == 1 && isLower(s)) {
    println("AC")
  } else {
    println("WA")
  }
  
  def isLower(s: List[Char]): Boolean = {
    (0 until s.length).forall{ i =>
      if (i != 0 && i != cIndex) {
        s(i).isLower
      } else {
        true
      }
    }  
  }
}

Measured memory_bytes: 55812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        if (R < 1200) {
            System.out.println("ABC");
        } else if (R < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
        sc.close();
    }
}

Measured memory_bytes: 22228
import math
a,b,x=map(int,input().split())

if x>=a**2*b/2:
    a=math.atan((2/a)*(b-x/(a**2)))
else:
    a=math.atan(a*b**2/2/x)

print("{:.8f}".format(a*(180/math.pi)))

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

template<class INT>
std::vector<INT> factorize(INT n){
    std::vector<INT> res;
    for (INT i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    auto F = factorize(accumulate(A.begin(), A.end(), 0L));
    sort(F.begin(), F.end(), greater<int>());

    for (const auto &f: F){
        vector<int> B(n);
        for (int i = 0; i < n; i++)
            B[i] = A[i] % f;
        auto S = accumulate(B.begin(), B.end(), 0L);
        auto i = S / f;
        nth_element(B.begin(), B.begin() + (n - i), B.end());
        if (max(accumulate(B.begin(), B.begin() + (n - i), 0L), i * f - accumulate(B.begin()+ (n - i), B.end(), 0L)) <= k){
            printf("%d\n", f);
            return 0;
        }
    }

    puts("0");
}

Measured memory_bytes: 256
H, W = map(int, input().split())

s = [["."] * (W+2) for _ in range(H+1)]
for i in range(H):
  s[1+i][1:1+W] = input()

ans = "Yes"
for i in range(1, H):
  for j in range(1, W):
    if s[i][j] != "#":
      continue
    if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
      ans = "No"
  
print(ans)
  
  

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
  ::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      res.emplace_back(i, 1);
      x /= i;
      while (x % i == 0) x /= i, res.back().second++;
    }
  }
  if (x != 1) res.emplace_back(x, 1);
  return res;
}

int64 bin(int64 x) {
  int64 l = 1, r = 100, m;
  while (r-l > 1) {
    m = (l + r) /2;
    if (m * (m+1) / 2 <= x) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  auto pf = primeFactors(N);
  int64 res = 0;
  for (auto &x : pf) {
    res += bin(x.sc);
  }
  cout << res << endl;
}


Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


using namespace std;
int main() {

	int a, b, c;
	int d;
	cin >> a >> b >> c;
	if (a == b)d = c;
	else if (a == c)d = b;
	else d = a;
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  
  int k,temp;
  int cnt=0;
  
  cin>>k;
  
  for(int i=1;i<k;i++){
    temp=i+1;
    while(temp<=k){
      cnt++;
      temp+=2;
   }
  }
   
   cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  string s;
  cin>>n>>s;
  //s=s[n-1]+s+s[0];
  int a=0,b=0;
  rep(hogee,2){
    rep(hogeee,2){
      vector<int> re(n);
      re[0]=a; re[1]=b;
      reps(i,1,n-1){
	if(re[i] == (s[i]=='o')) re[i+1]=1-re[i-1];
	else re[i+1]=re[i-1];
      }
      int f=1;
      rep(i,n){
	if(re[(i+n-1)%n] == re[(i+1)%n]){
	  if(re[i] == (s[i]=='o')) f=0;
	}else{
	  if(re[i] == (s[i]=='x')) f=0;
	}
      }
      if(f){
	rep(i,n) cout<<"SW"[re[i]]; cout<<endl;
	return 0;
      }
      b=1-b;
    }
    a=1-a;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 924
#include <bits/stdc++.h>
using namespace std;
void fast(){
cin.tie(0);
cin.sync_with_stdio(0);
}
int main()
{
    int n,m,q;cin>>n>>m>>q;int x,y; int c[n+1][n+1]={};
    for(int i=0;i<m;i++)
    {
      cin>>x>>y;
     c[x][y]++;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            c[i][j]+=c[i][j-1] + c[i-1][j] - c[i-1][j-1];
        }
    }
    for(int i=0;i<q;i++)
    {
        cin>>x>>y;
        cout<<c[y][y] - c[y][x-1] - c[x-1][y] + c[x-1][x-1]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1920
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 一  2/ 5 11:22:16 2018
 * Ended  Time*  : 一  2/ 5 11:37:07 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

const int MaxN = 4e5;
int pre[MaxN + 5], last[MaxN + 5], other[MaxN + 5], cost[MaxN + 5];
int a[123456];
bool vis[123456];
int n, m, all;
bool flag = true;

void build(int u, int v, int c){
	pre[++all] = last[u];
	last[u] = all;
	other[all] = v;
	cost[all] = c;
}

void dfs(int u, int sum){
	if(flag == false) return;
	if(vis[u] == false){
		vis[u] = true;
		a[u] = sum;
	}
	else{
		if(a[u] != sum) flag = false;
		return;
	}
	int ed = last[u];
	int dr, ned;
	while(ed != -1){
		dr = other[ed];
		ned = cost[ed];
		dfs(dr, sum + ned);
		ed = pre[ed];
	}
}


int main()
{
	memset(last, -1, sizeof(last)); all = -1;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		build(u, v, c);
		build(v, u, -c);
	}
	for(int i = 1; i <= n; i++)
		if(vis[i] == false) dfs(i, i);
	if(flag == true) printf("Yes\n");
	else printf("No\n");
    return 0;
}


Measured memory_bytes: 8832
use std::io::Read;
 
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let _: usize = itr.next().unwrap().parse().unwrap();
 
    println!("{}", a * b / 2);
}

Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
  	cin>>n>>l;
  	vector<string>v(n);
  	for(auto &x : v) cin>>x;
  	sort(v.begin(), v.end());
  	for(auto x : v) cout<<x;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
  int i, am, pm;
  char name[20];
  for (i = 0; i < 9; ++i) {
    scanf("%s%d%d", name, &am, &pm);
    printf("%s %d %d\n", name, am + pm, 200 * am + 300 * pm);
  }
  return 0;
}

Measured memory_bytes: 596
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x1=max(x)
y1=min(y)
for i in range(X+1,Y+1):
    if x1<i and y1>=i:
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long d = sc.NextLong();
        long[] c = sc.LongArray();
        long[,] s = new long[d, 26];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                s[i, j] = sc.NextLong();
            }
        }

        long[] last = new long[26];

        for (int i = 0; i < d; i++)
        {
            long maxDiff = long.MinValue;
            long answerIndex = 0;
            long secondDiff = long.MinValue;
            long secondIndex = 0;
            long nextMaxScore = 0;
            for (int j = 0; j < 26; j++)
            {
                long diff = 0;
                diff += s[i, j];
                diff += c[j] * (i + 1 - last[j]);
                if (diff > maxDiff)
                {
                    secondDiff = maxDiff;
                    maxDiff = diff;
                    secondIndex = answerIndex;
                    answerIndex = j;
                }
                if (i != d - 1 && s[i + 1, j] > nextMaxScore)
                {
                    nextMaxScore = s[i + 1, j];
                }
            }
            if ((i != d - 1) && (s[i + 1, answerIndex] > s[i, answerIndex] + 100) && (s[i + 1, answerIndex] == nextMaxScore))
            {
                answerIndex = secondIndex;
            }
            last[answerIndex] = i;
            Console.WriteLine(answerIndex + 1);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28840
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	len = strlen(s);
文字列長さ*/


/*
	string s;
	s.size()
*/


/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/


/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("Yes");
	else puts("No");
*/
/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

int main(){
	int n, m,ans;
	cin>>n>>m;
	ans=-1;
	if(n<10&&m<10){
		ans=n*m;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 512
from collections import deque
from heapq import heappush,heappop
import re
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

N,K = ints_raw()


def main():
    return N - K +1

print(main())


Measured memory_bytes: 38384
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        String str=scan.next();
        int length=str.length();
        int i,j;
        for(i=0;i<length;i++){
            if(str.charAt(i)=='A'){
                break;
            }
        }
        for(j=length-1;0<j;j--){
            if(str.charAt(j)=='Z'){
                break;
            }
        }
        int k=j-i+1;
        System.out.println(k);
    }
}

Measured memory_bytes: 27348
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    string s, t;
    cin >> s >> t;

    int c = 0;
    rep(i, s.size()) {
        if(s[i] != t[i]) {c++;}
    }

    cout << c << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Circle
            int r = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow(r, 2));
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<17, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	cout << (count(all(s), '7')>0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3612
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	long n, k;
	scanf("%ld %ld\n", &n, &k);
	auto as = readln.chomp.split.to!(long[]);
	auto fs = readln.chomp.split.to!(long[]);
	as.sort!"a<b";
	fs.sort!"a>b";

	long left = -1;
	long right = 10L^^12;

	while(right - left > 1) {
		long mid = left + (right - left) / 2;

		long k_ = k;
		foreach(i; 0..n) {
			k_ -= max(0, (as[i]*fs[i] - mid + fs[i] - 1) / fs[i]);
			if (k_ < 0) break;
		}

		if (k_ >= 0) right = mid;
		else left = mid;
	}
	right.write;
}


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

int main()
{
    int r, D;

    cin >> r >> D;

    int x[11];

    cin >> x[0];

    for (int i = 0; i < 10; i++)
    {
        x[i + 1] = r * x[i] - D;
        cout << x[i + 1] << endl;
    }

    return 0;
}

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

const int mod = 1e9 + 7;
vector<int> prime;
bool is_prime[1010];

void sieve(int n){
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) is_prime[i] = true;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

int main(){
    int n;
    cin >> n;
    long long ans = 1;
    sieve(1000);
    for(int i = 0; i < prime.size() && prime[i] <= n; i++){
        int cnt = 0;
        for(int j = prime[i]; j <= n; j += prime[i]){
            int tmp = j;
            while(tmp % prime[i] == 0){
                cnt++;
                tmp /= prime[i];
            }
        }
        ans = (ans * (cnt + 1)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
  int x,y;
  while(1){
    scanf("%d %d",&x,&y);
    if(x == 0 && y == 0)break;
    if(x < y){
      printf("%d %d\n",x,y);
    }else{
      printf("%d %d\n",y,x);
    }
  }
  return 0;
}


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

#define x first
#define y second
using namespace std;

typedef pair<int, int> pii;

const int N = 5e5+5;

struct node{
    int sum = 0;
    int lv = 0, rv = 0;
}t[N*50];

int sz;
int n , q;

int upd(int v, int pos, int val, int tl = 1, int tr = n){
    int nv = ++sz;
    t[nv] = t[v];
    t[nv].sum += val;
    if (tl == tr){
        return nv;
    }
    int tm = tl+tr >> 1;
    if (pos <= tm){
        t[nv].lv = upd(t[v].lv, pos, val, tl, tm);
    }
    else{
        t[nv].rv = upd(t[v].rv, pos, val, tm+1, tr);
    }
    return nv;
}

int get(int v, int l , int r, int tl = 1, int tr = n){
    if(l <= tl && tr <= r) {
        return t[v].sum;
    }
    if(r < tl || tr < l) return 0;
    int tm = tl+tr >> 1;
    return get(t[v].lv , l , r , tl , tm) + get(t[v].rv , l , r , tm+1 , tr);
}

int root[N];
int last[N] , a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= n; i ++) {
        root[i] = root[i-1];
        cin >> a[i];
        if(last[a[i]] == 0) {
            root[i] = upd(root[i] , i , 1);
        }
        else {
            root[i] = upd(root[i] , last[a[i]] , -1);
            root[i] = upd(root[i] , i , 1);
        }
        last[a[i]] = i;
    }
    while(q --) {
        int l , r;
        cin >> l >> r;
        cout << get(root[r] , l , r) << '\n';
    }
    return 0;
}


Measured memory_bytes: 241728
exponential = [10, 100, 1000, 10000, 100000]

# nは整数が入力される前提
n = gets.to_i

if exponential.include?(n)
  print(10)
else
  n = n.to_s
  numbers = n.split("").map(&:to_i).inject(:+)
  print(numbers)
end


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

			using ll = long long;
			using ld = long double;
			#define rep(i, a, n) for(ll i = (a); i < (n); i++)
			#define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
			#define F first
			#define S second
			#define endl "\n"
			#define all(x) begin(x),end(x)
			#define maxx(a, b) a = max(a, b)
			#define minn(a, b) a = min(a, b)
			#define db(x) cerr<<#x<<" = "<<x<<endl
			#define N 1111111
			#define mod 1000000007
			#define rt return
			#define inf 1234567891123456789ll

			using namespace std;
//			random_device rd;
//			mt19937 mt(rd());
//			using namespace __gnu_pbds;
//
//			typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

			#define error(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

			void err(istream_iterator<string> it) {}
			template<typename T, typename... Args>
			void err(istream_iterator<string> it, T a, Args... args)
			{
				cerr<<*it<<" = "<<a<<endl;
				err(++it, args...);
			}

			ll modlaber(ll a, ll m = mod)
			{
				rt ((a+m)%m+m)%m;
			}

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

				vector<int> nechta(1010101,0);
				int n; cin>>n;
				vector<int> v(n);
				rep(i,0,n)
				{
					int j; cin>>j;
					v[i] = j;
					nechta[j]++;
				}

				int ans = 0;

				rep(i,0,n)
				{
					int ok = 1;
//					db(v[i]);
					if(nechta[v[i]] > 1)
						continue;
					for(int j = 2; j*j <= v[i]; j++)
						if(v[i]%j == 0)
							if(nechta[j] || nechta[v[i]/j])
							{
								ok = 0;
								break;
							}
					if(nechta[v[i]] > 1 || nechta[1] && v[i] != 1)
						ok = 0;
					ans += ok;
//					if(ok)
//						cout<<i<<endl;
				}

				cout<<ans;

				rt 0;
			}





















Measured memory_bytes: 7952
import math
n,k = map(int,input().split(' '))
v =[]
for i in range(0,n):
    x = int(input())
    v.append(x)
v.sort()
ans = 20000000000000
for i in range(0,n):
    if i >= k - 1:
        ans = min(ans,abs(v[i] - v[i-k+1]))
print(ans)



Measured memory_bytes: 7512
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >> (istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007

int main(){
  inl(X,Y);

  if(X % Y == 0) die(-1);
  else out(X);
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, D;
  cin >> N >> D;
  vector<vector<int>> x(N, vector<int>(D));
  rep(i, N) {
    rep(j, D) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i, N) {
    rep(j, i) {
      int s = 0;
      rep(k, D) {
        s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      int t = sqrt(s);
      if (t * t == s) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string a,b;
	for (int i =0; i<3;i++) cin >>a[i];
	for (int i =0; i<3;i++) cin >>b[i];
	int count = 0;
	for (int i =0; i<3;i++) if (a[i] == b[i]) count++;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
using namespace std;
int main(int argc, char const *argv[])
{
  int n,i,count =0,s;
  int t = 0;
  cin >>s;
  REP(n,1,s+1)
  {
    if(n%2 != 0)
    {
      REP(i,1,s+1)
      {
      if(n%i == 0)
      count++;
      }
      if(count == 8)
      t++;
      count = 0;
    }
  }

  cout<<t<<endl;

return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long K=1e9+7;
int main(){
	int n;
	cin>>n;
	int a=n;
	int ans=0;
	while(n){
		ans+=(n%10);
		n/=10;
	}
	if(a%ans==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <array>
#include <algorithm>
#include <iostream>
#include <utility>
#include <numeric>

int main() {
	static constexpr usize Bitlength = 40;
	usize n;
	u64 k;
	::std::cin >> n >> k;
	::std::vector<u64> a(n);
	::std::array<usize, Bitlength> cnt = {};
	u64 ans = 0;
	for (auto &e : a) {
		::std::cin >> e;
		ans += e^k;
		for (const auto i : rep<>(0, Bitlength)) {
			if (e >> i & 1) {
				++cnt[i];
			}
		}
	}
	for (const auto i : rep<>(0, Bitlength)) {
		if (k >> i & 1) {
			u64 cur = 0;
			for (const auto j : rep<>(0, i)) {
				cur += (static_cast<u64>(1) << j)*::std::max(cnt[j], n - cnt[j]);
			}
			cur += (static_cast<u64>(1) << i)*(cnt[i]);
			for (const auto j : rep<>(i + 1, Bitlength)) {
				if (k >> j & 1) {
					cur += (static_cast<u64>(1) << j)*(n - cnt[j]);
				}
				else {
					cur += (static_cast<u64>(1) << j)*(cnt[j]);
				}
			}
			asmax(ans, cur);
		}
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define N 200005
    #define fs first
    #define sc second
    #define UNIVISITED 0
    #define EXPLORED 1
    #define VISITED 2

    using namespace std;
    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
   

   


    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,f=0;
    cin>>a>>b;
    int i;
    for( i=1;i<65;i++)
    {
      ll t=a*ceil(powl(2,i-1));
      if(t==b)
      {
        f=1;
        break;
      }
      if(t>b)
        break;
    }

if(f)
  cout<<i;
else
  cout<<i-1;





    return 0;


    }

Measured memory_bytes: 640
using System;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.Write("{0}:",n);
            while (n % 2 == 0)
            {
                n /= 2;
                Console.Write(" 2");
            }
            for(int i = 3; i * i <= n; i += 2)
            {
                while (n % i == 0)
                {
                    n /= i;
                    Console.Write(" {0}",i);
                }
            }
            if (n != 1)
            {
                Console.Write(" {0}\n", n);
            }
            else
            {
                Console.Write("\n", n);
            }
        }
    }
}

Measured memory_bytes: 9076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            var xs = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var cost = 0;
            foreach(var x in xs)
            {
                var cost1 = 2 * x;
                var cost2 = Math.Abs(K - x) * 2;
                cost += Math.Min(cost1, cost2);
            }
            Console.WriteLine(cost);
        }
    }
}

Measured memory_bytes: 11348
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e3 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, a, b, c, d, fac[N], inv[N], g[N][N], f[N][N], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int C(int n, int m)
{
	if(n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), a = read <int> (), b = read <int> (), c = read <int> (), d = read <int> (); 
	for(int i = (fac[0] = 1); i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = fpow(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	g[0][0] = 1; 
	for(int res = 1, i = a; i <= b; i++, res = 1)
		for(int j = 1; j <= n && i * j <= n; j++)
			g[i * j][j] = 1ll * g[i * (j - 1)][j - 1] * C(i * j, i) % mod * inv[j] % mod * fac[j - 1] % mod; 
	f[a - 1][0] = 1; 
	for(int i = a; i <= b; i++)
		for(int j = 0; j <= n; j++)
		{
			f[i][j] = f[i - 1][j]; 
			for(int k = c; k <= d; k++)
			{
				if(i * k > j) break; 
				f[i][j] = (1ll * f[i - 1][j - i * k] * C(n - (j - i * k), i * k) % mod * g[i * k][k] + f[i][j]) % mod; 
			}
		}
	printf("%d\n", f[b][n]); 
	return 0; 
}


Measured memory_bytes: 10728
import heapq

n, m = map(int, input().split())
l = list(map(lambda x:int(x)*-1, input().split()))
heapq.heapify(l)

for _ in range(m):
  a = heapq.heappop(l)
  heapq.heappush(l, a * (-1) // 2 * (-1))
  
print(sum(l)*-1)

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

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

  string result = "Yes";
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        result = "No";
        break;
      }
    } else {
      if (S[i] == 'R') {
        result = "No";
        break;
      }
    }
  }

  cout << result << endl;
}

Measured memory_bytes: 256