akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')

def main():
    a = input()
    if a.isupper():
        print('A')
    else:
        print('a')


if __name__ == '__main__':
    main()


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

B = [0] * (N + 1)
l = [i for i in range(N + 2)]
r = [i for i in range(N + 2)]

ans = 0
for i in range(N):
    B[A[i]] = i

for i in range(N, 0, -1):
    m = B[i]
    x, y = l[m], r[m]
    ans += i * (m - x + 1) * (y - m + 1)
    l[y + 1], r[x - 1] = x, y

print(ans)


Measured memory_bytes: 88244
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for y in range(H):
        if y % 2 == 0:
            moji = '#.'
        else:
            moji = '.#'
        print(moji * (W // 2) + (moji[0] if W % 2 != 0 else ''))
    print()
        
            


Measured memory_bytes: 5620
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from collections import defaultdict
dd = defaultdict(int)

N,K=MI()
A=LI()

for i in range(N):
    dd[A[i]]+=1
    
li=[]

for k,v in dd.items():
    li.append(v)
    
li.sort(reverse = True)

print(N - sum(li[:min(K,N)]))




Measured memory_bytes: 100680
class Edge:
    def __init__(self, dst, weight):
        self.dst, self.weight = dst, weight

    def __lt__(self, e):
        return self.weight > e.weight


class Graph:
    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, src, dst, weight):
        self.E[src].append(Edge(dst, weight))


class HeavyLightDecomposition:
    def __init__(self, g, root=0):
        self.g = g
        self.vid, self.head, self.heavy, self.parent = [0] * g.V, [-1] * g.V, [-1] * g.V, [-1] * g.V
        self.dfs(root)
        self.bfs(root)

    def dfs(self, root):
        stack = [(root, -1)]
        sub, max_sub = [1] * self.g.V, [(0, -1)] * self.g.V
        used = [False] * self.g.V

        while stack:
            v, par = stack.pop()
            if not used[v]:
                used[v] = True
                self.parent[v] = par
                stack.append((v, par))
                stack.extend((e.dst, v) for e in self.g.E[v] if e.dst != par)
            else:
                if par != -1:
                    sub[par] += sub[v]
                    max_sub[par] = max(max_sub[par], (sub[v], v))
                self.heavy[v] = max_sub[v][1]

    def bfs(self, root=0):
        from collections import deque
        k, que = 0, deque([root])
        while que:
            r = v = que.popleft()
            while v != -1:
                self.vid[v], self.head[v] = k, r
                for e in self.g.E[v]:
                    if e.dst != self.parent[v] and e.dst != self.heavy[v]:
                        que.append(e.dst)
                k += 1
                v = self.heavy[v]

    def lca(self, u, v):
        while self.head[u] != self.head[v]:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
            v = self.parent[self.head[v]]
        else:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
        return u

N = int(input())
g = Graph(N)
for i in range(N):
    for c in map(int, input().split()[1:]):
        g.add_edge(i, c, 1)
        g.add_edge(c, i, 1)
hld = HeavyLightDecomposition(g)
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(hld.lca(u, v))

Measured memory_bytes: 74212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
vector<int> v(3);
  REP(i,3)cin>>v[i];
SORT(v);
cout << v[0]*v[1]/2;
}

Measured memory_bytes: 256
using System;

namespace aoj8b
{
    class Program
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                int sum = 0;
                char[] line = (Console.ReadLine()).ToCharArray();
                if(line[0] == '0')
                {
                    break;      //?????????0??????????????????0????????§????????§??????
                }
                for(int i = 0; i < line.Length; i++)
                {                    
                    sum += int.Parse(line[i].ToString());
                }
                Console.WriteLine(sum);
            }
            
        }
    }
}

