akhauriyash/Code-Regression huggingface dataset:
/*
Author : N_o_o_B
Created : April 11 2020 10:56:36 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll x;
    cin >> x;
    ll ans = x/500*1000;
    x %= 500;
    ans += x/5*5;
    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val testCaseCount = readLine()!!.toInt()
    val testCases = (1..testCaseCount).map { readLine()!! }
    
    val testResults = arrayOf("AC","WA","TLE","RE")
    val counter = hashMapOf<String, Int>()
    
    testResults.forEach { counter[it] = 0 }
    testCases.forEach { counter[it] = counter[it]?.plus(1) ?: 1 }

    testResults.forEach {
        val result = it + " x " + counter[it].toString()
        println(result)
    }
}


Measured memory_bytes: 60748
N = int(input())

dic = {}
for i in range(N):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1

dictlist = []
for key, value in dic.items():
    temp = [key,value]
    dictlist.append(temp)
dictlist.sort(key=lambda x:(-x[1], x[0]))

top = dictlist[0][1]
for i in range(len(dictlist)):
    if dictlist[i][1] == top:
        print(dictlist[i][0])

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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int N = sc.nextInt();
        boolean flg = true;
        for (int i = 0; i < N; i++) {
            int Ai = sc.nextInt();
            if (Ai % 2 == 0) {
                if (Ai % 3 != 0 && Ai % 5 != 0) {
                    flg = false;
                    break;
                }
            }
        }
        out.println(flg ? "APPROVED" : "DENIED");
        out.flush();
    }
}

// FastScanner start
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
// FastScanner end


Measured memory_bytes: 22484
//Created Time:2019年12月23日 星期一 18时50分17秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define pi pair < int , int >
#define N 200005
#define fi first
#define se second
#define oo 999999999999999999

using namespace std;

int n;
pi b[N];

int main(){
	scanf("%d", &n); int mx = 0, mn = 999999999;
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &b[i].fi, &b[i].se);
		if(b[i].fi > b[i].se) swap(b[i].fi, b[i].se);
		mx = max(mx, b[i].se); mn = min(mn, b[i].fi);
	}
	//Case1 mx -> R, mn -> R
	//Case2 mx -> R, mn -> B
	long long ans1 = oo, ans2 = oo;
	int l2 = mx, r2 = mn, l1 = 999999999, r1 = 0;
	sort(b + 1, b + 1 + n);
	for(int i = 1; i <= n; ++i){
		l2 = min(l2, b[i].se); r2 = max(r2, b[i].fi);
		ans1 = min(ans1, 1ll * (mx - mn) * (max(b[n].fi, r1) - min(b[i].fi, l1)));
		l1 = min(l1, b[i].se); r1 = max(r1, b[i].se);
	}
	ans2 = 1ll * (mx - l2) * (r2 - mn);
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
int a,b;
char s[20];
bool pos = true;
scanf("%d %d",&a,&b);
scanf("%s",s);

if(s[a] != '-'){ //itu [A] karena di index 1,+1 -1 = karena di soal index 1 di awal
	pos = false;
}

for(int i = 0;s[i]!='\0';i++){ //\0 (selama dia tidak sampai ke null maka loop terus
	if(i != a){//jika karakter bukan di A maka cek(selain -)
		if(s[i]< '0' || s[i]> '9'){ //kalau bukan di rentang ini bye
		 pos = false;
		 break; //karena false break aja dari loopnya
		}
    }	
}
	//kalau benar dan tidak false print yes
	(pos) ? printf("Yes\n") : printf("No\n");
	return 0;
}

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans;
  if(a+b >= 2*c) {
    if(x<y) {
      if(2*y*c < 2*x*c + (y-x)*b) ans = 2*y*c;
      else ans = 2*x*c + (y-x)*b;
    }
    else {
      if(2*x*c < 2*y*c + (x-y)*a) ans = 2*x*c;
      else ans = 2*y*c + (x-y)*a;
    } 
  }
  else {
    ans = a*x + b*y;
  }
  cout << ans << endl;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	ll ma = 0;
	int u = min(n, k);
	for(int i=0; i<=u; i++){
		for(int j=0; j<i; j++){
			if(i+j > k) continue;
			rep(l, i+1){
//				cout << i << ' ' << j << ' ' << l << ':';
				vector<int> pu(i);
				rep(ll, i){
					pu.at(ll) = a.at((n-i+ll+l)%n);
				}
				sort(pu.begin(), pu.end());
				reverse(pu.begin(), pu.end());
				ll sum = 0;
				rep(ll, i-j){
					sum += pu.at(ll);
//					cout << pu.at(ll) << ' ';
				}
//				cout << endl;
				if(sum > ma) ma = sum;
				
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x , a , b;
    cin >> x >> a >> b;
    if ( a >= b ) cout << "delicious";
    else if ( a + x >= b ) cout << "safe";
    else cout << "dangerous";
}


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

int main(void){
	int i,j,k,flag = 0;
	char s[51];
	char t[51];
	char s1[51];
	char ans[51];
	scanf("%s",s);
	scanf("%s",t);
	int slen=strlen(s);
	int tlen=strlen(t);
	strcpy(s1,s);
	strcpy(ans,s);
	for(i=0;i<slen;i++){
		if(ans[i]=='?')ans[i]='z';
	}
	for(i=0;i<(slen-tlen)+1;i++){
		j=0;
		while(s[i+j]==t[j] || s[i+j]=='?'){
			j++;
			if(j==tlen)break;
		}
		if(j==tlen){
			//matchした場合はmatchした場所をtで置き換えて
			//??を全部'a'にして配列に保存する
			flag = 1;
			strcpy(s1,s);
			for(k=0;k<tlen;k++)s1[i+k]=t[k];
			for(k=0;k<slen;k++){
				if(s1[k]=='?')s1[k]='a';
			}
			if(strcmp(ans,s1)>0){
				strcpy(ans,s1);
			}
		}
	}
	if(flag==0)printf("UNRESTORABLE");
	else printf("%s",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

#define MAX 100

int main(){
    int N,D,X,A[MAX],res=0;
    
    SCANFD(N);

    scanf("%d %d",&D,&X);

    REPI(N){
        SCANFD(A[i]);
    }

    REPI(N){
        res += (D-1)/A[i]+1;
    }
    
    res += X;
    printf("%d\n",res);
        
    return 0;
}


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


N = int(input())
S = set([input() for _ in range(N)])

m = len([cand for cand in S if ((cand[0] == 'M')) ])
a = len([cand for cand in S if ((cand[0] == 'A')) ])
r = len([cand for cand in S if ((cand[0] == 'R')) ])
c = len([cand for cand in S if ((cand[0] == 'C')) ])
h = len([cand for cand in S if ((cand[0] == 'H')) ])

# print(set_elements_num)

comb = m*a*r + m*a*c + m*a*h
comb += m*r*c + m*r*h + m*c*h
comb += a*r*c + a*r*h + a*c*h
comb += r*c*h

print(comb)

Measured memory_bytes: 58200
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    
    int i = 1;
    while(111*i < N) {
      i++;
    }
    
    System.out.println(111*i);
    
  }
}

Measured memory_bytes: 21584
#include    <iostream>
#include    <cmath>

using namespace std;

int main() {
    int n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double da;

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

        da = (y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1);
        if(fabs(da) < 1e-10) { da = 0.0; }

        if(da == 0.0) { cout << "YES" << endl; }
        else { cout << "NO" << endl; }
    }

    return 0;
}


Measured memory_bytes: 3220
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			Vector2D[] list = new Vector2D[4];
			for(int i = 0; i < 4; i++) {
				list[i] = new Vector2D(stdIn.nextDouble(),stdIn.nextDouble());
			}
			if(hittest_point_polygon_2d(list[0],list[1],list[2],list[3])) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	
	static class Vector2D {
		Vector2D(double x, double y) {
			this.x = x;
			this.y = y;
		}
		double x;
		double y;
	}
	
	static Vector2D sub_vector(Vector2D a, Vector2D b) {
		Vector2D ret = new Vector2D(0,0);
		ret.x = a.x - b.x;
		ret.y = a.y - b.y;
		return ret;
	}
	
	static boolean hittest_point_polygon_2d(Vector2D a, Vector2D b, Vector2D c, Vector2D p) {
		Vector2D ab = sub_vector(b,a);
		Vector2D bp = sub_vector(p,b);
		
		Vector2D bc = sub_vector(c,b);
		Vector2D cp = sub_vector(p,c);
		
		Vector2D ca = sub_vector(a,c);
		Vector2D ap = sub_vector(p,a);
		
		double c1 = ab.x * bp.y - ab.y * bp.x;
		double c2 = bc.x * cp.y - bc.y * cp.x;
		double c3 = ca.x * ap.y - ca.y * ap.x;
		if( ( c1 > 0 && c2 > 0 && c3 > 0 ) || ( c1 < 0 && c2 < 0 && c3 < 0 ) ) {
		        //三角形の内側に点がある
		        return true;
		}
		return false;
		
	}
	
}

Measured memory_bytes: 23408
h, w = map(int,input().split())
C = [list(input().split()) for i in range(h)]
import string
A = [chr(i) for i in range(ord("A"), ord("Z")+1)]
a = -1
b = -1
for i in range(h):
    for j in range(w):
        if C[i][j] == "snuke":
            a = i
            b = j
print("{}{}".format(A[b], a+1))

Measured memory_bytes: 38512
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [isize; n],
    }

    let minus_count = aa.iter().map(|&x| x).filter(|&x| x < 0).count();
    let zero_count = aa.iter().map(|&x| x).filter(|&x| x == 0).count();

    let mut max = aa.iter().map(|&x| x.abs()).sum::<isize>();

    if zero_count == 0 && minus_count % 2 == 1 {
        let min = aa.iter().map(|&x| x.abs()).min().unwrap();
        max -= 2 * min;
    }
    println!("{}", max);
}

Measured memory_bytes: 3732
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type Point struct {
	x int
	y int
}

type Points []Point

func (p Points) Len() int {
	return len(p)
}

func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Points) Less(i, j int) bool {
	if p[i].x == p[j].x {
		return p[i].y < p[j].y
	}
	return p[i].x < p[j].x
}

func main() {
	scanner.Split(bufio.ScanWords)
	var points Points = []Point{}
	n := nextInt()
	for i := 0; i < n; i++ {
		x := nextInt()
		y := nextInt()
		points = append(points, Point{x, y})
	}
	sort.Sort(points)
	for i := range points {
		fmt.Printf("%d %d\n", points[i].x, points[i].y)
	}
}


Measured memory_bytes: 8908
import heapq
pq = []

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in A:
  heapq.heappush(pq, -i)
for i in range(M):
  x = pq[0]
  heapq.heappop(pq)
  heapq.heappush(pq, -((-x)//2))
print(-sum(pq))

Measured memory_bytes: 14180
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);

		int total = 0;
		for (int i = 0; i < k; i++) {
			total += p[i];
		}
		System.out.println(total);
	}
}

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

using namespace std;


#define MOD 1000000007
#define ll long long int
#define ff first
#define ss second
#define N 100001


template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.ff<<", "<<a.ss<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}
    

void solve()
{
	int n;
	cin>>n;
	double p[n+1];
	for(int i=1;i<=n;i++)
		cin>>p[i];

	double dp[n+1][n+1];
	memset(dp,0.0,sizeof dp);
	dp[0][0]=1;

	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if(j==0)
				dp[i][j]=(1-p[i])*dp[i-1][j];
			else
				dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
		}
	double answer=0;
	for(int i=n/2+1;i<=n;i++)
		answer+=dp[n][i];
	cout<<fixed<<setprecision(10)<<answer<<"\n";
}
	


int32_t main()
{
    //your code goes here...
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }    
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    int n;
    cin>> n;

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

    int ans = 0;

    for(int i = 0; i < n; ++i){
        if(v[i] - c[i] > 0){
            ans += v[i] - c[i];
        }
    }

    cout << ans << endl;

}

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

AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if AC[p]==0:
       if s=='AC':
            AC[p]=1
            ans+=WA[p]
       else:
            WA[p]+=1
print(sum(AC),ans)


Measured memory_bytes: 10408
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

int64_t solve(int64_t a, int64_t b)
{
    auto big = gcd(a, b);
    int64_t counter = 1;

    for (int64_t i = 2; i * i <= big; i++)
    {
        if (big % i == 0)
        {
            while (big % i == 0)
            {
                big /= i;
            }
            counter++;
        }
    }
    if (big > 1)
    {
        counter++;
    }
    return counter;
}

int main()
{
    int64_t a, b;
    cin >> a >> b;

    cout << solve(a, b) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = list(str(input()))

flag = []
for i in range(3):
    flag.append(False)
small = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if s[0] == 'A':
    flag[0] = True

if flag[0]:
    count1 = 0
    for i in range(2, len(s) - 1):
        if s[i] == 'C':
            count1 += 1
            tmp = i
    if count1 == 1:
        flag[1] = True

if flag[0] and flag[1]:
    count2 = 0
    for i in range(1, len(s)):
        if i != tmp and (s[i] in small):
            count2 += 1
    if count2 == len(s) - 2:
        flag[2] = True

if flag[0] and flag[1] and flag[2]:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<stdio.h>
#include<vector>
#include<set>
#include<utility>
#include<ctype.h>
#include<ctime>
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
# define ll long long
using namespace std;
int gcd(int a,int b){
    int r;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int GCD(int a,int b)
{
    if(a==0) return b;
    else return GCD(b%a,a);
}
long long int power(long long int a,long long int b){
    long long int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}
int palindrome(char *s,int len)
{
    int i,j,k,count=0,c=0;
    for(i=0,j=len-1;i<len,j>=0;i++,j--){
        if(s[i]==s[j]) count++;
    }
	if(count==len) return 1;
    	else return 0;
}
long long int binary(char *s,long long int len)
{
    long long int i,j,k,r=0,p=0,num;
    for(i=len-1;i>=0;i--){
        num=s[i]-'0';
        r+=(num*power(2,p));
        p++;
    }
    return r;
}
int binary_search(int *ara,int size,int n)
{
    int high,mid,low;
    low=0;
    high=size-1;
    while(low<=high){
        mid=(low+high)/2;
        if(ara[mid]==n){
            return 1;
        }
        else if(n>ara[mid]) low=mid+1;
        else if(n<ara[mid]) high=mid-1;
    }
    return -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll int i,j,k,n,T,q,a,b,x,sum=0;
	string s1,s2;
    cin>>a>>b>>x;
    sum=b/x;
    ll int left=a/x;
    if(a%x==0) left--;
    sum=sum-left;
    //if(a==0) sum++;
    cout<<sum<<endl;

}



Measured memory_bytes: 256
n, a, b = map(int, input().split())
town = list(map(int, input().split()))
dist = []
for i in range(n-1):
  dist.append((town[i+1]-town[i])*a)

ans = 0
for i in range(n-1):
  ans += min(dist[i], b)
print(ans)

Measured memory_bytes: 90788
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const int mod = 1000000007;

int main() {
    int n; cin >> n;
    string s; cin >> s;

    int count = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'I'){
            count++;
        }
        if(s[i] == 'D'){
            count--;
        }
        ans = max(ans,count);
    }
    print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c+d){
        print("Balanced");
    }else if(a+b > c+d){
        print("Left");
    }else{
        print("Right");
    }

}


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

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n' || c == '\r';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n' || c == '\r'; c = buff.get());
  return c;
}
#define mp make_pair
typedef pair<int, int> P;
int n, m;
vector <P> ans;
int main() {
  n = getint(), m = getint();
  int h = n / 2;
  if (n & 1) {
    for (int i = 1; i <= h; i++) ans.push_back(mp(i, n - i));
  } else {
    for (int i = 1; i <= h / 2; i++) {
      ans.push_back(mp(i, n + 1 - i)); 
    }
    for (int i = h / 2 + 1; i <= h - 1; i++) {
      ans.push_back(mp(i, n - i)); 
    }
  }
  for (int i = 0; i < m; i++) {
    putint(ans[i].first, ' ');
    putint(ans[i].second, '\n');
  }
  bufo.flush();
  return 0;
}


Measured memory_bytes: 4148
MAX = 1000001; 
  
# array to store 
# prime factors 
factor = [0]*(MAX + 1); 
  
# function to generate all  
# prime factors of numbers 
# from 1 to 10^6 
def generatePrimeFactors(): 
    factor[1] = 1; 
  
    # Initializes all the  
    # positions with their value. 
    for i in range(2,MAX): 
        factor[i] = i; 
  
    # Initializes all  
    # multiples of 2 with 2 
    for i in range(4,MAX,2): 
        factor[i] = 2; 
  
    # A modified version of  
    # Sieve of Eratosthenes 
    # to store the smallest  
    # prime factor that divides 
    # every number. 
    i = 3; 
    while(i * i < MAX): 
        # check if it has 
        # no prime factor. 
        if (factor[i] == i): 
            # Initializes of j  
            # starting from i*i 
            j = i * i; 
            while(j < MAX):  
                # if it has no prime factor  
                # before, then stores the  
                # smallest prime divisor 
                if (factor[j] == j): 
                    factor[j] = i; 
                j += i; 
        i+=1; 
  
# function to calculate 
# number of factors 
def calc(n): 
    if (n == 1): 
        return 1; 
    ans = 1; 
  
    # stores the smallest  
    # prime number that 
    # divides n 
    dup = factor[n]; 
  
    # stores the count of  
    # number of times a  
    # prime number divides n. 
    c = 1; 
  
    # reduces to the next  
    # number after prime 
    # factorization of n 
    j = int(n / factor[n]); 
  
    # false when prime  
    # factorization is done 
    while (j > 1): 
        # if the same prime  
        # number is dividing  
        # n, then we increase 
        # the count 
        if (factor[j] == dup): 
            c += 1; 
  
        # if its a new prime factor 
        # that is factorizing n,  
        # then we again set c=1 and  
        # change dup to the new prime  
        # factor, and apply the formula  
        # explained above.  
        else: 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
  
        # prime factorizes 
        # a number 
        j = int(j / factor[j]); 
  
    # for the last 
    # prime factor 
    ans = ans * (c + 1); 
  
    return ans;
generatePrimeFactors()
n=input()
c=0
for i in range(1,n):
    c+=calc(n-i)
print c


Measured memory_bytes: 81056
def net(end_num):
    if end_num < 2:
        return []
    primes = [2]
    nums = list(range(3, end_num, 2))
    while nums:
        primes.append(nums[0])
        nums = [n for n in nums if n % nums[0]]
    return primes

cumsum = [0, 0, 0]
sum_val = 0
primes = net(330)
for n in range(3, 100001):
    like_2017 = True
    for p in primes:
        if (n % p == 0) and (n > p):
            like_2017 = False
            break
        if (((n + 1) // 2) % p == 0) and (((n + 1) // 2) > p):
            like_2017 = False
            break
    sum_val += like_2017
    cumsum.append(sum_val)
    
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l - 1])

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  vector<long long> da(n);
  for(int i=0;i<n;i++)
    cin >> da[i];
  sort(da.begin(),da.end());
  if(n%2==0){
    for(int i=0;i<n/2;i++)
      ans-=da[i]*2;
    for(int i=n/2;i<n;i++)
      ans+=da[i]*2;
    ans-=da[n/2]-da[n/2-1];
  }
  else{
    for(int i=0;i<n/2;i++)
      ans-=da[i]*2;
    for(int i=n/2+1;i<n;i++)
      ans+=da[i]*2;
    ans-=min(da[n/2]-da[n/2-1],da[n/2+1]-da[n/2]);
  }
  cout << ans << endl;
}

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

using namespace std;

using int64 = long long;

bool IsPowerOfTwo(int x) {
  return x > 0 && (x & (x - 1)) == 0;
}

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

  int n;
  cin >> n;
  if (IsPowerOfTwo(n)) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  cout << 1 << " " << 2 << endl;
  cout << 2 << " " << 3 << endl;
  cout << 3 << " " << n + 1 << endl;
  cout << n + 1 << " " << n + 2 << endl;
  cout << n + 2 << " " << n + 3 << endl;
  for (int i = 4; i + 1 <= n; i += 2) {
    cout << 1 << " " << i << endl;
    cout << i << " " << i + 1 << endl;
    cout << 1 << " " << n + i + 1 << endl;
    cout << n + i + 1 << " " << n + i << endl;
  }

  if (n % 2 == 0) {
    for (int i = 1; i <= n - 1; i++) {
      if ((n ^ i ^ 1) < n) {
        int v1 = i;
        int v2 = n ^ i ^ 1;
        if (v1 == v2) continue;
        if (v1 % 2 == 1) v1 += n;
        if (v2 % 2 == 1) v2 += n;
        cout << n << " " << v1 << endl;
        // cout << v1 << " " << 1 << endl;
        // cout << 1 << " " << v2 << endl;
        cout << v2 << " " << 2 * n << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <string>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define Pii pair< int, int > 
#define Pid pair< int, double > 
#define Pdd pair< double, double > 
#define MOD 1000000007
#define EPS 0.00000001
#define N_MAX 100000

using namespace std;

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

int gcd(int x, int y) {
    if (x>y) swap(x,y);
    while (true) {
        y = y % x;
        if (y == 0) return x;
        swap(x,y);
    }
}

signed main() {
    int n,k;
    int ans = 0;
    cin >> n >> k;
    vector<int> a(k);
    REP(i,k) {
        a[i] = k / (i+1);
    }
    vector<int> b(k);
    REP(i,k) {
        int idx = k - 1 - i;
        REP(j,a[idx] - 1) {
            b[idx] = (b[idx] - b[(j+2)*(idx+1)-1] + MOD) % MOD;
        }
        b[idx] = (b[idx] + powmod(a[idx],n)) % MOD;
    }
    REP(i,k) {
        //cout << b[i] << "\n";
        ans = (ans + b[i] * (i+1)) % MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4844
#include<iostream>
using namespace std;
int main(){
    string S;
    cin>>S;
    int answer=0;
    if(S=="SUN"){
        answer=7;
    }
    else if(S=="MON"){
        answer=6;
    }
    else if(S=="TUE"){
        answer=5;
    }
    else if(S=="WED"){
        answer=4;
    }
    else if(S=="THU"){
        answer=3;
    }
    else if(S=="FRI"){
        answer=2;
    }
    else answer=1;
    cout<<answer<<endl;
}

Measured memory_bytes: 256
fn main() {
    let _: i64 = read();
    let s: String = read::<String>();

    let mut dp: Vec<i32> = vec![0];
    for c in s.chars() {
        let prev = *dp.last().unwrap();
        dp.push(prev + if c=='(' { 1 } else { -1 });
    }

    let x = *dp.iter().min().unwrap();

    for _ in 0..x.abs() {
        print!("(");
    }
    print!("{}", s);
    for _ in 0..(*dp.last().unwrap() + x.abs()) {
        print!(")");
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
N = int(input())
bigp = 10**9+7
L = [pow(i+1, bigp-2, bigp) for i in range(N)]
K = [L[0]]
for i in range(N-1):
    K += [(K[-1] + L[i+1]) % bigp]
M = [(K[i] + K[N-i-1] - 1) % bigp for i in range(N)]
fctN = 1
for i in range(N):
    fctN *= i+1
    fctN = fctN % bigp
U = [(M[i]*fctN)%bigp for i in range(N)]
A = list(map(int, input().split()))
S = 0
for i in range(N):
    S = (S + U[i]*A[i])%bigp
print(S)

Measured memory_bytes: 30184
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int n;
int a[400005];
long long ans = 0;
int main(){
    cin >> n;
    int t =n *3;
    for(int i = 0; i < t; i++){
        cin >> a[i];
    }
    sort(a,a+t);
    int k = t - 2;
    while(n--){
        ans += a[k];
        k -= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

using namespace std;

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

vector<pair<int,int>> v[100001];
int edge[100001];
int ans;

void dfs(int x ,int c)
{
    int cl=1;
    for(auto i:v[x])
    {
        if(edge[i.se]) continue;
        if(cl==c) cl++;
        edge[i.se]=cl;
        dfs(i.fi,cl);
        cl++;
    }
}

int main()
{
    IOS;
    int n;
    cin>>n;
    repf(i,0,n-1)
    {
        ll x,y;
        cin>>x>>y;
        v[x].pb({y,i});
        v[y].pb({x,i});
    }
    int u=-1;
    repf(i,1,n+1) 
    {
        if(ans<v[i].size())
        {
            ans=v[i].size();
            u=i;
        }
    }
    dfs(u,-1);
    cout<<ans<<endl;
    repf(i,0,n-1) cout<<edge[i]<<endl;
    return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string s;
  cin>>s;

  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    if(i>n-i-1) break;
    if(i==n-i-1) continue;
    if(s[i]!=s[n-i-1]) ans++;
  }
  cout<<ans<<endl;

  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> v = {"AC", "WA", "TLE", "RE"};
  rep(i,4) {
    cout << v[i] << " x " << mp[v[i]] << endl;
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++) 
#define _For(i,a,b) for(int i=a;i>=b;i--)
#define LL long long 
inline LL CinLL(){LL x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline int Cin(){int x=0,f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return f*x;}
const int INF = 0x3f3f3f3f;
const int N = 100005;
int t,n,m,ans;
int a[N];
vector<int> v;
bool check(int x){
	if(x/10000==x%10&&(x/1000)%10==(x%100)/10){
		return true;
	}
	return false;
}
int main(){
//	freopen("2.txt","r",stdin);
	int l,r;
	cin>>l>>r;
	for(int i=l;i<=r;i++){
		if(check(i)){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	int a=n/1000,b=n/100%10,c=n/10%10,d=n%10;

	if     (a+b+c+d==7){ cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl; }
	else if(a+b+c-d==7){ cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl; }
	else if(a+b-c+d==7){ cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl; }
	else if(a+b-c-d==7){ cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl; }
	else if(a-b+c+d==7){ cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl; }
	else if(a-b+c-d==7){ cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl; }
	else if(a-b-c+d==7){ cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl; }
	else if(a-b-c-d==7){ cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl; }

	return 0;
}


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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


// int chmin(int &a, int b){ return a = min(a, b);}
int chmin(int &a, int b){ return a = min(a, b); }

int main(){
	int N;
	cin >> N;
	
	vector<int> yen;
	yen.push_back(1);
	for(int i=1; i<=5; i++) yen.push_back(pow(9, i));
	for(int i=1; i<=6; i++) yen.push_back(pow(6, i));
	sort(yen.rbegin(), yen.rend());

	// dp[i][j]: i-1番目のお札まで考慮した時に j円を作ることができる最小手数
	const int INF = N;
	vector<vector<int>> dp((int)yen.size()+2, vector<int>(N+1, INF+1));
	dp[0][0] = 0;

	for(int i=0; i<=(int)yen.size(); i++){
		for(int j=0; j<=N; j++){
			chmin(dp[i+1][j], dp[i][j]);// //yen[i]を使わない
			if(j+yen[i] <= INF) chmin(dp[i+1][j+yen[i]], dp[i][j] + 1);// yen[i]を1回目使う
			if(j+yen[i] <= INF) chmin(dp[i+1][j+yen[i]],dp[i+1][j] + 1);// yen[i]を2回目以上使う
		}
	}

	// print_vec2(dp);
	cout << dp[(int)yen.size()][N] << endl;



	// for(int i=0; i< (int)yen.size(); i++){
	// 	int sum = 0;
	// 	int cnt = 0;
	// 	for(int j=yen[i]; j<INF; j+= yen[i]){
	// 		if(sum > N) break;
	// 		sum += yen[i];
	// 		cnt++;
	// 	}
	// }

	// for(int i=yen[0]; i<INF; i += yen[0]){
	// 	for(int j=yen[1]; j<INF; j += yen[1]){

	// 	}

	// }


	// using P = pair<int, int>;
	// vector<P> aaa;
	// for(int i=0; i<(int)yen.size(); i++){
	// 	int num = N / yen[i];
	// 	N -= num*yen[i];
	// 	ans += num;
	// 	aaa.push_back(P(yen[i], num));
	// }
	// print_pairvec(aaa);

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



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

int main()
{
    int n, k ;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k - 1] == 'A') s[k - 1] = 'a';
    if (s[k - 1] == 'B') s[k - 1] = 'b';
    if (s[k - 1] == 'C') s[k - 1] = 'c';
    cout << s << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#define REP(i, START, n, STEP) for(int i = START; i < (n); i += (STEP))
#define rep(i, n) REP(i, 0, n, 1)
using namespace std;

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

int main() {
	int n, m;
	cin >> n >> m;
	int size = 1 << n;
	vector<P> key;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		int s = 0;
		rep(j, b) {
			int c;
			cin >> c;
			c--;
			s |= 1 << c;
		}
		key.emplace_back(s, a);
	}

	vector<int> dp(1 << n, -1);
	dp[0] = 0;
	rep(s, size) {
		// このノードに来れない場合
		if (dp[s] == -1)
			continue;
		rep(i, m) {
			// 移動先ノード
			int t = s | key[i].first;
			// 移動しない場合
			if (t == s)
				continue;
			// 最小コスト計算
			int cost = dp[s] + key[i].second;
			if (dp[t] == -1)
				dp[t] = cost;
			else
				dp[t] = min(dp[t], cost);
		}
	}

	if (dp[size - 1] == -1)
		cout << -1;
	else
		cout << dp[size - 1];

	return 0;
}


Measured memory_bytes: 256
// mai iss duniyaa ka sbse bada chutiyaaa huu

#include<bits/stdc++.h> 
#include <chrono> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl '\n'
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono; 

template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less_equal<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
       'j','k','l','m','n','o','p','q','r','s','t','u','v',
       'w','x','y','z'};

// rectangle intersection
// x5 = max(x1, x3);
// y5 = max(y1, y3);
// x6 = min(x2, x4);
// y6 = min(y2, y4); 

// const int mx = 100005;

// char get_next(char c) {
// 	for(int i=0; i<25; i++) if(c == alphabet[i]) return alphabet[i+1];
// 	return 'a';
// }

int32_t main() {
 	fastIO;
	int tc;
	// cin >> tc;
	tc = 1;
	while(tc --) {
		int n;
		cin >> n;
		if(n < 30) cout << "No" << endl;
		else cout << "Yes" << endl;
	}     
}



Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    D = int(input().strip())
    C = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    S = np.empty((D, 26), dtype=np.int32)
    for i in range(D):
        s = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
        S[i, :] = s[:]
    return D, C, S


@njit
def diff_satisfaction(C, S, d, p, last):
    """d日目にコンテストpを開催するときの、満足度の更新量を求める
    """
    v = 0
    for i in range(26):
        v -= C[i] * (d - last[i])
    v += C[p] * (d - last[p])
    v += S[d, p]
    return v


@njit
def change_schedule(D, C, S, T, d, q, cumsat):
    """d日目のコンテストをqに変更する
    """
    p = T[d]
    dp1, dq1 = -1, -1
    dp3, dq3 = D, D
    for i in range(0, d):
        if T[i] == p: 
            dp1 = i
        if T[i] == q:
            dq1 = i
    for i in range(D-1, d, -1):
        if T[i] == p:
            dp3 = i
        if T[i] == q:
            dq3 = i
    cumsat = cumsat - S[d, p] + S[d, q] - C[p] * (dp3-d) * (d-dp1) + C[q] * (dq3-d) * (d-dq1)
    return cumsat


@njit
def greedy(D, C, S):
    T = np.zeros(D, dtype=np.int32)
    last = np.zeros(26, dtype=np.int32)
    cumsat = 0
    for d in range(D):
        max_p = 0
        max_diff = -999999999

        # select contest greedily
        for p in range(26):
            diff = diff_satisfaction(C, S, d, p, last)
            if diff > max_diff:
                max_p = p
                max_diff = diff
        
        # update schedule
        cumsat += max_diff
        T[d] = max_p
        last[max_p] = d
    return cumsat, T


@njit
def solve(D, C, S):
    cumsat, T = greedy(D, C, S)
    for t in T:
        print(t+1)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 113696
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <map> 
using namespace std;
inline int gi() {
    register int data = 0, w = 1;
    register char ch = 0;
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar();
    while (isdigit(ch)) data = data * 10 + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 1e5 + 5; 
const int dx[] = {-2, -1, 0}, dy[] = {-2, -1, 0}; 

int H, W, N; 
map<pair<int, int>, int> mp; 
int ans[20]; 
int main () { 
	H = gi(), W = gi(), N = gi(); 
	for (int i = 1; i <= N; i++) { 
		int x = gi(), y = gi(); 
		for (int j = 0; j < 3; j++) 
			for (int k = 0; k < 3; k++) { 
				int _x = x + dx[j], _y = y + dy[k]; 
				if (_x < 1 || _x + 2 > H || _y < 1 || _y + 2 > W) continue; 
				mp[make_pair(_x, _y)]++; 
			} 
	} 
	for (auto ite : mp) ans[ite.second]++, ans[0]--; 
	printf("%lld\n", 1ll * (H - 2) * (W - 2) + ans[0]); 
	for (int i = 1; i <= 9; i++) printf("%d\n", ans[i]); 
    return 0; 
} 

Measured memory_bytes: 56448
#include <iostream>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <map>
#include <fstream>
#include <bitset>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vec;


int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	double t, a; cin >> n >> t >> a;
	int bestindex = -1;
	double bestval = 1e9;
	for (int i = 0; i < n; i++) {
		double x; cin >> x;
		if (abs(a - (t - x * 0.006)) <= bestval) {
			bestval = abs(a - (t - x * 0.006));
			bestindex = i + 1;
		}
	}

	cout << bestindex;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e8
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

typedef pair<ll,ll> P;

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

  int a[1000], b[1000], c[1000], dist[100][100];

  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = INF;
    }
  }

  for (int i = 0; i < m; ++i) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = m;
  rep(i,m) {
    bool shortest = false;
    rep(j,n) if(dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
    if (shortest) ans--;
  }

  cout << ans << endl;
}


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

int n;
int main(){
  int ans=0;
  cin >> n ;
  vector<int> a(n),b(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
 
  REP(i,n){
    if ((a[i]-b[i])>0)
      ans+=a[i]-b[i];
  }
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256