akhauriyash/Code-Regression huggingface dataset:
package main

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

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

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

					`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	a := nextInt()
	b := nextInt()
	h := nextInt()
	m := nextInt()

	hs := float64(-30*(float64(h%12)+float64(m)/60.) + 90)
	ms := float64(-6*m + 90)

	hx := float64(a) * math.Cos(hs/180*math.Pi)
	hy := float64(a) * math.Sin(hs/180*math.Pi)
	mx := float64(b) * math.Cos(ms/180*math.Pi)
	my := float64(b) * math.Sin(ms/180*math.Pi)

	ans := math.Sqrt((mx-hx)*(mx-hx) + (my-hy)*(my-hy))

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define mod 924844033
const int g=5;
typedef long long ll;
inline int add(int a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	return a;
}
inline int mult(int a,int b)
{
	ll t=1ll*a*b;
	if(t>=mod)t%=mod;
	return t;
}
inline int power(int a,int b)
{
	int out=1;
	while(b)
	{
		if(b&1)out=mult(out,a);
		a=mult(a,a);
		b>>=1;
	}
	return out;
}
inline int dec(int a,int b)
{
	a-=b;
	if(a<0)a+=mod;
	return a;
}
class edge
{
	public:
		int e,nxt;
		edge(int e1=-1,int nxt1=-1)
		{
			e=e1,nxt=nxt1;
		}
};
int siz[200010],cnt[200010],jc[200010],inv[200010],n;
inline int c(int a,int b)
{
	if(a<b)return 0;
	return mult(jc[a],mult(inv[b],inv[a-b]));
}
class graph
{
	public:
		edge g[400010];
		int head[200010],tmpcnt;
		graph()
		{
			memset(head,255,sizeof(head));
			tmpcnt=0;
		}
		void addedge(int s,int e)
		{
			g[tmpcnt]=edge(e,head[s]),head[s]=tmpcnt++;
			g[tmpcnt]=edge(s,head[e]),head[e]=tmpcnt++;
		}
		void dfs(int np,int fath)
		{
			siz[np]=1;
			for(int i=head[np];i!=-1;i=g[i].nxt)
			{
				if(g[i].e!=fath)
				{
					dfs(g[i].e,np);
					++cnt[siz[g[i].e]];
					siz[np]+=siz[g[i].e];
				}
			}
			if(siz[np]<n)++cnt[n-siz[np]];
		}
}G;
int a[4097152],b[4097152],R[4097152],I;
void ntt(int *A,int lim,int flag)
{
	for(int i=0;i<lim;i++)if(i<R[i])swap(A[i],A[R[i]]);
	for(int j=1;j<lim;j<<=1)
	{
		int bas=power(g,(mod-1)/(j<<1));
		if(flag==-1)bas=power(I,(mod-1)/(j<<1));
		for(int i=0;i<lim;i+=(j<<1))
		{
			int t=1;
			for(int k=0;k<j;t=mult(t,bas),k++)
			{
				int nx=A[i+k],ny=mult(t,A[i+k+j]);
				A[i+k]=add(nx,ny);
				A[i+k+j]=dec(nx,ny);
			}
		}
	}
}
int main()
{
	I=power(g,mod-2);
	scanf("%d",&n);
	for(int i=1,ti,tj;i<n;i++)
	{
		scanf("%d%d",&ti,&tj);
		G.addedge(ti,tj);
	}
	G.dfs(1,0);
	jc[0]=1;
	for(int i=1;i<=n;i++)jc[i]=mult(jc[i-1],i);
	inv[n]=power(jc[n],mod-2);
	for(int i=n-1;i>=0;i--)inv[i]=mult(inv[i+1],i+1);
	for(int i=0;i<=n;i++)
	{
		a[i]=mult(cnt[i],jc[i]);
		b[i]=inv[n-i];
	}
	int lim=1,lgnum=0;
	while(lim<=n)lim<<=1,++lgnum;
	lim<<=1,++lgnum;
	for(int i=0;i<lim;i++)R[i]=(R[i>>1]>>1)|((i&1)<<(lgnum-1));
	ntt(a,lim,1);
	ntt(b,lim,1);
	for(int i=0;i<lim;i++)a[i]=mult(a[i],b[i]);
	ntt(a,lim,-1);
	for(int i=0;i<lim;i++)a[i]=mult(a[i],power(lim,mod-2));
	for(int i=1;i<=n;i++)
	{
		int nval=a[i+n];
		printf("%d\n",dec(mult(c(n,i),n),mult(nval,inv[i])));
	}
	return 0;
}

Measured memory_bytes: 26496
import java.util.Scanner;


public class Main {
    static Scanner s = new Scanner(System.in);

    static boolean black,white;
    static char[][] map;
    static int W,H;

    public static void main(String[] args) {
        int count;
        while (true) {
            W = s.nextInt();
            H = s.nextInt();
            if (W == 0 && H == 0) break;

            int bCount=0,wCount=0;
            map = new char[H][W];

            for (int i = 0; i < H; i++) {
                map[i] = s.next().toCharArray();
            }

            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    black=false;
                    white=false;
                    count=0;

                    if(map[i][j]=='.')
                        count=search(i,j);

                    if(black && !white)
                        bCount+=count;
                    else if(!black && white)
                        wCount+=count;
                }
            }
            System.out.println(bCount+" "+wCount);
        }
    }

    static int search(int i,int j) {
        int count=0;
        if(i<0 || i>=H || j<0 || j>=W) return 0;
        if(map[i][j]=='.'){
            map[i][j]='x';
            count++;
            count+=search(i+1,j)+search(i-1,j)+search(i,j+1)+search(i,j-1);
        }else if(map[i][j]=='B'){
            black=true;
        }else if(map[i][j]=='W'){
            white=true;
        }
        return count;
    }
}

Measured memory_bytes: 33212
#include <iostream>
#define MAX_N 200000
using namespace std;

int main(void) {
	int n;
	int profits[MAX_N+1];

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

	int _max = -2000000000;
	int _min = profits[0];
	for(int i = 1; i < n; i++) {
		_max = max(_max, profits[i] - _min);
		_min = min(_min, profits[i]);
	}

	cout << _max << endl;

	return 0;
}

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

int main() {
    int N, a, ans = 0;
    cin >> N;
    while (N--) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ++ans;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 55;
const int mod = 1e9 + 7;
int n;
struct Mat {
	int arr[maxn][maxn];
	
	void I() {
		memset(arr, 0, sizeof(arr));
		for (int i = 0; i <= 50; i++) {
			arr[i][i] = 1;
		}	
	}
	
	Mat operator * (const Mat &A) const {
		Mat B;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				B.arr[i][j]  = 0;
				for (int k = 0; k < n; k++) {
					B.arr[i][j] = (B.arr[i][j] + A.arr[i][k] * arr[k][j]) % mod;  	
				}
			}
		}
		return B;
	}
} A;

int fast_pow(int k) {
	Mat tmp;
	tmp.I();
	while (k) { 
		if (k & 1) {
			tmp = tmp * A;
		}
		k /= 2;
		A = A * A;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += tmp.arr[i][j];
			ans %= mod;
		}
	}
	return ans;
}

main() {
	IOS
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> A.arr[i][j];
		} 
	} 
	cout << fast_pow(k) << "\n";
}


Measured memory_bytes: 3704
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<>();
        int n = scanner.nextInt();
        int l = scanner.nextInt();

        for(int i = 0; i < n; i++){
            list.add(scanner.next());
        }

        Collections.sort(list);
        for(String str: list){
            System.out.print(str);
        }

        System.out.println();
    }
}

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

int main(void)
{
    int A, B;
    cin >> A >> B;

    int max = 0;

    if(A + B  > A - B)
        max = A + B; 
    else 
        max = A - B;

    if(max > A * B)
        cout << max << endl;
    else
        cout << A * B << endl;
    

}


Measured memory_bytes: 256
N,M=list(map(int,input().split()))
X=list(map(int,input().split()))

X.sort()
#print(X)

if M<=N:
	print(0)
else:
	D=[]
	for i in range(M-1):
		D.append(X[i+1]-X[i])
	D.sort()
#	print(D)
	print(sum(D[:M-N]))

Measured memory_bytes: 13968
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
int n,a[N];
int main(){
    cin>>n;
    int ans=0;
    lol(i,n){
	cin>>a[i];
	ans+=a[i]-1;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	double v, t;
	
	while (scanf("%lf", &v) != EOF){
		t = v / 9.8;
		for (n = 1; 4.9 * t * t >= 5 * n - 5; n++){
		}
		printf("%d\n", n);
	}
	
	return (0);
}

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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;



template<class T>
map<T,T> fact(T n){
    map<T,T> Map;
    for(T i = 2; i * i <= n; i++){
        while(n % i == 0){
            Map[i]++;
            n /= i;
        }
    }
    if(n == 1)return Map;
    Map[n]++;
    return Map;
}

int main()
{
    int n;
    cin >> n;
    map<int,int> mp;
    vector<mint> in(n);
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        in[i] = t;
        map<int,int> Map = fact(t);
        for(auto i : Map) {
            mp[i.first] = max(i.second, mp[i.first]);
        }
    }
    mint ans(1);
    for(auto i : mp) {
        ans *= (mint)i.first^i.second;
    }
    mint sum = 0;
    for(int i = 0; i < n; i++) {
        sum += ans / in[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  vi A(M);
  rep(i,M) {
    cin >> A[i];
  }
  ll s = 0;
  rep(i,M) {
    s += A[i];
  }
  cout << max(-1ll,N-s) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    char c[3];
    int a = 0,maxa;
    cin >> c;
    maxa = a;
    for(int i=0;i<3;i++){
        if(c[i] == 'R'){
            a++;
            maxa = max(maxa,a);
        }else{
            a = 0;
        }
    }
    cout << maxa << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    if (N % 2 == 0) cout << N / 2 << endl;
    else cout << N / 2 + 1 << endl;
    return 0;
}

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



int main()
{
        int x;
        int badnumber;
        int y;
        int i;
        int placeholder;

        for(i=0;i<3000;i++)
        {    
            cin>>x;
            cin>>y;
          
                if(x>=10000||y>=10000)
                {      break;
                }
                 else if (x<0||y<0)
                { break;
                }
                else if (x==0 && y==0) {
                   break;
                }
                else if(x>y)
                {       placeholder=x;
                        x=y;
                        y=placeholder;
                
                }

                
                cout<<x<<" "<<y<<endl;
                
         }
}



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

int main()
{
  int n;
  string ans;
  cin>>n;
  for(int i=1;i<10;i++)
  {
    if(n%i==0)
    {
      if(n/i<10)
        {
          ans="Yes";
          break;
        }
      else
        {
          continue;
        }
    }
    else
    {
      continue;
    }
  }
  if(ans!="Yes")
  {
    ans="No";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, a[N], sg[N], k;
void get_sg() 
{
	bitset <N> vis;
	for(int i=1;i<=k;i++)
	{
		sg[i] = 0;
		vis.reset();
		for(int j=1;j<=n&&a[j]<=i;j++)
			vis[sg[i-a[j]]] = 1;
		int ans = 0;
		while(vis[ans]) ans++;
		sg[i] = ans;
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	get_sg();
 	if(sg[k]) cout << "First\n";
 	else cout << "Second\n";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    vector<ll> A(N);
    rep (i, N) { cin >> A[i]; }

    ll ans = 0;

    rep (i, N)
    {
        ans += ((i + 1) & 1) && (A[i] & 1) ? 1 : 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
A = int(input())  # 500
B = int(input())  # 100
C = int(input())  # 50
X = int(input())  # tgt


ret = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            money = int(500*a + 100*b + 50*c)
            if money==X:
                ret += 1

print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int c1,c5,c10,c50,c100,c500;
	cin>>c1>>c5>>c10>>c50>>c100>>c500;
	if(c1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	/*int d,c;
	cin>>d>>c;
	cout<<d*c<<endl;*/
	//cout << "Hello world!!" << endl;
	return 0;
}



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


int main(){
    int n, k, a[100000];
    int c = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a[i];   
    }

    n -= k;
    k--;
    c++;
    while(n > 0){
        n -= k;
        c++;
    }
	cout << c << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include <set>
#include<map>
using namespace std;
typedef long long ll;




int main()
{
    string s;
    cin>>s;
    int c=0;
    for(int i = 0; i<s.length(); i++){
        if(s[i]=='1')c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

typedef long long ll;

string x;

int main() {

//    ifstream in("/Users/koichihasegawa/src/repository/cpp/AtCoder/ABC/abc130/input.txt");
//    cin.rdbuf(in.rdbuf());

    cin >> x;

    char prev = '.';
    string ans = "Good";
    REP(i, x.size()) {
        if (prev == x[i]) {
            ans = "Bad"              ;
        }
        prev = x[i];
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N;
    cin >> N;
    int p[N];
    cins(p, p + N);
    cout << accumulate(p, p + N, 0) - (*max_element(p, p + N)) / 2 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
    long long res;
    int t; char a[2];
    scanf("%d", &t);
    res = t;
    for ( ; ;) {
        scanf("%2s", &a);
        if (a[0] == '=') break;
        scanf("%d", &t);
        if (a[0] == '+') res+=t;
        else if (a[0] == '-') res-=t;
        else if (a[0] == '*') res*=t;
        else if (a[0] == '/') res/=t;
    }
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 2e5+2;

int m;
ll ans, d[MM], c[MM], ns;

int main(){
    
    scan(m);
    
    for(int i = 0; i < m; i++){
        scan(d[i], c[i]);
        ll v = d[i]*c[i];
        ans += c[i]-1 + (v-1)/9;
        //print(c[i]-1, (v-1)/9);
        v %= 9;
        if(v == 0 && d[i] != 0)
            v = 9;
        ns += v;
    }
    
    ans += m-1+(ns-1)/9;
    
    print(ans);
    
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ac,wa,re,tle;
    map<string,int> cnt;
    for(int i = 0; i < n; ++i){
    	string ans;
    	cin >> ans;
    	cnt[ans] ++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	cout << s.substr(0, 3) << '\n';
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

//Time to Study
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int t = sc.nextInt();
			if(t==0)break;
			int n = sc.nextInt(), sum = 0;
			for(int i=0;i<n;i++){
				int s = sc.nextInt(), f = sc.nextInt();
				sum+=f-s;
			}
			System.out.println(t<=sum?"OK":t-sum);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
n = int(input())

n_100 = n//100
n_10 = (n - n_100 *100) // 10 
n_1 = n - n_100*100 - n_10*10

m = n_100 * 111

if m >= n:
  print(m)
else:
  print((n_100 +1) * 111)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct node{int p,l,r;};

node T[MAX];
int n,D[MAX];

void print(int u){
    int  i,c;
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].p<<", ";
    cout <<"depth = "<<D[u]<<", ";

if(T[u].p==NIL)cout <<"root, ";
else if(T[u].l==NIL)cout <<"leaf, ";
    else cout <<"internal node, ";
cout <<"[";

for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)cout<<", ";
    cout <<c;
}
cout <<"]"<<endl;
}

int rec(int u,int p){
    D[u]=p;
    if(T[u].r!=NIL)rec(T[u].r,p);
    if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
    int i,j,d,c,v,l,r;
    cin>>n;
    for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

    for(i=0;i<n;i++){
        cin>>v>>d;//v=±???£?d=¶?
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0)T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL)r=i;
    }
    rec(r,0);
    for(i=0;i<n;i++)print(i);
    return 0;

}

Measured memory_bytes: 7748
x=int(input())
l=[]

for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
        

for j in l:
    for k in l:
        aa=j-k
        if j!=k and aa==x:
            ans=[]
            for z in [j,k]:
                aaa=abs(z)**(1/5)
                if z>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)                
            exit()


Measured memory_bytes: 9392
n = int(input())
x = [int(w) for w in input().split()]
x = sorted(x)
ans = 1
f = False
for i in range(n):
    ans *= x[i]
    if ans > 10**18:
        f = True
        break
    
if ans > 10**18:
    f = True
    
if(f):
    print(-1)
    
else:
    print(ans)

Measured memory_bytes: 21596
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string s;
    cin >> s;
    char last = s[s.size()-1];
    int n = last - '0';
    if (n == 3) {
        cout << "bon" <<  endl;
    }
    else if (n == 1 || n == 0 || n == 6 || n==8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
}

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


Measured memory_bytes: 3576
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int N; std::cin >> N;
  int i = N / 100;
  for (; i < 10; i++) {
    int target = i*100 + i*10 + i;
    if (target >= N) {
      std::cout << target << std::endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
const int MAXN=1e5 +10;

vector<int> G[MAXN];
int n, a[MAXN],m;
bool vis[MAXN], flag[MAXN];
int DFS(int u){
	vis[u] = true;
	int res= u;
	for (int i=0; i<G[u].size(); i++)
		if ( !vis[G[u][i]]){
			int nx= DFS(G[u][i]);
			if ( a[nx] < a[res]) res=nx;
		}
	return res;
}
int main(){

	scanf("%d%d", &n, &m);
	for (int i=0; i<n ; i++) scanf("%d", &a[i]);
	for (int i=0, u,v; i<m; i++){
		scanf("%d%d", &u, &v);
		G[u].PB(v); G[v].PB(u);
	}
	int c=0;
	
	for (int u=0; u<n ; u++)
		if ( !vis[u]){
			flag[ DFS(u)] = true;
			c++;
		}
	if ( c==1){
		printf("0\n");
		return 0;
	}
	vector<int> co;
	LL ans=0;
	for (int i=0;i <n; i++) if ( !flag[i]) co.PB(a[i]);	else ans+=a[i];
	#ifdef che
	debug("initial ans= %lld , co.size()=%d c=%d\n", ans, co.size(),c);
	#endif
	if ( co.size() <c-2)	printf("Impossible\n");
		else{
			sort(co.begin(), co.end());
			for (int i=0; i<c-2; i++) ans+=co[i];
			printf("%lld\n", ans);
		}
	return 0;
}


Measured memory_bytes: 7036
def main(a,b,c,d):
    return (abs(c - a) <= d) or (abs(b - a) <= d and abs(c - b) <= d)
  
if __name__ == "__main__":
    a,b,c,d = map(int,input().split())
    print("Yes" if main(a,b,c,d) else "No")

Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    a[0] += 'A' - 'a';
    b[0] += 'B' - 'b';
    c[0] += 'C' - 'c';
    cout << a[0] << b[0] << c[0] << endl;
}

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

ll gcd(ll a, ll b){ return b ? gcd(b,a%b) : a; }

void solve(long long K){
    ll ans = 0;
    for(ll a = 1; a <= K; ++a){
        for(ll b = 1; b <= K; ++b){
            ll ab = gcd(a, b);
            for(ll c = 1; c <= K; ++c){
                ans += gcd(ab, c);
            }
        }
    }
    cout << ans << endl;
    return;
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3648
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(i=1;i<=n;i++)
#define   FOR(i,a,b)      for(i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
LL n,i,j,ans = 0;
LL a[1000000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL n,m ; 
    cin>>n>>m ; 
    REP(i,n)
    {  LL x,y ; 
       cin>>x ; 
       for(j=1;j<=x;j++) cin>>y,a[y]++ ;  
         
    }
    REP(i,1000000) if(a[i]==n) ans++ ; 
    cout<<ans<<endl ; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 256
#include <stdio.h>

int prime[999999];

int main( void ) {

	int i, j, n, count;
	
	for ( i = 0; i < 999999; i++ ) { prime[i] = 1; }

	prime[0] = 0;

	for ( i = 0; i < 999999; i++ ) {

		if ( prime[i] == 1 ) {

			for ( j = 2; ( i + 1 ) * j < 1000000; j++ ) { prime[( i + 1 ) * j - 1] = 0; }

		}
	
	}

	while ( scanf( "%d", &n ) != EOF ) {

		count = 0;

		for ( i = 0; i < n; i++ ) {

			if ( prime[i] == 1 ) { count++; }

		}

		printf( "%d\n", count );

	}

	return 0;

}

Measured memory_bytes: 4500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <utility>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,t;
    cin >> n >> t;
    int ans = 0;
    int deru = -1;
    rep(i,n){
        int a;
        cin >> a;
        ans += t-max(0,deru-a);
        deru = a+t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	ll K, A, B; cin >> K >> A >> B;
	if ( A >= B || A > K){
		cout << 1 + K << endl;
		return 0;
	}
	K -= A - 1;
	ll sum = ( K & 1 ) + A + (( K ) / 2 ) * ( B - A );
	if ( sum < K + A )
		cout << K + A << endl;
	else
		cout << sum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 166 C - Peaks
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/03
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

int n, m;
int h[100000];
int a[100000];
int b[100000];

void solve() {
    int ma[n+1];
    memset(ma, 0, sizeof(ma));
    for (int i=0;i<m;i++) {
        ma[a[i]] = max(ma[a[i]], h[b[i]-1]);
        ma[b[i]] = max(ma[b[i]], h[a[i]-1]);
    }
    int cnt = 0;
    for (int i=1;i<=n;i++) {
        if (h[i-1] > ma[i])
            cnt++;
    }
    printf("%d\n", cnt);
}

int main() {

    scanf("%d", &n);
    scanf("%d", &m);
    for (int i=0;i<n;i++) {
        scanf("%d", &h[i]);
    }
    for (int i=0;i<m;i++) {
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
    }

    solve();
}

Measured memory_bytes: 4756
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

double pi=2*acos(0.0);

int d[300000];
vector<pair<int,int> > a;

int main()
{
  int i,j,x,y,x1,y1,x2,y2,n,ed,cnt;
  int left,right,mid;
  double ans;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  if (x1>x2)
  {
    swap(x1,x2);
    swap(y1,y2);
  }
  scanf("%d",&n);
  for (i=0;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    if ((x1<=x)&&(x<=x2))
    {
      a.push_back(make_pair(x,y));
    }
    
  }
  sort(a.begin(),a.end());
  for (i=0;i<300000;i++)
    d[i]=2000000000;
  if (y2<y1)
  {
    reverse(a.begin(),a.end());
    d[0]=y2-1;
    ed=y1;
  }
  else
  {
    d[0]=y1-1;
    ed=y2;
  }
  for (i=0;i<a.size();i++)
  {
    //cout<<a[i].first<<" "<<a[i].second<<endl;
    left=-1;right=300000;
    while (right-left>1)
    {
      mid=(left+right)/2;
      if (d[mid]<a[i].second) left=mid;
      else right=mid;
    }
    if (left==-1) continue;
    if (a[i].second<d[left+1]) d[left+1]=a[i].second;
  }
  //cout<<ed<<endl;
  for (i=0;i<300000;i++)
    if (d[i]>ed) break;
  i--;
  cnt=i;
  //cout<<cnt<<endl;
  if ((cnt==abs(x1-x2)+1)||(cnt==abs(y1-y2)+1))
  {
    ans=100.0*(abs(x1-x2)+abs(y1-y2));
    //cout<<ans<<endl;
    ans-=cnt*20.0;
    ans+=(cnt+1)*5.0*pi;
    
  }
  else
  {
    ans=100.0*(abs(x1-x2)+abs(y1-y2));
    //cout<<ans<<endl;
    ans-=cnt*20;
    ans+=cnt*5*pi;
  }
  printf("%.12lf\n",ans);
  return 0;
}

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

const int N = 220000;

int a[N], b[N], c[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	int ret = 0;
	for (int j = 0; j < 29; j++) {
		long long ans = 0;
		for (int i = 0; i < n; i++) c[i] = b[i] & ((1 << j + 1) - 1);
		sort(c, c + n);
		for (int i = 0; i < n; i++) {
			int x = a[i] & ((1 << j + 1) - 1);
			int L = 1 << j, R = (1 << j + 1) - 1;
			L = max(0, L - x), R = max(0, R - x);
			ans += upper_bound(c, c + n, R) - lower_bound(c, c + n, L);
			L = (1 << j) + (1 << j + 1); R = (1 << j + 2) - 1;
			L = max(0, L - x), R = max(0, R - x);
			ans += upper_bound(c, c + n, R) - lower_bound(c, c + n, L);
		}
		if (ans & 1) ret += 1 << j;
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 2560
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template< class T >
class RecSum {
private:
	vector<vector<T>> data;
	int H = 0, W = 0;
public:
	RecSum(vector<vector<T>> const &vec) : H(vec.size()), W(vec[0].size()), data(H + 1, vector<T>(W + 1, 0)) {
		for (int row = 0; row <= H; row++) {
			for (int col = 0; col <= W; col++) {
				data[row + 1][col + 1] += data[row + 1][col] + data[row][col + 1] - data[row][col] + vec[row][col];
			}
		}
	}

	RecSum(int H, int W) : H(H), W(W), data(H + 1, vector<T>(W + 1, 0)) {}
	void add(int x, int y, T z) { data[x + 1][y + 1] += z; }
	void init() {
		for (int row = 0; row < H; row++) {
			for (int col = 0; col < W; col++) {
				data[row + 1][col + 1] += data[row + 1][col] + data[row][col + 1] - data[row][col];
			}
		}
	}

	// [sx, gx) x [sy, gy)
	T operator()(int sx, int sy, int gx, int gy) {
		return data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy];
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	RecSum<int> grid(4 * K, 4 * K);
	int x, y; char w;
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> w;
		if (w == 'W') {
			x %= 2 * K;
			y %= 2 * K;
		}
		else {
			x += K;
			x %= 2 * K;
			y %= 2 * K;
		}
		grid.add(x, y, 1);
		grid.add(x + 2 * K, y, 1);
		grid.add(x, y + 2 * K, 1);
		grid.add(x + 2 * K, y + 2 * K, 1);
	}

	grid.init();

	int ans = 0;
	for (int row = 0; row < 2 * K; row++) {
		for (int col = 0; col < 2 * K; col++) {
			ans = max(ans, grid(row, col, row + K, col + K) + grid(row + K, col + K, row + 2 * K, col + 2 * K));
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 62976
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define loop(i,a,b) for(lli i=a;i<b;i++)
	#define loopi(i,a,b) for(int i=a;i<b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<char, lli> &a, const pair<char, lli> &b)
				{return a.second < b.second;}


int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
		lli n,i,d,a,b,c,j,k=0,flag=0,x,y,ans,tt=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
      if(i%3 ==0 )
      continue;
      if(i%5 ==0 )
      continue;
      if(i%15 ==0 )
      continue;
      tt+=i;

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


Measured memory_bytes: 3580
using System;

class Program
{
    static void Main()
    {
                int a, b, men, syu;
                string mozi = Console.ReadLine();
                string[] data = mozi.Split(' ');
                a = int.Parse(data[0]);
                b = int.Parse(data[1]);
            if (1 <= a && b <= 100)
            {
                men = a * b;
                syu = a * 2 + b * 2;
                System.Console.WriteLine("{0} {1}", men, syu);
            }
        }
    }


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

int n;
char can[45][45];

long long memo[45][45][45];

long long dp(int i,int j,int k){
	if ((j^i)&1) return 0;
	if (i==j) return 1;
	if (i==k || j==k) return 0;
	else if (memo[i][j][k]!=-1) return memo[i][j][k];
	
	long long ans=0;
	
	for (int x=i;x<k;x++){
		for (int y=k+1;y<=j;y++){
			if (can[x][y]=='0') continue;
			for (int d1=x+1;d1<=k;d1++){
				for (int d2=k+1;d2<=y;d2++){
					ans+=dp(i,d1-1,x)*dp(d1,d2-1,k)*dp(d2,j,y);
				}
			}
		}
	}

	return memo[i][j][k]=ans;
}

int main(){
	memset(memo,-1,sizeof(memo));

	scanf("%d",&n);
	
	for (int x=1;x<=2*n;x++){
		scanf("%s",can[x]+1);
	}
	
	long long ans=0;
	
	for (int x=2;x<=2*n;x++){
		if (can[1][x]=='1') ans+=dp(2,2*n,x);
	}
	
	printf("%lld\n",ans);
}

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

#define W 5
#define DELETE -1

int main(void){
    while(true){
        int H;
        cin >> H;
        if(H == 0)
            break;
        
        //?????¢???????????????
        vector<vector<int> > puyo(H, vector<int>(W));
        for(int i=0; i < H; i++)
            for(int j=0; j < W; j++)
                cin >> puyo[i][j];
        
        //???????¶????????????§??°?????????
        int flag, ans = 0;
        do{
            //?????????????????°????????£?????????
            flag = false;
            
            //??¨????????°???????????????
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(puyo[i][j] == DELETE)
                        continue;
            
            //??????[i][j]?????????????????¨???????????????????????§????????????????±???????
                    int seg;
                    for(seg = 1; j + seg < W; seg++)
                        if(puyo[i][j] != puyo[i][j + seg])
                            break;
            
            //??£?¶???????????????\???????????°?¶????
                    if(seg >= 3){
                        for(int k = 0;k < seg; k++){
                            flag = true;
                            ans += puyo[i][j + k];
                            puyo[i][j + k] = DELETE;
                        }
                    }
                }
            }
            
            //DELETE????????£??????????????????????????????(???????????????????????§??????)
            for(int k = 0; k < H; k++){
                for(int i = 1; i < H; i++){
                    for(int j = 0; j < W; j++){
                        if(puyo[i][j] == DELETE){
                            int tmp = puyo[i][j];
                            puyo[i][j] = puyo[i-1][j];
                            puyo[i-1][j] = tmp;
                        }
                    }
                }
            }
        }while(flag);
    
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
// O(|E| + |V|)

#include <vector>
#include <cassert>
#include <queue>
#include <algorithm>

using namespace std;

class TopologicalSort {
#define MAX_V 10001
private:

  struct Edge {
    int to;
    Edge(int to): to(to) { }
  };

  int V;
  vector<Edge> G[MAX_V];

public:
  TopologicalSort(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to) {
    G[from].push_back(Edge(to));
  }

  vector<int> Solve() {
    int k = 0;
    vector<int> ord(V), in(V);
    for (int i = 0; i < V; i++) {
      for (auto &e : G[i]) {
        in[e.to]++;
      }
    }
    queue<int> q;
    for (int i = 0; i < V; i++) {
      if (in[i] == 0) {
        q.push(i);
      }
    }
    while (!q.empty()) {
      int v = q.front(); q.pop();
      ord[k++] = v;
      for (auto &e : G[v]) {
        if (--in[e.to] == 0) {
          q.push(e.to);
        }
      }
    } 

    return (*max_element(in.begin(), in.end()) == 0)? ord : vector<int>();
  }
};

#include <iostream>

int main() {
  int V, E;
  cin >> V >> E;
  TopologicalSort ts(V);

  for (int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    ts.AddEdge(s, t);
  }

  vector<int> ans = ts.Solve();

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 6e5 + 5;

int n, m;
int a_[maxn], b_[maxn];
int a[maxn], b[maxn], ans[maxn];
int s[maxn], z[maxn];
int ok[maxn];

inline void zMatch(){
	memset(z, 0, sizeof(z));
	z[0] = m;
	int l = -1, r = -1;
	FOR(i, 1, m){
		if(i <= r)
			z[i] = min(r - i + 1, z[i - l]);
		for(int &j = z[i]; i + j < m && s[j] == s[i + j]; ++j);
		if(i + z[i] - 1 > r){
			l = i, r = i + z[i] - 1;
		}
	}
	return;
}

int main(){
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%d", a_ + i);
	FOR(i, 0, n){
		scanf("%d", b_ + i);
	}
	FOR(it, 0, 30){
		FOR(i, 0, n){
			a[i] = a_[i] >> it & 1;
			b[i] = b_[i] >> it & 1;
		}
		m = 0;
		FOR(i, 0, n)
			s[m + i] = b[i];
		m += n;
		FOR(i, 0, n)
			s[m + i] = a[i];
		m += n;
		FOR(i, 0, n)
			s[m + i] = a[i];
		m += n;
/*		FOR(i, 0, m)
			printf("%d ", s[i]);
		puts("");
*/		zMatch();
/*		FOR(i, 0, m)
			printf("%d ", z[i]);
		puts("");
*/		memset(ok, 0, sizeof(ok));
		FOR(i, n, n << 1) if(~ans[i - n] && z[i] >= n){
//			printf("i = %d\n", i);
			ok[i - n] = true;
		}
		FOR(i, 0, n)
			s[i] ^= 1;
/*		FOR(i, 0, m)
			printf("%d ", s[i]);
		puts("");
*/		zMatch();
/*		FOR(i, 0, m)
			printf("%d ", z[i]);
		puts("");
*/		FOR(i, n, n << 1) if(~ans[i - n] && z[i] >= n){
//			printf("i = %d\n", i - n);
			ok[i - n] = true;
			ans[i - n] ^= (1 << it);
		}
		FOR(i, 0, n) if(!ok[i])
			ans[i] = -1;
	}
	FOR(i, 0, n) if(~ans[i])
		printf("%d %d\n", i, ans[i]);
	return 0;
}


Measured memory_bytes: 21888
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;

    vector<ll> b(n);
    ll cent = n/2;
    if(n%2 == 0){
        rep(i, n){
            ll a;
            cin >> a;
            if(i%2 == 0)b[cent+(i+1)/2]=a;
            else b[cent-(i+1)/2] = a;
        }
    }
    else {
        rep(i, n){
            ll a;
            cin >> a;
            if((i+1)%2 == 1)b[cent-(i+1)/2]=a;
            else b[cent+(i+1)/2] = a;
        }
    }

    rep(i, n)cout << b[i] << " ";
    
}

Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys


def solve(N: int):
    q, m = divmod(N, 2)
    if m == 1:
        print(q+1)
    else:
        print(q)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060