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

using namespace std;

int const MAXN = 2e5 + 5;
struct Edges { int to, next; } e[MAXN];
int head[MAXN], tot;
int vis[MAXN], Ring[MAXN], stk[MAXN], top, a[MAXN], cnt, dfn[MAXN];
int ok[MAXN][21], b[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = to;
}

void Dfs(int now) {
  if (vis[now]) {
    while (stk[top] != now) a[++cnt] = stk[top--];
    a[++cnt] = stk[top--];
    return;
  }
  stk[++top] = now;
  vis[now] = 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (!dfn[e[i].to]) Dfs(e[i].to);
  dfn[now] = 1;
  --top;
}

void Work(int now) {
  for (RI i = head[now]; i; i = e[i].next)
    if (!Ring[e[i].to])
      Work(e[i].to), ok[now][b[e[i].to]] = 1;
  for (RI i = 0; i < 20; ++i)
    if (!ok[now][i])
      return b[now] = i, void();
}

int main() {
//  freopen("a.in", "r", stdin);
  ios :: sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n; cin >> n;
  for (RI i = 1, x; i <= n; ++i)
    cin >> x, addedge(x, i);
  for (RI i = 1; i <= n; ++i)
    if (!dfn[i]) Dfs(i);
  if (cnt % 2 == 0) return puts("POSSIBLE"), 0;
  for (RI i = 1; i <= cnt; ++i) Ring[a[i]] = 1;
  for (RI i = 1; i <= cnt; ++i)
    Work(a[i]);
  for (RI i = 2; i <= cnt; ++i)
    if (b[a[i]] != b[a[1]]) return puts("POSSIBLE"), 0;
  puts("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 23552
n, m = map(int, input().split())
check = [0 for i in range(m)]
for i in range(n):
   k = [int(x) for x in input().split()]
   k.pop(0)
   tmp = [check[i]+1 if i+1 in k else 0 for i in range(m)]
   check = tmp

print(len([x for x in check if x == n]))


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 998244353;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    vi cnt(n);
    rep(i, n) cnt[d[i]]++;
    bool ok = (cnt[0] == 1);
    rep1(i, n-1) if (cnt[i]>0 && cnt[i-1]==0) ok = false;
    if (!ok) {
        cout << 0 << endl;
        return 0;
    }
    int md = -1;
    rep(i, n) if (cnt[i] > 0) md = max(md, i);
    mint ans = 1;
    rep1(i, md) ans *= mint(cnt[i-1]).pow(cnt[i]);
    cout << ans << endl;
    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();

            Console.WriteLine(Math.Pow(N, 3));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int sq(int n)
{
    int t=sqrt(n);
    if(t*t==n)
    {
        return 1;
    }
    else
    {
        return 0;

    }
}
int main()
{
    int i,j,k=0;
    char a[10],b[5];
    cin>>a>>b;
    strcat(a,b);

    int ara[strlen(a)];
    for(i=0;i<strlen(a);i++)
    {
        ara[i]=a[i]-'0';
    }

    for(i=strlen(a)-1,j=1;i>=0;i--)
    {
       k=k+ara[i]*j;
       j*=10;
    }

    if(sq(k)==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import fractions

input = sys.stdin.readline


def main():
    N = int(input())
    T = []
    for _ in range(N):
        T.append(int(input()))

    ans = 1
    for t in T:
        ans = (ans * t) // fractions.gcd(ans, t)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        s: Chars
    }
    
    let n = s.len();
    let mut b_num = 0;
    let mut idx_sum = 0;
    for (i, c) in s.iter().enumerate() {
        if *c == 'B' {
            b_num += 1;
            idx_sum += i;
        }
    }

    let sum = (0..n).rev().take(b_num).sum::<usize>();

    println!("{}", sum - idx_sum);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 3024
n = [int(input()) for hoge in range(5)]
c = 0
t = 0
a = [10]
while t < 5:
  if n[t]%10 == 0:
    c += n[t]
  else:
    c += (n[t]//10 + 1)*10
    a.append(n[t]%10)
  t += 1
c -= (10-min(a))
print(c)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  ll h,w;cin>>h>>w;
  bool ok=true;
  vin dx={-1,0,1,0},dy={0,-1,0,1};
  vvb g(h,vb(w,0));
  rep(i,0,h){
    rep(j,0,w){
      char x;cin>>x;
      if(x=='#'){g[i][j]=1;}
    }
  }
  rep(i,0,h){
    rep(j,0,w){
      if(g[i][j]){
        bool ok2=false;
        rep(k,0,4){
          if(i+dx[k]<h&&i+dx[k]>=0&&j+dy[k]<w&&j+dy[k]>=0){
            if(g[i+dx[k]][j+dy[k]]){ok2=true;}
          }
        }
        if(!ok2){ok=false;}
      }
    }
  }
  if(ok){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 * 1000 + 9;

int n;
ll h[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}

	for(int i = n - 1; i > 0; i--){
		if(h[i] <= h[i + 1]){
			continue;
		}
		if(h[i] > h[i + 1]){
			if(h[i] - h[i + 1] > 1){
				cout << "No\n";
				return 0;
			} else {
				h[i] = h[i + 1];
			}
		}
	}
	
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 1024
a, b=map(int, input().split())
nums=set([str(i) for i in range(10)])
s=input()
for x in range(a):
  if s[x] in nums:
    pass
  else:
    print('No')
    exit()
if s[a]=='-':
  pass
else:
  print('No')
  exit()
for x in range(a+1, a+1+b):
  if s[x] in nums:
    pass
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 9152
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0 ;
	    int arr[] = new int[n];
	    int arr2[] = new int[n];
	    for(int  i = 0 ; i < n ; i ++) {
	    	arr[i] = scan.nextInt();
	    }
	    for(int  i = 0 ; i < n ; i ++) {
	    	arr2[i] = scan.nextInt();
	    }
	    int sum = 0 ;
	    for(int i = 0 ; i < n ; i++) {
	    	if(arr[i] - arr2[i] >0) {
	    		sum+= arr[i] - arr2[i];
	    	}
	    }
	    System.out.println(sum);
	}
}	

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

int N, M, Q;
int a[50], b[50], c[50], d[50];
int A[10];
int max_score = 0;

void dfs(int dep, int low) {
    if (dep == N) {
        int score = 0;
        for (int i = 0; i < Q; ++i) {
            if (A[b[i]-1] - A[a[i]-1] == c[i]) {
                score += d[i];
            }
        }
        max_score = max(max_score, score);
    }
    else {
        for (int i = low; i <= M; ++i) {
            A[dep] = i;
            dfs(dep + 1, i);
        }
    }
}

int main() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(0, 1);
    cout << max_score << "\n";
}

Measured memory_bytes: 3608
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();

  vector<vector<int64_t>> DP(N + 1, vector<int64_t>(13, 0));
  const int64_t mod = 1e9 + 7;
  if (S[0] == '?') {
    rep(k, 10) DP[0][k] = 1;
  } else {
    DP[0][S[0] - '0'] = 1;
  }

  for (int i = 1; i < N; ++i) {
    if (S[i] == '?') {
      rep(j, 13) {
        rep(k, 10) {
          int mod13 = (j * 10 + k) % 13;
          DP[i][mod13] = (DP[i][mod13] + DP[i - 1][j]) % mod;
        }
      }
    } else {
      rep(j, 13) {
        int mod13 = (j * 10 + (S[i] - '0')) % 13;
        DP[i][mod13] = (DP[i][mod13] + DP[i - 1][j]) % mod;
      }
    }
  }
  cout << DP[N - 1][5] << endl;
  return 0;
}


Measured memory_bytes: 13648
# -*- coding: utf-8 -*-

x = int(input())

kk = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

ans = [i for i in kk if (i <= x)]
print(ans[-1])



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

int main(void) {
    int a[4][3][10] = {};
    int n,b,f,r,v;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }
    for (int i=0; i<4; i++) {
        if (i) cout << "####################" << endl;
        for (int j=0; j<3; j++) {
            for (int k=0; k<10; k++) {
                cout << " " << a[i][j][k];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3104
class LinkedList

  @@top = nil

  def initialize(key = nil)
    @key = key
    @prev = self
    @next = self
    @@top = self if @@top.nil?
  end

  attr_accessor :key, :next, :prev

  def insert(key)
    new = LinkedList::new(key)
    new.prev = @@top
    new.next = @@top.next
    @@top.next.prev = new
    @@top.next = new
  end

  def print
    i = 0
    p = @@top
    loop do
      puts "[#{i}]:#{p.key} prev:#{p.prev ? p.prev.key : nil} next:#{p.next ? p.next.key : nil}"
      p = p.next
      i += 1
      break if p == @@top || p.nil?
    end
    puts
  end

  def p
    a = []
    p = @@top.next
    while p != @@top && p
      a << p.key
      p = p.next
    end
    puts a * " "
  end

  def find(key)
    p = @@top.next
    while p != @@top && p
      return p if p.key == key
      p = p.next
    end
    return nil
  end

  def delete(key)
    delete_node(self.find(key))
  end

  def delete_node(p)
    return if p.nil? || p == @@top
    p.prev.next = p.next
    p.next.prev = p.prev
  end
  
  def delete_first
    delete_node(@@top.next)
  end
  
  def delete_last
    delete_node(@@top.prev)
  end
end

p = LinkedList::new()
gets
while gets
  c,x=$_.split.map &:to_s
  case c
  when "insert"
    p.insert(x.to_i)
  when "delete"
    p.delete(x.to_i)
  when "deleteFirst"
    p.delete_first
  when "deleteLast"
    p.delete_last
  else
    puts c,x
    raise
  end
end
p.p




Measured memory_bytes: 59676
use std::io::stdin;
 
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut start:usize = 0;
    let mut end:usize = 1;
    let mut result: i64 = 1;
    for i in 1..(s.len()) {
        if s[start..end] != s[end..i+1] {
            start = end;
            end = i+1;
            result += 1;
        };
    };
    println!("{}", result);
}

Measured memory_bytes: 2996
using System;
using System.Collections.Generic;

namespace ABC146A
{
    class Program
    {
        static void Main(string[] args)
        {
            var weeks = new Dictionary<string, string> { { "SUN", "7"}, { "MON", "6" }, { "TUE", "5" }, { "WED", "4" }, { "THU", "3" }, { "FRI", "2" }, { "SAT", "1" } };
            var S = Console.ReadLine();

            Console.WriteLine(weeks[S]);

        }
    }
}

Measured memory_bytes: 11104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	int N = S.length();
	int c = 0;
	long ans = 0;
	for(int i=0;i<N;i++){
		if(S[i] == 'B'){
			c++;
		}
		else{
			ans += c;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < 2; i++) {
            if(a > b) {
                ans += a;
                a--;
            }else {
                ans += b;
                b--;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35748
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val n = StdIn.readLong()
    val s = StdIn.readLong()

    val n2 = math.sqrt(n).ceil.toLong

    var found = -1L

    if (n == s) {
      found = n + 1L
      println(found)
    }

    for (i <- 2L to n2 if found < 0L) {
      if (f(i, n) == s) {
        found = i
        println(found)
      }
    }

    if (found < 0L) {
      for (i <- (n2 - 1L).to(1L, -1L) if found < 0L) {
        val b1 = n / (i + 1) + 1
        val a1 = n % b1 + i
        val max = n / i

        findInSequence(s, a1, -i) match {
          case Some(j) if j > 0 =>
            val b = b1 + (j - 1)
            if (b <= max) {
              found = b
            }
          case _ =>
        }
      }

      println(found)
    }
  }

  def findInSequence(x: Long, a1: Long, d: Long): Option[Long] = {
    val y = x - a1 + d
    if (y % d == 0L) Some(y / d) else None
  }

  def f(b: Long, n: Long): Long = {
    if (n < b) {
      n
    } else {
      f(b, n / b) + n % b
    }
  }
}



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

int main(){
  int n; 
  cin>>n;
  vector<double> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  
  double sum = 0;
  rep(i,n-1) for(int j=i+1;j<n;j++){
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    sum += sqrt(dx*dx + dy*dy);
  }
  sum = sum*2/n;
  printf("%.6f\n",sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{   int a,b,c,d;
   while(cin>>a>>b>>c>>d){
     int flag=0;
     if(abs(c-a)<=d){
            cout<<"Yes"<<endl;
            continue;
     }
     if(abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
        continue;
     }

     cout<<"No"<<endl;

   }

return 0;

}


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

#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rep1(i,N) for(int i=1;i<=(int)N;++i)

using int64 = long long;
using i64 = long long;

const int inf = 1 << 30;
const i64 inf64 = 1ll << 60;

const int mod = 1e9 + 7;

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

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

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

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   return os << "(" << p.first << ", " << p.second << ")";
}

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   for (auto& e : v) os << e << ", ";
   return os << "]";
}

template <typename T>
vector<T> dijkstra(const vector<vector<pair<int, T>>>& g, int s) {
   const auto inf = numeric_limits<T>::max();
   using P = pair<T, int>;

   vector<T> dist(g.size(), inf);
   priority_queue<P, vector<P>, greater<P>> que;
   dist[s] = 0;
   que.emplace(0, s);
   while (!que.empty()) {
      int u;
      T cost;
      tie(cost, u) = que.top(); que.pop();
      if (dist[u] < cost) continue;
      for (auto& e : g[u]) {
         T next_cost = cost + e.second;
         if (dist[e.first] <= next_cost) continue;
         dist[e.first] = next_cost;
         que.emplace(next_cost, e.first);
      }
   }

   return dist;
}

int main() {
   int V, E, r;
   cin >> V >> E >> r;
   using P = pair<int, int64>;
   vector<vector<P>> g(V);
   rep(i, E) {
      int u, v;
      i64 d;
      cin >> u >> v >> d;
      g[u].emplace_back(v, d);
   }

   auto dist = dijkstra(g, r);
   for (auto e : dist) {
      if (e == INT64_MAX) cout << "INF" << endl;
      else cout << e << endl;
   }
}


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

int main(){
  string s;
  cin >> s;
  
  bool flag = false;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s.at(i) == s.at(i+1)) {
      flag = true;
    }
  }
  
  if (flag) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double height;
    double max=0;
    double min=10000;
    double def=0;
    while(scanf("%lf",&height)!=EOF){
        if(max<height)
        max=height;
        if(min>height)
        min=height;
        def=max-min;
        
    }
        printf("%.1lf\n",def);
        return 0;
    
}



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

using vi  = vector<int>;
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)

signed main(){
  string s; cin >> s;
  int l, m, r;
  l = m = r = 0;
  vi ans(s.size());
  while(1){
    while(s.substr(m,2) != "RL") m++;
    r = m;
    while(r < s.size()-1 and s.substr(r,2) != "LR") r++;
    ans[m] += (r-l+1)/2;
    ans[m+1] += (r-l+1)/2;
    if((r-l+1)%2==1) ans[m + ((m-l)&1)]++;
    
    if(r == s.size()-1) break;
    l = m = r+1;
  }
  cout << ans[0];
  FOR(i,1,s.size()) cout << " " << ans[i];
}

Measured memory_bytes: 1024
N, W = [int(_) for _ in input().split()]
WV = [[int(_) for _ in input().split()] for _ in range(N)]
dp = {}
dp[0] = 0
for w, v in WV:
    dp_o = dp.copy()
    for k in dp_o:
        dp[k + v] = min(dp_o.get(k + v, float('inf')), dp_o[k] + w)
print(max([k for k, v in dp.items() if v <= W]))


Measured memory_bytes: 120652
// written by : soumya_27
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define mod ((int)1e9+7)//998244353//((int)1e18+7)
#define M_PI 3.14159265358979323846
// #define maxx ((int)1e7+7)
#define pb push_back
#define ins insert
#define F first
#define S second
#define ins insert
#define pii pair <int , int>
#define lb lower_bound
#define ub upper_bound
#define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin >> t; while(t--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int add(int a, int b) {return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)     
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
using namespace std;
int fact[1000006];
// void facto() {fact[0] = 1; for(i=1 ; i<1000006 ; i++) fact[i] = mul(fact[i-1], i);}
// int ncr(int n, int r) { int res = fact[n]; res = mul(res, inv(fact[r])); res = mul(res, inv(fact[n-r])); return res;}
void solve()
{
    fast
    // test
    {
        int n, i, j, k, c = 0;
        cin >> n >> k;
        k *= k;
        while(n--)
        {
        	int x, y;
        	cin >> x >> y;
        	if(x*x + y*y <= k)
        		c++;
        }
        cout << c << "\n";
    }
}

signed main()
{
    // time__("solve")
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2e5+5;
int n,m,k,a[N];
int main()
{
	n=read(),m=read();int k0=read();
	fo(i,1,n) a[i]=n+1;
	fo(i,1,k0)
	{
		int x=read(),y=read();
		chkmin(a[x],y);
	}
	int w=0;
	fo(i,1,n)
	{
		if(i-a[i]>w) return printf("%d\n",i-1),0;
		else
		if(i-a[i]==w) ++w;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
  int n,m,up=0,down=0,high[1000]={0};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> m;
    for(int j=0;j<m;j++){
      cin >> high[j];
    }
    for(int j=0;j<m;j++){
      if(high[j+1]!=0){
	if(high[j]<high[j+1]){
	  if(up<high[j+1]-high[j]){
	    up=high[j+1]-high[j];
	  }
	}
	else if(high[j]>high[j+1]){
	  if(down<high[j]-high[j+1]){
	    down=high[j]-high[j+1];
	  } 
	}
      }
    }
    cout << up << " " << down << endl;
    up=0;
    down=0;
    for(int j=0;j<200;j++){
      high[j]=0;
    }
  }
}

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

int main(void) {
    string S;
    cin>>S;
    bool pre = false;
    bool aft = false;
    if (1 <= stoi(S.substr(0, 2)) && stoi(S.substr(0, 2)) <= 12) pre = true;
    if (1 <= stoi(S.substr(2, 2)) && stoi(S.substr(2, 2)) <= 12) aft = true;
    if (pre && aft) cout << "AMBIGUOUS" << endl;
    else if (pre) cout << "MMYY" << endl;
    else if (aft) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s, vector<Weight> &dist) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

int w,h;

int trans(int x,int y, int k) {
  return x*h*4+y*4+k;
}

int main() {
  while(cin>>w>>h,w+h) {
    int ba[w][h];
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
      }
    }
    int c[4];
    REP(i,4)
      cin >> c[i];
    
    Graph g(w*h*4);

    int const dx[] = {0,1,0,-1};
    int const dy[] = {-1,0,1,0};
    // ツ湘」ツ右ツ可コツ債カ
   
    REP(y,h) {
      REP(x,w) {
        REP(k,4) {
          REP(i,4) {
            int xx = x+dx[i];
            int yy = y+dy[i];
            if(xx<0||w<=xx||yy<0||h<=yy) continue;

            int hoge = i-k; if (hoge<0) hoge+=4;
            int cost = c[hoge];
            if (ba[x][y]!=4 && i==(k+ba[x][y])%4) cost = 0;
            
            g[trans(x,y,k)].push_back(Edge(trans(x,y,k), trans(xx,yy,i), cost));
          }
        }
      }
    }
    vector<int> v;
    shortestPath(g,1,v);
    cout << min(v[trans(w-1,h-1,1)],v[trans(w-1,h-1,2)]) << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)1e5+5;

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

    int n;
    cin>>n;
    vector<int> a(n+1),cnt(n+1);
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll ans = 0;
    for(int i=1;i<=n;i++) {
        ans += ((ll)cnt[i]*(cnt[i]-1))/2;
    }
    for(int i=1;i<=n;i++) {
        int k = a[i];
        ll fans = ans;
        fans -= ((ll)cnt[k]*(cnt[k]-1))/2;
        fans += ((ll)(cnt[k]-2)*(cnt[k]-1))/2;
        cout<<fans<<"\n";
    }
}


