akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	ans := 0
	for i, c := range s {
		if c != rune(t[i]) {
			ans++
		}
	}
	fmt.Printf("%d", ans)
}


Measured memory_bytes: 4588
import std.stdio;
import std.algorithm;
import std.array;

int[5000] count;

void main(){
	int n, c;
	while (readf("%d\n", &n), n) {
		int[] list;
		count[] = 0;
		// step1
		for (int i = 1; i < n; i++) {
			c = i*i % n;
			if (find(list, c).empty) list ~= c;
		}
		// step2
		foreach (a; list) {
			foreach (b; list) {
				c = a - b;
				if (c < 0) c += n;
				if (c > (n-1)/2) c = n - c;
				count[c]++;
			}
		}
		// step3
		for (int i = 1; i <= (n-1)/2; i++) {
			writeln(count[i]);
		}
	}
}

Measured memory_bytes: 1056
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n;
long long a[110000],te,ans,s;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	s=0;
	fo(i,1,n){
		s+=a[i];
		if (i&1){
			if (s>=0){
				ans+=s+1;
				s=-1;
			}
		}
		else{
			if (s<=0){
				ans+=1-s;
				s=1;
			}
		}
	}
	
	s=0;
	fo(i,1,n){
		s+=a[i];
		if (i&1){
			if (s<=0){
				te+=1-s;
				s=1;
			}
		}
		else{
			if (s>=0){
				te+=s+1;
				s=-1;
			}
		}		
	}
	if (te<ans) ans=te;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
logs = gets.chomp.split.map(&:to_i).sort
ans = 0
n.times do |i|
    (i+1).upto(n-1) do |j|
        c = logs.bsearch_index{|x| x >= (logs[i]+logs[j])} || n
        tmp = c - (j+1)
        ans += tmp if tmp > 0
    end
end

puts ans

Measured memory_bytes: 14368
#include<math.h>
#include<iostream>
using namespace std;
int main(){
	double x,y=100;
	int n=0;
	cin>>x;
	while(y<x){
        y = y*1.01;
        y = (long long) y;
 
        n++;
	}
	cout<<n;
  return 0;
}

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

int main (){
  ll n;cin>>n;
  vector<ll> v(n-1),x(n,0);
  rep(i,n-1){
    cin>>v.at(i);
  }
  rep(i,n-1){
    x.at(v.at(i) - 1)++;
  }
  rep(i,n){
    cout << x.at(i) << endl;
  }
}

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

