akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
//#define M 32
using namespace std;
//const int N = 1e5+7;
//const int MOD = 1e9+7;
char a[7][7];
void solve() {
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>a[i][j];
            
     //cout<<a[0][2]<<"\n";
    int ans=0;
    for(int r=0; r<((1<<h)-1); r++) {
        for(int c=0; c<((1<<w)-1); c++) {
            int black=0;
            for(int i=0; i<h; i++)
                for(int j=0; j<w; j++) {
                    if(((r>>i)&1)==0 && ((c>>j)&1)==0 && a[i][j]=='#')
                        black++;
                }
            if(black==k)
                ans++;

        }
    }
    cout<<ans<<"\n";
}
int32_t main() {
    ios
    //int t;
    //cin>>t;
    solve();
    return 0;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    map<char, int> dic;
    for (int i = 0; i < 4; i++) {
        if (dic.count(s.at(i))) {
            dic[s.at(i)]++;
        } else {
            dic[s.at(i)] = 1;
        }
    }

    string ans = "Yes";
    if (dic.size() == 2) {
        for (auto p : dic) {
            if (p.second != 2) {
                ans = "No";
            }
        }
    } else {
        ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int c = 0;
    for(int i = 0; i < n-2; i++){
        int mi = MIN(p[i], MIN(p[i+1], p[i+2]));
        int ma = MAX(p[i], MAX(p[i+1], p[i+2]));
        if(p[i+1] == mi) continue;
        else if(p[i] != p[i+1] && p[i+1] != p[i+2] && p[i+1] == ma){
            continue;
        }
        c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    IN(ll, K);
    AIN(ll, A, N);
    AIN(ll, B, M);
    ll s = 0;
    ll j;
    for (j = 0; j < M; ++j)
    {
        if (s + B[j] <= K)
        {
            s += B[j];
        }
        else
        {
            break;
        }
    }
    ll ans = j;
    REP(i, N)
    {
        s += A[i];
        while (s > K and j >= 1)
        {
            --j;
            s -= B[j];
        }
        if (s <= K)
        {
            CH(max, ans, i + j + 1);
        }
    }
    OUT(ans);
}

Measured memory_bytes: 6376
using System;
using System.Collections.Generic;
using System.Linq;

namespace Reverse
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            List<string> i = Console.ReadLine().Split(' ').ToList();
            i.Reverse();

            for(int j = 0; j < i.Count; j++)
            {
                Console.Write(i[j] + (j < i.Count - 1 ? " " : "\n"));
            }
        }
    }
}

