akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<vector<ll>> pascals_triangle(int n) {
    vector<vector<ll>> combi(n + 1, vector<ll>(n + 1));
    REP(i, n + 1) REP(j, i + 1) {
        if (j == 0 || j == i) combi[i][j] = 1LL;
        else combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
    }
    return combi;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

void solve() {
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll l = lcm(n, m);
    ll gs = l / n;
    ll gt = l / m;
    ll a = 0;
    ll b = 0;
    while (a < n and b < m) {
        if (gs * a + 1 == gt * b + 1) {
            if (s[a] != t[b]) {
                cout << -1 << endl;
                return;
            }
            a++;
            b++;
        } else if (gs * a + 1 > gt * b + 1) {
            b++;
        } else {
            a++;
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
using namespace std;
const int N=300005;
int n,L,ans=1,cnt,ok;
int x[N],t[N];
bool l[N],r[N];
int main(){
	n=read();L=read()<<1;
	for(int i=1;i<=n;i++)x[i]=read()<<1;
	for(int i=1;i<=n;i++)t[i]=read();
	for(int i=1;i<=n;i++){
		int v=t[i]%L;
//		ans+=t[i]/L+(t[i]%L!=0);
		ans+=(1ll*t[i]+L-1)/L;
		l[i]=(0<v&&v<=x[i]);
		r[i]=(0<v&&v<=L-x[i]);
	}
	for(int i=1;i<n;i++)
		if(cnt&&r[i]){if(l[i])++ok;--ans;--cnt;}
		else if(l[i]) ++cnt;
		else if(r[i]&&ok) --ok,++cnt;
	if(r[n])ans--;
	printf("%lld\n",1ll*ans*L);
	return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

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

		int x = 800*N;
		int y = 200*(N/15);
		System.out.println(x-y);
	}
}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		double N = sc.nextDouble();
		
		for (double i = N; i >= 0; i--) {
			double root = Math.sqrt(i);
			if (root % 1 == 0) {
				System.out.println((int)i);
				return;
			}
		}
		
	}
}


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

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

	int n,d,t;
	vector <int> x[11];
	int res = 0;

	cin >> n >> d;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			cin >> t;
			x[i].push_back(t);
		}
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int val = 0;
			for(int k=0;k<d;k++)
			{
				val += ((x[i][k] - x[j][k])*(x[i][k] - x[j][k]));
			}
			int a = sqrt(val);
			if(a*a==val)
			{
				res++;
			}
		}
	}

	cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int solve(){
	ll a ;
	string b ;
	cin >> a >> b ;
	ll c = (b.at(0)-'0')*100+(b.at(2)-'0')*10+b.at(3)-'0' ;
	cout << a*c/100 << endl ;
    return 0 ;
}

int main(){
	solve() ;
}

Measured memory_bytes: 3588
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	
	int n;
	int[][] es;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		es = new int[n][n];
		for (int[] a: es) fill(a, INF);
		for (int i=0;i<n;i++) es[i][i] = 0;
		for (int i=0;i<n;i++) {
			int r = sc.nextInt()-1, k = sc.nextInt();
			for (int j=0;j<k;j++) {
				int t = sc.nextInt()-1;
				es[r][t] = 1;
			}
		}
		
		for (int k=0;k<n;k++) for (int i=0;i<n;i++) for (int j=0;j<n;j++) {
			es[i][j] = min(es[i][j], es[i][k] + es[k][j]);
		}
		int p = sc.nextInt();
		for (int i=0;i<p;i++) {
			int s = sc.nextInt()-1, d = sc.nextInt()-1, v = sc.nextInt();
			System.out.println((es[s][d] + 1 <= v ? es[s][d] + 1 : "NA"));
		}
	}
	

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 26200
use std::str::FromStr;

#[derive(Default)]
struct Conf {
    antennas: [u8; 5],
    k: u8,
}

impl Conf {
    fn new() -> Conf {
        Conf::default()
    }
}

fn parse_line(buf: &mut String) -> u8 {
    buf.clear();
    std::io::stdin().read_line(buf).unwrap();
    let buf = buf.trim();
    u8::from_str(buf).unwrap()
}