Measured memory_bytes: 9088
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] scales = {60, 80, 100, 120, 140, 160};
		int[] weights = {2, 5, 10, 15, 20, 25};
		int[] prices = {600, 800, 1000, 1200, 1400, 1600};
		
		while(true){
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			int sum = 0;
			
			for(int i = 0; i < N; i++){
				final int s = sc.nextInt() + sc.nextInt() + sc.nextInt();
				final int w = sc.nextInt();
				
				int rank = Integer.MIN_VALUE;
				
				boolean found = false;
				for(int j = 0; j < scales.length; j++){
					if(s <= scales[j]){
						rank = Math.max(rank, j);
						found = true;
						break;
					}
				}
				
				if(!found){
					continue;
				}
				
				found = false;
				for(int j = 0; j < weights.length; j++){
					if(w <= weights[j]){
						rank = Math.max(rank, j);
						found = true;
						break;
					}
				}
				
				if(!found){
					continue;
				}
				
				
				if(rank < prices.length){
					sum += prices[rank];
				}
			}
			
			System.out.println(sum);
			
		}
		
	}

}

Measured memory_bytes: 12000
H,W = map(int,input().split())
s = [input() for _ in range(H)]
A = "Yes"

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j] == "#" and s[i-1][j] == "." and s[i][j-1] == "." and s[i+1][j] == "." and s[i][j+1] == ".":
            A = "No"
print(A)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {


    Scanner sc =new Scanner(System.in);
   int a = sc.nextInt();
   int[] aa=new int[a];
   for(int i=0;i<a;i++) {
	   aa[i]= sc.nextInt();

   }
   int b =0;
   Loop1:for(int j=0;j>=0;j++) {
   for(int p=0;p<a;p++) {
	  if(aa[p]%2==0) {
		  aa[p]=aa[p]/2;

	  }
	  else {break Loop1;}

   }
   b++;
   }
   System.out.println(b);
}
  }


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

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

void solve_abc_d() {
	ll n, m;
	ll a, b;
	ll x, y, z;
	//ll h, w;
	ll k;
	//string s, rs;
	ll l_ans = 0;

	cin >> n >> k;
	ll r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;

	V dp(n + 5, 0);
	map<char, ll> point;
	point['r'] = p;
	point['s'] = r;
	point['p'] = s;
	vector<ll> cnt(n + 5, 0);
	rep(i, n) {
		if (i >= k) {
			if (t[i] == t[i - k]) {
				if (cnt[i - k] % 2 == 0) {
					chmax(dp[i + 1], dp[i]);
				}
				else{
					chmax(dp[i + 1], dp[i] + point[t[i]]);
				}
				cnt[i] = cnt[i - k] + 1;
			}
			else {
				chmax(dp[i + 1], dp[i] + point[t[i]]);
			}
		}
		else {
			chmax(dp[i + 1], dp[i] + point[t[i]]);
		}
	}

	cout << dp[n] << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
double a, b, x;
int main() {
    cin >> a >> b >> x;
    double v = a*a*b;
    double limit = v / 2.0;
    double lx = 0.0;
    double theta = 0.0;
    if(limit >= x) {
        double sa = x / a;
        lx = (2.0*sa) / b;
        theta = atan(b/lx);
    }else {
        double vv = v - x;
        double sb = vv / a;
        lx = (2.0*sb) / a;
        theta = atan(lx/a);
    }

    double angle = 180.0 / M_PI * theta;

    printf("%.14f\n", angle);
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	Vec p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];

	sort(all(p));
	sort(all(q));
	sort(all(r));
	reverse(all(p));
	reverse(all(q));
	reverse(all(r));

	Vec eat;
	rep(i, x) eat.pb(p[i]);
	rep(i, y) eat.pb(q[i]);
	sort(all(eat));

	rep(i, min(x + y, c)){
		if(!chmax(eat[i], r[i])) break;
	}

	ll sum = 0;
	rep(i, x + y) sum += eat[i];
	co(sum);

	return 0;
}


Measured memory_bytes: 4724
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


 class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/
    public static void main(String[] args)
        {
            Scanner sc=new Scanner(System.in);



           int n=sc.nextInt();
           int m=sc.nextInt();
           if(n==m)
               System.out.println("Yes");
           else
               System.out.println("No");

        }
    }



Measured memory_bytes: 23124
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int n, a, b;
	const int v[4] = { 6000,4000,3000,2000 };
	for (n = 3; fscanf(stdin, "%d%d", &a, &b),P(d, v[a-1]*b),n--;);
		return 0;
}

Measured memory_bytes: 604
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

def comb(n,k)
  return nil if k > n
  result = 1
  1.upto() do |d|
    result *= n
    result /= d
    n -= 1
  end
  result
end