Measured memory_bytes: 9184
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S, T;
    int i;
    cin >> S >> T ;
    int N = S.size(), count = 0;
    for (i = 0; i < N; i++)
    {
        if (S[i] != T[i]) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,h=1,cur=2,ans;
    cin>>a>>b;
    while (1)
    {
        if (h<a)
        {
            h+=cur;
            cur++;
        }
        else
        {
            if ((h-a)==(h+cur-b))
            {
                ans=h-a;
                break;
            }
            h+=cur;
            cur++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}


void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<int> v[26];
  rep(i, sz(s)) v[s[i] - 'a'].insert(i);

  int q;
  cin >> q;
  while (q--) {
    int key;
    cin >> key;
    // cout << key << endl;
    if (key == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;

      auto it = v[s[i] - 'a'].lower_bound(i);
      v[s[i] - 'a'].erase(it);

      s[i] = c;
      it = v[c - 'a'].lower_bound(i);
      v[c - 'a'].insert(it, i);

      continue;
    }
    int l, r;
    cin >> l >> r;
    l--; r--;

    int cnt = 0;
    rep(i, 26) {
      auto it = v[i].lower_bound(l);
      if (it == v[i].end()) continue;
      if (*it <= r) cnt++;
    }
    cout << cnt << endl;
  }

}


Measured memory_bytes: 26268
# import matplotlib.pyplot as plt
import math

def squaredDistance(a, b):
  return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2

# for X in range(1, 180):
angle = 90
X = int(input())
iter = 0
current = [0, 0]
previous = current

while (iter == 0 or squaredDistance(current, [0, 0]) > 0.00001):
  if (iter > 500):
    break

  dir = [math.cos(math.radians(angle)), math.sin(math.radians(angle))]
  current = [current[0] + dir[0], current[1] + dir[1]]
  angle = (angle + X) % 360
  # plt.plot([previous[0], current[0]], [previous[1], current[1]])
  previous = current
  iter = iter + 1

  # plt.show()

print(iter)
  # print("X = {} : {}".format(X, iter))



Measured memory_bytes: 9380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef double LD;
const int N=6;
const int C=1000;
const int M=100;
int n,c;
int l[N+10];
namespace task {
    int p[N+10];
    LD f[C+10][M+10][C+10];
    LD Solve() {
        for (int i=1;i<n;i++)
            p[i]=i;
        LD invfac=1;
        for (int i=1;i<n;i++) invfac/=i;
        LD ans=0;
        do {
            for (int i=0;i<=n*c;i++)
                for (int j=0;j<(1<<(n-1));j++)
                    for (int k=0;k<=n*c;k++)
                        f[i][j][k]=0;
            f[0][0][l[1]*n]=1;
            for (int i=0;i<n*c;i++)
                for (int j=0;j<(1<<(n-1));j++)
                    for (int k=0;k<=n*c;k++) {
                        if (f[i][j][k]==0||i>k) continue;
                        f[i+1][j][k]+=f[i][j][k];
                        if (i%n) {
                            if (j&(1<<(i%n-1))) continue;
                            int nowr=min(n*c,max(k,i+l[p[i%n]+1]*n));
                            f[i+1][j|(1<<(i%n-1))][nowr]+=f[i][j][k]*1.0/c;
                        }
                    }
            ans+=f[n*c][(1<<(n-1))-1][n*c];
        } while (next_permutation(p+1,p+n));
        return ans*invfac;
    }
}
int main() {
    scanf("%d%d",&n,&c);
    for (int i=1;i<=n;i++)
        scanf("%d",&l[i]);
    sort(l+1,l+n+1);
    reverse(l+1,l+n+1);
    LD ans=task::Solve();
    printf("%.15lf\n",ans);
    return 0;
}


Measured memory_bytes: 260992
# ３重ループではTLE
# a < b < c & c < a + b

import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0

for i in range(N):
    for j in range(i+1,N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L,t)
        ans += max(0, idx-j-1) # c < a + b の範囲を総取り
print(ans)


Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n%10 == 2 || n%10==4||n%10==5||n%10==7||n%10==9){
            System.out.println("hon");
        } else if(n%10==0||n%10==1||n%10==6||n%10==8){
            System.out.println("pon");
        } else{
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 35568
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2,key;
    cin >> s;
    key = "keyence";
    if(s == key){
        cout << "YES" << endl;
        return 0;
    }
    for(int i=0; i<s.size()-1;i++){
        for(int j=i;j<s.size();j++){
            s1="";
            for(int k=0;k<s.size();k++){
                if(i<=k&&k<=j)
                    continue;
                else
                    s1.push_back(s[k]);
            }
            if(s1==key){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
import collections
class Dinic:
    def __init__(self, vnum):
        self.edge = [[] for i in range(vnum)]
        self.n = vnum
        self.inf = float('inf')
    def addedge(self, st, en, c):
        self.edge[st].append([en, c, len(self.edge[en])])
        self.edge[en].append([st, 0, len(self.edge[st])-1])
    def bfs(self, vst):
        dist = [-1]*self.n
        dist[vst] = 0
        Q = collections.deque([vst])
        while Q:
            nv = Q.popleft()
            for vt, c, r in self.edge[nv]:
                if dist[vt] == -1 and c > 0:
                    dist[vt] = dist[nv] + 1
                    Q.append(vt)
        self.dist = dist
    def dfs(self, nv, en, nf):
        nextv = self.nextv
        if nv == en:
            return nf
        dist = self.dist
        ist = nextv[nv]
        for i, (vt, c, r) in enumerate(self.edge[nv][ist:], ist):
            if dist[nv] < dist[vt] and c > 0:
                df = self.dfs(vt, en, min(nf, c))
                if df > 0:
                    self.edge[nv][i][1] -= df
                    self.edge[vt][r][1] += df
                    return df
            nextv[nv] += 1
        return 0
    def getmf(self, st, en):
        mf = 0
        while True:
            self.bfs(st)
            if self.dist[en] == -1:
                break
            self.nextv = [0]*self.n
            while True:
                fl = self.dfs(st, en, self.inf)
                if fl > 0:
                    mf += fl
                else:
                    break
        return mf

H, W = map(int, input().split())
G = [input() for _ in range(H)]
T = Dinic(H+W)
inf = 10**9+7
SS = []
for i in range(H):
    for j in range(W):
        if G[i][j] == '.':
            continue
        if G[i][j] == 'o':
            T.addedge(i, H+j, 1)
            T.addedge(H+j, i, 1)
            continue
        SS.append(i)
        SS.append(H + j)
        T.addedge(i, H+j, inf)
        T.addedge(H+j, i, inf)
ans = T.getmf(SS[0], SS[-1])
if ans >= 10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 48236
import numpy as np
h, n = map(int, input().split())
attack = [0] * n
magic = [0] * n
#ab = np.array([list(map(int, input().split())) for _ in range(n)])
for i in range(n):
    a, b = map(int, input().split())
    attack[i] = a
    magic[i] = b
attack = np.array(attack)
mgic = np.array(magic)

lim = 0
dp = [lim] * (h + 1)
dp = np.array(dp)
dp[0] = 0
# dp; 体力iに対するCost Accumulation
#
# np.zeros > 0埋め
# np.ones >　１埋め
# np.full > 　任意の埋め

for i in range(1, h + 1):
    temp = dp[np.maximum(i - attack, 0)] + magic
    # 1ステップ前のAccumulationに、Magicを足す。
    dp[i] = np.min(temp)

print(dp[h])

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

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

  long long r=0,g=0,b=0;
  for (int i = 0; i < n; i++)
  {
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }

  long long ans = r*g*b;
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      int k = j+j-i;
      if(k<n){
        if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]) ans--;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

int swap(int &a,int &b){
	int c;
	c=a;
	a=b;
	b=c;

	return 0;
}



int main(){
	int a,b;
	cin>>a>>b;
	cout<<a/b<<" "<<a%b<<" "<<fixed<<static_cast<double>(a)/b;
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1244
N = int(input())
TXY = [[int(i) for i in input().split()] for _ in range(N)]

flag = True
for i in range(N):
    if i == 0:
        dist = TXY[i][1] + TXY[i][2]
        if TXY[i][0] >= dist and (TXY[i][0] - dist) % 2 == 0:
            continue
        flag = False
        break
    dist = abs(TXY[i][1]-TXY[i-1][1]) + abs(TXY[i][2]-TXY[i-1][2])
    if TXY[i][0] >= TXY[i-1][0]+dist and (TXY[i][0]-TXY[i-1][0]-dist) % 2 == 0:
        continue
    flag = False
    break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21156
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

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

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S := sc.nextRuneSlice()
	Q := sc.nextInt()
	var changed bool
	var front, back []rune
	for i := 0; i < Q; i++ {
		query := sc.nextInt()
		if query == 1 {
			changed = !changed
		} else {
			f := sc.nextInt()
			c := sc.nextRuneSlice()[0]
			if changed {
				if f == 1 {
					back = append(back, c)
				} else {
					front = append(front, c)
				}
			} else {
				if f == 1 {
					front = append(front, c)
				} else {
					back = append(back, c)
				}
			}
		}
	}
	var ans []rune
	if !changed {
		for l, r := 0, len(front)-1; l < r; l, r = l+1, r-1 {
			front[l], front[r] = front[r], front[l]
		}
		ans = append(ans, front...)
		ans = append(ans, S...)
		ans = append(ans, back...)
	} else {
		for l, r := 0, len(back)-1; l < r; l, r = l+1, r-1 {
			back[l], back[r] = back[r], back[l]
		}
		for l, r := 0, len(S)-1; l < r; l, r = l+1, r-1 {
			S[l], S[r] = S[r], S[l]
		}
		ans = append(ans, back...)
		ans = append(ans, S...)
		ans = append(ans, front...)
	}
	fmt.Fprintln(wtr, string(ans))
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    if((a*b) % 2 == 1) Yes;
    else No;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;
const LL M  = 998244353;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, k;
	std::cin >> n >> k;
	std::vector<LL> dp(n), s(n);
	auto sum = [&](int k) -> LL{
		return k >= 0 ? s[k] : 0;
	};
	std::vector<std::pair<int, int>> p(k);
	for (auto &[x, y] : p) std::cin >> x >> y;
	s[0] = dp[0] = 1;
	for (int i = 1; i < n; ++i) {
		for (auto [l, r] : p) {
			dp[i] += sum(i - l) - sum(i - r - 1);
		}
		dp[i] %= M;
		if(dp[i] < 0) dp[i] += M;
		s[i] = s[i - 1] + dp[i];
		if (s[i] >= M) s[i] -= M;
	}
	std::cout << dp.back() << std::endl;
	return 0;
}

Measured memory_bytes: 6360
(N,) = [int(x) for x in input().split()]
brackets = [input() for i in range(N)]

delta = []
minDelta = []
for s in brackets:
    balance = 0
    mn = 0
    for c in s:
        if c == "(":
            balance += 1
        else:
            balance -= 1
        mn = min(mn, balance)
    delta.append(balance)
    minDelta.append(mn)

if sum(delta) == 0:
    # Want to get balance as high as possible
    # Take any positive delta first as long there's enough balance to absorb their minDelta
    # Can sort since any that works will only increase balance and the ones with worse minDelta comes last
    posIndices = [i for i in range(N) if delta[i] > 0]
    posIndices.sort(key=lambda i: (minDelta[i], delta[i]), reverse=True)

    # At the top can take all with zero delta, just need to absorb minDelta
    eqIndices = [i for i in range(N) if delta[i] == 0]

    # When going back down, 
    negIndices = [i for i in range(N) if delta[i] < 0]
    negIndices.sort(key=lambda i: (delta[i] - minDelta[i], minDelta), reverse=True)

    balance = 0
    for i in posIndices + eqIndices + negIndices:
        if balance + minDelta[i] < 0 or balance + delta[i] < 0:
            print("No")
            exit()
        balance += delta[i]
    assert balance == 0

    print("Yes")
else:
    print("No")


Measured memory_bytes: 242948
N = int(input())
As = list(map(int, input().split()))

data = [0] * N
d0 = As[0] + 1
if d0 < N:
	data[d0] = 1

count = 0
for j in range(1, N):
#	print(data)
	A = As[j]
	d = j + 1 - A
	if d >= 0:
		count += data[d]
	d = A + j + 1
	if d < N:
		data[d] += 1

print(count)

Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
bool visprime[10000000];
vector<ll>prime;
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime.pb(i);}}


bool vis[100000+10];
int main()
{

  int n;
  cin>>n;
  string x,y;
  cin>>x;
  cin.ignore();
  cin>>y;
  for(int i=0;i<n;i++)
  {
      cout<<x[i]<<y[i];
  }
  cout<<endl;



}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int n;
int a[200005];

bool check(int mxc) {
	set <pii> nw;
	rep(i, n) if (i) {
		if (a[i] > a[i - 1]) continue;
		while (!nw.empty() && nw.rbegin() -> first > a[i]) nw.erase(-- nw.end());
		int nwpos = a[i];
		while (nwpos && !nw.empty() && nw.rbegin() -> first == nwpos && nw.rbegin() -> second == mxc) {
			nw.erase(-- nw.end()); -- nwpos;
		}
		if (!nwpos) return 0;
		if (!nw.empty() && nw.rbegin() -> first == nwpos) {
			int x = nw.rbegin() -> second;
			nw.erase(-- nw.end()); nw.insert(mp(nwpos, x + 1));
		} else {
			if (2 > mxc) return 0;
			nw.insert(mp(nwpos, 2));
		}
	}
	return 1;
}

int main() {
	n = read();
	rep(i, n) a[i] = read();
	int lb = 1, rb = n;
	while (lb < rb) {
		int md = (lb + rb) >> 1;
		if (check(md)) rb = md;
		else lb = md + 1;
	}
	printf("%d\n", lb);
	return 0;
}

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

int main() {
  int A, N;
  cin >> N >> A;
  
  if(N % 500 == 0){
    cout << "Yes" << endl;
  }
  else if(N % 500 <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

template <class T>
inline void tense(T &a, const T &b)
{
	if (b < a)
		a = b;
}

const int MaxN = 1000;
const int MaxM = 5000;
const int INF = 0x3f3f3f3f;

int n;
vector<int> adj[MaxN + 1];

int sum[MaxN + 1];

int f[MaxN + 1];
int g[MaxM + 1];

struct object
{
	int x, y;
	object() {}
	object(const int &_x, const int &_y)
		: x(_x), y(_y) {}
};
vector<object> cur;

int main()
{
	cin >> n;
	for (int v = 2; v <= n; ++v)
	{
		int u = getint();
		adj[u].push_back(v);
	}

	for (int u = 1; u <= n; ++u)
		sum[u] = getint();

	for (int u = n; u >= 1; --u)
	{
		cur.clear();
		for (int v : adj[u])
			cur.emplace_back(sum[v], f[v]);

		g[0] = 0;
		for (int i = 0; i <= sum[u]; ++i)
			g[i] = 0;

		for (object p : cur)
			for (int i = sum[u]; i >= 0; --i)
			{
				int ret = INF;
				if (i >= p.x)
					tense(ret, g[i - p.x] + p.y);
				if (i >= p.y)
					tense(ret, g[i - p.y] + p.x);

				g[i] = ret;
			}

		f[u] = INF;
		for (int i = 0; i <= sum[u]; ++i)
			tense(f[u], g[i]);
	}

	if (f[1] < INF)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  int h, w, n;
  cin >> h >> w >> n;
  int x = max(h,w);
  int ans = dup(n,x);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Sn = 0;
		String NS = String.valueOf(N);
		for(int i = 0;i < NS.length(); i++) {
			Sn += Integer.parseInt(String.valueOf(NS.charAt(i)));
		}
		if(N % Sn == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cassert>
#include<set>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back

typedef long long ll;

bool vis[10][10];
char m[10][10];

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

bool isout(int ney,int nex,int r,int c){
  return nex==-1||ney==-1||nex==c||ney==r;
}

bool isok(int y,int x,int r,int c){
  int all=0,cnt=0;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c))continue;
    all++;
    if (m[ney][nex] == '0')cnt++;
  }
  if (cnt <= 1)return false;
  return true;
}

bool vis2[10][10];
void canvisitall(int r,int c,int y,int x,
		 int &tmp){
  if (vis2[y][x])return;
  vis2[y][x]=true;
  tmp--;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c)||
	m[ney][nex] == '1')continue;
    canvisitall(r,c,ney,nex,tmp);
  }
}

