akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1;
typedef long long ll;

int n,m,ans;
int a[maxn];

int main()
{
	int i,j,k;
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	ll maxv=(n-1)*b+a,minv=(n-1)*a+b;
	ll ans=maxv-minv+1;
	if(ans<0) ans=0;
	printf("%lld",ans);
	
	return 0;
}


Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

b = ns()
m = dict()
m["A"] = "T"
m["T"] = "A"
m["G"] = "C"
m["C"] = "G"
print(m[b])

Measured memory_bytes: 3060
package main

import (
        "fmt"
)

func main() {
        var a [3]int
        for i := range a {
                fmt.Scan(&a[i])
        }

        sum := 0
        for i := range a {
                sum += a[i]
        }
        max := a[0]
        for i := 1; i < len(a); i++ {
                if max < a[i] {
                        max = a[i]
                }
        }

        n := max
        if max*len(a)%2 != sum%2 {
                n++
        }
        cnt := (n*len(a) - sum) / 2
        fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

typedef struct {
	int *par, *size, *height;
} UF_forest;

void UF_initialize(UF_forest *F, int n)
{
	int i;
	F->par = (int*)malloc(sizeof(int) * (n + 1));
	F->size = (int*)malloc(sizeof(int) * (n + 1));
	F->height = (int*)malloc(sizeof(int) * (n + 1));
	for (i = 1; i <= n; i++) {
		F->par[i] = i;
		F->size[i] = 1;
		F->height[i] = 1;
	}
}

void UF_merge(UF_forest *F, int u, int v)
{
	for (; F->par[u] != u; u = F->par[u]);
	for (; F->par[v] != v; v = F->par[v]);
	if (u == v) return;
	else if (F->height[u] > F->height[v]) {
		F->par[v] = u;
		F->size[u] += F->size[v];
	} else {
		F->par[u] = v;
		F->size[v] += F->size[u];
		if (F->height[u] == F->height[v]) F->height[v]++;
	}
}

int UF_root(UF_forest *F, int v)
{
	for (; F->par[v] != v; v = F->par[v]);
	return v;
}

int main()
{
	int i, u, w, N, M;
	scanf("%d %d", &N, &M);
	
	if (N - 1 - M > N / 2) {
		printf("Impossible\n");
		fflush(stdout);
		return 0;
	}
	
	data a[100001];
	for (i = 0; i < N; i++) {
		scanf("%d", &(a[i].key));
		a[i].id = i + 1;
	}
	merge_sort(a, N);
	
	UF_forest F;
	UF_initialize(&F, N);
	for (i = 1; i <= M; i++) {
		scanf("%d %d", &u, &w);
		UF_merge(&F, u + 1, w + 1);
	}
	
	int k, r, count[100001] = {}, comp = 0;
	long long ans = 0;
	for (i = 0, k = 0; k < (N - 1 - M) * 2; i++) {
		r = UF_root(&F, a[i].id);
		if (count[r] == 0) {
			comp++;
			count[r]++;
			ans += a[i].key;
			k++;
		} else if (count[r] < N - 1 - M && (N - 1 - M) * 2 - k > N - M - comp) {
			count[r]++;
			ans += a[i].key;
			k++;
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();
        void Omame()
        {
            cin = new Scanner();
            int n = cin.nextInt();

            int[] x = new int[n];
            int[] y = new int[n];
            for (int i = 0; i < n; i++)
            {
                x[i] = cin.nextInt();
                y[i] = cin.nextInt();
            }

            double[,] d = new double[n, n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    d[i, j] = Math.Pow(Math.Pow(x[j] - x[i], 2) + Math.Pow(y[j] - y[i], 2), 0.5);
                }
            }
            double sumD = 0;
            int count = 0;

            Permutation(0, n);

            for (int i = 0; i < permList.Count; i++)
            {
                int start = permList[i][0];
                for (int j = 1; j < n; j++)
                {
                    int goal = permList[i][j];
                    sumD += d[start, goal];
                    start = goal;
                }
                    count++;
            }

            Console.WriteLine(sumD / count);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 230828
n,m=map(int,input().split())
hoge=list(map(int,input().split()))
hoge.sort()

if(sum(hoge)<m):
  print(n-1)
  exit()

ans=0
for i in range(n):
  if(hoge[i]<=m):
    ans+=1
    m-=hoge[i]
  else:
    break
print(ans)

Measured memory_bytes: 3064
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;

fn main() {
    let mut sc = Scanner::new();
    let (a, b, c) = (sc.parse::<i32>(), sc.parse::<i32>(), sc.parse::<i32>());
    if a <= c && c <= b {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define db double
const db eps = 1e-8;

struct Point{
    db x, y;
    Point(db x=0, db y=0): x(x), y(y) {}    //必须有初始化
    bool operator < (const Point &p){
        return x < p.x || (x == p.x && y < p.y);
    }
};

typedef Point Vector;
Vector operator + (Vector a, Vector b){ return Point(a.x+b.x, a.y+b.y);}
Vector operator - (Point a, Point b){ return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, db k){ return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, db k){ return Vector(a.x/k, a.y/k);}

//inline将函数名为内联函数，不使用栈空间，直接运算，但不能有while,switch等复杂语句
inline db dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}
inline db cross(Vector a, Vector b){
    return a.x*b.y - b.x*a.y;
}
db length(Vector a){
    return sqrt(dot(a, a));
}
db angle(Vector a, Vector b){
    return acos(dot(a, b) / length(a) / length(b));
}

int dcmp(db x){
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}
bool operator == (Point a, Point b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

struct Segment{
    Point p1, p2;
};
typedef Segment Line;
vector<Point> Polygon;
Point project(Line l, Point p){
    Vector a = l.p2 - l.p1, b = p - l.p1;
    db len_a = dot(a, a);   //这里不加sqrt，是因为下面算投影长度时，要除以两次len_a
    Vector tmp = a * (dot(a, b) / len_a);
    return Point(tmp.x+l.p1.x, tmp.y+l.p1.y);
}
Point reflect(Line l, Point p){
    Point tmp = project(l, p);
    return p + (tmp - p)*2;
}

void line_relation(Point p1, Point p2, Point p3, Point p4){
    Vector a = p2 - p1, b = p4 - p3;
    if(cross(a, b) == 0)
        puts("parallel");
    else if(dot(a, b) == 0)
        puts("orthogonal");
    else
        puts("others");
}
int com_segment_relation(Point p0, Point p1, Point p2){
    Vector a = p1-p0, b = p2-p0;
    db flag = cross(p1-p0, p2-p0);
    if(flag < 0)  return 2;
    else if(flag > 0)  return 1;
    else{       //重合
        if(a.x*b.x < 0 || a.y*b.y < 0) return 3;
        else if(length(a) < length(b)) return 4;
        else return 5;
    }
}

int segment_intersection(Point p1, Point p2, Point p3, Point p4){
    Point node1[2] = {p1, p2}, node2[2] = {p3, p4};
    sort(node1, node1+2), sort(node2, node2+2);
    if(node2[1] < node1[0] || node1[1] < node2[0])
        return 0;       //同一直线上，最大最小排除
    else if(cross(p2-p1, p3-p1)*cross(p2-p1, p4-p1) > 0 || cross(p4-p3, p1-p3)*cross(p4-p3, p2-p3) > 0)
        return 0;
    else
        return 1;
}
int main()
{
    Point p1, p2, p3, p4;
    int n;
    cin >>p1.x >>p1.y >>p2.x >>p2.y;
    cin >>n;
    while(n --){
        cin >>p3.x >>p3.y;
        int flag = com_segment_relation(p1, p2, p3);
        if(flag == 1)   puts("COUNTER_CLOCKWISE");
        else if(flag == 2) puts("CLOCKWISE");
        else if(flag == 3) puts("ONLINE_BACK");
        else if(flag == 4) puts("ONLINE_FRONT");
        else puts("ON_SEGMENT");
    }
    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
#define ll long long
using namespace std;
ll n,h[100001],k,f[100001],oo=127;
int main ()
{
    ///i-> i+j;(j<=k)
    cin>>n>>k;
    fori(i,1,n) cin>>h[i];
    memset(f,oo,sizeof(f));
   f[1] = 0;
    fori(i,1,n)
    {
        fori(j,1,k)
        {
            if(i-j>0){
                f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
   cout<<f[n];
}


Measured memory_bytes: 1792
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a); i < (b); ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1); i >= (b); --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
template<class T>
void cmax(T & a, T b) {a = max(a, b);}
template<class T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		for (char x : "([{") c += *s == x;
		for (char x : ")]}") c -= *s == x;
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD() {return 1;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<class T, class ... TT>
bool RD(T & a, TT & ... b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define DR(T,...) T __VA_ARGS__; RD(__VA_ARGS__)
#define RI(...) DR(int,__VA_ARGS__)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char s = ' ', char e = '\n'>
void PL() {if (e) PT(e);}
template<char s = ' ', char e = '\n', class T, class ... TT>
void PL(const T&a,const TT&...b){PT(a);if(sizeof...(b)&&s)PT(s);PL<s,e>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	DR(ll,a,b,c,d,n);
	a = min(min(a*4,b*2),c);
	PL(min(n/2*d+n%2*a,n*a));
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

int n,m;
int a[100007],b[100007];
unsigned long long ans = 0;

struct drink{
	unsigned long long a,b;
}all[100007];

bool cmp(drink a,drink b){
	return a.a < b.a;
}

int main(){
	cin>>n>>m;
	for(int i = 1;i<=n;i++) cin>>all[i].a>>all[i].b;
	sort(all+1,all+n+1,cmp);
    for(int i = 1;i<=n;i++){
    	if(m <= all[i].b){
    		ans += all[i].a * m;
    		break;
    	}
    	else {
    		ans += all[i].b * all[i].a;
    		m -= all[i].b;
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=1e9+7,N=1e3+5,M=25;
int n,m,f[M][N],C[N][N],a[M];

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

signed main(){
	read(n,m);
	for(int i=1;i<=m;i++) read(a[i]);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	f[0][0]=1;
	for(int i=0;i<m;i++) for(int j=0;j<=n;j++) for(int k=0;k+j<=n&&k<=a[i+1];k++) f[i+1][j+k]=(f[i+1][j+k]+1ll*f[i][j]*C[n-j][k]%mod*C[n-k][a[i+1]-k]%mod)%mod;
	write(f[m][n]);
}

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

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

int main()
{
    int64_t N, A, B, AB = 0;
    cin >> N >> A >> B;
    AB = A + B;
    if (N < AB)
    {
        if (N < A)
            cout << N << endl;
        else
        {
            cout << A << endl;
        }
    }
    else
    {
        int64_t cnt = (N / AB) * A;
        if (N % AB != 0)
        {

            if (N % AB <= A)
                cnt += N % AB;

            else if (N % AB > A)
                cnt += A;
        }
        cout << cnt << endl;
    }

    return 0;
}


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

int main(){
  int n; cin>>n;
  string s,t; cin>>s>>t;
  
  int c=0; vector<int> v;
  int M=max(max(s.size(),t.size())-n,min(s.size(),t.size()));
  for(int i=0;i<M;i++){
    if(t.substr(0,i+1)==s.substr(s.size()-1-i,i+1)){
      c=i+1;
    }
  }
  
  cout<<s.size()+t.size()-c;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int a1,a2,a3,a;
  cin>>a1>>a2>>a3;
  a=a1+a2+a3;
  if(a>=22)
  {
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    a: isize,
    b: isize,
    c: isize,
    d: isize,
  }
  
  let mut max = isize::min_value();
  
  max = std::cmp::max(a * c, max);
  max = std::cmp::max(a * d, max);
  max = std::cmp::max(b * c, max);
  max = std::cmp::max(b * d, max);
  
  println!("{}", max);
}

Measured memory_bytes: 2136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int ans=0;
  bool flag=1;
  while(flag){
    flag=0;
    for(int j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	swap(A[j],A[j-1]);
	flag=1;
	ans++;
      }
    }
  }
  for(int i=0;i<n;i++) cout<<A[i]<<" \n"[i==n-1];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	string S; ll K;
	cin >> S >> K;
	for (int i = 0; i < min((ll)S.size(), K); i++) {
		if (S[i] >= '2') { 
			cout << S[i] << endl; 
			return 0; 
		}
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
//AtCoder-agc006C
#include <algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
typedef long long ll;
#define rg register

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;
}

const int N=101000;
int a[N],vis[N],st[N];
ll b[N],p[N],k;
int n,m,tp;

void init();void work();void print();
int main(){init();work();print();return 0;}

void work(){
	int x;
	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);
	for(rg int i=1;i<=n;++i)if(!vis[i]){
		vis[st[0]=x=i]=tp=1;
		while(!vis[a[x]])
			vis[st[tp++]=x=a[x]]=1;
		int e=k%tp;
		for(rg int j=0;j<tp;++j)
			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];
	}
}

void print(){
	ll sm(0ll);
	for(rg int i=1;i<=n;++i)
		printf("%lld\n",sm+=b[i]);
}

void init(){
	read(n);
	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;
	for(rg int i=n;i;--i)p[i]-=p[i-1];
	read(m),read(k);
}

Measured memory_bytes: 3968
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	long long int N, A, B;
	cin >> N >> A >> B;
	long long int C, D;
	C = N / (A + B);
	D = N % (A + B);
	if (D > A) {
		D = A;
	}
	cout << C * A + D << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

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

	REP(i, 10) {
		if (i * 111 >= N) {
			cout << i * 111 << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int[] a = new int[n];
		str = br.readLine().split(" ");
		for(int i = 0; i < n; i++) a[i] = Integer.parseInt(str[i]);
		str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int b = Integer.parseInt(str[0]);
			int e = Integer.parseInt(str[1]);
			e -= 1;
			for(int j = b; j < b + (e - b + 1) / 2; j++){
				int k = e - (j - b);
				int bf = a[j];
				a[j] = a[k];
				a[k] = bf;
			}
		}
		for(int i = 0; i < n; i++){
			System.out.print(a[i]);
			if(i != n - 1) System.out.print(" ");
		}
		System.out.print("\n");
	}
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

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

int main() {


   int n,l; cin >> n >> l;

   int ideal = 0;
   rep(i, n) {
       ideal += l+i;
   }

   int ans = 0;
   int tmp = INT_MAX;
   rep(i, n) {
       int sabun = (l+i);
       if(tmp > abs(sabun)) {
           ans = ideal-sabun;
           tmp = abs(sabun);
       }
   }



   cout << ans << endl;

   return 0;
    
}


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

int main()
{    
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0;i<n;++i) cin >> arr[i];
        vector<ll> ans(n+1);
    for(ll i=1;i<n;++i)
    {   if(i==1)
            ans[i]=ans[i-1]+abs(arr[i]-arr[i-1]);
        else
            ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << ans[n-1];
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,T,ans=0;
  cin>>N>>T;
  vec v(T);
  rep(i,T)cin>>v[i];
  v.pb(0);
  vrsort(v);
  while(v[1]!=0){
    v[0]--;
    v[1]--;
    vrsort(v);
  }
  cout<<max(v[0]-1,0LL)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)
const int MAX = 18;

int N, A, B;

int P0[1<<MAX], P1[1<<MAX];
int bit[MAX];
int flg[MAX];

bool evenBit(int x) {
    bool r = false;
    while (x) {
        r ^= (x&1);
        x >>= 1;
    }
    return r;
}

int count1(int x) {
    int n = 0;
    while (x) {
        if (x&1) n++;
        x >>= 1;
    }
    return n;
}

int makeP0(int n) {
    if (n==0) {
        return 1;
    } else {
        int m = makeP0(n-1);
        int nn = n, bb = B;
        int r = 1;
        while (1) {
            if ((bb&1) == 0) nn--;
            if (nn == 0) break;
            bb >>= 1;
            r <<= 1;
        }
        for (int i = m; i < 2*m; i++) {
            P0[i] = P0[2*m-i-1]+r;
        }
        return m*2;
    }
}

const int pattern[3][4][2] = {
    {{0,0},{1,0},{1,1},{0,1}},
    {{1,1},{1,0},{0,0},{0,1}},
    {{0,1},{0,0},{1,0},{1,1}}
};

void makeP1(int n) {
    int idx = 0, nn = 0;
    while (nn < n) {
        if (B&(1<<idx)) bit[nn++] = (1<<idx);
        idx++;
    }
    REP (k, n) {
        int q = k&1;
        int o = 0;
        REP (i, 1<<n) {
            int p = (i>>(2*(k>>1)))%4;
            P1[i] += bit[k] * pattern[o][p][q];
            if (p == 3 && ((i+1)>>(2*(k>>1)))%4 == 0) {
                if (o <= 1) o = 2;
                else o = 1;
            }
        }
    }
}

int main() {
    cin >> N >> A >> B;
    if (evenBit(A) == evenBit(B)) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    B ^= A;

    int n1 = count1(B);
    int n0 = N-n1;
    makeP0(n0);
    makeP1(n1);

    REP (i, 1<<n1) {
        REP (j, 1<<n0) {
            int r1 = P1[i];
            int r0 = (i&1) ? P0[(1<<n0)-j-1] : P0[j];
            cout << ((r1+r0)^A) << ((i+1==(1<<n1) && (j+1==(1<<n0))) ? "\n" : " ");
        }
    }
}

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

int main()
{
    int n,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            if(!(a%3==0||a%5==0))
                c=1;
        }
    }
    if(!c)
        cout<<"APPROVED";
    else 
        cout<<"DENIED";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,n;
  long s=0;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    if(i%3!=0 && i%5!=0)
      s+=i;
  
  printf("%ld",s);
  
  return 0;
}
    

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> p(n);
  for (int i=0;i<n;++i) cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end());
  
  long long ans=0;
  for (int i=0;i<n;++i){
    long long buy = min(m,p[i].second);
    ans += buy*p[i].first;
    m-=buy;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
# 入力
N = int(input())
a = list(map(int, input().split()))

# しゃくとり法
count = 0
right = 0
total = 0
xor= 0
for left in range(N):
    # 条件を満たす最大のrightを求める
    while (right < N and xor ^ a[right] == total + a[right]):        
        xor = xor ^ a[right]
        total += a[right]
        right += 1
        
    # 組み合わせの数を数える
    count += (right - left)

    # leftをインクリメントする準備
    if(right == left):
        right += 1
    else:
        total -= a[left]
        xor ^= a[left]

# 結果出力
print(count)

Measured memory_bytes: 24840
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll f[200][10], p[200][20];
    rep(i, n) rep (j, 10) cin >> f[i][j];
    rep(i, n) rep (j, 11) cin >> p[i][j];
    ll ans = -(1<<30);
    rep(i, 1<<10) {
        if (i == 0) continue;
        ll tmp = 0;
        rep(j, n) {
            ll cnt = 0;
            rep(k, 10) {
                if ((i>>k & 1) && f[j][k] == 1) cnt++;
            }
            tmp += p[j][cnt];
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int MAXLEN=100;
char s[MAXLEN+1];
char l[MAXLEN/2+1];
char r[MAXLEN/2+1];

int main(){
	cin>>s;
	int len=strlen(s);
	
	//len是偶数，len是6的话，l=0,1,2,  r=5,4,3 
	//len是奇数，len是7的话，l=0,1,2,  r=6,5,4 
	for(int i=0;i<len/2;i++) l[i]=s[i];
	
	int rbegin;
	if(len%2==0) rbegin=len/2;
	else rbegin=len/2+1;
	for(int j=len-1,i=0;j>=rbegin;j--,i++) r[i]=s[j];

	int ans=0;
	for(int i=0;i<len/2;i++){
		if(l[i]!=r[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
A,B,H,M = map(int,input().split())

H_th = 2*np.pi/12*H + 2*np.pi/12/60*M
M_th = 2*np.pi/60*M

c = np.sqrt(A**2 + B**2 -2*A*B*np.cos(H_th-M_th))
print(c)

Measured memory_bytes: 27184
#include <stdio.h>
#include <math.h>

int main(){

  double a,b,d;

  double c;

  scanf("%lf %lf %lf",&a,&b,&d);

  d=d*3.14159265/180;//radにする

  double s,l,h;

  c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(d));

  s=a*b*sin(d)/2;

  l=a+b+c;

  h=b*sin(d);

  printf("%f\n%f\n%f\n",s,l,h);

  return 0;

}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll N, K;
    cin >> N >> K;
    vvi w(4 * K + 1, vi(4 * K + 1));
    vvi sw(4 * K + 1, vi(4 * K + 1));
    rep(i, 0, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') x += K;
        w[y % (2 * K)][x % (2 * K)]++;
        // w[y % (2 * K) + 2 * K][x % (2 * K) + 2 * K]++;
        // debug2(x % (2 * K), y % (2 * K));
        // debug2(x % (2 * K) + 2 * K, y % (2 * K) + 2 * K);
    }

    for (int x = 0; x < 4 * K; x++) {
        for (int y = 0; y < 4 * K; y++) {
            w[x][y] = w[x % (2 * K)][y % (2 * K)];
        }
    }

    // rep(i, 0, 4 * K) {
    //     rep(j, 0, 4 * K) {
    //         cout << w[4 * K - 1 - i][j] << " ";
    //     }
    //     cout << endl;
    // }

    rep(i, 0, 4 * K) rep(j, 0, 4 * K) {
        sw[i + 1][j + 1] = sw[i][j + 1] + sw[i + 1][j] - sw[i][j] + w[i][j];
    }

    int ans = 0;
    rep(i, 0, 2 * K) rep(j, 0, 2 * K) {
        int h = 0;
        h += sw[i + K][j + K] - sw[i + K][j] - sw[i][j + K] + sw[i][j];
        h += sw[i + 2 * K][j + 2 * K] - sw[i + 2 * K][j + K] - sw[i + K][j + 2 * K] + sw[i + K][j + K];
        // debug2(i, h);
        chmax(ans, h);
    }
    cout << ans << endl;

    // rep(i, 0, 4 * K) {
    //     rep(j, 1, 4 * K + 1) {
    //         cout << sw[4 * K - i][j] << " ";
    //     }
    //     cout << endl;
    // }
    return 0;
}


Measured memory_bytes: 252672
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			int n = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			int[][] result = new int[h][w];
			int color = 1;
			int currentX = 0, currentY = 0;
			for (int ai : a) {
				while (currentY + ai >= w) {
					// 改行が発生する
					fill(result, currentX, currentY, w, color);
					currentX++;
					ai -= (w - currentY);
					currentY = 0;
				}
				fill(result, currentX, currentY, currentY + ai, color);
				currentY += ai;
				color++;
			}
			IntStream.range(0, h).forEach(i -> println(result[i], i));
		}
	}

	/**
	 * 結果配列にx座標のy座標開始〜y座標終了-1までに色を塗る
	 * 
	 * @param result 結果配列
	 * @param x      x座標
	 * @param yStart y座標開始
	 * @param yEnd   y座標終了
	 * @param color  色
	 */
	private static void fill(int[][] result, int x, int yStart, int yEnd, int color) {
		for (int i = yStart; i < yEnd; i++) {
			result[x][i] = color;
		}
	}

	/**
	 * 数列を出力する
	 * 
	 * @param a      出力する数列
	 * @param lineNo 行数
	 */
	private static void println(int[] a, int lineNo) {
		if (0 == (lineNo & 1)) {
			// lineNoが偶数の場合，左から右へ出力する
			System.out.println(Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
		} else {
			// 右から左へ出力する
			System.out.println(IntStream.range(0, a.length).mapToObj(i -> String.valueOf(a[a.length - 1 - i]))
					.collect(Collectors.joining(" ")));
		}
	}
}


Measured memory_bytes: 33836
#include <queue>
#include <tuple>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

#pragma warning(disable : 4996)

using namespace std;

int N, M, C, A, B, E; long long sum;

vector<long long> P;

vector<tuple<int, int, int> > edges;

vector<vector<pair<int, int> > > G;

int main()
{
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &C);

	G.resize(N);

	for (int i = 0; i < M; i++)
	{
		scanf("%d", &A);
		scanf("%d", &B);
		scanf("%d", &E);

		sum += E;

		G[A - 1].push_back(make_pair(B - 1, E));
		G[B - 1].push_back(make_pair(A - 1, E));

		edges.push_back(make_tuple(A - 1, B - 1, E));
	}

	vector<long long> D(N, 999999999999999999LL); D[0] = 0;

	priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que;

	que.push(make_pair(0LL, 0));

	while (!que.empty())
	{
		pair<long long, int> p1 = que.top(); que.pop();

		long long dist = p1.first;

		int node = p1.second;

		for (int i = 0; i < G[node].size(); i++)
		{
			if (D[G[node][i].first] > D[node] + G[node][i].second)
			{
				D[G[node][i].first] = D[node] + G[node][i].second;

				que.push(make_pair(D[G[node][i].first], G[node][i].first));
			}
		}
	}

	vector<pair<long long, int> > I;

	for (int i = 0; i < M; i++)
	{
		I.push_back(make_pair(max(D[get<0>(edges[i])], D[get<1>(edges[i])]), get<2>(edges[i])));
	}

	sort(I.begin(), I.end());

	vector<long long> J; for (int i = 0; i < M; i++) J.push_back(I[i].first);

	vector<long long> K = { 0 }; for (int i = 0; i < M; i++) K.push_back(K[i] + I[i].second);

	long long ret = 999999999999999999LL;

	for (int i = 0; i < N; i++)
	{
		int ptr = upper_bound(J.begin(), J.end(), D[i]) - J.begin();

		ret = min(ret, C * D[i] + sum - K[ptr]);
	}

	printf("%lld\n", ret);

	return 0;
}

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


int main() {
  int n,k; cin >> n >> k;
  vector<int> h(n); rep(i,n)cin >> h[i];
  int ans = 0;
  rep(i,n)if(h[i] >=k)ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String S = "";
        if(N==0){
            System.out.println(0);
            return;
        }
        for(int i=0; i<1000; i++){
            int n = Math.abs(N);
            if(N%2==0){
                S += 0;
            }
            else{
                S += 1;
            }
            N -= n % 2;
            N /= -2;
            if(N==0){
                break;
            }
        }

        StringBuffer str = new StringBuffer(S);
        S = str.reverse().toString();
        System.out.println(S);
    }
}

Measured memory_bytes: 22740
#include <iostream>

int main() {
    int H[301], W[301];
    using namespace std;

    int r = 0;
    while(1){
        cin >> H[r] >> W[r];

        if (H[r] == 0 && W[r] == 0){
        break;
        }
        ++r;
    }

    for (int i = 0; H[i] != 0 && W[i] != 0; ++i){
        for (int y = 0; y < H[i]; ++y){
            for (int x = 0; x < W[i]; ++x){
                if ( 0 == ((x+y)%2)){
                cout << "#";
                }else{
                cout << ".";
                }

            }
                cout << endl;
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	double r, pi;
  	cin >> r;
  	pi = 2*acos(0.0);
  	printf( "%.12f %.12f\n", pi*r*r, 2*pi*r);
    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int power(int x, int t)
{
	int ret = 1;
	while(t > 0) {
		if(t & 1) ret = 1LL * ret * x % MOD;
		x = 1LL * x * x % MOD;
		t >>= 1;
	}
	return ret;
}

void fwt(int n, int to[])
{
	rep(i, n) rep(j, 1 << n)
	if(j >> i & 1) {
		int lj = j ^ 1 << i;
		int d0 = to[lj], d1 = to[j];
		to[lj] = (d0 + d1) % MOD;
		to[j] = (d0 - d1 + MOD) % MOD;
	}
}

int n, a[262144];
int dat[2][262144], datd[2][262144];

int main()
{
	scanf("%d", &n);
	rep(i, 1 << n) scanf("%d", &a[i]);
	
	int sum = 0;
	rep(i, 1 << n) sum = (sum + a[i]) % MOD;
	sum = power(sum, MOD - 2);
	rep(i, 1 << n) a[i] = 1LL * a[i] * sum % MOD;
	fwt(n, a);
	
	rep(i, 1 << n) {
		if(a[i] == 1) dat[1][i] = 1;
		else dat[0][i] = power((1 - a[i] + MOD) % MOD, MOD - 2);
		if(a[i] == 1) datd[1][i] = 1;
		else datd[1][i] = 1LL * a[i] * power((1 - a[i] + MOD) % MOD, MOD - 3) % MOD;
	}
	
	fwt(n, dat[0]);
	fwt(n, dat[1]);
	fwt(n, datd[0]);
	fwt(n, datd[1]);
	
	rep(i, 1 << n) {
		int hv = (dat[0][0] - dat[0][i] + MOD) % MOD;
		printf("%d\n", hv);
	}
	
	return 0;
}

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

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

  long long A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);

  int ite = 1;
  long long tmp_left = A[0];
  long long tmp_right = A[0];
  int min = 1;
  int max = N-1;
  long long result1 = 0;
  while(ite<N){
    if(ite % 4 == 0){
      result1 += abs(A[min] - tmp_left);
      tmp_left = A[min];
      min++;
    }else if(ite % 4 == 1){
      result1 += abs(A[max] - tmp_right);
      tmp_right = A[max];
      max--;
    }else if(ite % 4 == 2){
      result1 += abs(A[min] - tmp_right);
      tmp_right = A[min];
      min++;
    }else{
      result1 += abs(A[max] - tmp_left);
      tmp_left = A[max];
      max--;
    }
    ite++;
  }

  ite = 1;
  tmp_left = A[N-1];
  tmp_right = A[N-1];
  min = 0;
  max = N-2;
  long long result2 = 0;
  while(ite<N){
    if(ite % 4 == 0){
      result2 += abs(A[max] - tmp_left);
      tmp_left = A[max];
      max--;
    }else if(ite % 4 == 1){
      result2 += abs(A[min] - tmp_right);
      tmp_right = A[min];
      min++;
    }else if(ite % 4 == 2){
      result2 += abs(A[max] - tmp_right);
      tmp_right = A[max];
      max--;
    }else{
      result2 += abs(A[min] - tmp_left);
      tmp_left = A[min];
      min++;
    }
    ite++;
  }
  if(result1 < result2){
    result1 = result2;
  }
  cout << result1 << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int i,j,n,cards[256][14];
  int mark[4]={'S','H','C','D'};
  for(i=0;i<256;i++){
      for(j=0;j<14;j++){
          cards[i][j]=0;
      }
  }
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
      char c=0;
      int num=0;
      scanf("%c %d\n",&c,&num);
      cards[c][num]=1;
  }
  for(j=0;j<4;j++){
      for(i=1;i<14;i++){
          if(cards[mark[j]][i]==0){
              printf("%c %d\n",mark[j],i);
          }
      }
  }
  return 0;  
}



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

ll dp[N][N] ;
ll cum[N][N] ;
ll C[N][N] ;

int main () {

    ll  n , MAX , MOD ;
    cin >> n >> MAX >> MOD ; n++ ;
    C[0][0] = 1 ;
    for (int i = 1 ; i < 305 ; i++) {
        C[i][0] = C[i][i] = 1 ;
        for (int j = 1 ; j < i ; j++) {
            C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD ;
        }
    }
    for (int label = 0 ; label <= MAX ; label++) {
        dp[1][label] = 1;
    }
    for (int nodes = 2 ; nodes <= n ; nodes++) {
        for (int label = MAX ; label >= 0 ; label--) {
            cum[nodes-1][label] = ( cum[nodes-1][label + 1] + dp[nodes-1][label] ) % MOD;
            //cout << "nodes: " << nodes-1 << " label: " << label << " cum: " << cum[nodes-1][label] << endl ;
        }
        for (int label = 0 ; label <= MAX ; label++) {
            for (int k = 1 ; k <= nodes-1 ; k++) {
                dp[nodes][label] += ( ( ( cum[k][label+1] * dp[nodes-k][label] ) % MOD ) * (C[nodes-2][k-1]) ) % MOD ;
                dp[nodes][label] %= MOD  ;
            }
            //cout << "nodes: " << nodes << " label: " << label << " " << dp[nodes][label] << endl ;
        }
    }

    printf ("%lld\n" , dp[n][0]) ;
}


Measured memory_bytes: 2432
from itertools import accumulate

n = int(input())
s = input()
d = {'R':1, 'G':2, 'B':3}
ss = list(map(d.get, s))
r = list(accumulate([i == 1 for i in ss]))
g = list(accumulate([i == 2 for i in ss]))
b = list(accumulate([i == 3 for i in ss]))
ans = 0
for i in range(1,n-1):
    if ss[i] == 1:
        tmp = g[i-1] * (b[-1] - b[i-1]) + b[i-1] * (g[-1] - g[i-1])
    elif ss[i] == 2:
        tmp = r[i-1] * (b[-1] - b[i-1]) + b[i-1] * (r[-1] - r[i-1])
    elif ss[i] == 3:
        tmp = r[i-1] * (g[-1] - g[i-1]) + g[i-1] * (r[-1] - r[i-1])

    ans += tmp
    # print(i, tmp, ans)

for i in range(n-2):
    for j in range(i+1, n-1):
        idx =  2*j-i
        if idx >= n:
            break
        if ss[i] != ss[j] and ss[j] != ss[idx] and ss[idx] != ss[i]:
            # print(i,j,idx, s[i], s[j], s[idx])
            ans -= 1

print(ans)


Measured memory_bytes: 68836
count = int(input())
lists = []

for i in range(count):
  new = input()
  lists.append(new)

ac_count = lists.count('AC')
wa_count = lists.count('WA')
tle_count = lists.count('TLE')
re_count = lists.count('RE')

print("AC x " + str(ac_count))
print("WA x " + str(wa_count))
print("TLE x " + str(tle_count))
print("RE x " + str(re_count))



Measured memory_bytes: 16184
import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
removal=0
B=set(A)
for i in B:
  m=(bisect.bisect_right(A,i)-bisect.bisect_left(A,i))
  if m-i<0:
    removal+=m
  else:
    removal+=m-i
print(removal)

Measured memory_bytes: 64296
#include <iostream>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int n;
vector<int> edges[2010];

int k;

int flag[2010];


void input()
{
	cin >> n >> k;

	for(int i = 0;i < n - 1;i++)
	{
		int a,b;
		cin >> a >> b;

		edges[a].push_back(b);
		edges[b].push_back(a);
	}
}

int dist = 0;

typedef pair<int,int> P;

int memo[2010];

int main()
{
	input();

	int ans = 10000;

	if(k % 2 == 0)
	{
		for(int i = 1;i <= n;i++)
		{
			int cou = 0;
			queue<P> que;
			vector<bool> vis(n + 1,false);
			que.push(P(i,0));
			while(!que.empty())
			{
				int v = que.front().first;
				int d = que.front().second;
				que.pop();

				if(vis[v]) continue;
				vis[v] = true;

				if(k / 2 < d) cou++;

				for(int to : edges[v])
				{
					if(vis[to] == false)
					{
						que.push(P(to,d + 1));
					}
				}
			}

			ans = min(cou , ans);
		}
	}
	else
	{
		for(int i = 1;i <= n;i++)
		{
			for(int next : edges[i])
			{
				int cou = 0;
				queue<P> que;
				vector<bool> vis(n + 1,false);
				que.push(P(i,0));
				que.push(P(next,0));
				while(!que.empty())
				{
					int v = que.front().first;
					int d = que.front().second;
					que.pop();

					if(vis[v]) continue;
					vis[v] = true;

					if((k - 1) / 2 < d) cou++;

					for(int to : edges[v])
					{
						if(vis[to] == false)
						{
							que.push(P(to,d + 1));
						}
					}
				}


				ans = min(cou , ans);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

		




Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  var ans = mutableListOf<Char>()

  for (si in s) {
    if (si == 'B') {
      if (ans.isEmpty()) {
        continue
      }
      ans = ans.dropLast(1).toMutableList()
      continue
    }
    ans.add(si)
  }

  println(ans.joinToString(""))

}


Measured memory_bytes: 38592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.Int();
            int B = in.Int();
            out.println(A * B);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32724
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int i ;
  for(i=0;i<s.size();i++){                                                       if(s[i]!=t[i]){
      cout << "No" << "\n";
      return 0;
    }
    else continue;
  }
  cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 3624