def perm(n,k)
  return nil if k > n
  result = 1
  k.times do
    result *= n
    n -= 1
  end
  result
end

def kaibun(str)
  str == str.reverse
end

#####
n = gi
s = gs
max = 0
x = 0
n.times do |i|
  if s[i] == "I"
    x += 1
  else
    x -= 1
  end
  #print x
  max = [x,max].max
end
puts max

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

int main(){

    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        if(s.size()%2==1) ans++;
    }

    cout<<ans<<endl;




    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;

    return 0;
}



Measured memory_bytes: 3608
S = input()
S_list = list(S)
answers = []
acgt = 0
for s in S_list:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        acgt += 1
    else:
        answers.append(acgt)
        acgt = 0
answers.append(acgt)
if answers:
    print(max(answers))
else:
    print(acgt)


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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
    double n;
    scanf("%lf",&n);
    printf("%.12lf",(n / 3.0)*(n / 3.0)*(n / 3.0));
    return 0;
}



Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

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

struct edge {
	int to, cost, dist;
	edge(int t, int c, int d):to(t), cost(c), dist(d){}
};
typedef pair<int, int> P;

vector<vector<edge> > es;
vector<int> dist;
vector<int> cost;

void inline init(int n) {
	es.clear();
	es.resize(n);
	dist.clear();
	dist.resize(n, INT_MAX);
	cost.clear();
	cost.resize(n, INT_MAX);
}

// 全ての点への最短経路を計算
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	dist[s] = 0;
	cost[s] = 0;

	while(!que.empty()) {
	    P p = que.top();
		que.pop();
		int v = p.second;
		if(dist[v] < p.first)
			continue;
		for(int i = 0; i < es[v].size(); ++i) {
			const edge& e = es[v][i];
			if(dist[e.to] > dist[v] + e.dist) {
				dist[e.to] = dist[v] + e.dist;
				que.push(P(dist[e.to], e.to));
				cost[e.to]  = e.cost;
			}
			else if(dist[e.to] == dist[v] + e.dist)
				chmin(cost[e.to], e.cost);
		}
	}
}

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

	for(int n, m; cin >> n >> m, n | m;) {
		init(n);

		for(int i = 0; i < m; ++i) {
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			
			--u;
			--v;
			
			es[u].push_back(edge(v, c, d));
			es[v].push_back(edge(u, c, d));
		}
		
		dijkstra(0);
		cout << accumulate(cost.begin(), cost.end(), 0) << endl;
	}
	return EXIT_SUCCESS;
}

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

int n, c;
int hikaru[33] = {}, osu[33] = {};
int memo[33][1<<17];

int solve(int q, int bit){
  
  if(q == n) return 0;
  if(~memo[q][bit]) return memo[q][bit];
  int prev = bit;
  int ans = 0;
  for(int i=0;i<c;i++){
    bit = prev;
    int count = 0;
    for(int j=0;j<16;j++){
      if((bit&1<<j) && (osu[i]&(1<<j))){
	bit = bit&~(1<<j);
	count++;
      }
    }
    ans = max(ans, solve(q+1, bit | hikaru[q+1])+count);
  }
 
  return memo[q][prev] = ans;
}

int main(){
  
  int a;
  
  while(cin >> n >> c){
    if(!n && !c) break;
    
    memset(hikaru, 0, sizeof(hikaru));
    memset(osu, 0, sizeof(osu));
    memset(memo, -1, sizeof(memo));

    for(int i=0;i<n;i++){
      for(int j=15;j>=0;j--){
	cin >> a;
	hikaru[i] |= a<<j;
      }
    }
    
    for(int i=0;i<c;i++){
      for(int j=15;j>=0;j--){
	cin >> a;
	osu[i] |= a<<j;
      }   
    }
    cout << solve(0, hikaru[0]) << endl;
  }
}

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


int main(){
  int n;
  cin >> n;
  bool ok=true;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    if(a%2!=0) ok=false;
  }
  if(ok) cout << "second" << endl;
  else cout << "first" << endl;
  return 0;
}


Measured memory_bytes: 3684
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int, int>;
     
const int MOD = 1e9 + 7;