ll geta(int r,int c){
  ll ret=0;
  rep(i,r){
    rep(j,c)ret=ret*2+vis[i][j];
  }
  return ret;
}

set<ll> S;
int ini;
bool search(int r,int c,int y,int x,int cnt,
	    int sy,int sx,int py,int px){
  if (cnt==0){
    return x==sx && y == sy;
  }
  if (vis[y][x])return false;
  
  int tmp=cnt+1;
  rep(i,r)rep(j,c)vis2[i][j]=vis[i][j];
  vis2[sy][sx]=false;

  canvisitall(r,c,y,x,tmp);
  if ((x!=sx||y!=sy) && tmp != 0){
    return false;
  }

  vis[y][x]=true;
  ll tmp2=geta(r,c);
  if (S.find(tmp2) != S.end()){
    vis[y][x]=false;
    return false;
  }
  S.insert(tmp2);

  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c)||
	m[ney][nex] == '1')continue;
    if (nex == px && ney == py)continue;
    if (search(r,c,ney,nex,cnt-1,sy,sx,y,x))return true;
  }
  vis[y][x]=false;
  return false;
}

main(){
  int r,c;
  while(cin>>c>>r && r){
    S.clear();
    int sx=0,sy=0;
    int cnt=0;
    bool haveans=true;
    rep(i,r){
      rep(j,c){
	cin>>m[i][j];
	if (m[i][j] == '0')sx=j,sy=i,cnt++;
	vis[i][j]=false;
      }
    }

    rep(i,r){
      rep(j,c){
	if (m[i][j]=='0'&&!isok(i,j,r,c))haveans=false;
      }
    }

    ini=cnt;
    if (ini == 1||ini == 0){
      cout <<"No" << endl;
      continue;
    }
    if (ini > 1 && haveans && search(r,c,sy,sx,cnt,sy,sx,-1,-1))
      cout << "Yes" << endl;
    else cout <<"No" << endl;
  }
  return false;
}