#define ll long long
#define eb emplace_back
#define nl '\n'
#define deb(x) cerr << #x" = " << x << nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    int n, m; cin >> n >> m; cout << n * (n - 1) / 2 + m * (m - 1) / 2 << nl;
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string a, b, c; cin >> a >> b >> c;
  int A = 0, B = 0, C = 0;
  char state = 'a';
  while(true) {
    if(state == 'a') {
      state = a[A];
      A++;
    }

    if(state == 'b') {
      state = b[B];
      B++;
    }

    if(state == 'c') {
      state = c[C];
      C++;
    }

    if(A == a.size() + 1) {
      cout << "A" << endl;
      break;
    }

    if(B == b.size() + 1) {
      cout << "B" << endl;
      break;
    }

    if(C == c.size() + 1) {
      cout << "C" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import itertools
n = int(input())
m,a,r,c,h = [0]*5
for i in range(n):
    s = input()
    if s[0] == "M":m += 1
    if s[0] == "A": a += 1
    if s[0] == "R": r += 1
    if s[0] == "C": c += 1
    if s[0] == "H": h += 1
x = [m,a,r,c,h]
y = ["M","A","R","C","H"]
ans = 0
for i in itertools.combinations(x,3):
    ans += i[0]*i[1]*i[2]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
 vll a(n);
  rep(i,0,n) cin >> a[i];
 
  
  ll f=1; 
 ll ans=0; 
 while(f){ 
  ll s=0;
  vll num(n);
  rep(i,0,n){
   num[i]=a[i]/n; 
   s+=num[i];
  }
  rep(i,0,n){
   a[i]-=num[i]*n; 
   a[i]+=s-num[i];
  } 
  ans+=s; 
  
  if(*max_element(all(a))<n) f=0;
  
 }
  cout << ans << endl; 
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int cnt = 0;
  REP(i, N){
    if(A[i]%2 == 1) cnt++;
  }

  cnt%2? NO: YES;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

ll func(ll a, ll b, ll c){
    ll q, r;
    q = a/c;
    r = a%c;
    if(r==0){
        return  b/c-q+1;
    }
    else{
        return  b/c-(q+1)+1;
    }
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll numc,numd,numcd;
    numc = func(a,b,c);
    numd = func(a,b,d);
    numcd = func(a,b,lcm(c,d));
    cout << (b-a+1)-(numc+numd-numcd);
}

Measured memory_bytes: 256
S = input()

N = len(S)
dp = [[0 for i in range(13)] for j in range(N + 1)]
mod = 10**9 + 7

dp[0][0] = 1
for i in range(N):
    for j in range(13):
        if S[i] != "?":
            dp[i + 1][(j * 10 + int(S[i])) % 13] += dp[i][j]
        else:
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
    for j in range(13):
        dp[i + 1][j] %= mod

print(dp[N][5])


Measured memory_bytes: 68136
package main

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

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

const DIV int = 1e9 + 7

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N := nextInt()

	S2 := 0
	S := 0

	for i := 0; i < N; i++ {
		a := nextInt()
		S = (S + a) % DIV
		S2 = (S2 + a*a) % DIV
	}

	c := (S*S - S2) % DIV
	if c%2 == 0 {
		fmt.Println(c / 2)
	} else {
		fmt.Println((c + DIV) / 2)
	}
}


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

using namespace std;

int main(){

	int n;
	while(cin>>n){
		vector<int> v;
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			v.push_back(t);
		}
		sort(v.begin(),v.end());
		int sum=0;
		int pen=0;
		for(int i = 0; i < v.size(); i++){
			sum+=pen+v[i];
			pen+=v[i];
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 998244353;
const double PI = acos(-1);

map<pair<long long, long long>, int> cnt;

void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        long long s; cin >> s;
        long long no_cube = s;
        for (long long j = 2; j * j * j <= s; j++) {
            if (s % (j * j * j) == 0) {
                no_cube = s / (j * j * j);
            }
        }
        long long fi = 1, se = 1;
        long long dublic = no_cube;
        for (long long j = 2; j * j * j <= no_cube; j++) {
            long long p = 1;
            while (dublic % j == 0) {
                dublic /= j;
                p *= j;
            }
            if (p == j) fi *= j;
            else if (p >= j) se *= j;
        }
        long long root = (long long)(sqrt(dublic));
        bool ok = false;
        for (int i = -1; i < 2; i++) {
            root += i;
            if (root * root == dublic) {
                ok = true;
                break;
            }
            root -= i;
        }
        if (ok) se *= root;
        else fi *= dublic;
        cnt[make_pair(fi, se)]++;
        if (!cnt.count(make_pair(se, fi))) {
            cnt[make_pair(se, fi)] = 0;
        }
    }
    int res = 0;
    set<pair<int, int> > setik;
    for (auto it : cnt) {
        pair<long long, long long> para = it.first;
        int num = it.second;
        if (para.first == 1 and para.second == 1) res++;
        else {
            res += max(num, cnt[make_pair(para.second, para.first)]);
            cnt[para] = 0;
            cnt[make_pair(para.second, para.first)] = 0;
        }
    }
    cout << res << endl;
} 

int main() {
    jonathan; 
    livingston;
    solve();
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
  else if (s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R') ans = 2;
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
    ll N; scanf("%I64d", &N);
    for(ll h = 1; h <= 3500; ++h) {
        for(ll n = 1; n <= 3500; ++n) {
            ll ans1 = N*h*n;
            ll ans2 = n*h*4 - N*(n+h);
            if(ans2 <= 0) continue;
            if(ans1 % ans2 == 0) {
                printf("%I64d %I64d %I64d\n", h, n, ans1 / ans2);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(getMaxValue(n, W, v, w));
	}

	private int getMaxValue(int n, int W, int[] v, int[] w) {
		int[][] dp = new int[n + 1][W + 1];
		for (int i = 0; i < n; i++) {
			int vl = v[i];
			int wt = w[i];
			for (int j = 0; j <= W; j++) {
				if (wt > j) {
					dp[i + 1][j] = dp[i][j];
				} else {
					dp[i + 1][j] = Math.max(dp[i][j], Math.max(dp[i][j - wt] + vl, dp[i + 1][j - wt] + vl));
				}
			}
		}
		return dp[n][W];
	}
}


Measured memory_bytes: 29280
#include <cstdio>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    // solve
    reversed_priority_queue<pair<int, int> > que;
    repeat (i, n) {
        que.emplace(a[i], i);
    }
    set<int> sep;
    sep.insert(-1);
    sep.insert(n);
    ll result = 0;
    while (not que.empty()) {
        int a_i, i; tie(a_i, i) = que.top(); que.pop();
        auto it = sep.upper_bound(i);
        int r = *it;
        int l = *(-- it) + 1;
        result += (i - l + 1) * (ll) (r - i) * a_i;
        sep.insert(i);
    }
    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 12016
package main
import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)
var in = NewScanner(os.Stdin, 0)
func main(){
	N := in.Int()
	a, b := in.ArrayInt(N), in.ArrayInt(N)
	t := 0
	ans := 0
	c := make([]int, N)
	for i := 0; i < N; i++{
		c[i] = b[i] - a[i]
		if c[i] > 0{
			t += c[i]
			ans++
		}
	}
	Eln(c)
	sort.Ints(c)
	Eln(c)
	for i := 0; i < N; i++{
		if c[i] < 0 && t > 0{
			t += c[i]
			ans++
		}
	}
	if t > 0{
		Pln(-1)
	} else{
		Pln(ans)
	}
}
const M7 = 1000000007
type Scanner struct{
	*bufio.Scanner
}
func NewScanner(r io.Reader, x int) *Scanner{
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if x <= 0{
		x = 1048576
	}
	s.Buffer([]byte{}, x)
	return &Scanner{s}
}
func (s *Scanner) Int() int{
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil{
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) IntSlice{
	r := make(IntSlice, n)
	for i := 0; i < n; i++{
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool{
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(d []byte, e bool) (int, []byte, error){
	s := 0
	for s < len(d) && isSpace(d[s]){
		s++
	}
	for i := s; i < len(d); i++{
		if isSpace(d[i]){
			return i + 1, d[s:i], nil
		}
	}
	if e && len(d) > s{
		return len(d), d[s:], nil
	}
	return s, nil, nil
}
func Eln(s ...interface{}){
	fmt.Fprintln(os.Stderr, s...)
}
func Pln(s ...interface{}){
	fmt.Println(s...)
}
type ByteSlice []byte
type IntSlice []int


Measured memory_bytes: 7936
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    ll n,X; cin >> n >> X;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];

    vector<ll> dx(n);
    rep(i,n){
        dx[i] = abs(x[i] - X);
    }
    ll d = dx[0];
    rep(i,n){
        d = __gcd(dx[i],d);
    }
    cout << d << endl;
}

Measured memory_bytes: 1792
s = input()

ans = 10000
index = 0
for i in range(len(s)-2):
    a = 100 * int(s[i])
    b = 10 * int(s[i+1])
    c = int(s[i+2])
    hog = a + b + c
    tmp = abs(hog - 753)
    if ans > tmp:
        ans = tmp

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
struct point
{
	ll x,y;
}p[N];
bool cmp(point a,point b)
{
	return atan2(a.y,a.x)<atan2(b.y,b.x);
}
int main()
{
	int n;	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&p[i].x,&p[i].y);

	int nx[N];
	for(int i=1;i<=n;i++)
		nx[i]=i+1;
	nx[n]=1;
	sort(p+1,p+1+n,cmp);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x=p[i].x;	ll y=p[i].y;
		ans=max(ans,x*x+y*y);
		for(int j=nx[i];j!=i;j=nx[j])
		//for(int j=1;j<=n;j++)
		{
				x += p[j].x;
            	y += p[j].y;
            	ans = max(ans, x * x + y * y);
		}	
	}
	printf("%.10lf\n",sqrt(ans));
	
	return 0;
} 

Measured memory_bytes: 768
N,A,B = map(int,input().split())

ans = 0

def judge(number):
    number_str = str(number)
    list_a = []
    for i in number_str:
        list_a.append(int(i))
    list_sum = sum(list_a)
    return list_sum

for i in range(1,N+1):
    if A <= judge(i) <= B:
        ans += i

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ATwoRectangles {
public:
	void solve(istream& in, ostream& out) {
        int a, b, c, d;
        in >> a >> b >> c >> d;
        out << max(a * b, c * d) << endl;
	}
};

int main() {
	ATwoRectangles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b
  | b = putStrLn "YES"
  | otherwise = putStrLn "NO"

yesNo b
  | b = putStrLn "Yes"
  | otherwise = putStrLn "No"

main = do
  [x, a, b] <- readInt
  yesNoUpper $ (a * 10 + b) `mod` 4 == 0


Measured memory_bytes: 380
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int n;
	int a[100];

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--)
	{
		cout << a[i];
		if (i != 0)
		{
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
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...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL d(n);
	cin >> d;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int n,q;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++)cin>>b[i];
	int res=0;
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			if(a[j]==b[i]){
				res++;break;
			}
		}
	}	
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int count = 0;
  int ans = 0;
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      count++;
      if(count > ans){
        ans = count;
      }
    }else{
      count = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char S[100000],T[10000],*p;
	int i,judge=0,length;
	scanf("%s",&S);
	length=strlen(S);
	for(i=0;i<length;i++){
		if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'){
			if(S[i+5]=='e'&&S[i+6]=='r'){
				i=i+6; judge=1;
			}
			else{
				i=i+4; judge=0;
			}

		}else if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'){
			if(S[i+5]=='r'){
				i=i+5; judge=1;
			}
			else{
				i=i+4; judge=0;
			}
		}else{
			if(judge==1){
				i-=3; judge=0;
			}else{
			break;
			}
		}
	}

	printf("%s\n",i>=length||judge==1 ? "YES" : "NO" );
	return 0;
}

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