int main(){
   ll n;
   cin >> n;
   if(n % 2 == 1){
      cout << 0 << endl;
   }
   else{
      ll res = 0;
      ll r = 1;
     n /= 2;
      while(r < n){
         r *= 5;
         res += (n / r);
      }
      cout << res << endl;
   }
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(){
	int i;
	int ch;
	while((ch = getchar())!=EOF){
		if(ch>='a' && ch<='z') ch ='A'+ch-'a';
		else if(ch>='A' && ch<='Z') ch = 'a'+ch-'A';
		printf("%c",ch);
	}
	return 0;
}

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

int n, m, ans;
string x;

int main() {
  map<string, int> card;
  cin >> n;
  ans = 0;
  rep (i, n) {
    cin >> x;
    card[x]++;
  }
  cin >> m;
  rep (i, m) {
    cin >> x;
    card[x]--;
  }
  for (auto i = card.begin(); i != card.end(); ++i) {
    ans = max(ans, i->second);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		string s;
		cin>>s;
		ll moves = 0;
		ll i=0, j=n-1;
		while(i<=j) {
			if(s[i]=='W') {
				if(s[j]=='R') {
					i++;
					j--;
					moves++;
				}else j--;
			}else i++;
		}
		cout<<moves<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

struct Node {
	int parent = -1,left = -1,right = -1;
};

Node T[100000];
int depth[100000];

void setDepth(int u, int d) {
	depth[u] = d;
	if (T[u].left != -1) {
		setDepth(T[u].left, d + 1);
	}
	if (T[u].right != -1) {
		setDepth(T[u].right, d);
	}
}

int getDepth(int u) {
	return depth[u];
}

void getType(int u) {
	if (T[u].parent == -1) {
		cout << "root";
		return;
	}
	if (T[u].left == -1) {
		cout << "leaf";
		return;
	}
	cout << "internal node";
	return;
}

void getChildren(int u) {
	int k = T[u].left;
	if (k == -1) { cout << ", []"; return; }
	cout << ", ["<<k;
	while (T[k].right != -1) {
		k = T[k].right;
		cout << ", " << k;
	}
	cout << "]";
}

int getRoot(int u) {
	int k = u;
	while (T[k].parent != -1) {
		k = T[k].parent;
	}
	return k;
}


int main()
{
	int n,m,q,mark,qq;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m;
		cin >> q;
		if (q == 0) { continue; }
		cin >> qq;
		T[qq].parent = m;
		T[m].left = qq;
		mark = qq;
		for (int k = 1; k < q; k++) {
			cin >> qq;
			T[qq].parent = m;
			T[mark].right = qq;
			mark = qq;
		}
	}

	setDepth(getRoot(m), 0);

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].parent << ", depth = " << getDepth(i) << ", ";
		getType(i);
		getChildren(i);
		cout << endl;
	}
	
}


Measured memory_bytes: 4648
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int a[2*SIZE+2];
int b[2*SIZE+2];
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=2*N-1;i++){
		scanf("%d",&a[i]);
	}
	a[0]=a[1];
	a[2*N]=a[2*N-1];
	int d=1,u=2*N-1;
	while(u-d>1){
		int mid=(u+d)/2;
		for(int i=0;i<=2*N;i++){
			b[i]=((a[i]>=mid) ? 1:0);
		}
		//for(int i=0;i<=2*N;i++)cout<<b[i]<<" ";
		//cout<<endl;
		//int hoge=b[N];
		int lef,rig;
		for(int i=0;i<=N-1;i++){
			if(b[i]==b[i+1]){
				lef=i+1;
			}
		}
		for(int i=2*N-1;i>=N;i--){
			if(b[i]==b[i+1]){
				rig=i;
			}
		}
		int flag;
		//cout<<lef<<" "<<rig<<endl;
		if(N-lef<rig-N){
			flag=b[lef];
		}else{
			flag=b[rig];
		}
		if(flag==0){
			u=mid;
		}else{
			d=mid;
		}
		//cout<<d<<" "<<u<<endl;
	}
	cout<<d<<endl;
}

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