Measured memory_bytes: 16000
n = int(input())
che = [input()]
for i in range(1,n):
  a = input()
  if a in che:
    print('No')
    exit()
  else:
    che.append(a)
    if che[i-1][-1] == che[i][0]:
      continue
    else:
      print('No')
      exit()
print('Yes') 

Measured memory_bytes: 9100
//Cheese
#include <iostream>
#include <queue>

using namespace std;
static const int MAX = 1000;
static const int dx[4] = {1, 0, -1, 0};
static const int dy[4] = {0, 1, 0, -1};

int H, W, N, gx, gy;
int A[MAX][MAX];
bool visited[MAX][MAX];

struct State {
    int x, y, d;
    State() {}
    State(int x, int y, int d): x(x), y(y), d(d) {}
};

int bfs(int t, int x, int y) {
    queue<State> Q;
    Q.push(State(x, y, 0));
    for(int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            visited[i][j] = false;
        }
    }
    visited[y][x] = true;
    while(!Q.empty()) {
        State s = Q.front();
        Q.pop();
        if(A[s.y][s.x] == t) {gx = s.x; gy = s.y; return s.d;}
        for(int i = 0; i < 4; i++) {
            int sx, sy;
            sx = s.x + dx[i];
            sy = s.y + dy[i];
            if(sx >= 0 && sy >= 0 && sx < W && sy < H) {
                if(A[sy][sx] == -1) continue;
                if(visited[sy][sx]) continue;
                Q.push(State(sx, sy, s.d + 1));
                visited[sy][sx] = true;
            }
        }
    }
    return 0;
}

