akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m,q;
vvb a;

int main(){
	cin>>n>>m>>q;
	a=vvb(n,vb(m,0));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		char c;
		cin>>c;
		if(c=='1') a[i][j]=1;
	}
	vvi s(n+1,vi(m+1)),s_(n+1,vi(m+1));
	vvi h(n+1,vi(m+1)),w(n+1,vi(m+1));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(a[i][j]){
		int num=0,H=0,W=0;
		if(i&&a[i-1][j]){
			num++;
			W++;
		}
		if(j&&a[i][j-1]){
			num++;
			H++;
		}
		s_[i+1][j+1]=1-num;
		h[i+1][j+1]=1-H;
		w[i+1][j+1]=1-W;
	}
	s=s_;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
		h[i][j]+=h[i][j-1];
	}
	for(int i=1;i<=m;i++) for(int j=1;j<=n;j++) w[j][i]+=w[j-1][i];
	for(int i=0;i<q;i++){
		int x,y,X,Y;
		cin>>x>>y>>X>>Y;
		int res=s[X][Y]-s[X][y]-s[x][Y]+s[x][y];
//		cout<<'A'<<res<<endl;
		res+=h[x][Y]-h[x][y];
//		cout<<'B'<<res<<endl;
		res+=w[X][y]-w[x][y];
//		cout<<'C'<<res<<endl;
		if(a[x-1][y-1]) res++;
		cout<<res<<endl;
	}/*
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++) cout<<h[i][j]<<' ';
		cout<<endl;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++) cout<<w[i][j]<<' ';
		cout<<endl;
	}*/
}

Measured memory_bytes: 66304
#include<iostream>
#include<algorithm>

using namespace std;

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

    int a,b;
    int max = -1;
    int min = N+1;
    for(int i =0;i<M;i++){
        cin >> a;
        if(max < a) max = a;
        cin >> b;
        if(min > b) min = b;
    }

    if(min - max +1 >=0 )cout << min - max +1 << endl;
    else cout << 0 <<endl;
    return 0;
}

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

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

	int ans = 0;
	for(int i = 1; i < N; i++)
		if (S[i-1] != 'z' && S[i] != S[i-1]) {
			S[i] = 'z';
			S[i-1] = 'z';
			ans++;
		}

	cout << ans << endl;
}


Measured memory_bytes: 3324
#include <stdio.h>

int main(){
    int i, s;
    char x[1001];
    
    while(scanf("%s", x), x[0] != '0'){
        s = 0;
        
        for(i = 0; x[i] != '\0'; ++i){
            s += x[i] - '0';
        }
        
        printf("%d\n", s);
    }
    
    return 0;
}


Measured memory_bytes: 2708
#include<bits/stdc++.h>   
using namespace std;      
int main(){
    long long b;
    while(true){
        cin >> b;
        if (b==0)return 0;
        long long now,count,temp;
        now = 1,count=1;
        long long token=b;
        for(long long i = 2;i<1000000000;i++){
            now += i;
            while(now>b){
                now -= count;
                count++;
            }
            if(now == b){
                cout << count << " " << i - count +1 << endl;
                break; 
            }
            
        }
    }
}


Measured memory_bytes: 3076
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

odd = 1
for v in a:
    if v % 2 == 0:
        odd *= 2
    else:
        odd *= 1

print(3 ** n - odd)


Measured memory_bytes: 81396
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n; cin >> n;
    vector<int> d(n); rep(i, 0, n) cin >> d[i];
    sort(d.begin(), d.end());
    int mid = n / 2;
    int ans = d[mid] - d[mid - 1];
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<double,ll> P;
const ll mod=1e9+7;

int n,a,b;
vector<ll> v(60);

vector<vector<ll> > comb(int n) {
  vector<vector<ll> > v(n+1,vector<ll>(n+1,0));
  rep(i,len(v)){
    v[i][0]=1;
    v[i][i]=1;
  }
  FOR(j,1,len(v))FOR(k,1,j){
    v[j][k]=v[j-1][k-1]+v[j-1][k];
  }
  return v;
}