void chmax(ll &x, const ll y) {
    if (x < y) x = y;
}

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

    ll r, s, p;
    cin >> r >> s >> p;

    string t;
    cin >> t;

    rep(i, n) {
        if (i - k < 0) continue;
        if (t[i - k] == t[i]) t[i] = 'o';
    }

    long long ans = 0;
    rep(i, n) {
        if (t[i] == 'r') ans += p;
        if (t[i] == 's') ans += r;
        if (t[i] == 'p') ans += s;
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

const LL mod=(1e9)+7;
int main()
{
   int n;
   cin>>n;
   set<int>s;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       s.insert(x);
   }
   if(s.size()==n)
    cout<<"YES";
   else
    cout<<"NO";
}


Measured memory_bytes: 12948
#include <stdio.h>

int main()
{
    int input_a, input_b, input_c;
    
    scanf("%d %d %d", &input_a, &input_b, &input_c);

    if((input_a < input_b) && (input_b < input_c)) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2148
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    
    int X = A + B;
    int Y = A - B;
    int Z = A * B;
    
    int ans = Math.max(X, Math.max(Y, Z));
    
    System.out.println(ans);
  }
}

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

const int N = (int)1e5;
const int MOD = (int)1e9 + 7;

int dat[N+5];

int main() {
    int n,m; scanf("%d %d", &n, &m);
    for (int i=1; i<=m; i++) scanf("%d", dat+i);

    int a=0, b=1, pos=0;
    for (int i=1; i<=n; i++) {
        int temp = (a + b) % MOD;
        if (dat[pos+1] == i) {
            temp = 0;
            pos += 1;
        }

        a = b;
        b = temp;
    }

    printf("%d\n", b);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll minv, ab, bc, ca;
    ab = a * b;
    bc = b * c;
    ca = c * a;
    minv = min(ab, bc);
    minv = min(minv, ca);

    ll ans; 
    if(minv == ab) {
        ans = (c % 2) * ab; 
    } else if(minv == bc) {
        ans = (a % 2) * bc;
    } else {
        ans = (b % 2) * ca;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long inf = 1000000007;
  long dp[n+1][4][4][4];
  for(int i = 0;i < n+1;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        for(int l = 0;l < 4;l++){
            dp[i][j][k][l] = 0;
        }
      }
    }
  }
  dp[0][3][3][3] = 1;
  for(int i = 0;i < n;i++){
    for(int k = 0;k < 4;k++){
      for(int l = 0;l < 4;l++){
        for(int m = 0;m < 4;m++){
          for(int j = 0;j < 4;j++){
            if(j == 1 && k == 2 && l == 0) continue;
            if(j == 2 && k == 1 && l == 0) continue;
            if(j == 2 && k == 0 && l == 1) continue;
            if(j == 2 && l == 1 && m == 0) continue;
            if(j == 2 && k == 1 && m == 0) continue;
            dp[i+1][j][k][l] += dp[i][k][l][m];
            dp[i+1][j][k][l] %= inf;
          }
        }
      }
    }
  }
  int ans = 0;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        ans += dp[n][i][j][k];
        ans %= inf;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int s[1000000],n;

int binarysearch(int key){
	int left=0,right=n,mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==s[mid]) return 1;
		if(key>s[mid]) left=mid+1;
		else if(key<s[mid]) right=mid;
	}
	return 0;
}

int main(){
	int i,q,k,m=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&k);
		if(binarysearch(k)) m++;
	}
	
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 2968
N = int(input())
def count(start, end):
  return end - start + 1
keta = 1
while True:
  if 10**keta > N:
    break
  else:
    keta += 1
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))
print(num)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    int kkkk;
    int ababa, bcbc;
    cin >> kkkk >> ababa >> bcbc;

    int qa, ra, qb, rb;

    qa = ababa / kkkk;
    ra = ababa % kkkk;
    qb = bcbc / kkkk;
    rb = bcbc % kkkk;

    if (ra == 0 || rb == 0) {
        cout << "OK";
    } else if (qb - qa > 0) {
        cout << "OK";
    } else
        cout << "NG";

    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << (s < t ? "Yes" : "No") << endl;
    return 0;
}


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

#define NMAX 100
#define KMAX 100
static const int INFTY = (1<<21);