int main() {
    cin >> H >> W >> N;
    char c;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> c;
            if(c == '.') A[i][j] = 0;
            else if(c == 'X') A[i][j] = -1;
            else if(c == 'S') {A[i][j] = 0; gx = j; gy = i;}
            else A[i][j] = c - '0';
        }
    }

    int d = 0;
    for(int i = 1; i < N + 1; i++) d += bfs(i, gx, gy);

    cout << d << endl;

    return 0;
}


Measured memory_bytes: 7924
tate, yoko = gets.chomp.split(' ').map(&:to_i)
grid = []
indexes = []
tate.times do
  line = gets.chomp.split('')
  if (line.include?('#'))
    indexes << line.size.times.select{ |i| line[i]=='#' }
    grid << line
  end
end
indexes = indexes.flatten.uniq.sort
grid.each do |line|
  indexes.each do |i|
    print line[i]
  end
  puts
end

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  unordered_map<int, int> uo{};
  for (int i = 1; i <= 102; i++) {
    for (int j = 1; j <= 102; j++) {
      for (int k = 1; k <= 102; k++) {
        int tmp = i * i + j * j + k * k + i * j + j * k + k * i;
        uo[tmp]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << uo[i] << endl;
  }
}

Measured memory_bytes: 5112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

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

	int count = 0;
	for (int i = 0; i < s.size(); i+=2)
	{
		if (s.size() == 1)
		{
			break;
		}

		if (s.size() % 2 != 0)
		{
			break;
		}

		if (s.compare(i,2,"hi") == 0)
		{
			count++;
		}
		else
		{
			count = 0;
			break;
		}
	}

	if (count > 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

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

#define int long long
main()
{
    int mi=1e15;
   // cout<<mi<<endl;
    int n;cin>>n;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            int q=i,qq=n/i;
            int ww=qq+q-2;
            if(ww<mi) mi=ww;
        }
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

m = 1000000007

a = [e for e in A if e > 0]
b = [e for e in A if e < 0]
c = [e for e in A if e == 0]
# プラスルート
if len(a) >= K - (min(K, len(b)) // 2) * 2:
    a.sort(reverse=True)
    b.sort()
    result = 1
    i = 0
    j = 0
    k = 0
    while k < K:
        if k < K - 1 and i < len(a) - 1 and j < len(b) - 1:
            x = a[i] * a[i + 1]
            y = b[j] * b[j + 1]
            if y >= x:
                result *= y
                result %= m
                j += 2
                k += 2
            else:
                result *= a[i]
                result %= m
                i += 1
                k += 1
        elif k < K - 1 and j < len(b) - 1:
            y = b[j] * b[j + 1]
            result *= y
            result %= m
            j += 2
            k += 2
        elif i < len(a):
            result *= a[i]
            result %= m
            i += 1
            k += 1
        elif j < len(b):
            result *= b[j]
            result %= m
            j += 1
            k += 1
    print(result)
# 0 ルート
elif len(c) != 0:
    print(0)
# マイナスルート
else:
    a.sort()
    b.sort(reverse=True)
    result = 1
    i = 0
    j = 0
    k = 0
    while k < K:
        if i < len(a) and j < len(b):
            if a[i] <= -b[i]:
                result *= a[i]
                result %= m
                i += 1
                k += 1
            else:
                result *= b[j]
                result %= m
                j += 1
                k += 1
        elif i < len(a):
            result *= a[i]
            result %= m
            i += 1
            k += 1
        elif j < len(b):
            result *= b[j]
            result %= m
            j += 1
            k += 1
    print(result)


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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a)
        cout << k;
    else if(k <= a + b)
        cout << a;
    else
        cout << a - (k - a - b);

}

Measured memory_bytes: 3604
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cumsum_a = [0] * (N + 1)
cumsum_b = [0] * (M + 1)

for i in range(1, N + 1):
    cumsum_a[i] = cumsum_a[i - 1] + A[i - 1]

for i in range(1, M + 1):
    cumsum_b[i] = cumsum_b[i - 1] + B[i - 1]

ans = 0
bi = M
for i in range(N+1):
    for j in range(bi, -1, -1):
        t = cumsum_a[i] + cumsum_b[j]
        if t <= K:
            ans = max(ans, i + j)
            bi = j
            break

print(ans)


Measured memory_bytes: 48704
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
A = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n, m = map(int, input().split())
g = [set() for i in range(n+1)]
e = set();
for i in range(m):
    a,b=map(int,input().split())
    g[a].add(b);
    g[b].add(a);
    e.add((a,b))

color = [0]*(n+1)
def dfs(u, p):
#    print(u, p);
    color[u] = 1
    for next_u in g[u]:
        if next_u == p:
            continue
        if not color[next_u]:
            dfs(next_u, u)

ret = 0
for edge in e:
    color = [0]*(n+1)
    g[edge[0]].remove(edge[1]);
    g[edge[1]].remove(edge[0]);
#    print(g)
    dfs(edge[0], -1)
    ret += color[edge[1]]
    g[edge[0]].add(edge[1]);
    g[edge[1]].add(edge[0]);

print(m-ret);


Measured memory_bytes: 12496
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << (e - a > k ? ":(" : "Yay!"
    );
}
#endif


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {

        try (Scanner sc = new Scanner(System.in)){
       
	   final int n = sc.nextInt();
           int i = 1;
           do {
               int x = i;
               if ( x % 3 == 0) {
                  System.out.printf(" " + i);
                } else{
                    do{
                        if( x % 10 == 3) {
                           System.out.print(" " + i);
                           break;
                      }
                      x /= 10;
                    } while (x != 0);
                 }
               } while (++i <= n);
               System.out.println();
          }
    }
}