#define all(n) n.begin(),n.end()
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
//#define ((x|y)-y) (x&(~y))
//#define gcd(fibo(x),fibo(y)) = fibo(gcd(x,y))
using namespace std;
const ll maxn=3e5+1;
const ll maxx=1e13;
const ll mod=1e9+7;
const ll mod1=998244353;

vector <pll> adj[maxn];
set<ll> adj1[maxn];
//vector<ll> ans;
//bool kt[maxn];
ll a[maxn];
ll b[maxn] ;
pll p[maxn];

vector<ll> ans;
bool check(ll a,ll b,vector<ll>& nw)
{
    queue<ll> q;
    q.push(a);
    vector<ll> dd(52,0);
    dd[a]=1;
    /*for (auto p:nw )
    {
        cout <<p<<" ";
    }*/

    while (!q.empty())
    {

        auto p=q.front();
       // cout <<p<<" ";
        q.pop();
        dd[p]=1;
        if (p==b) return 1;
        for (auto t:nw)
        {
            ll to= p%t;
         //   cout <<to<<" "<<dd[to]<<endl;
            if (!dd[to])
            {
             //   cout <<to;
                dd[to]=1;
                q.push(to);
            }
        }

    }
    return 0;
}
ll n;
bool check1(vector<ll>& nw  )
{

    for (int i=1;i<=n;i++)
    {
      //  cout <<a[i]<<" "<<b[i]<<endl;
        if (check(a[i],b[i],nw)==0)
        {
           // cout <<i<<endl;
            return 0;
        }
    }
    return 1;
}
int main()
{
    // freopen("test.txt","r",stdin);
    // freopen("CHEMIST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   cin>>n;
   for (int i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   for (int i=1;i<=n;i++) cin>>b[i] ;
   vector<ll> necessery ;
   ll ans=0;
    for (int i=50;i>=1;i--)
    {
        auto nw=necessery;
        for (int j=1;j<i;j++) nw.pb(j);
        if (check1(nw)) continue;
      //  cout <<i<<endl;
        necessery.pb(i);
        ans=ans+(1ll<<i);

    }
    if (check1(necessery))cout <<ans;
    else cout <<-1;


}


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

const int N=200010;
int n,m,a[N];
int mmp[N<<1],*cnt=mmp+N;
int val[N<<2],sum[N<<2];

void build(int o,int l,int r)
{
    if(l==r){val[o]=1;return;}
    int mid=(l+r)/2;
    build(o<<1,l,mid);
    build(o<<1|1,mid+1,r);
    val[o]=val[o<<1]+val[o<<1|1];
}

void update(int o,int l,int r,int k,int x)
{
    if(k<=0||k>n) return;
    if(l==r)
    {
        sum[o]+=x;
        if(sum[o]==0) val[o]=1;
        else val[o]=0;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid) update(o<<1,l,mid,k,x);
    else update(o<<1|1,mid+1,r,k,x);
    val[o]=val[o<<1]+val[o<<1|1];
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++) cnt[a[i]]++;
    build(1,1,n);
    int p,x;
    for(int i=1;i<=n;i++)
        for(int j=0;j<cnt[i];j++)
            update(1,1,n,i-j,1);
    while(m--)
    {
        scanf("%d%d",&p,&x);
        if(a[p]>0&&a[p]<=n) update(1,1,n,a[p]-cnt[a[p]]+1,-1);
        cnt[a[p]]--;a[p]=x;cnt[a[p]]++;
        if(a[p]>0&&a[p]<=n) update(1,1,n,a[p]-cnt[a[p]]+1,1);
        printf("%d\n",val[1]);
    }
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N;
	ll K;
	cin >> N >> K;

	vector<ll> x(N + 1);
	repn(i, N) cin >> x[i];

	ll ans = 0;
	repn(i, N) ans += min(x[i], K - x[i]);

	cout << ans*2;

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2100;
#define mod 1000000007
int i,j,k,n,m,x,y,t;
ll fac[N*N],inv[N*N],f[N][N];
ll c(int x,int y){ return fac[x]*inv[y]%mod*inv[x-y]%mod; }
int read(){ int x=0,f=1;char ch=getchar(); for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f; for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0'; return x*f; }
int main(){
	n=read();k=read();f[n][n]=1;
	if (k==1) {printf("1\n");return 0;}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N*N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N*N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N*N;i++) inv[i]=inv[i-1]*(inv[i]+mod)%mod;
	for (int i=n;i>=0;i--) for (int j=i;j>=0;j--){ f[i][j]=(f[i][j]+f[i+1][j])%mod; if (i>j) f[i][j]=(f[i][j]+f[i][j+1]*c((n-j)*k-(i-j)-1,k-2))%mod; }
	printf("%lld\n",f[0][0]*fac[n]%mod);
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}


const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
        // 1 2 3 4 5 6 7 8 9
int f[] = {2,5,5,4,5,6,3,7,6};

int dp[10005]; // dp[i]:=マッチをi個使うときの桁数の最大

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n,m;
  cin>>n>>m;
  vi a(m);
  rep(i,m) cin>>a[i];
  vsort(a);
  
  rep(i,m) {
    dp[f[a[i]-1]]=1;
  }
  rep(i,n+1){
    rep(j,m) {
      if(dp[max(0,i-f[a[j]-1])]==0) continue;
      chmax(dp[i],dp[max(0,i-f[a[j]-1])]+1);
    }
  }
  
  string ans="";
  int remain=dp[n];
  int match=n;
  while(match>0){
    for(int i=m-1; i>=0; i--){
      if(remain==1){
        if(f[a[i]-1]==match){
          ans+='0'+a[i];
          match-=f[a[i]-1];
          remain--;
          break;
        }
      }
      else if(dp[match-f[a[i]-1]]==remain-1){
        ans+='0'+a[i];
        match-=f[a[i]-1];
        remain--;
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
bool f(int a){
    if(a==1)    return false;
    else if(a==2 || a==3)   return true;
    else{
        for(int i=2; i<=sqrt(a); i++){
            if(a%i==0)  return false;
        }
        return true;
    }
}
int main(){
    ios::sync_with_stdio(false);
    int n;
    int count=0;
    cin>>n;
    while(n--){
        int a;
        cin>>a;
        if(f(a))    count++;
    }
    cout<<count<<endl;
    return 0;
}


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

int main() {
	int N = 0;
	int L = 0;
	cin >> N >> L;
	vector<string> a(N+1);
	rep(i, N) {
		cin >> a.at(i);
	}
	a.at(N) = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	rep(j, N) {
		rep(i, N) {
			if (a.at(i).compare(a.at(i+1)) > 0) {
				swap(a.at(i), a.at(i+1));
			}
		}
	}
	string str;
	rep(i, N) { 
		str = str + a.at(i) ;
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ld H;
    cin>>H;
    
    
    ll t=1;
    while(H){
        H=floor(H/2);
        t*=2;
    }
    cout<<t-1;
    //cout<<fixed<<setprecision(15)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - . (Single Dot)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 1000;
const int MAX_XN = MAX_N * 2 + MAX_M + 1;
const int MAX_YN = MAX_M * 2 + MAX_N + 1;
const int dxs[] = { 0, 1, 0, -1 }, dys[] = { 1, 0, -1, 0 };

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;
typedef queue<pii> qpii;

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N];
int ds[MAX_M], es[MAX_M], fs[MAX_M];
int xs[MAX_XN], ys[MAX_YN];
bool ls[MAX_XN][MAX_YN][4], used[MAX_XN][MAX_YN];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  int xn = 0, yn = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", as + i, bs + i, cs + i);
    xs[xn++] = as[i], xs[xn++] = bs[i], ys[yn++] = cs[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", ds + i, es + i, fs + i);
    xs[xn++] = ds[i], ys[yn++] = es[i], ys[yn++] = fs[i];
  }
  xs[xn++] = ys[yn++] = 0;

  sort(xs, xs + xn);
  sort(ys, ys + yn);
  xn = unique(xs, xs + xn) - xs;
  yn = unique(ys, ys + yn) - ys;
  //printf("xn=%d, yn=%d\n", xn, yn);

  for (int i = 0; i < n; i++) {
    int x0 = lower_bound(xs, xs + xn, as[i]) - xs;
    int x1 = lower_bound(xs, xs + xn, bs[i]) - xs;
    int y = lower_bound(ys, ys + yn, cs[i]) - ys;
    for (int x = x0; x < x1; x++) {
      ls[x][y][2] = true;
      if (y > 0) ls[x][y - 1][0] = true;
    }
  }

  for (int i = 0; i < m; i++) {
    int x = lower_bound(xs, xs + xn, ds[i]) - xs;
    int y0 = lower_bound(ys, ys + yn, es[i]) - ys;
    int y1 = lower_bound(ys, ys + yn, fs[i]) - ys;
    for (int y = y0; y < y1; y++) {
      ls[x][y][3] = true;
      if (x > 0) ls[x - 1][y][1] = true;
    }
  }

  int sx = lower_bound(xs, xs + xn, 0) - xs;
  int sy = lower_bound(ys, ys + yn, 0) - ys;
  used[sx][sy] = true;
  ll s = (ll)(xs[sx + 1] - xs[sx]) * (ys[sy + 1] - ys[sy]);

  qpii q;
  q.push(pii(sx, sy));

  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int ux = u.first, uy = u.second;

    for (int di = 0; di < 4; di++)
      if (! ls[ux][uy][di]) {
	int vx = ux + dxs[di], vy = uy + dys[di];
	if (vx < 0 || vx >= xn - 1 || vy < 0 || vy >= yn - 1) {
	  puts("INF");
	  return 0;
	}

	if (! used[vx][vy]) {
	  used[vx][vy] = true;
	  s += (ll)(xs[vx + 1] - xs[vx]) * (ys[vy + 1] - ys[vy]);
	  q.push(pii(vx, vy));
	}
      }
  }

  printf("%lld\n", s);
  return 0;
}


Measured memory_bytes: 44476
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#ifdef XLor
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 200000 + 5;

int n, x, d;

int main() {
  cin >> n >> x >> d;
  if (d == 0) {
    if (x == 0) cout << 1 << endl;
    else cout << 1 + n << endl;
    return 0;
  } else if (d < 0) {
    d = -d, x = -x;
  }
  vector<tuple<ll,ll,ll> > all;
  for (int i = 0; i <= n; i++) {
    ll st = 1ll * i * (i - 1) / 2;
    ll ed = 1ll * i * (n - 1 + n - i) / 2;
    ll fi = 1ll * i * x;
    st += fi / d; ed += fi / d;
    all.emplace_back(fi % d, st, ed);
  }
  sort(begin(all), end(all));
  ll ans = 0;
  for (int i = 0, j; i <= n; i = j) {
    j = i;
    while (j <= n && get<0>(all[i]) == get<0>(all[j])) {
      j++;
    }
    for (int p = i, q; p < j; p = q) {
      q = p;
      ll ri = get<2>(all[p]);
      while (q < j && get<1>(all[q]) <= ri) {
        ri = max(ri, get<2>(all[q])); q++;
      }
      ans += ri - get<1>(all[p]) + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

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

    int k,x;
    cin >> x >> k;
    for (int i = max(k - x + 1,-1000000); i <= min(k + x - 1, 1000000); i++) {
        cout << i << " " << " \n"[i == min(k + x - 1, 1000000)];
    }
}

int main(int argc, char *argv[]){

    /* Regular */
    int case_num = 1;
    if (argc > 1 && stoi(argv[1])) cin >> case_num;
    REP(case_no, case_num) {
      cerr << endl << "case " << case_no + 1 << endl;
      solve();
    }

    // /* AOJ */
    // solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
ac, wa, tle, re = 0, 0, 0, 0
for i in range(N):
    S = input()
    if S == "AC" :
        ac += 1
    elif S == "WA":
        wa += 1
    elif S == "RE":
        re += 1
    else:
        tle += 1

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)


Measured memory_bytes: 9120
Option Explicit On
Option Strict On

Module Module1

    Sub Main()

        Dim N As Integer = CInt(Console.ReadLine())
        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim ret As String = "APPROVED"

        For i As Integer = 0 To tmp.Length - 1
            Dim w As Integer = CInt(tmp(i))
            If w Mod 2 = 0 Then
                If w Mod 3 <> 0 AndAlso w Mod 5 <> 0 Then
                    ret = "DENIED"
                End If
            End If
        Next

        Console.WriteLine(ret)

    End Sub

End Module



Measured memory_bytes: 13536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using i128 = __int128_t;
int main() {
  ll x, k, d; cin >> x >> k >> d;
  i128 X = abs(x);
  while (k) {
    ll k2 = (k + 1) / 2;
    X = abs(X - i128(k2) * d);
    k /= 2;
  }
  cout << ll(X) << endl;
}


Measured memory_bytes: 3600
time = [[int(input())] for _ in range(5)]

for i in range(5):
  if time[i][0]%10!=0:
    time[i].append(time[i][0]%10)
  else:
    time[i].append(10)

time = sorted(time, key = lambda time:time[1])
ans = 0
import math
for i in range(1,5):
  ans = ans + math.ceil(time[i][0]/10)*10
  
ans = ans + time[0][0]
print(ans)

Measured memory_bytes: 3188
fun main(args: Array<String>) = IO().exec {
    val n = int()
    for (i in n) {
        val acc = mutableListOf<Int>()
        for (j in i+1 until n) {
            val xor = i.xor(j)
            val k = Integer.numberOfTrailingZeros(xor)
            acc.add(k+1)
        }
        println(acc.joinToString(" "))
    }
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 38312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a=0,i,n;
  string s;
  cin >> n >> s;
  int ans=0;
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      a++;
    }
  }
  for(i=0;i<a;i++){
    if(s[i]=='W'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3748
import collections
n=int(input())
A=list(map(int,input().split()))
if A[0]!=0:
  print(0)
  exit()
mod=998244353
C=[0]*n
for i in range(n):
  C[A[i]]+=1
ans=1
if C[0]!=1:
  print(0)
  exit()
for i in range(n-1):
  ans=ans*pow(C[i],C[i+1],mod)%mod
print(ans)

Measured memory_bytes: 14780
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    int a,b;
    cin>>a>>b;
    vector<string> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    rep(i,a){
        cout<<vec.at(i);
    }
    cout<<endl;
}



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)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const ll MOD = 1e9+7;
const int inf = 1e8;

int main() {
	int N;
	cin>>N;
	ll ans=1;
	rep1(i,N+1){
		ans =ans*i%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
main=print =<< solve <$> getLine

solve x@('T':xr) = sol (length $ takeWhile (=='T') x) (dropWhile (=='T') xr)
solve x = sol 0 x

sol a "" = a
sol a x
    | ns==0 || nt==0 = a + length x
    | ns == nt  = sol a xx
    | ns < nt   = sol (a+nt-ns) xx
    | otherwise = sol a ((replicate (ns-nt) 'S')++xx)
    where
        (xs,xr) = span (=='S') x
        (xt,xx) = span (=='T') xr
        ns = length xs
        nt = length xt

Measured memory_bytes: 15740