// n >= k
int compute( int n, int k, int S[NMAX+1] ){
    
    int M[NMAX+1][KMAX+1], D[NMAX+1][KMAX+1];
    int P[NMAX+1];
    
    P[0] = 0;
    for ( int i = 1; i <= n; i++ ) P[i] = P[i-1] + S[i];
    
    for ( int i = 1; i <= n; i++ ) M[i][1] = P[i];
    for ( int j = 1; j <= k; j++ ) M[1][j] = S[1];
    
    for ( int i = 2; i <= n; i++ ){
	for ( int j = 2; j <= k; j++ ){
	    M[i][j] = INFTY;
	    for ( int x = 1; x <= i-1; x++ ){
		int maximum = max( M[x][j-1], P[i] - P[x] );
		if ( M[i][j] > maximum ){
		    M[i][j] = maximum;
		    D[i][j] = x;
		}
	    }
	}
    }

    return M[n][k];
}

int main(){
    int n, k, S[NMAX+1];
    while(1){
	cin >> k >> n;
	if ( k == 0 && n == 0 ) break;
	for ( int i = 1; i <= n; i++ ) cin >> S[i];
	cout << compute(n, k, S) << endl;
    }
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int k=a.at(N-M);
  int sum=0;
  rep(i,N){
    sum+=a.at(i);
  }
  k=4*M*k;
  if(sum>k){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    int arr[N];
    for(int i =0; i< N; i++)
    {
        cin >> arr[i];
    }
    if(N==2)
    {
        cout<< abs(arr[1]-arr[0]);
    }
    else{
    int dp[N];
    dp[0] = 0;
    dp[1]= abs( arr[1]-arr[0]);
    for(int i = 2; i <N;i++)
    {
        dp[i] = min(dp[i-1]+ abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[N-1];
    }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int solve(vector<int>v) {
	int N=v.size();
	int amax=0;
	for (int i = 0; i < N; ++i) {
		if(i>amax)return false;
		int t=v[i]/10;
		amax=max(amax,i+t);
	}
	return true;
}

int main() {	
	int N;cin>>N;
	vector<int>v;
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		v.push_back(a);
	}
	bool ok=solve(v);
	reverse(v.begin(),v.end());
	ok&=solve(v);
	if(ok)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 5308
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> P(N);
  rep(i, N) cin>> P[i];

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

  auto itA = lower_bound(all(P), A + 1);
  auto itB = lower_bound(all(P), B + 1);
  int LCount = distance(P.begin(), itA);
  int MCount = distance(itA, itB);
  int HCount = distance(itB, P.end());

  cout << min(LCount, min(MCount, HCount)) << endl;

  return 0;
}

Measured memory_bytes: 3100
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Set<String> saidWords = new HashSet<String>();

		int n = scanner.nextInt();
		scanner.nextLine();
		String wi_1 = scanner.nextLine();
		saidWords.add(wi_1);
		boolean isSafe = true;
		for (int i = 1; i < n && isSafe; i++) {
			String wi = scanner.nextLine();
			if (!wi.startsWith(wi_1.substring(wi_1.length()-1))) {
				isSafe = false;
			}
			if (saidWords.contains(wi)) {
				isSafe = false;
			}
			saidWords.add(wi);
			wi_1 = wi;
		}

		if (isSafe) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

ans = 0
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1
    ans += a[i]

if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)


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

int main()
{
  int N, M, X, Y;
  int x[110], y[110];
  bool res=true;
  cin >> N >>M >>X >> Y;

  rep(i,N) {
    cin >> x[i];
  }
  sort(x,x+N);
  rep(i,M) {
    cin >> y[i];
  }
  sort(y,y+M);
  if(y[0] <= x[N-1]) res=false;
  if(y[0] <= X) res=false;
  if(x[N-1] >= Y) res = false;

  if(res) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x * (-1), a))
heapq.heapify(a)
while m != 0:
    price = heapq.heappop(a) * (-1)
    price //= 2
    m -= 1
    heapq.heappush(a, (-1) * price)
print(sum(a) * (-1))

Measured memory_bytes: 14184
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		long[] arr=new long[n];
		long k=s.nextLong();
		
		for(int i=0;i<n;i++) {
			arr[i]=s.nextLong();
		}
		
		long ans=Long.MAX_VALUE;
		
		long st=1;
		long end=1000000000000000l;
		
		while(st<=end) {
			long mid=(st+end)/2;
			
			long b=0;
			for(int i=0;i<n;i++) {
				long p=arr[i]/mid;
				if(arr[i]%mid!=0) {
					p++;
				}
				
				b=b+p-1;
				
			}
			if(b<=k) {
				ans=mid;
				end=mid-1;
			}else {
				st=mid+1;
			}
			
			
			
		}
		
		
		System.out.println(ans);
		
		
	}
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  string kind;
  set<string> s;
  for (int i = 0; i < n; ++i) {
    cin >> kind;
    s.insert(kind);
  }
  printf("%s\n", s.size() == 3 ? "Three" : "Four");
  return 0;
}


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

        signed main() {
            int n,ans=0;string s;
            cin>>n>>s;
            for(int i=0;i<=n-3;i++){
                    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
            }
            cout<<ans;
         return 0;

        }