Measured memory_bytes: 29824
import sys
input = sys.stdin.readline
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = sorted(list(int(i) for i in input().split()))
  f = sorted(list(int(i) for i in input().split()),reverse = True)
  if sum(a) <= k:
    print(0)
    exit()
  
  ng = 0
  ok = 10**15

  while ok-ng >1 :
    next = (ok+ng)//2
    #a*fの値がnext以下になるか判定する
    tmpk = k
    for i in range(n):
      ta = a[i]
      tf = f[i]
      if ta*tf > next:
        tmpk -= math.ceil((ta*tf-next)/tf)
    if tmpk < 0:
       ng = next
    else:
       ok = next
  print(ok)
    
solve()

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

int main(){
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
	
	long long int h,n;
	cin>>h>>n;
	long long int i,temp,sum=0;
	for(i=0;i<n;i++){
	    cin>>temp;
	    sum=sum+temp;
	}
	if(sum>=h){
	    cout<<"Yes";
	}
	else{
	    cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r)
{
    // pからr-1までをパーティションする
    int x, i, j, t;
    x = A[r];  // A[r]を基準としてxをA[r]とする
    i = p - 1;  // iはp-1とする
    for (j = p; j < r; j++) {
        // p <= j < rとしてjは1つずつ大きくなる
        if (A[j] <= x) {
            // A[j]がx以下のとき
            // iをインクリメントして，A[i]とA[j]を交換する
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
        // A[j]がxより大きいときは何もしない
    }
    // A[i + 1]とA[r]を交換する
    // つまりxより大きい要素で最も交換されたのが遅いものとA[r + 1]を交換する
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;  // A[r]が移動した場所を返す
}

int main(int argc, char const *argv[])
{
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        // 移動済みの数列を表示する．
        // 基準となった数のみ[]で囲まれる
        if (i) {
            printf(" ");
        }
        if (i == q) {
            printf("[");
        }
        printf("%d", A[i]);
        if (i == q) {
            printf("]");
        }
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<double> fact(10);

int main() {
  int N;
  cin >> N;
  vector<P> XY(N);
  rep(i, N) {
    cin >> XY[i].first;
    cin >> XY[i].second;
  }
  fact[0] = 1; fact[1] = 1;
  for (double i = 2; i <= N; i++) {
    fact[i] = fact[i-1] * i;
  }
  double ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      double x = (XY[i].first - XY[j].first);
      double y = (XY[i].second - XY[j].second);
      double dis = pow((x * x + y * y), 0.5);
      ans += dis * 2 * fact[N-1];
    }
  }
  printf("%.10f\n", ans / fact[N]);
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<ll> X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];

    int ans = 0;

    auto f = [&](int i){
        return X[i] * X[i] + Y[i] * Y[i] <= D * D;
    };

    rep(i, N) {
        if (f(i)) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
 
int main()
{
	fio
	int n;
	cin>>n;
	vector<ll int>nm(n);
	vector<ll int>sm(n);
	for(int i=0;i<n;++i)
	{
		cin>>nm[i];
		if(i==0)
		{
			sm[i]=nm[i];
		}
		else{
			sm[i]=sm[i-1]+nm[i];
		}
	}
	vector<vector<ll int>>D(n,vector<ll int>(n,-1));
	for(int i=0;i<n;++i)
	{
		for(int j=i;j>=0;--j)
		{
			if(i==j)
			{
				D[j][i]=0;
			}
			else if(i-j==1)
			{
				D[j][i]=nm[i]+nm[j];
			}
			else{
				for(int x=j;x<i;++x)
				{
					if(D[j][i]==-1)
					{
						D[j][i]=D[j][x]+D[x+1][i]+sm[i]-(j==0?0:sm[j-1]);
					}
					else{
						D[j][i]=mn(D[j][i],D[j][x]+D[x+1][i]+sm[i]-(j==0?0:sm[j-1]));
					}
					
				}
			}
		}
	}
	cout<<D[0][n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 4512
N=int(input())
W=[]
ans ='Yes'

for i in range(N):
    W += [input()]
    

for i in range(N-1):
    if W[i][-1]!= W[i+1][0]:
        ans ='No'

if len(set(W)) != N:
    ans = 'No'

print(ans)      

Measured memory_bytes: 3060
N = int(input())
B = list(map(int, input().split()))
res = 0

for i in range(N):
  if i == 0:
    res += B[0]
  elif i == N-1:
    res += B[-1]
  else:
    res += min(B[i], B[i-1])
    
print(res)
  
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int count = 0, y = 0;
    for (int i = 0; i < n && y <= x; i++) {
        count++;
        y += v[i];
    }
    if (y <= x)
        count++;
    cout << count << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double b;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2!=0)
		{
			ans++;
		}
	}
	b=ans/(n*1.00000000);
	printf("%.8f",b);
	return 0;
}

Measured memory_bytes: 256