bool c(double x,int k){
  double ret=0;
  rep(i,k){
    ret+=v[i]-x;
  }
  return ret>=0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    rep(i,n) cin>>v[i];
    sort(begin(v),end(v),greater<ll>());
    vector<P> ans;
    FOR(k,a,b+1){
      double lb=0,lh=1e18,mid;
      rep(i,100){
        //cout<<lb<<' '<<lh<<endl;
        mid=(lh+lb)/2;
        if(c(mid,k)) lb=mid;
        else lh=mid;
      }
      ans.push_back(P(lb,k));
    }
    sort(begin(ans),end(ans),greater<P>());
    double ma=ans[0].first;
    ll cnt=0;
    vector<vector<ll> > com=comb(50);
    rep(i,len(ans)){
      if(ans[i].first!=ma) break;
      ll ind=ans[i].second;
      ll last=v[ind-1];
      ll cnt1=count(begin(v),end(v),last);
      ll cnt2=count(begin(v),begin(v)+ind,last);
      //cout<<ans[i].first<<' '<<ans[i].second<<' '<<cnt1<<' '<<cnt2<<' '<<com[cnt1][cnt2]<<endl;
      cnt+=com[cnt1][cnt2];
    }
    cout<<setprecision(30)<<ma<<endl;
    cout<<cnt<<endl;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  vector<int> stone(1, X);
  for (int i = 1; i < K; i++) {
    stone.push_back(X-i);
    stone.push_back(X+i);
  }
  sort(stone.begin(), stone.end());
  for (int i = 0; i < stone.size(); i++) cout << stone[i] << " ";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int gcd(int x, int y)
{
    return x == 0 ? y : gcd(y % x, x);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int K;
    cin >> K;
    lint ret = 0;
    FOR(a, 1, K + 1)
        FOR(b, 1, K + 1)
            FOR(c, 1, K + 1)
                ret += gcd(a, gcd(b, c));
    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 3580
import numpy as np
n, m, c = map(int, input().split())
b_row  = np.array(list(map(int, input().split())))
a_rows = np.array([list(map(int, input().split())) for i in range(n)])

# print(b_row)
# print(a_rows)

ans_count = 0
for a_row in a_rows:
    # リストの各要素の積の合計を求める
    if sum(a_row * b_row) + c > 0:
        ans_count += 1

print(ans_count)

Measured memory_bytes: 12444
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define X first
#define Y second
#define MAXN 100010

char s[2][100];
ll dp[100][3];
const int mod = 1e9 + 7;

ll DP(int n, int c)
{
	if (n == 0) return 1;
	if (dp[n][c] != -1) return dp[n][c];
	
	if (s[0][n] == s[1][n])
	{
		if (c == 0)
		   return dp[n][c] = 3 * DP(n - 1, 1) % mod;
		if (c == 1)
		   return dp[n][c] = 2 * DP(n - 1, 1) % mod;
		if (c == 2)
		   return dp[n][c] = DP(n - 1, 1);	   
	}
	else
	{
		if (c == 0)
			return 6 * DP(n - 2, 2) % mod; 
		if (c == 1)
		   return 2 * DP(n - 2, 2) % mod;
		if (c == 2)
		   return 3 * DP(n - 2, 2) % mod;
	}
}

int main()
{
	//freopen("input", "r", stdin);
	//freopen("output", "w", stdout);
	
	memset(dp, -1, sizeof(dp));
	int n;
	scanf("%d", &n);
	scanf("%s %s", s[0] + 1, s[1] + 1);
	
	cout << DP(n, 0) << endl;
	return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	int i;string k;
	for(i=0;i<2*n;i++)
	{
	if(i%2==0)
	k.push_back(s[i/2]);
	else
	k.push_back(t[i/2])	;
	}
	cout<<k<<endl;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)

func scanLargeLine() string {
	// for large string > 64*1024
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sumSlice(nums []int) int {
	sum := 0
	for _, n := range nums {
		sum += n
	}
	return sum
}

func main() {
	scanner.Split(bufio.ScanWords) // switch to separating by space
	scanner.Buffer([]byte{}, 1000000009)
	N := nextInt()
	S := nextLine()

	totalLength := N
	var previousColor rune

	for _, color := range S {
		if color == previousColor {
			totalLength--
		}
		previousColor = color
	}

	fmt.Println(totalLength)
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int a;
	long long total =0;
	int sum =0;
	int z =0;
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			total +=i;
	    }
	}
	printf("%lld",total);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

    ll n,k;
    cin>>n>>k;
    ll pre =0;
    ll suf = 0;
    ll ans = 0;
    for(ll i = k; i<=n+1; i++){
        pre = (i-1)*i/2;
        suf = n*i - pre;
        ans+= suf - pre + 1;
    }
    cout<<ans%MOD<<"\n";   
}

Measured memory_bytes: 3644
package main

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

func main() {
	N, K, X, Y := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	if K >= N {
		fmt.Println(N * X)
		return
	}
	fmt.Println((N-K)*Y + K*X)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1840
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
horizontal = []
vertical = []
x_co = {INF, -INF}
y_co = {INF, -INF}
for _ in range(n):
    a, b, c = LI()
    x_co.add(a)
    x_co.add(b)
    y_co.add(c)
    vertical += [(a, b, c)]

for _ in range(m):
    d, e, f = LI()
    x_co.add(d)
    y_co.add(e)
    y_co.add(f)
    horizontal += [(d, e, f)]

x_len = len(x_co) * 2 - 1
y_len = len(y_co) * 2 - 1
x_co = sorted(list(x_co))
y_co = sorted(list(y_co))
x_comp = {val:i for i, val in enumerate(x_co)}
y_comp = {val:i for i, val in enumerate(y_co)}
grid = [[0] * y_len for _ in range(x_len)]

x_range = [0] * x_len
y_range = [0] * y_len
x_range[0] = x_range[-1] = INF
y_range[0] = y_range[-1] = INF

for i, (x1, x2) in enumerate(zip(x_co, x_co[1:])):
    x_range[i * 2 + 1] = x2 - x1
    if x1 <= 0 <= x2:
        sx = i * 2 + 1

for i, (y1, y2) in enumerate(zip(y_co, y_co[1:])):
    y_range[i * 2 + 1] = y2 - y1
    if y1 <= 0 <= y2:
        sy = i * 2 + 1


for a, b, c in vertical:
    y = y_comp[c] * 2
    for x in range(x_comp[a] * 2 + 1, x_comp[b] * 2 + 1, 2):
        grid[x][y] = 1

for d, e, f in horizontal:
    x = x_comp[d] * 2
    for y in range(y_comp[e] * 2 + 1, y_comp[f] * 2 + 1, 2):
        grid[x][y] = 1

ans = 0
dq = deque([(sx, sy)])
grid[sx][sy] = 1
diff = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans += x_range[sx] * y_range[sy]
while dq:
    x, y = dq.popleft()
    for dx, dy in diff:
        nx, ny = dx + x, dy + y
        if grid[nx][ny]:
            continue
        nx += dx;
        ny += dy
        if grid[nx][ny]:
            continue
        grid[nx][ny] = 1
        dq.append((nx, ny))
        ans += x_range[nx] * y_range[ny]
        if ans >= INF:
            print("INF")
            exit()

print(ans)

Measured memory_bytes: 435876
n = int(input())
Data = []
buildings =[[ [0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(n):
    b, f, r, v = map(int, input().split())
    Data.append([b,f,r,v])
    buildings[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' '+str(buildings[i][j][k]),end = '')
            #if k != 9:
            #    print(' ', end = '')
        print('')
    if i != 3:
        print('#'*20)



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

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

using namespace std;

int dp[17][17];

using M = tuple<int, int>;

int main() {
  int T;
  cin>>T;
  REP(cnt,T){
    int gx,gy;
    cin>>gx>>gy;
    REP(i,16)REP(j,16)dp[i][j] = 0;
    dp[0][0] = 1;
    int p;
    cin>>p;
    set<M> vm;
    set<M> hm;
    REP(i,p) {
      int x1,y1,x2,y2;
      cin>>x1>>y1>>x2>>y2;
      if (x1 > x2) swap(x1, x2);
      if (y1 > y2) swap(y1, y2);
      if (x1 == x2) vm.emplace(x1,y1);
      else hm.emplace(x1,y1);
    }
    REP(i,gy+1)REP(j,gx+1){
      if(!vm.count(M(j,i))) dp[i+1][j] += dp[i][j];
      if(!hm.count(M(j,i))) dp[i][j+1] += dp[i][j];
    }
    if (dp[gy][gx])
      cout << dp[gy][gx] << endl;
    else
      cout << "Miserable Hokusai!" << endl;
  }
  return 0;
}

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

int atscore(vector<int> p, vector<int> c, int G ){
  vector<int> num(p.size(),10000);
  int n;
  /* cout << "atscore(p, c, " << G << "){" << endl;
  for(int i = 0; i < p.size(); i++)
    cout << p.at(i) << ", ";
    cout << endl;*/
  if(G <= 0) n = 0;
  else{
    for(int i = 0; i < p.size(); i++){
      if(p.at(i) == 0) continue;
      else if(G>p.at(i)*(i+1)*100){
	int tmp = p.at(i);
	p.at(i) = 0;
	num.at(i) = atscore(p, c, G-tmp*(i+1)*100 - c.at(i)) + tmp;
	p.at(i) = tmp;
      }else{
	num.at(i) = (double)G/((i+1)*100) + 0.9999;
      }
    }
    sort(num.begin(),num.end());
    n = num.at(0);
  }
  /*for(int i = 0; i < p.size(); i++)
    cout << num.at(i) << " :";
  cout << endl;
  cout << n << endl;
  cout << "}atscore(p, c, " << G << ")" << endl;*/
  return n;
}

int main(){
  int D, G, i;
  cin >> D >> G;
  vector<int> p(D) , c(D);
  
  for(i = 0; i < D; i++){
    cin >> p.at(i) >> c.at(i);
  }
  cout << atscore(p,c,G) << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n%1000 % 111 == 0||n/10%111==0)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using namespace std;


int main()
{
    long long N, a[5], tmp;
    long long min = LONG_MAX;
    
    cin >> N;

    for (int i= 0; i < 5; i++) {
        cin >> a[i];
    }
    for (int i= 0; i < 5; i++) {
        if (min > a[i]) {
            min = a[i];
        }
    }

    if (N%min == 0) {
        tmp = N / min + 4;
    } else {
        tmp = N / min + 5;
    }
   
    cout << tmp << endl;
    
    return 0;   
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    
    int n,v,j;
    int A[10];
    
    for(int i=0; i<10; i++){
        scanf("%d",&A[i]);
    }
    for (int i=1; i<10; i++) {
        v=A[i];
        j = i-1;
        while (j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
        }
         A[j+1]=v;
    }
    printf("%d\n",A[9]);
    printf("%d\n",A[8]);
    printf("%d\n",A[7]);
    return 0;
}



Measured memory_bytes: 2116
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
        x,y = input().split()
        a.append([x,int(y),i+1])
a.sort(key=lambda x : (x[0],-x[1]))
for i,j,k in a:
        print(k)


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

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

  int n;
  cin >> n;
  list<int> l;
  REP(i, n) {
    string com;
    cin >> com;
    int k;
    if (com == "insert") {
      cin >> k;
      l.push_front(k);
    } else if (com == "delete") {
      cin >> k;
      auto it = find(ALL(l), k);
      if (it != l.end()) {
        l.erase(it);
      }
    } else if (com == "deleteFirst") {
      l.pop_front();
    } else if (com == "deleteLast") {
      l.pop_back();
    }
  }
  vector<int> vec{ALL(l)};
  REP(i, SZ(vec)) cout << (i ? " " : "") << vec.at(i);
  cout << endl;

  return 0;
}


Measured memory_bytes: 33988
#include<set>
#include<iostream>
#include<algorithm>

#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
int gx,gy;
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//
    return false;
  }
  
  void make_next(int now,priority_queue<state,vector<state>,greater<state> >&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }


  bool operator>(const state & a)const{
    if ( cnt != a.cnt)return cnt > a.cnt;
    
    return max(x[0],gx)-min(x[0],gx)+max(y[0],gy)-min(y[0],gy) >
      max(a.x[0],gx)-min(a.x[0],gx)+max(a.y[0],gy)-min(a.y[0],gy) ;
  }
  
  bool operator<(const state & a)const{

    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  priority_queue<state,vector<state>,greater<state> > Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.top();
    Q.pop();

    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    gx=dx;gy=dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 28000
# -*- coding: utf-8 -*-
S= list(input())

isR = True
cnt_tmp = 0
cntList = []
for s in S:
    if s == 'R':
        if isR:
            cnt_tmp += 1
        else:
            cntList.append(cnt_tmp)
            isR = True
            cnt_tmp = 1
    else:
        if isR:
            cntList.append(cnt_tmp)
            isR = False
            cnt_tmp = 1
        else:
            cnt_tmp += 1

cntList.append(cnt_tmp)

ans = []

for i,cnt in enumerate(cntList):
    if i % 2 == 0:
        # R
        ans += [0] * (cnt - 1)
        q, mod = divmod(cnt, 2)
        ans += [q+mod, q]
    else:
        #L
        q, mod = divmod(cnt, 2)
        ans[len(ans)-2] += q
        ans[len(ans)-1] += (q+mod)
        ans += [0] * (cnt - 1)

print(' '.join([str(n) for n in ans]))

Measured memory_bytes: 11940
# include <iostream>
# include <stdio.h>
# include <cmath>
# include <iomanip>
# include <cstring>
# include <string>
# include <cctype>
# include <algorithm> //transformの関数はaslgorithmライブラリに入っているみたい。
using namespace std;
class dice{
public:
  int label[6];
  void roll(char);
};
void dice::roll(char direction){
  int temp;
  if(direction == 'E'){
    temp = label[2];
    label[2] = label[0];
    label[0] = label[3];
    label[3] = label[5];
    label[5] = temp;
  }else if(direction == 'N'){
    temp = label[4];
    label[4] = label[0];
    label[0] = label[1];
    label[1] = label[5];
    label[5] = temp;
  }else if(direction == 'S'){
    temp = label[1];
    label[1] = label[0];
    label[0] = label[4];
    label[4] = label[5];
    label[5] = temp;
  }else if(direction == 'W'){
    temp = label[3];
    label[3] = label[0];
    label[0] = label[2];
    label[2] = label[5];
    label[5] = temp;
  }
}
int main(){
  dice d1;
  int q,num1,num2;
  for(int i = 0;i<6;i++){
    cin >> d1.label[i];
  }
  cin >> q;
  for(int i =0;i<q;i++){
    cin >> num1 >> num2;
    if(num1 == d1.label[1]){
      d1.roll('N');
    }else if(num1 == d1.label[2]){
      d1.roll('W');
    }else if(num1 == d1.label[3]){
      d1.roll('E');
    }else if(num1 == d1.label[4]){
      d1.roll('S');
    }else if(num1 == d1.label[5]){
      d1.roll('S');
      d1.roll('S');
    }

    if(num2 == d1.label[1]){
      cout << d1.label[2] << endl;
    }else if(num2 == d1.label[2]){
      cout << d1.label[4] << endl;
    }else if(num2 == d1.label[4]){
      cout << d1.label[3] << endl;
    }else if(num2 == d1.label[3]){
      cout << d1.label[1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int A[100010],B[100010],C[100010],n,t[100010];
void update(int x,int d){while(x<=n)t[x]+=d,x+=x&-x;}
int query(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
std::vector<int>intvl[100010];
bool used[100010];
std::priority_queue<std::pair<int,int>>que;
int ans[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi()+1;
	for(int i=1;i<n;++i)A[i]=gi(),B[i]=gi();
	for(int i=1;i<=n;++i)C[i]=gi();
	std::sort(C+1,C+n+1);
	for(int i=1;i<n;++i)A[i]=std::lower_bound(C+1,C+n+1,A[i])-C;
	for(int i=1;i<n;++i)B[i]=std::lower_bound(C+1,C+n+1,B[i])-C;
	for(int i=1;i<n;++i)if(B[i]<A[i])intvl[A[i]-1].push_back(i);
	for(int i=1;i<=n;++i)update(i,-1);
	for(int i=1;i<n;++i)update(A[i],1);
	int now=n-1,Q=gi();
	for(int i=n;i;--i){
		int qi=-1-query(i);
		for(int j:intvl[i])if(!used[j])que.push({-B[j],j});
		while(qi-->0){
			if(que.empty()||i<-que.top().first){while(Q--)puts("-1");return 0;}
			int t=que.top().second;used[t]=1;que.pop();
			update(B[t],1);update(A[t],-1);
			--now;
		}
	}
	while(!que.empty())que.pop();
	for(int i=1;i<=n;++i)intvl[i].clear();
	for(int i=1;i<n;++i)if(B[i]<A[i]&&!used[i])intvl[B[i]].push_back(i);
	for(int i=1;i<=n;++i){
		ans[i]=now;
		int qi=-query(i);
		for(int j:intvl[i])if(!used[j])que.push({A[j],j});
		while(qi-->0){
			if(que.empty()||i>que.top().first){now=-1e9;break;}
			int t=que.top().second;used[t]=1;que.pop();
			update(B[t],1);update(A[t],-1);
			--now;
		}
	}
	ans[n+1]=-1e9;
	while(Q--){
		int a=gi(),b=gi();
		a=std::lower_bound(C+1,C+n+1,a)-C;
		b=std::lower_bound(C+1,C+n+1,b)-C;
		int res=-1;
		if(res<ans[a]+1)res=std::max(res,ans[a]+1);
		if(res<ans[b])res=std::max(res,ans[b]);
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 9328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    ll t[n+1];
    ll all = 0LL;
    for(int i = 1; i <= n; i++){
        cin >> t[i];
        all += t[i];
    }
    int m;
    cin >> m;
    int p[m];
    ll x[m];
    for(int i = 0; i < m; i++){
        cin >> p[i] >> x[i];
    }
    for(int i = 0; i < m; i++){
        cout << all - t[p[i]] + x[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t_point = 0
h_point = 0
n.times{
    t = gets.split.map(&:to_s)
    if t[0].to_s < t[1].to_s
        h_point += 3
    elsif t[0].to_s > t[1].to_s
        t_point += 3
    else
        t_point += 1
        h_point += 1
    end
}
puts "#{t_point} #{h_point}"


Measured memory_bytes: 6856
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S
import Debug.Trace
main = mapM_ (print . solve) . analyze . map readInt . B.words =<< B.getContents
readInt = fst . fromJust . B.readInt
analyze (n:k:cs) = let (as,bs) = splitAt n cs in (n,k,as):analyze bs
analyze _ = []
solve::(Int,Int,[Int])->Int
solve (n,k,as) = fst . foldr f (0,(0,S.empty)) . zip [n,n-1..] $ as where
  f (i,a) (c,(d,s)) = (c+r,(e,t)) where
    e = k-a+d
    t = S.insert (d,i) s
    r = case S.lookupGE (e,0) t of
      Just x  -> i-(fromJust . S.lookupIndex x $ t)
      Nothing -> 0

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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;

    cout << "A" << B.at(0) << "C" << endl;
}


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

using namespace std;

const int MaxN = 1e5 + 15;

int n;
vector <int> v[MaxN];
string s;


int cnt[MaxN];

int dp[MaxN];
int dp1[MaxN];
int dp2[MaxN];

int all;
int bw;

void dfs1(int x, int p = 0)
{
    int curCnt = 0;

    for(int to : v[x])
    {
        if(cnt[to] > 0)
            ++curCnt;
        if(to != p)
            dfs1(to, x);
    }

    if(curCnt & 1)
        if(s[x] == 'W')
            s[x] = 'B';
        else
            s[x] = 'W';
}

void dfs(int x, int p = 0)
{
    ++all;

    vector <int> dps;

    dp1[x] = dp2[x] = dp[x] = -1e9;

    for(int to : v[x])
        if(to != p)
            if(cnt[to] > 0)
            {
                dfs(to, x);
                dps.push_back(dp1[to]);

                dp[x] = max(dp[x], dp[to]);
            }

    if(s[x] == 'W')
        ++bw;

    if(!dps.empty())
    {

        sort(dps.begin(), dps.end());
        reverse(dps.begin(), dps.end());

        dp1[x] = 1 + dps[0] + (s[x] == 'W' ? 1 : -1);

        if(dps.size() > 1)
            dp2[x] = 2 + dps[0] + dps[1] + (s[x] == 'W' ? 1 : -1);

    }else
        dp1[x] = (s[x] == 'W' ? 1 : -1);

    dp[x] = max(max(dp[x], dp1[x]), dp2[x]);
}

int main()
{
//    freopen("output.txt", "r", stdin);

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    for(int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);

        ++cnt[x];
        ++cnt[y];
    }

    cin >> s;
    s = "#" + s;

    if(find(s.begin(), s.end(), 'W') == s.end())
        return cout << 0 << '\n', 0;

    set<int> ss;

    for(int i = 1; i <= n; ++i)
    {
        if(cnt[i] == 1 && s[i] == 'B')
            ss.insert(i);
    }

    while(!ss.empty())
    {
        int x = (*ss.begin());
        ss.erase(ss.begin());

        cnt[x] = -1;

        for(int to : v[x])
        {
            --cnt[to];
            if(cnt[to] == 1 && s[to] == 'B')
                ss.insert(to);
        }
    }

    int root = 0;

    for(int i = 1; i <= n; ++i)
        if(cnt[i] == 1 || cnt[i] == 0)
            root = i;

    if(!root)
        return cout << 0 << '\n', 0;

    dfs1(root);

    dfs(root);

    if(all == 1)
        return cout << 1 << '\n', 0;

    cout << -1 + 2 * (all - 1) - dp[root] + bw << '\n';

    return 0;
}


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

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

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

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;


    private void slove() {

        int n = sc.nextInt();

        long dp[] = new long[n+1];
        long dpx[] = new long[n+1];
        dp[1] = 0;
        dpx[1] = 1;
        long pow = 8;
        for (int i = 2; i <= n ; i++) {
            dp[i] = ((dp[i-1]*10)%MOD + dpx[i-1]*2)%MOD;
            dpx[i] = (dpx[i-1]*9 + pow)%MOD;
            pow = (pow*8)%MOD;
        }



        System.out.println(dp[n]);





    }

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


Measured memory_bytes: 52500
#include <bits/stdc++.h>
using namespace std;
#define LL long long

const int maxn = (int) 2e5 + 20;
const int MOD = (int) 1e9 + 7;

string s, t;

int op[26][26], iop[26][26];

void work()
{
    cin >>s >>t;
    for(int i = 0; i < s.size(); i++)
    {
        int x = s[i] - 'a';
        int y = t[i] - 'a';
        op[x][y] = 1;
        iop[y][x] = 1;
    }

    int flag = 1;
    for(int i = 0; i < 26; i++)
    {
        int c = 0, ic = 0;
        for(int j = 0; j < 26; j++) c += op[i][j];
        for(int j = 0; j < 26; j++) ic += iop[i][j];

        if(c > 1 || ic > 1) flag = 0;
    }

    puts(flag ? "Yes" : "No");

}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 776
import sys

readline = sys.stdin.readline


def main():
    S = readline().strip()
    N = len(S)
    M = 10 ** 5
    K = len(bin(M)) - 2

    A = [[0] * N for _ in range(K)]
    for i, c in enumerate(S):
        if c == 'R':
            A[0][i] += i + 1
        else:
            A[0][i] += i - 1

    for k in range(K - 1):
        for i in range(N):
            A[k + 1][i] = A[k][A[k][i]]

    B = list(range(N))
    ans = [0] * N
    for k in range(K):
        if M & (1 << k):
            for i in range(N):
                B[i] = A[k][B[i]]

    for b in B:
        ans[b] += 1

    print(' '.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 96652
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

k = lines[0][0]
n = lines[0][1]
a = lines[1]

houses = a.sort

distance = []

for i in 1..n-1
  distance.push(houses[i] - houses[i-1])
end
distance.push(k - houses[n-1] + houses[0])

max_dist = distance.max
print k - max_dist

Measured memory_bytes: 22000
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	a = int(input())
	#b , c = tin()
	#s = input()
	dd = defaultdict(lambda :0)
	for i in range(2, a):
		while a % i == 0:
			dd[i]+=1
			a = a // i
		if i ** 2 > a:
			if a != 1:
				dd[a]+=1
			break
	
	ret = 0
	for key in dd:
		v = dd[key]
		for i in range(1, 100):
			if v < i:
				break
			v -= i
			ret += 1
	print(ret)
		
			
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

long long int dp[101][100101];
const int INF = 1001001001;

int main(){
    int n,W,ans = 0;
    cin >> n >> W;

    vector<int>w(n);
    vector<int>v(n);

    for(int i = 0;i < n;i++)
        cin >> w[i] >> v[i];
    
    for(int i = 0;i <= 100100;i++)
        dp[0][i] = INF;
    dp[0][0] = 0;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= 100100;j++){
            if(j < v[i])
                dp[i+1][j] = dp[i][j];
            else 
                dp[i+1][j] = min(dp[i][j-v[i]]+w[i],dp[i][j]);
        }
    }

    for(int i = 0;i <= 100100;i++)
        if(dp[n][i] <= W)ans = max(ans,i);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 79232
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

count = 0
for i in range(N):
    A = list(map(int, input().split()))
    summention = sum(a*b for a, b in zip(A, B))
    if summention + C > 0:
        count += 1
print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int32_t main()
{
	IOS;
	int n, k;
	cin>>n>>k;
	set<int> st;
	for(int i=0; i<k; i++)
	{
		int d;
		cin>>d;
		for (int i = 0; i < d; ++i)
		{
			int x;
			cin>>x;
			st.insert(x);
		}
	}
	cout<<n-st.size()<<endl;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(void){
	int n,k;
	int pairables, solos;
	
	while (scanf("%d", &n), n){
		pairables = solos = 0;
		for (int i=0; i<n; i++){
			scanf("%d", &k);
			if (k==1) solos++;
			if (k>=2) pairables++;
		}
		if (pairables==0){
			puts("NA");
		} else {
			printf("%d\n", solos + pairables + 1);
		}
	}
	return 0;
}
		

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

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a+b)>(c+d)) cout << "Left" << endl;
    else if((a+b)==(c+d)) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        if (A >= 13) { Console.WriteLine(B); }
        else if(A<=5){ Console.WriteLine(0); }
        else { Console.WriteLine(B/2); }
    }
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

	bool chpal(string s){
		int n=sz(s);
		rep(i,n/2) if(s[i]!=s[n-1-i]) return false;
		return true;
	}

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n;
	s = to_string(n);
	
	cout<< (chpal(s)? "Yes": "No") <<"\n";
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
xp0,yp0,xp1,yp1 = map(float,raw_input().split())
q = int(raw_input())
for i in range(q):
    xp2,yp2 = map(float,raw_input().split())
    p0p2 = (xp2-xp0,yp2-yp0)
    p0p1 = (xp1-xp0,yp1-yp0)
    k = ((p0p2[0]*p0p1[0]+p0p2[1]*p0p1[1])/(p0p1[0]**2 + p0p1[1]**2))
    # p2t??¨p0p1????????????T??¨??????
    p0T = (k*p0p1[0],k*p0p1[1])
    OT = (xp0+p0T[0],yp0+p0T[1])
    p2t = (2*(OT[0]-xp2),2*(OT[1]-yp2))
    Ot =  (p2t[0] + xp2,p2t[1] + yp2)
    print "%.10f %.10f" % (Ot[0],Ot[1])

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int a,b;
	cin>>a>>b;
	int k =a+b;
	if(k>=24){
		cout<<k-24<<endl;
	  }
	  else{
	cout<<a+b<<endl;}
}


Measured memory_bytes: 256
X = "a".ord
A = [-1] + gets.chomp.chars.map{ |c| c.ord - X } + [26]
FIN = A.size-1
Heads = Array.new(26, FIN)
Edges = Array.new(A.size, nil)
(0...A.size-1).reverse_each{ |i|
  c = A[i]
  Edges[i] = Heads.dup
  Heads[c] = i
}

#p Edges
BackEdges = Array.new(A.size, nil)
row = [0]
while true do
  h = {}
  rs = []
  row.each{ |i|
    ei = Edges[i]
    (0...26).each{ |k|
      j = ei[k]
      #p [i,k,j,BackEdges[j]]
      next if BackEdges[j] || h[j]
      h[j] = 1
      rs << [i,k,j]
    }
  }
  rs.each{ |i,k,j|
    BackEdges[j] = [k,i]
  }
  row = rs.map{ |i,k,j| j }
  #p rs, row, FIN
  break if BackEdges[FIN]
end

#p BackEdges

ans = []
a = BackEdges[FIN]
while a do
  k,i = a
  ans << k
  a = BackEdges[i]
end
puts ans.reverse.map{ |a| (a+X).chr }.join


Measured memory_bytes: 101732
#include <iostream>
#include<ctype.h>
#include<stdio.h>
using namespace std;

int main() {

	char ch[2000];
	scanf("%[^\n]", ch);
	for (int i = 0; ch[i] != '\0'; i++) {
		char c = ch[i];
		if ('a' <= c && c <= 'z') {
			printf("%c", toupper(c));
		}
		else if ('A' <= c && c <= 'Z') {
			printf("%c", tolower(c));
		}
		else {
			printf("%c",c);
		}
	}printf("\n");
		return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int a, b;
int N;

signed main(int argc, char *argv[], char *envp[]){
	cin >> N;
	bool flag = false;
	for(int i = 1; i<10; ++i){
		if(N % i == 0){
			a = N /i;
			b = N / a;
			if ((a > 0) && (a <= 9.0) && (b > 0) && (b <= 9.0)){
				flag = true;
			}
		}
	}
	if(flag){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int x[3];
    x[0]=a+b;
    x[1]=a-b;
    x[2]=a*b;
    sort(x,x+3);
    cout<<x[2]<<endl;
    return 0;
}


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

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    long long tmp = a - k;
    cout << ((a >= k) ? a - k : 0) << " " << ((a >= k) ? b : ((a+b > k) ? a+b-k : 0)) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N , L,ans=0,ll=9999;
  cin>>N>>L;
  vector<int> date(N);
  for(int i=0;i<N;i++){
     date[i]=L+i;
     ans+=date[i];
  }
  for(int i=0;i<N;i++){
    ll = min(ll, abs(date[i]));
  }
  if(ans>0) cout<<ans-ll<<endl;
  if(ans<=0) cout<<ll+ans<<endl;
}


Measured memory_bytes: 256
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    int i,x;

    for (i=0;; i++){
        scanf("%d", &x);
        if (!x)
            break;
        printf("Case %d: %d\n", succ(i), x);
    }
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

Measured memory_bytes: 600
r,c = [int(i) for i in input().split()]
list = []

for i in range(r):
    a = [int(i) for i in input().split()]
    list.append(a)
    list[i].append(sum(a))

list.append([])

for i in range(c+1):
    sum = 0
    for j in range(r):
        sum += list[j][i]
    list[r].append(sum)


for a in list:
    for i in range(c+1):
        if i == c:
            print("{}".format(a[i]),end = "")
        else:
            print("{}".format(a[i]),end = " ")
    print()



Measured memory_bytes: 6248
import copy
h,w,k=map(int,input().split())
L=[list(input()) for i in range(h)]
r=0
for i in range(1<<h):
    for j in range(1<<w):
        T=copy.deepcopy(L)
        for l in range(h):
            if i & (1<<l):
                for a in range(w):
                    T[l][a]='.'
        for m in range(w):
            if j & (1<<m):
                for b in range(h):
                    T[b][m]='.'
        c=0
        for d in range(h):
            for e in range(w):
                if T[d][e]=='#':
                    c+=1
        if c==k:
            r+=1
print(r)

Measured memory_bytes: 9172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

int main() {
    int n; scanf("%d", &n);
    vector<int> t(n); repeat (i, n) scanf("%d", &t[i]);
    vector<int> v(n); repeat (i, n) scanf("%d", &v[i]);
    const int max_v = *max_element(whole(v));
    constexpr int zoom = 2;
    vector<double> cur(zoom * max_v + 3, - INFINITY);
    vector<double> prv(zoom * max_v + 3, - INFINITY);
    cur[0] = 0;
    repeat (i, n) {
        fill(cur.begin() + (zoom * v[i] + 1), cur.end(), - INFINITY);
        fill(prv.begin() + (zoom * v[i] + 1), prv.end(), - INFINITY);
        repeat (tick, zoom * t[i]) {
            cur.swap(prv);
            cur[0] = max(prv[0], prv[1] + 0.5 / zoom);
            repeat_from (a, 1, zoom * v[i] + 1) {
                cur[a] = max({ prv[a - 1] - 0.5 / zoom, prv[a], prv[a + 1] + 0.5 / zoom }) + a /(double) (zoom * zoom);
            }
        }
    }
    printf("%.12lf\n", cur[0]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,K,Q;
    scanf("%d%d%d",&N,&K,&Q);
    int A[Q];
    int Point[N],Flag[N];
    for(int i = 0;i < Q; i++)
    scanf("%d",&A[i]);

    for(int i = 0;i < N; i++){
        Flag[i] = 0;        //No
        Point[i] = 0;
    }

    for(int i=0;i< Q; i++){
        int x = A[i];
        Point[x-1] = Point[x-1]+1;                          //〇人目なので、-1しないとおかしくなる
        //printf("%d人目のポイントは%d\n",A[i],Point[A[i]]);
    }

    // for(int i=0;i<N;i++){
    //     printf("途中の%d人目のポイントは%d \n",i,Point[i]);
    // }

    for(int i=0; i<N; i++){
        Point[i] = K - Q + Point[i];
        if(Point[i]>0){
            Flag[i]=1;
        }
    }

    for(int i=0; i<N; i++){
        //printf("最終の%d人目のポイントは%d ",i,Point[i]);
        if(Flag[i]==0){
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
    }

}



Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef long long int lli;
const lli inf = 1e18;

int pow2[21];
struct triple{
    int u,v,w;
    triple(int u, int v, int w):u(u),v(v),w(w){}
    triple(){}
};

int main(){
    pow2[0] = 1;
    for(int i=0; i<20; i++){
        pow2[i+1] = pow2[i]*2;
    }

    int l;
    cin >> l;
    int n=-1;
    for(int i=0; i<25; i++){
        if((1<<i & l) != 0) n=i;
    }
    
    vector<triple> ans;
    for(int i=0; i<n; i++){
        ans.emplace_back(i+1, i+2, 0);
        ans.emplace_back(i+1, i+2, pow2[i]);
    }

    int num = pow2[n];
    for(int i=n-1; i>=0; i--){
        if((1<<i & l) != 0){
            ans.emplace_back(i+1, n+1, num);
            num += pow2[i];
        }
    }

    cout << n+1 << " " << ans.size() << endl;
    for(triple a: ans){
        cout << a.u << " " << a.v << " " << a.w << endl;
    }

    return 0;
}

Measured memory_bytes: 256