Measured memory_bytes: 256
import sys

input_data = []
input_pointer = 0

output_data = []

def input_scan():
    global input_data
    input_data = sys.stdin.readlines()
    input_data = [x[:-1] for x in input_data]

def next_line():
    global input_pointer
    global input_data
    if input_pointer < len(input_data):
        input_pointer += 1
        return input_data[input_pointer - 1]
    else:
        return ""

def append_output(string):
    global output_data
    output_data.append(string)

def print_output():
    global output_data
    output_data.append("")
    sys.stdout.write("\n".join(output_data))

alpha = input()
if alpha.isupper():
    print("A")
else:
    print("a")


Measured memory_bytes: 9064
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 INF(1e18);

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

    i64 d;
    while(cin >> d && d) {
        int n, m;
        cin >> n >> m;
        vector<i64> a(n + 1, d);
        for(int i : in(1, n)) cin >> a[i];
        a[0] = 0LL;
        sort(a.begin(), a.end());
        i64 ans = 0LL;
        for(int _ : in(m)) {
            i64 k;
            cin >> k;
            auto hi = upper_bound(a.begin(), a.end(), k);
            auto lo = hi - 1;
            ans += min(k - *lo, *hi - k);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3516
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
char num[1000][8],win[100][8];
int money[100];
int check(int wi,int nu){
	int flg=1,i=7;
	while(i>=0){
		if(win[wi][i]=='*')break;
		if(win[wi][i]!=num[nu][i]){
			flg=0;break;
		}
		i--;
	}
	if(flg==1){
		return money[wi];
	}else{
		return 0;
	}
}
int main(){
	while(1){
		int n,m,i,j,k,sum=0;
		cin>>n>>m;
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>win[i]>>money[i];
		}
		for(i=0;i<m;i++){
			cin>>num[i];
		}
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				sum+=check(i,j);
			}
		}
		cout<<sum<<endl;
	}
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, c; cin >> a >> b >> c;
	if(a == b and b == c) cout << "Yes" << endl;
	else cout << "No" <<  endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> c;
    for(int i = 0; i < n; i++){
        c.push_back("");
        for (int j = 0; j < n; ++j) {
            char tmp;
            cin >> tmp;
            c[i]+=tmp;
        }
    }
    int count = 0;
    for(int B = 0; B < n; B++){
        bool can = true;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(c[(i+B)%n][j] != c[(j+B)%n][i]){
                    can = false;
                    i = j = n;
                }
            }
        }
        if(can) count++;
    }
    cout << count * n << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a<b&&b<c){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}



Measured memory_bytes: 26252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF= 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    ll N,M;
    cin >> N >> M;
    map<ll,ll> ma;
    for(int i = 0;i < N;i++) {
        ll A;
        cin >> A;
        ma[A]++;
    }
    for(int j = 0;j < M;j++) {
        ll A,B;
        cin >> A >> B;
        for(auto x:ma) {
            if(x.first >= B) {
                break;
            }
            else if(A < x.second) {
                ma[x.first] -= A;
                ma[B] += A;
                break;
            }
            else {
                A -= x.second;
                ma[B] += x.second;
                ma.erase(x.first);
            }
        }
    }
    ll ret = 0;
    for(auto x:ma) {
        ret += x.first * x.second;
    }
    cout << ret << endl;
}

Measured memory_bytes: 6528
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll ans=nrm,n,a[201],tmp;
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++)
    {
        while(a[i]%2==0) a[i]/=2,tmp++;
        ans=min(ans,tmp);
        tmp=0;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256