fn parse() -> Conf {
    let mut conf  = Conf::new();
    let mut buf = String::new();

    for i in 0..5 {
        conf.antennas[i] = parse_line(&mut buf);
    }
    conf.k = parse_line(&mut buf);

    conf
}

fn main() {
    let conf = parse();

    let min = conf.antennas.iter().min().unwrap();
    let max = conf.antennas.iter().max().unwrap();

    if conf.k < (max - min) {
        println!(":(");
    } else {
        println!("Yay!");
    }

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
	int n,i,j;
	char trumps[4][13];
	char mark[4]={'S','H','C','D'};
	
	/*?????????*/
	memset(trumps,0,4*13);
	
	/*????????????*/
	scanf("%d\n",&n);
	
	for(i=0;i<n;i++){
		int num, j;
		char pict;
		scanf("%c %d\n",&pict,&num);
		for(j=0;pict!=mark[j];j++);
		trumps[j][--num]=1;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(!trumps[i][j])
			printf("%c %d\n",mark[i],j+1);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int A(int x) {
	return x * 2;
}
int B(int x,int y) {
	return x + y;
}
int main() {
	int n, k,a=1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		if (a < k) {
			a = A(a);
		}
		else {
			a = B(a, k);
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
s = input()
n = int(input())

def p (a:int,b:int):
    print (s[a:b+1])

def rev (a:int,b:int):
    tmp = s[a:b+1]
    return s[:a]+tmp[::-1]+s[b+1:]

def rep (a:int,b:int,p:str):
    return s[:a]+p+s[b+1:]

for _ in range(n):
    i = input().split()
    if i[0] == "print":
        p (int(i[1]),int(i[2]))
    elif i[0] == "reverse":
        s = rev (int(i[1]),int(i[2]))
    else:
        s = rep (int(i[1]),int(i[2]),i[3])



Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int A[2<<17];
main()
{
	cin>>N;
	long ans=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	sort(A,A+N);
	reverse(A,A+N);
	ans+=A[0];
	int rest=N-2;
	for(int i=1;i<N;i++)
	{
		if(rest>=2)
		{
			ans+=A[i]*2;
			rest-=2;
		}
		else if(rest==1)
		{
			ans+=A[i];
			rest=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4376
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;

    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    string a;
    cin>>a;
    for(i=0; i<a.size(); i++){
        if(a[i]=='W'){
            s+=(i-p);
            p++;
        }
    }
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 3752
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]

    def add_edge(self, fr, to, cap):
        #[to, cap, rev]
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.g[fr].append(forward)
        self.g[to].append(backward)

    def add_bidirectional_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.g[v1].append(edge1)
        self.g[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.n
        deq = deque([s])
        level[s] = 0
        g = self.g
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in g[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**30
        g = self.g
        while self.bfs(s, t):
            self.it = list(map(iter, self.g))
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

ans = []
while 1:
    m, n = MAP()
    if m == 0:
        break
    D = Dinic(m+n+2)
    B = LIST()
    while len(B) < m:
        B += LIST()

    R = LIST()
    while len(R) < n:
        R += LIST()
    s = m+n
    t = s+1

    for i in range(m):
        D.add_edge(s, i, 1)

    for i in range(n):
        D.add_edge(m+i, t, 1)

    for i, x in enumerate(B):
        for j, y in enumerate(R):
            if gcd(x, y) != 1:
                D.add_edge(i, m+j, 1)

    ans.append(D.flow(s, t))
print(*ans, sep="\n")



Measured memory_bytes: 40200
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int x,y;
	if(c%b!=0){
		x=(c/b)+1;
	}
	else{
		x=c/b;
	}
	if(a%d!=0){
		y=(a/d)+1;
	}
	else{
		y=a/d;
	}
	if(x<=y){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			var n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		List<Team> L=new List<Team>();
		for(int i=0;i<N;i++){
			L.Add(new Team(ria()));
		}
		
		L.Sort((x,y)=>x.A>y.A?-1:(x.A<y.A?1:(x.P>y.P?1:(x.P<y.P?-1:0))));
		
		List<Team> Pass=new List<Team>();
		Dictionary<int,int> D=new Dictionary<int,int>();
		
		for(int i=0;i<L.Count;i++){
			Team A=L[i];
			if(Pass.Count<10){
				if(!D.ContainsKey(A.U))D.Add(A.U,0);
				if(D[A.U]<3){
					Pass.Add(A);
					D[A.U]++;
				}
			}else if(Pass.Count<20){
				if(!D.ContainsKey(A.U))D.Add(A.U,0);
				if(D[A.U]<2){
					Pass.Add(A);
					D[A.U]++;
				}
			}else if(Pass.Count<26){
				if(!D.ContainsKey(A.U))D.Add(A.U,0);
				if(D[A.U]<1){
					Pass.Add(A);
					D[A.U]++;
				}
			}
		}
		
		
		for(int i=0;i<Pass.Count;i++){
			Console.WriteLine(Pass[i].I);
		}
	}
	int N;
	public Sol(int n){
		N=n;
	}

	class Team{
		public int I;
		public int U;
		public int A;
		public int P;
		public Team(int[] in_){
			I=in_[0];
			U=in_[1];
			A=in_[2];
			P=in_[3];
		}
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 6272
s= input()
q = int(input())
insts = [input().split() for _ in range(q)]

for inst in insts:
    a,b = int(inst[1]), int(inst[2]) + 1
    if inst[0] == "replace":
        p = inst[3]
        s = s[:a] + p + s[b:]
    elif inst[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif inst[0] == "print":
        print(s[a:b])




Measured memory_bytes: 5620
//package src.com.jetman.atcoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;


    private void slove() {

        int n = sc.nextInt();

        long[][] a = new long[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextLong();
            a[i][1] = sc.nextLong();
        }

        long ans = Long.MIN_VALUE;
        for(int k=0;k<(1<<2);k++)
        {
            long mi=Long.MAX_VALUE;
            long ma=Long.MIN_VALUE;
            for(int i=0;i<n;i++)
            {
                long tmp=0;
                for(int j=0;j<2;j++)
                    if((k&(1<<j)) > 0) tmp+=a[i][j];
                    else tmp-=a[i][j];
                ma=Math.max(ma,tmp);
                mi=Math.min(mi,tmp);
            }
            ans=Math.max(ans,ma-mi);
        }

        System.out.println(ans);





    }

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


Measured memory_bytes: 66680
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N; cin >> N;
  N%=10;
  if(N==3) cout << "bon" <<endl;
  else if(N==0 || N==1 || N==6 || N==8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}


Measured memory_bytes: 3620
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: u64 = 1e9 as u64 + 7;

fn main() {
    let n: u32 = read();
    let a: Vec<u64> = read_vec();
    let mut sum: u64 = 0;

    for i in 0..60 as usize
    {
        // 最下位ビットが1であるAの数
        let mut ones = 0;
        // 最下位ビットが0であるAの数
        let mut zeros = 0;
        for j in 0..n as usize
        {
            if (a[j] >> i) & 1 == 1 { ones += 1; } else { zeros += 1; }
        }

        let per = (1u64 << i) % MOD;
        sum += ones * zeros % MOD * per % MOD;
        sum %= MOD;
    }

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


Measured memory_bytes: 15608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long ans = 0;
    for(long b = 1; b <= n; b++) {
      long r = n % b;
      long t = n / b;
      ans += (t * Math.max(0, (b - k)));
      ans += Math.max(0, r - k + 1);
    }
    if(k == 0) ans -= n;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();	
      int r = sc.nextInt();
      int D = sc.nextInt();
      int x = sc.nextInt();
      for(int i = 0; i < 10; i++){
        x = r * x - D;
        System.out.println(x);
      }
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

const ll MAX_V = 50;
const ll MAX_S = MAX_V*50;
 
int main() {
    ll n, m, S;
    cin >> n >> m >> S;  
    chmin(S, MAX_S);  
    
    vector<vector<pair<ll, P>>> G(n);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;  v--;
        G[u].pb(make_pair(v, make_pair(a, b)));
        G[v].pb(make_pair(u, make_pair(a, b)));
    }

    vl c(n), d(n);
    rep(i, n) {
        cin >> c[i] >> d[i];
    }

    // 拡張ダイクストラ法。計算量はO((V+E)*log(V))
    vvl dp(MAX_V, vl(MAX_S+10, INF));  // dp[v][i] : 頂点vに所持金i円でいる状態になるのにかかる時間の最小値
    const ll sv = 0;  // 始点となる頂点
    dp[sv][S] = 0;
    priority_queue<pair<ll, P>, vector<pair<ll, P>>, greater<pair<ll, P>>> prQ;
    prQ.push(make_pair(dp[sv][S], make_pair(sv, S)));  // (頂点vまでの所持金がiのときの時間t, (いまいる頂点v, 所持金i))
    while(!prQ.empty()) {
        auto p1 = prQ.top();
        prQ.pop();
        ll t = p1.first;  // 頂点vまでの所持金がiのときの時間t
        ll v = p1.second.first;  // いまいる頂点v
        ll i = p1.second.second;  // 所持金i
        if(dp[v][i] < t) {
            continue;
        }
        ll ni = min(MAX_S, i + c[v]);
        if(dp[v][ni] > dp[v][i] + d[v]) {
            dp[v][ni] = dp[v][i] + d[v];
            prQ.push(make_pair(dp[v][ni], make_pair(v, ni)));
        }
        for(auto p2 : G[v]) {
            ll u = p2.first;
            ll a = p2.second.first;
            ll b = p2.second.second;
            if(i < a) {
                continue;
            }
            if(dp[u][i-a] > dp[v][i] + b) {
                dp[u][i-a] = dp[v][i] + b;
                prQ.push(make_pair(dp[u][i-a], make_pair(u, i-a)));
            }
        }
    }

    vl ans(n, INF);
    exrep(i, 1, n-1) {
        rep(j, MAX_S+10) {
            chmin(ans[i], dp[i][j]);
        }
    }

    exrep(i, 1, n-1) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 7344
#include <iostream>
using namespace std;
int main(void){
    int time;
    cin >> time;
    int h,m,s;
    h = time / 3600;
    time = time - 3600 * h;
    m = time / 60;
    time = time - 60 * m;
    s = time;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}



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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<bool> clear(N+1, false);
  vector<int>  miss(N+1, false);
  
  for(int i=0; i<M; i++){
    int p;
    string s;
    cin >> p >> s;

    if(!clear[p])
    {
      if (s=="WA") ++miss[p];
    }
    
    if(s == "AC") clear[p] = true;
  }
  
  int nClear = 0;
  int nMiss  = 0;
  
  for(int i=1; i<=N; i++){
    if (clear[i]) 
    {
      nClear += 1;
      nMiss  += miss[i];
    }
  }
  
  cout << nClear << " " << nMiss;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  private static int N;
  private static int W;
  private static int[] weight;
  private static int[] value;
  private static int[][] dp;

  private static int calc() {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= W; j++) {
        if (j < weight[i]) {
          dp[i][j] = dp[i - 1][j];
        } else {
          dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - weight[i]] + value[i]);
        }
      }
    }

    return dp[N][W];
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    W = in.nextInt();

    value = new int[N + 1];
    weight = new int[N + 1];

    // init
    value[0] = 0;
    weight[0] = 0;
    for (int i = 1; i <= N; i++) {
      value[i] = in.nextInt();
      weight[i] = in.nextInt();
    }

    dp = new int[N + 1][W + 1];
    for (int i = 0; i <= N; i++) {
      dp[i][0] = 0;
    }
    for (int j = 0; j <= W; j++) {
      dp[0][j] = 0;
    }

    int result = calc();
    System.out.println(result);
  }
}

Measured memory_bytes: 30848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax=200010;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	char c[3];
	int price = 700;
	for(int i=0;i < 3;i++){
		cin >> c[i];
		if(c[i] == 'o') price += 100;
	}
	cout << price << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

bit = 1
for a in A:
    bit |= (bit<<a)

S = sum(A)
for i in range((S+1)//2, S+1):
    if bit&(1<<i):
        print(i)
        break

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

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

using namespace std;

struct N {
	int64_t p;
	int64_t i;
};

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

	int n; cin >> n;
	vector<N> ps(n);
	FOR_LT(i, 0, n) {
		cin >> ps[i].p;
		ps[i].i = i;
	}

	sort(ps.begin(), ps.end(), [](auto& lhs, auto& rhs) {
		return lhs.p > rhs.p;
	});

	set<int> used;
	int64_t sum = 0;
	for (auto& p : ps) {
		if (used.size() == 0) {
			used.insert(p.i);
			continue;
		}
		if (used.size() == 1) {
			int64_t i = p.i;
			int64_t j = *used.begin();
			if (j < i) swap(i, j);

			sum += p.p * (i + 1) * (n - j);

			used.insert(p.i);
			continue;
		}

		auto itu = used.lower_bound(p.i);
		if (itu == used.begin()) {
			int64_t i = *itu;
			itu++;
			int64_t j = *itu;

			sum += p.p * (p.i + 1) * (j - i);
		}
		else if (itu == used.end()) {
			auto itl = itu;
			itl--;
			int64_t j = *itl;
			itl--;
			int64_t i = *itl;

			sum += p.p * (n - p.i) * (j - i);
		}
		else {
			auto itl = itu;
			itl--;

			int64_t iu = *itu;
			int64_t ju = n;
			itu++;
			if (itu != used.end()) {
				ju = *itu;
			}

			int64_t il = *itl;
			int64_t jl = -1;
			if (itl != used.begin()) {
				itl--;
				jl = *itl;
			}

			sum += p.p * (p.i - il) * (ju - iu);
			sum += p.p * (iu - p.i) * (il - jl);
		}

		used.insert(p.i);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;

signed main()
{
	//FILEIO
 	//start_routine
	
	int tests = 1;
	//cin>>tests;

	while(tests--)
	{
		string s;
		cin>>s;
		int i;
		char c[5] = {'K', 'I', 'H', 'B', 'R'};

		int p = 0, ind = 0;
		if(s.size() > 9) return cout<<"NO\n",0;

		int ans  = 1;

		fr(i,0,s.size())
		{
			if(s[i] == 'A') 
			{
				if(i > 0 && s[i-1] =='A') {ans = 0; break;}
				if(i+1<s.size() && s[i + 1] == 'A'){ans = 0; break;}
				continue;
			}
			else if(s[i] != c[p])  {ans = 0; break;}
			if(s[i] == 'I' && (s[i - 1] == 'A' || s[i + 1] == 'A') ) {ans = 0; break;}
			p++;
		}
		if(p!=5) ans = 0;

		if (ans == 0)
		{
			cout<<"NO\n";
		}
		else cout<<"YES\n";
	}

 	//end_routine
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'



int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    string s;cin>>s;
    ll n=s.size();
    if(n%2==0) s+='g';

    ll ans=0;
    for(ll i=1;i<=n;i+=2)
    {
        ll x=0,y=0;
        if(s[i]=='g')
            x++;
        if(s[i+1]=='p')
            x--;

        if(s[i]=='p')
            y--;
        if(s[i+1]=='g')
            y++;
        ans+=max(x,y);
    }
    cout<<ans;

    #ifdef APNA_IO
        end_routine();
    #endif
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();

		for (int i = 0; i < s.length(); i++) {
			int c = (int)(s.charAt(i) - 'a');
			if (i == s.length() - 1) {
				c = (c + k) % 26;
			} else if (c != 0 && 26 - c <= k) {
				k -= 26 - c;
				c = 0;
			}
			System.out.printf("%c", (char)c + 'a');
		}
		System.out.println();
	}
}


Measured memory_bytes: 47304
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];
  map<Int, Int> r;
  for(Int i=0;i<n;i++) r[d[i]]=i;

  vector<vector<Int> > G(n);
  auto NO=[](){cout<<-1<<endl;exit(0);};
  auto add_edge=[&](Int x,Int y){
		  G[x].emplace_back(y);
		  G[y].emplace_back(x);
		};

  using P = pair<Int, Int>;
  priority_queue<P> pq;
  vector<Int> s(n,1),used(n,0);
  for(Int i=0;i<n;i++) pq.emplace(d[i],i);
  
  while(pq.size()>1u){
    Int x,v;
    tie(x,v)=pq.top();pq.pop();
    
    Int nd=x-(n-s[v])+s[v];
    if(!r.count(nd)) NO();
    
    Int u=r[nd];    
    if(used[u]) NO();
    
    add_edge(v,u);
    s[u]+=s[v];    
    used[v]=1;
  }

  vector<Int> sz(n,1);
  vector<Int> dp1(n,0),dp2(n,0);
  function<Int(Int, Int)> dfs1=
    [&](Int v,Int p){
      for(Int u:G[v]){
	if(u==p) continue;
	dp1[v]+=dfs1(u,v);
	dp1[v]+=sz[u];
	sz[v]+=sz[u];
      }
      return dp1[v];
    };
  
  function<void(Int, Int, Int)> dfs2=
    [&](Int v,Int p,Int d){
      Int sum=0;
      dp2[v]=dp1[v]+d;
      for(Int u:G[v])
	if(u!=p) sum+=dp1[u]+sz[u];
      for(Int u:G[v])
	if(u!=p) dfs2(u,v,d+sum-(dp1[u]+sz[u])+(n-sz[u]));
    };
  
  dfs1(0,-1);
  dfs2(0,-1,0);

  //for(Int i=0;i<n;i++) cout<<d[i]<<" "<<dp2[i]<<endl;
  for(Int i=0;i<n;i++) if(d[i]!=dp2[i]) NO();
  
  for(Int v=0;v<n;v++)
    for(Int u:G[v]) if(v<u) cout<<v+1<<" "<<u+1<<endl;
  return 0;
}


Measured memory_bytes: 28656
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >>b;

    if (a % 2 != 0 && b % 2 != 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if ( a[a.length()-1] == b[0] && b[b.length()-1] == c[0] ) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
t_won=0
h_won=0
for _ in range(n):
    t_wd,h_wd = input().split()
    if   t_wd > h_wd: t_won += 1
    elif t_wd < h_wd: h_won += 1
print(t_won*3 + (n-t_won-h_won), h_won*3 + (n-t_won-h_won))


Measured memory_bytes: 5592
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(n) for(ll i=0;i<n;i++)
#define Pll std::pair<ll, ll>
#define all(v) v.begin(), v.end()

typedef long long ll;

int main(){
    ll length = 0, n, k;
    scanf("%lld %lld", &n, &k);
    std::vector<Pll> v(n);
    rep(n) scanf("%lld %lld", &v[i].first, &v[i].second);
    std::sort(all(v));
    for(Pll p: v){
        if(length < k && k <= length+p.second){
            printf("%lld\n", p.first);
            return 0;
        }
        length += p.second;
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,z;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	if(x>=c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h> /* for atof() */
#include<ctype.h>
#define NUMBER '0'
int getop(char []);
void push(double);
double pop(void);
double value[100];
int sp = 0;
char buf[100];
int bufp = 0;

int getch(void);
void ungetch(int);
main()
{
    int type;
    double op2;
    char s[100];
    while ((type = getop(s)) != EOF) {
        switch (type) {
            case NUMBER:
                push(atof(s));
                break;
            case '+':
                push(pop() + pop());
                break;
            case '*':
                push(pop() * pop());
                break;
            case '-':
                op2 = pop();
                push(pop() - op2);
                break; 
            case '\n':
                printf("%.8g\n", pop());
                break;
            default:
                break;
        }
    }
}
void push(double f)
{
    if(sp < 100)
        value[sp++]=f;
    else
        printf("error\n");
}

double pop(void)
{
    if(sp>0)
        return value[--sp];
    else
    {
        printf("error\n");
        return 0.0;
    }
}

int getop(char s[])
{
    int i,c;

    while((s[0] = c = getch()) == ' ' || c =='\t')
        ;
    s[1] = '\0';
    
    i = 0;
    if(!isdigit(c) && c!='.' && c!='-')
        return c;

    if(c=='-')
        if(isdigit(c=getch()) || c == '.')
            s[++i]=c;
        else
        {
            if(c!=EOF)
                ungetch(c);
            return '-';
        }
    
    if(isdigit(c))
        while(isdigit(s[++i] =c =getch()))
            ;

    if(c=='.')
        while(isdigit(s[++i] = c=getch()))
            ;
    
    s[i] = '\0';
    if(c!=EOF)
        ungetch(c);
    return NUMBER;
}
int getch(void)
{
    return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c)
{
    if(bufp >= 100)
        printf("error");
    else
        buf[bufp++] = c;
}



Measured memory_bytes: 2076
A,B,C,X,Y=gets.split.map(&:to_i)
a=0
b=0
r=0
if C*2<A+B
    a=b=[X,Y].min
    r+=C*a*2
end
if C*2<A
    b+=X-a
    r+=(X-a)*C*2
    a=X
end
if C*2<B&&b<Y
    a+=Y-b
    a=X if a>X
    r+=(Y-b)*C*2
    b=Y
end
r+=(X-a)*A
r+=(Y-b)*B
puts r


Measured memory_bytes: 14304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize ("trapv")
using namespace std;

#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define DEBUG 1
#define cerr if (DEBUG) cerr
#define test cerr << "hi\n";

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<long long>(l, r)(rng)
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 300005
//#define MOD 998244353LL
#define MOD 1000000007LL

void solve() {
    long long ans = 0;
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        q.push(x);
    }
    for (int iter = 0; iter < m; iter++) {
        int x = q.top(); q.pop();
        x /= 2;
        q.push(x);
    }
    while (q.size()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    auto start_time = clock();
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
//    cin >> t;
    for (int no = 1; no <= t; no++) {
//        cout << "Case #" << no << ": ";
        solve();
    }

#ifdef LOCAL
    cerr << "TIME ELAPSED: " << double(clock() - start_time) / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 3896
#include<iostream>
using namespace std;
int main (){
  int n,i,j,r[200000];
  long long v,max=-1000000000,min=1000000000;

//get number
  cin>>n;
 
//get max1,2&min1,2
 for(i=0;i<n;i++){
    cin>>r[i];
  }
 
 min=r[0];

    for(i=1;i<n;i++){
      v=r[i]-min;
      if(v>=max){
	max=v;
      }
     if(r[i]<=min){
	min=r[i];
      }
    }

  cout<< max <<endl;

  return 0;
}

Measured memory_bytes: 3864
N, K = [int(i) for i in input().split()]
ans = []
A = [[]*2]*N
num = 0
for i in range(N):
    A[i] = [int(i) for i in input().split()]
A.sort()
i = 0
while num < K:
    num += A[i][1]
    i += 1

print(A[i-1][0])

Measured memory_bytes: 21652
list_32 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
K -= 1
print(list_32[K])

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

ll f(ll n){
    switch (n%4) {
        case 0:
            return n;
        case 1:
            return 1;
        case 2:
            return n+1;
        default:
            return 0;
    }
}

int main() {
    ll a,b;
    cin>>a>>b;
    
    ll ans=f(a-1)^f(b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let mut ans: i64 = 0;
    let mut black: i64 = 0;
    for i in s {
        match i {
            'W' => ans += black,
            _ => black += 1,
        }

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


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

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

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

int main(){
  double N;
  cin >> N;
  double k = 4 / N;
  for (int n = 1; n <= 3500; n++) {
    for (int w = 1; w <= 3500; w++)
    {
      double bunsi = n * w;
      double bunbo = k*n*w - w - n;
      double h = bunsi / bunbo;
      if(ceil(h) == (h) && h > 0 && h <= 3500)
      {
        cout << h << " " << n << " " << w <<  endl;
        return 0;
      }
    }

  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	int s[105];
	int w,e;
	w = 0,e = 0;
	for (int i = 1; i <= b; i++)
	{
		scanf("%d",&s[i]);
		if (s[i] < x) w++;
		else e++;
	}
	printf("%d",min(w,e));
}

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

#define MOD 1000000007
int main()
{
	ll h,w,i,j;
	cin>>h>>w;
	vector<string> str(h);
	for(i=0;i<h;i++)
	{
		cin>>str[i];
	}
	
	vector<ll> dp(w+1,0);
	dp[0]=1;
	for(i=0;i<h;i++)
	{
		if(str[i][0]=='#')
		{
			dp[0]=0;
		}
		for(j=1;j<w;j++)
		{
			if(str[i][j]=='.')
			{
				dp[j]+=dp[j-1];
				dp[j]%=MOD;
			}
			else
			{
				dp[j]=0;
			}
		}
	//	cout<<" "<<dp[i]<<endl;
	}
	cout<<dp[w-1];
	return 0;
	
}

Measured memory_bytes: 1280
while True:
    a = input().split()
    N = [int(i) for i in a]
    A,B,C,D = N
    if  (A or B or C or D) < 1 or (A or B or C or D) > 10:
        continue
    if A+B > C+D:
        print('Left')
    if A+B < C+D:
        print('Right')
    if A+B == C+D:
        print('Balanced')
    break

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int kaijo(int x)
{
    int ans = 1;
    rep(i, 1, x + 1) ans *= i;
    return ans;
}

string n_shin(int x, int n)
{
    string s;
    while (x > 0)
    {
        s += to_string(x % n + 1);
        x /= n;
    }
    while (s.size() < n)
    {
        s += '0';
    }
    s.reserve();
    //cout << s << endl;
    return s;
}

int main()
{
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    bool ans = true;
    rep(i, 0, n - 1)
    {
        if (a[i] == a[i + 1])
        {
            ans = false;
            break;
        }
    }
    Print(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define len(v) (int)(v).size()

using namespace std;

typedef pair<int,int>P;

class UF {
public:
    int sz; vector<int> par,nrank;
    UF(int node_size){
        sz = node_size; par.resize(sz),nrank.resize(sz,0);
        rep(i,sz) par[i] = i;
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(nrank[x] < nrank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(nrank[x] == nrank[y]) nrank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

const int MAX_N = 100005;

vector<int> x[MAX_N],y[MAX_N];

int main()
{
    int n,w,h;
    cin >> n >> h >> w;
    UF uf(n);
    bool hasi = true;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(a == 1 || a == h || b == 1 || b == w){
            hasi = false;
        }
        x[a-1].push_back(i), y[b-1].push_back(i);
    }
    rep(i,h){
        rep(j,len(x[i])-1){
            uf.unite(x[i][j],x[i][j+1]);
        }
    }
    rep(i,w){
        rep(j,len(y[i])-1){
            uf.unite(y[i][j],y[i][j+1]);
        }
    }
    set<int> st;
    rep(i,n){
        st.insert(uf.find(i));
    }
    if(len(st) == 1){
        cout << n-1 << "\n";
    }else{
        cout << n+len(st)-2+hasi << "\n";
    }
}



Measured memory_bytes: 11160
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d" @@ fun s ->
  let rec solve n an set =
    if IntSet.mem an set then n
    else solve (n + 1) (if an mod 2 = 0 then an / 2 else 3 * an + 1) (IntSet.add an set) in
  Printf.printf "%d" @@ solve 1 s IntSet.empty

Measured memory_bytes: 3860
main(){
  int i,j=2,k=0,n,r,s[78499];
  s[k++]=j++;
  for(;j<999984;j+=2){
    r=(int)sqrt(j)+1;
    for(i=3;i<r;i+=2)
      if(j%i==0){
	r=0;
	break;
      }
    if(r)
      s[k++]=j;
  }
  s[78498]=1000000;
  while(scanf("%d",&n)!=-1){
    for(i=0;s[i]<=n;i++);
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 588