Measured memory_bytes: 4224
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (n >= sum) {
        cout << n-sum << endl;
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(1<=a && a<=9 && 1<=b && b<=9){
        cout<<a*b;
    }
    else cout<<-1;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    //int n;cin>>n;
    //vector<int>a(n);
    //for(int i=0;i<n;i++)
        //cin>>a[i];
    //int a,b;cin>>a>>b;
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    int cnt=n/2;
    int now=0;
    while(cnt--){
        if(s[now]!=s[n-1-now])
            ans++;
        now++;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int k,s,i,j,l;
    scanf("%d %d",&k,&s);
    int count = 0;
    for(int i = 0;i<=k;i++){
        for(int j = 0;j<=k;j++){
            // printf("i = %d j = %d\n",i,j);
            if(s - i - j <= k && s - i - j >= 0){
                count++;
                // printf("maru\n");
            }
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N,K;cin>>N>>K;
  vll A(N);rep(i,N)cin>>A[i];
  ll left=0,right=1e9+1;
  while(right-left>1){
    ll mid=(right+left)/2;
    ll cnt=0;
    rep(i,N){
      if(A[i]%mid!=0) cnt++;
      cnt += A[i]/mid;
      cnt--;
    }
    if(cnt<=K) right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
 
 
 
#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long
 
using namespace std;
 
 
int main(){
    ll N,res;
    cin >> N;
 
    vector <ll> A(N),B(N),C(N),Bget(N,0);
 
    REP(i,N)
    {
        cin >> A[i];
    }
    REP(i,N)
    {
        cin >> B[i];
    }
    REP(i,N)
    {
        cin >> C[i];
    }
 
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
 
    //メモ化
    //B[i]を選択したときに、何個のC[j]を選べるか
 
    ll ne = 0;
    REP(i,N)
    {
        if(B[i] >= C[N-1])break;
 
        for(ll j = ne; j < N; j++)
        {
            if(B[i] < C[j])
            {
                Bget[i] = N-j;
                ne = j;
                break;
            }
 
        }
    }
 
    //BgetSumの作成
    vector <ll> BgetSum(N+1,0);
 
    for(ll i = N-1; i >= 0; i--)
    {
        BgetSum[i] = BgetSum[i+1] + Bget[i];
    }
 
    ne = 0;
    //A[i]を選択したときに、何個のB[j]を選べるか B[j]を足し合わせる
    REP(i,N)
    {
        if(A[i] >= B[N-1])break;
 
        for(ll j = ne; j < N; j++)
        {
            //以降のBgetはすべて獲得できる
            if(A[i] < B[j])
            {
                res += BgetSum[j];
                ne = j;
                break;
            }
        }
    }
 
    cout << res << endl;
 
}

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


using namespace std;

template <typename T>
class arr {
  int n;
  T *a;
  void raise(int x) {
    T *b=a;
    a=new T[x];
    copy(b,b+n,a);
    delete b;
  }
  T& operator << (T x) {
    if ((n&-n)==n) {
      raise(n<<1);
    }
    a[n++]=x;
  }
  void resize(int x) {
    if (n<x) {
      raise(1<<(32-__builtin_clz(x)));
    }
    n=x;
  }
  arr() {
    n=0;
    a=NULL;
  }
  arr(int x) {
    n=0;
    a=NULL;
    resize(x);
  }
  T& operator << (int x) {
    return a[x];
  }
};

int main() {
  long long a,b;
  cin>>a>>b;
  cout<<((a+b==15)?'+':(a*b==15?'*':'x'))<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
L = [0]*(N+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            c = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if c <= N:
                L[c] += 1
for i in range(1,N+1):
    print(L[i])


Measured memory_bytes: 69892
//
//  main.cpp
//  Problem Code
//
//  Created by Algo张伯威 on 2020/4/24.
//  Copyright © 2020 Algo张伯威. All rights reserved.
//

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

int main() {
    int s,w;
    scanf("%d%d", &s,&w);
    if(w >= s) printf("unsafe\n");
    else printf("safe\n");
        
    return 0;
}
























Measured memory_bytes: 1616
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0111

"""
import sys
from sys import stdin
input = stdin.readline


def solve(data):
    txt = ''
    for d in data:
        txt += rev_decoder[d]

    result = ''
    while txt:
        match = False
        for k in rev_encoder.keys():
            if txt.startswith(k):
                match = True
                result += rev_encoder[k]
                txt = txt[len(k):]
                break
        if match is False:
            break
    return result


# AOJ 0088?????????
encoder = {' ':'101', "'":'000000', ',':'000011', '-':'10010001', '.':'010001', '?':'000001', 'A':'100101', 'B':'10011010',
               'C':'0101','D':'0001', 'E':'110', 'F':'01001', 'G':'10011011', 'H':'010000', 'I':'0111','J':'10011000',
               'K':'0110', 'L':'00100', 'M':'10011001', 'N':'10011110', 'O':'00101', 'P':'111', 'Q':'10011111', 'R':'1000',
               'S':'00110', 'T':'00111', 'U':'10011100', 'V':'10011101', 'W':'000010', 'X':'10010010', 'Y':'10010011', 'Z':'10010000'
}
rev_encoder = dict(zip(encoder.values(), encoder.keys()))

decoder = {'00000':'A', '00001':'B', '00010':'C', '00011':'D', '00100':'E', '00101':'F', '00110':'G', '00111':'H',
               '01000':'I', '01001':'J', '01010':'K', '01011':'L', '01100':'M', '01101':'N', '01110':'O', '01111':'P',
               '10000':'Q', '10001':'R', '10010':'S', '10011':'T', '10100':'U', '10101':'V', '10110':'W', '10111':'X',
               '11000':'Y', '11001':'Z', '11010':' ', '11011':'.', '11100':',', '11101':'-', '11110':"'", '11111':'?'
}
rev_decoder = dict(zip(decoder.values(), decoder.keys()))
def main(args):
    for data in sys.stdin:
        result = solve(data.strip('\n'))
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7540
#include<cstdio>
int main()
{
	int a,b,ans=0;
	int n1,n2,n3,n4;
	scanf("%d %d",&a,&b);
	for(int i=a;i<=b;i++)
	{
		n1=i/10000;
		n2=i/1000%10;
		n3=i/10%10;
		n4=i%10;
		if(n1==n4&&n2==n3)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  int S,h,m,s;
  
  cin >> S;
  
  h = S/3600;
  m = (S-3600*h)/60;
  s = S-3600*h-60*m;
  
  cout << h << ":" << m << ":" << s << endl;
  
  return 0;
}



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

int main(void) {
	int A, B, C, X, Y;
	int ans;
	std::cin >> A >> B >> C >> X >> Y;

	if (A + B <= 2 * C) {
		ans = A * X + B * Y;
		std::cout << ans << '\n';
		return 0;
	}
	if (X == Y) {
		ans = X * 2 * C;
		std::cout << ans << '\n';
		return 0;
	}
	if (X > Y) {
		ans = std::min(std::abs(X - Y) * A + std::min(X, Y) * 2 * C, X * 2 * C);
		std::cout << ans << '\n';
		return 0;
	}
	// X < Y
	ans = std::min(std::abs(X - Y) * B + std::min(X, Y) * 2 * C, Y * 2 * C);
	std::cout << ans << '\n';
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);

    int pre_ans=0;
    int ans =0;

    rep(i,n){
        ll temp;
        cin >> temp; 
        h[i] = temp;
        if (i==0) continue;
        if (h[i-1]>=h[i]){
            pre_ans++;
        }
        else{
            ans = max(ans, pre_ans);
            pre_ans = 0;
        } 
    }

    ans = max(ans, pre_ans);
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    map <int, int> mp;

    for(int i = 0; i < m; i ++)
    {
    	int u, v;
    	cin >> u >> v;
    	mp[u] ++;
    	mp[v] ++;
    }

    for(int i = 1; i <= n; i ++)
    	cout << mp[i] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<vector>
int az[26];
using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
long long int x[100000], y[100000];
long long int MOD = 1000000007;

int main() {
	
	//D
	int n, m;
	int i;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	//sort(x, x + n);
	for (i = 0; i < m; i++) {
		cin >> y[i];
	}
	//sort(y, y + n);
	long long int xsum = 0, ysum = 0;
	long long int l = x[n - 1] - x[0];
	xsum = l % MOD;
	l = l % MOD;
	for (i = 1; i < n; i++) {
		l = l + x[n - 1 - i] - x[i] + MOD;
		l = l % MOD;
		xsum = xsum + l;
		xsum = xsum % MOD;
	}
	l = y[m - 1] - y[0];
	ysum = l % MOD;
	l = l % MOD;
	for (i = 1; i < m; i++) {
		l = l + y[m - 1 - i] - y[i] + MOD;
		l = l % MOD;
		ysum = ysum + l;
		ysum = ysum % MOD;
	}
	cout << (xsum * ysum) % MOD << endl;
	return 0;

	//C
	/*
	string s;
	int n;
	cin >> n;
	int i, j, k;
	
	for (j = 0; j < 26; j++) {
		az[j] = 100;
	}
	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; j < 26; j++) {
			k = count(s.cbegin(), s.cend(), 'a' + j);
			az[j] = min(k, az[j]);
		}
	}
	char c;
	for (i = 0; i < 26; i++) {
		for (j = 0; j < az[i]; j++) {
			c =  'a' + i;
			cout << c;	
		}
	}
	cout << endl;
	return 0;
	*/
}

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


Measured memory_bytes: 5188
#pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
double x[10], y[10],sum;
double cal(double a1,double b1,double a2,double b2)
{
	return sqrt(((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2)));
}
int main()
{
	//freopen("C:\\Users\\HP\\Desktop\\in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lf%lf", &x[i], &y[i]);
	for (int i = 1; i <= n; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			sum+=cal(x[i], y[i], x[j], y[j]);
		}
	}
	double ans = sum * 2.0 / (1.0 * n);
	printf("%.10lf\n", ans);
	return 0;
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

string S;

signed main() {
    cin >> S;
    rep(i, S.size() - 1) {
        if (S[i] == 'A') {
            if (S[i + 1] == 'C') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
from math import atan, pi
a,b,x=map(int,input().split())
if x<=a*a*b/2:
  h=x/b/a*2
  print(atan(b/h)*180/pi)
else:
  h=(a*a*b-x)/(a*a)*2
  print(atan(h/a)*180/pi)
  

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> B(N);
    vector<int> C(N);

    bool ok = true;
    REP(i,N){
        int b;
        cin >> b;
        B[i] = b;

        C[b]++;

        vector<int> D(N);
        for(int j = 1; j < N; j++){
            D[j] = C[j] + D[j-1];
        }

        if(b != 1 && D[b-1] < b-1) ok = false;
    }

    if(!ok){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    REP(i,N){
        int idx;
        int high = -1;
        REP(k,B.size()) {
            if(k+1 == B[k] && high < B[k]){
                idx = k;
                high = B[k];
            }
        }
        B.erase(B.begin() + idx);
        //cout << i << endl;
        ans.push_back(high);
    }

    reverse(ans.begin(), ans.end());

    for(auto&& x : ans){
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string str1,str2;
    int num,taro=0,hana=0;
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>str1>>str2;
        if(str1>str2)taro+=3;
        else if(str1<str2)hana+=3;
        else taro++,hana++;
    }
    cout<<taro<<" "<<hana<<endl;
    
    return 0;
}



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

int main(){

	ll n,m;
	cin>>n>>m;
	if(n == 1 || m == 1){	
		cout<<"1\n";
		return 0;
	}

	ll ans = (n*m)/2;

	if((n*m)%2)
		ans++;

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
S = int(input())
mod = 10**9+7
if S <= 2:
    print(0)
else:
    lst = [1]*(S+1)
    for i in range(3,S-2):
        for j in range(i+3,S+1):
            lst[j] += lst[i]
            lst[j] %= mod
    print(lst[S]%mod)


Measured memory_bytes: 65776
#include<bits/stdc++.h>
using namespace std;
int m,n;
int main(){
	scanf("%d",&m);
	printf("%d\n",n=(m>1?m+3>>2<<1:1));
	for(int i=0;i<n;i++,puts(""))
	for(int j=0;j<n;j++)
	printf("%d ",1+(i+j)%n+((j&1)&&(i+j)%n+n<m?n:0));
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

vector<int> adj[N];
vector<int> first(N), subsize(N);
vector<ll> cnt(N,0);
vector<int> arr;
vector<int> visited(N,0);

void dfs(int node){
	arr.push_back(node);
	subsize[node] = 1;
	first[node] = arr.size() - 1;
	for(auto y : adj[node]){
		if( ! visited[y] ){
			visited[y] = 1;
			dfs(y);
			subsize[node] += subsize[y];
		}
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  int n,q;
	cin>>n>>q;
	for(int i=0; i<n-1; ++i){
		int x,y;
		cin>>x>>y;
		x--; y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	visited[0] = 1;
	dfs(0);
	while(q--){
		int p;
		ll x;
		cin>>p>>x;
		p--;
		int get = first[p];
		cnt[get] += x;
		cnt[get + subsize[p] ] -= x;
	}
	for(int i=1; i<n; ++i){
		cnt[i] += cnt[i-1];
	}
	vector<int> prep_ans(n,0);
	for(int i=0; i<n; ++i){
		prep_ans[arr[i]] = cnt[i];
	}
	for(int i=0; i<n; ++i){
		cout<<prep_ans[i]<<" ";
	}
	cout<<'\n';

	return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
        return 0;
    }
    cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
struct seg{Point p1,p2;};
//??????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//??????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´?????????
bool C90(seg s1,seg s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
bool C0(seg s1,seg s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


main(){
  int n;
  cin>>n;
  while(n--){
    seg a,b;
    cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
    cin>>b.p1.x>>b.p1.y>>b.p2.x>>b.p2.y;
    if(C0(a,b))cout<<"2"<<endl;
    else if(C90(a,b))cout<<"1"<<endl;
    else cout<<"0"<<endl;
  }
}

Measured memory_bytes: 3236
#include <stdio.h>
#include <stdlib.h>
long gcd(long a, long b);

int main(void)
{
	long N, X, x[100000], d;
	scanf("%ld%ld", &N, &X);
	for (int i = 0; i < N; ++i)
	{
		scanf("%ld", &x[i]);
		x[i] = labs(x[i]-X);
	}
	d = x[0];
	if (N > 1)
	{
		for (int i = 1; i < N; ++i)
		{
			if (x[i] >= d)
			{
				d = gcd(x[i], d);
			}
			else
			{
				d = gcd(d, x[i]);
			}
		}
	}
	printf("%ld\n", d);
	return 0;
}

long gcd(long a, long b)
{
	long l;
	if (a == b)
	{
		return a;
	}
	else
	{
		l=(a-b)/b;
		a-=l*b;
		if (a>b) a-=b;
		b = gcd(b, a);
	}
	return b;
}

Measured memory_bytes: 896