akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    char s;
    cin >> s;
    
    if(s=='a'||s=='b'||s=='c'||s=='d'||s=='e'||s=='f'||s=='g'||s=='h'||s=='i'||s=='j'||s=='k'||s=='l'||s=='m'||s=='n'||s=='o'||s=='p'||s=='q'||s=='r'||s=='s'||s=='t'||s=='u'||s=='v'||s=='w'||s=='x'||s=='y'||s=='z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,f,b;
    scanf("%d %d %d",&m,&f,&b);
    b-=m;
    if(b<=0){
        cout <<"0"<< endl;
    }else if(f>=b){
        cout << b << endl;
    }else if(f<=b){
        cout <<"NA"<< endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string s; cin>>s;
    int a=s.at(0)-'0';
    int b=s.at(1)-'0';
    int c=s.at(2)-'0';
    int d=s.at(3)-'0';
    char op1='-',op2='-',op3='-';
    for(int i=-1; i<=1; i+=2){
        for(int j=-1; j<=1; j+=2){
            for(int k=-1; k<=1; k+=2){
                if(a+b*i+c*j+d*k == 7){
                    op1=(i==-1?'-':'+');
                    op2=(j==-1?'-':'+');
                    op3=(k==-1?'-':'+');
                }
            }
        }
    }
    string ans="0000000=7";
    for(int i=0; i<4; i++){
        ans.at(0+i*2) = s.at(i);
    }
    ans.at(1)=op1; ans.at(3)=op2; ans.at(5)=op3;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    # return nearest index
    b, d = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
    res = INF
    for s in [S[b-1], S[b]]:
        for t in [T[d-1], T[d]]:
            d1, d2 = abs(s - x) + abs(t - s), abs(t - x) + abs(s - t)
            res = min(res, d1, d2)
    print(res)



Measured memory_bytes: 12812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



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

    if(n==1) out("Hello World");
    else {
        cin >> a >> b;
        out(a+b);
    }
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    double W,H;
    cin >> W >> H;


    double x,y;
    cin >> x >> y;

    double ans = W*H / 2;

    int dub = 0;
    if( x == W/2 && y == H/2 ) dub = 1;

    printf ("%lf %d\n", ans , dub );

    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x<0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,k,l=map(int,input().split())
uf1=UnionFind(n)
uf2=UnionFind(n)
for _ in range(k):
  u,v=map(int,input().split())
  uf1.unite(u-1,v-1)
for _ in range(l):
  u,v=map(int,input().split())
  uf2.unite(u-1,v-1)
d=defaultdict(int)
for i in range(n):
  d[(uf1.find(i),uf2.find(i))]+=1
ans=[d[(uf1.find(i),uf2.find(i))] for i in range(n)]
print(*ans)

Measured memory_bytes: 41700
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var abcxy = IO.RSInt;

            var ans = 0;
            if (2 * abcxy[2] < abcxy[0] + abcxy[1])
            {
                ans += Min(abcxy[3], abcxy[4]) * 2 * abcxy[2];
            }
            else
            {
                ans += Min(abcxy[3], abcxy[4]) * (abcxy[0] + abcxy[1]);
            }
            var res = Abs(abcxy[3] - abcxy[4]);
            var resPri = abcxy[3] - abcxy[4] >= 0 ? abcxy[0] : abcxy[1];
            if (2 * abcxy[2] < resPri)
            {
                ans += res * 2 * abcxy[2];
            }
            else
            {
                ans += res * resPri;
            }
            WriteLine(ans);
        }
    }
    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cassert>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <limits.h>
#include <fstream>

#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define pll pair <ll, ll>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
#define uint unsigned int

const int maxn = 110;
char s[maxn][maxn];
int dp[maxn][maxn];

int n, m;

int go(int x, int y) {
	if (x == n - 1 && y == m - 1) {
		if (s[x][y] == '#') {
			return dp[x][y] = 1;
		}
		else {
			return dp[x][y] = 0;
		}
	}

	if (x >= n || y >= m) {
		return dp[x][y] = (int)1e9;
	}

	if (dp[x][y] != -1) {
		return dp[x][y];
	}

	int ans = go(x + 1, y) + (s[x][y] == '#' && s[x + 1][y] == '.');
	ans = min(ans, go(x, y + 1) + (s[x][y] == '#' && s[x][y + 1] == '.'));
	return dp[x][y] = ans;
}

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

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

	memset(dp, -1, sizeof dp);

	cout << go(0, 0) << '\n';
}

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

using namespace std;

typedef long long ll;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int a, b;
        cin >> a >> b;
        for (int x = 0; x <= 100000; x++)
                if (2 * x / 25 == a && x / 10 == b) {
                        cout << x << "\n";
                        return 0;
                }
        cout << "-1\n";
        return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a
n,m=map(int,input().split())
s = input()
t = input()
g = gcd(n,m)
l = n*m//g
s1 = n/g
t1 = m/g
x = []
y = []
for i in range(len(s)):
  if i % s1 == 0:
    x.append(s[i])  
for i in range(len(t)):
  if i % t1 == 0:
    y.append(t[i])  
print(l) if x==y else print(-1)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define PB push_back
#define FOR(i, a, b) for (int i {a}; i < b; i++) // a = i's initial value, b = limit

int main(){
    int n{};
    cin >> n;
    cout << 6.28 * n;

    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
#define inf 1000000007

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
 
signed main(){
	string s;
	cin>>s;
	stack<char> v;
	for(int i=0;i<s.size();i++){
		if(v.empty())v.push(s[i]);
		else if(v.top()=='S'&&s[i]=='T')v.pop();
		else v.push(s[i]);
	}
	cout<<v.size()<<endl;
}


Measured memory_bytes: 644
package main

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

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var N int
	fmt.Scan(&N)

	sc.Split(bufio.ScanWords)
    arr := make([]int64, N)
    for i, _:=range arr{
        arr[i] = nextInt()
    }
    max:=arr[0]
    sum := int64(0)
    for _, a := range arr{
        if a < max {
            sum +=(max -a)
        }else{
            max = a
        }
    }

    fmt.Println(sum)
}
func bc(s string, pos int) string {
	ch := "1"
	if string(s[pos]) == "1" {
		ch = "0"
	}
	pre := string(s[:pos])
	post := ""
	if pos != len(s)-1 {
		post = string(s[pos+1:])
	}
	tmp := pre + ch + post
	return tmp
}
func popCount(n string) int {
	count := 0
	for _, s := range n {
		if string(s) == "1" {
			count++
		}
	}
	return count
}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 5936
#include<stdio.h>
#define N 10000
#define Q 500
int linearSearch(int);
int n,S[N];
int main()
{
  int   q,i,j,count=0,T[Q],key;

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

  scanf("%d",&q);
  for(j=0;j<=q-1;j++){
    scanf("%d",&T[j]);
    if(linearSearch(T[j])==1)
    count++;
}
 
  /* for(i=0;i<=n-1;i++){
   key=S[i];
   for(j=0;j<=q-1;j++){
     if(T[j]==key)
       count++;
     
   }
 }
  */
 printf("%d\n",count);
 return 0;
}
int linearSearch(int key)
{
  int i;
 
  for(i=0;i<n;i++){
    if(S[i]==key) return 1;
 }
return 0;
}

Measured memory_bytes: 636
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    int a;
    cin >> a;
    cout << (a + a * a + a * a * a) << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

typedef unsigned int u_int;

u_int euclid(u_int m,u_int n);

int main(void){
  u_int m,n;
  while(fscanf(stdin,"%u %u",&m,&n)!=EOF) printf("%u %u\n",euclid(m,n),m/euclid(m,n)*n);
  return 0;
}

u_int euclid(u_int m,u_int n){
  if(n==0) return m;
  return euclid(n,m%n);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;


#define INF 1e18
#define int long long

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

    int ans = INF;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ans = min(ans, i - 1 + (n / i) - 1);
        }
    }

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


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc150/tasks/abc150_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, len;
    cin >> N;
    string s;
    cin >> s;
    len = s.length();
    s = s + "  ";
    int count = 0;
    REP(i, len) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            count++;
            i += 2;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int cnt=0;
	for(int i=1;i<n-1;i++)
	{
		//vector<int> b;
		if((a[i]<a[i-1] && a[i]>a[i+1]) || (a[i]>a[i-1] && a[i]<a[i+1]))
		{
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}








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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

bool is_prime(int n)
{
  for (int i = 2; i * i <= n; i++){
    if (n % i == 0) return false;
  }
  return true;
}


int main()
{
  int cnt = 0;
  for (int n = in(); n--;){
    cnt += is_prime(in());
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		
			   Scanner s = new Scanner(System.in);
			   int a = s.nextInt();
			   String op = s.next();
			   int b = s.nextInt();
			   if(op.equals("+")){
			   System.out.println(a + b);
			   }
			   else if(op.equals("-")){
			    System.out.println(a - b);
			   }

			  return;
			
		
	}
}

Measured memory_bytes: 23380
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		char c;
		String ch, charc;
		Pattern p = Pattern.compile("[a-zA-Z]");
		Matcher m;
		
		
		ch = scan.nextLine();
		
		StringBuilder sb = new StringBuilder(ch);
		
		for( int i = 0; i < ch.length(); i++) {
			c = ch.charAt(i);
			charc = String.valueOf(c);
			m = p.matcher(charc);
			
			if(m.find()) {
				if(Character.isUpperCase(c)) {
					charc = charc.toLowerCase();
				}else {
					charc = charc.toUpperCase();
				}
				
				char cc [] = charc.toCharArray();
				sb.setCharAt(i, cc[0]);
			}
		}
		
		System.out.println(sb);
	}
}


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

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

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	string S; cin >> S;
	vector<vector<int>> dp(S.size()+1, vector<int>(13, 0));
	dp[0][0] = 1;
	int keta = 1;
	rep(i, S.size()) {
		if (S[S.size() - i - 1] == '?') {
			rep(j, 10) {
				int num = j * keta;
				num %= 13;
				rep(k, 13) {
					dp[i + 1][(num + k) % 13] += dp[i][k];
				}
				rep(k, 13)dp[i + 1][k] %= MOD;
			}
		}
		else {
			int num = S[S.size() - i - 1] - '0';
			//cout << num << endl;
			num = (num * keta) % 13;
			rep(k, 13) {
				dp[i + 1][(num + k) % 13] += dp[i][k];
			}
		}
		rep(j, 13)dp[i + 1][j] %= MOD;
		keta *= 10;
		keta %= 13;
	}

	cout << dp[S.size()][5];
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	double n, k, t, u, v, l;
	cin >> n >> k >> t >> u >> v >> l;
	queue<int> d;
	REP(i, n)
	{
		int a;
		cin >> a;
		d.push(a);
	}
	int car = 0;
	int run = 0;
	int walk = 0, running = 0;

	REP(i, l)
	{
		if (!d.empty() && d.front() == i)
		{
			d.pop();
			if (run == 0) run += t*v;
			else
			{
				if (car < k) car++;
				else run = t*v;
			}
		}

		if (run == 0 && car>0)
		{
			car--;
			run = t*v;
		}

		if (run > 0)
		{
			running++;
			run--;
		}
		else walk++;


	}

	cout << D10 << running / v + walk / u << endl;
	return 0;
}

Measured memory_bytes: 1300
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<" "<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<
    s[11]<<s[12]<<" "<<s[14]<<s[15]<<s[16]<<s[17]<<s[18]<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int Max_N = 100000;

int N;
typedef pair <int ,int> P;
vector<P> robot;
bool compare(P a, P b){
    return a.first + a.second < b.first + b.second;

}
int main(){
    cin >> N;
    REP(i,N){
        int first,second;
        cin >> first >> second;
        P p(first,second);
        robot.push_back(p);
    }
    sort(ALL(robot),compare);

    int count = 1;
    P robo = robot[0];
    REP(i,N){
        int x = robot[i].first - robot[i].second;
        if(x >= robo.first + robo.second){
            count++;
            robo = robot[i];
        }
    }
    /*REP(i,N){
        printf("%d %d\n",robot[i].first,robot[i].second);
    }*/
    cout << count << endl;
}

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

int main() {
  int N;
  int d[100];
  int count = 0;
  cin >> N;
  for(int i=0; i<N; ++i) cin >> d[i];
  sort(d, d+N);
  for(int i=0; i<N; i++){
    if(d[i] == d[i+1]) continue;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut cnts = vec![0; 200];
    for &c in s.iter() {
        cnts[c as u8 as usize] += 1;
    }
    cnts.sort();
    cnts.reverse();
    println!("{}", if cnts[0] == 2 && cnts[1] == 2 { "Yes" } else { "No" });
}


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

#[fastout]
fn main() {
    let mut s: String;
    input! {s: String};
    let mut a = false;
    let mut b = false;

    for i in s.chars() {
        if i == 'A' {
            a = true;
        } else {
            b = true;
        }
    }

    if a && b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2140
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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 < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    double sum = 0;
    rep(i, n) {
      double money;
      string u;
      cin >> money >> u;
      if (u == "JPY") {
        sum += money;
      } else {
        double rm = money * 380000.0;
        sum += rm;
      }
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, GSB):
    def f(N, gsb):
        dp = [[0] * (N+1) for _ in range(4)]
        for i in range(3):
            v = gsb[1][i] - gsb[0][i]
            a = gsb[0][i]
            if v > 0:
                for w in range(N+1):
                    dp[i+1][w] = dp[i][w]
                    if w >= a:
                        dp[i+1][w] = max(dp[i][w], dp[i+1][w-a] + v)
            else:
                dp[i+1] = dp[i]
        return dp[3][N] + N
    tmp = f(N, GSB)
    # print(tmp)
    GSB[0], GSB[1] = GSB[1], GSB[0]
    return f(tmp, GSB)


def main():
    N = read_int()
    GSB = [read_int_n() for _ in range(2)]
    print(slv(N, GSB))


if __name__ == '__main__':
    main()


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int ans=3;
	if(a==b){ans--;}
	if(b==c){ans--;}
	if(c==a){ans--;}
	if(a==b && b==c){ans++;}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=4444;
int n,m;
int a[mxn],b[mxn],c[mxn],d[mxn],e[mxn],f[mxn];
bool vis[mxn][mxn],up[mxn][mxn],dw[mxn][mxn],le[mxn][mxn],ri[mxn][mxn]; //blockage

int const dx[]={-1,0,1,0};
int const dy[]={0,-1,0,1};
vi xx={-MOD,MOD}, yy={-MOD,MOD};

void bfs(int x, int y){
	queue<ii>q;
	q.emplace(x,y);
	vis[x][y]=1;
	while(!q.empty()){
		x = q.front().fi;
		y = q.front().se;
		q.pop();
		for(int i=0; i<4; i++){
			if(i==0&&le[x][y])continue;
			if(i==1&&dw[x][y])continue;
			if(i==2&&ri[x][y])continue;
			if(i==3&&up[x][y])continue;
			int X = x+dx[i];
			int Y = y+dy[i];
			if(X<0||X>=(int)xx.size()-1)continue;
			if(Y<0||Y>=(int)yy.size()-1)continue;
			if(vis[X][Y])continue;
			vis[X][Y]=1;
			q.emplace(X,Y);
		}
	}
	return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i] >> c[i];
		xx.pb(a[i]);
		xx.pb(b[i]);
		yy.pb(c[i]);
	}
	for(int i=0; i<m; i++){
		cin >> d[i] >> e[i] >> f[i];
		xx.pb(d[i]);
		yy.pb(e[i]);
		yy.pb(f[i]);
	}
	sort(all(xx));
	xx.erase(unique(all(xx)),xx.end());
	sort(all(yy));
	yy.erase(unique(all(yy)),yy.end());
	//setting up blockage
	for(int i=0; i<n; i++){
		int x1 = lower_bound(all(xx),a[i])-xx.begin();
		int x2 = lower_bound(all(xx),b[i])-xx.begin();
		int y = lower_bound(all(yy),c[i])-yy.begin();
		// at y x1 --- x2
		for(int j=x1; j<x2; j++){
			up[j][y-1]=1;
			dw[j][y]=1;
		}
	}
	for(int i=0; i<m; i++){
		int x = lower_bound(all(xx),d[i])-xx.begin();
		int y1 = lower_bound(all(yy),e[i])-yy.begin();
		int y2 = lower_bound(all(yy),f[i])-yy.begin();
		/* at x
			y1
			|
			|
			|
			y2
		*/
		for(int j=y1; j<y2; j++){
			ri[x-1][j]=1;
			le[x][j]=1;
		}
	}
	int x = lower_bound(all(xx),0)-xx.begin()-1; 
	int y = lower_bound(all(yy),0)-yy.begin()-1; 
	bfs(x,y);
	if(vis[0][0]||vis[xx.size()-1][yy.size()-1]){
		cout << "INF" << endl;
		return 0;
	}
	ll ans = 0LL;
	for(int i=0; i<(int)xx.size()-1; i++)
		for(int j=0; j<(int)yy.size()-1; j++)
			if(vis[i][j])
				ans += ll(xx[i+1]-xx[i])*(yy[j+1]-yy[j]);
	cout << ans << endl;
}	


Measured memory_bytes: 53744
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        ha: [u64; n],
    }

    let mut ha = ha;
    ha.sort();

    let ans = ha.windows(k).map(|array| array[k-1] - array[0]).min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int n = 1;

		while ((x * n % 360) != 0) {
			n++;
		}

		System.out.println(n);

	}

}

Measured memory_bytes: 35636
from bisect import bisect_left,insort
n=int(input())
ab=[]
data=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    ab.append([a,b,i])
    data[a].append(b)
    data[b].append(a)
ans=[0]*(n-1)
ab.sort()
flag=[-1 for i in range(n+1)]
flag[1]=0
que=[1]
while que:
    h=que.pop()
    k=1
    if flag[h]==k:
        k+=1
    for u in data[h]:
        if flag[u]==-1:
            flag[u]=k
            if h>u:
                h,u=u,h
            ans[ab[bisect_left(ab,[h,u])][2]]=k
            que.append(u)
            k+=1
            if flag[h]==k:
                k+=1
print(max(ans))
for i in range(n-1):
    print(ans[i])

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

using namespace std;

typedef long long ll;

#define MAXN 20002

int main(void) {
  ll N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  
  for(int i=0; i<N; ++i) cin >> H[i];
  
  //ソートして，先頭のK個を飛ばす
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  
  ll sum = 0;
  for(int i=K; i<N; ++i) {  
    sum += H.at(i);
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 1024
S = input()
K = int(input())
pre_s = ''
cnt = 1
ans = 0
flag = False
for s in S:
    if s == pre_s:
        cnt += 1
    else:
        ans += cnt // 2
        pre_s = s
        cnt = 1
ans += cnt // 2

if S[0] == S[-1]:
    pre_s = S[0]
    cnt = 1
    for s in S[1:]:
        if s == pre_s:
            cnt += 1
        else:
            break
    end_cnt = 1
    for s in reversed(S[:-1]):
        if s == pre_s:
            end_cnt += 1
        else:
            break
    if (end_cnt + cnt) % 2 == 0 and end_cnt % 2 == 1:
        ans += 1
        flag = True
        
if len(set(S)) == 1 and len(S) % 2 == 1:
    print((len(S)//2)*(K//2+K%2) + (len(S)//2+1)*(K//2))
elif flag:
    print(ans*K-1)
else:
    print(ans*K)


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

int main()
{
    int sum=0;
    string s;
    cin>>s;

    for(int i=0;i<s.length();i++)
    {
        int p=s[i]-48;
        sum+=p;
    }

    if(sum%9 == 0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

     return 0;

}



Measured memory_bytes: 3696
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	string s;
	cin >> s;
	int a, b;
	a = atoi(s.substr(0, 2).c_str());
	b = atoi(s.substr(2, 2).c_str());

	bool x, y;
	x = y = false;
	if (1 <= a && a <= 12) x = true;
	if (1 <= b && b <= 12) y = true;
		
	if (x && y) cout << "AMBIGUOUS" << "\n";
	
	if (x && !y) cout << "MMYY" << "\n";
		
	if (!x && y) cout << "YYMM" << "\n";
			
	if (!x && !y) cout << "NA" << "\n";
	
	



	return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

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

        long a = Long.parseLong(scan.next());
        long b = Long.parseLong(scan.next());
        long c = Long.parseLong(scan.next());

        scan.close();

        if (a + b >= c) {
            System.out.println("No");
        } else if (4 * a * b >= (c - a - b) * (c - a - b)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

    }

}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, k, w[110], v[110], ans, dp[110][100010];

int main(){
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> w[i] >> v[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(i!=0||j!=0) dp[i][j] = -1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(j-w[i]>=0&&dp[i-1][j-w[i]]!=-1) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
			if(dp[i-1][j]!=-1) dp[i][j] = max(dp[i][j], dp[i-1][j]);
			if(i==n) ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[1])
S=0
T=True
for i in range(N):
    S+=A[i][0]
    if A[i][1]<S:
        T=False
if T==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 48492
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)s

bool isMM(int N){
    if(N!=0 && N<13){
        return true;
    }else{
        return false;
    }
}

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

    int bit0=S[0]-'0';
    int bit1=S[1]-'0';
    int bit2=S[2]-'0';
    int bit3=S[3]-'0';

    int upper,downer;
    upper=bit0*10 +bit1;
    downer=bit2*10 +bit3;

    if(isMM(upper) && isMM(downer)){
        cout << "AMBIGUOUS"<<endl;
    }else if(isMM(upper)){
        cout << "MMYY"<<endl;
    }else if(isMM(downer)){
        cout << "YYMM"<<endl;
    }else{
        cout << "NA"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
[print(['Yes','No'][d[bisect.bisect_right(a,b[i])]<c[i]]) for i in range(m)]

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

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	int total = 0;

	for (int i=1; i<=N; i++) {
		int sum = findSumOfDigits(i);
		if (sum>=A && sum<=B) {
			total += i;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>
#include <queue>

using namespace std;

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

ll encode(int d[]) {
  ll res = 0;
  for (int i = 0; i < 9; i++) {
	res *= 16;
	res += d[i];
  }
  return res;
}

void decode(int d[], ll u) {
  for (int i = 8; i >= 0; i--) {
	d[i] = u%16;
	u /= 16;
  }
}

int ch, cv;
int s[9], g[9];

int solve() {
  priority_queue<P, vector<P>, greater<P>> q;
  map<ll, bool> used;
  q.push(P(0, encode(s)));
  ll goal = encode(g);
  int buf[9];
  while (!q.empty()) {
	auto p = q.top(); q.pop();
	if (used[p.second]) continue;
	used[p.second] = true;
	if (p.second == goal) {
	  return p.first;
	}
	decode(buf, p.second);
	int zp = 0;
	for (int i = 0; i < 9; i++) {
	  if (buf[i] == 0) {
		zp = i;
		break;
	  }
	}
	swap(buf[zp], buf[(zp+1)%9]);
	q.push(P(p.first+ch, encode(buf)));
	swap(buf[zp], buf[(zp+1)%9]);

	swap(buf[zp], buf[(zp+8)%9]);
	q.push(P(p.first+ch, encode(buf)));
	swap(buf[zp], buf[(zp+8)%9]);

	swap(buf[zp], buf[(zp+3)%9]);
	q.push(P(p.first+cv, encode(buf)));
	swap(buf[zp], buf[(zp+3)%9]);

	swap(buf[zp], buf[(zp+6)%9]);
	q.push(P(p.first+cv, encode(buf)));
	swap(buf[zp], buf[(zp+6)%9]);
  }
}

int main() {
  while (true) {
	cin >> ch >> cv;
	if (!ch && !cv) break;
	for (int i = 0; i < 9; i++) {
	  cin >> s[i];
	}
	for (int i = 0; i < 9; i++) {
	  cin >> g[i];
	}
	cout << solve() << endl;
  }
}

Measured memory_bytes: 30872
A_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))

bingo = [A_list1, A_list2, A_list3, [A_list1[0], A_list2[1], A_list3[2]], [A_list1[2], A_list2[1], A_list3[0]], [A_list1[0], A_list2[0], A_list3[0]], [A_list1[1], A_list2[1], A_list3[1]], [A_list1[2], A_list2[2], A_list3[2]]]

N = int(input())

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

ans = "No"
for b in bingo:
    c = 0
    for B in b:
        if B in b_list:
            c += 1
    if c == 3:
        ans = "Yes"
        break

print(ans)


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

ll f(ll n, ll p) {
  ll ret = 0;
  if (n == 0) return 0;
  ll t = n%p;
  ret += f(t, __builtin_popcountll(t));
  return ret + 1;
}

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

  ll d = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == '1') d++;
  }

  vector<vector<ll>> a(n, vector<ll>(2));
  for (int j=0; j<2; j++) {
    ll e = d;
    if (j == 0) e++;
    else e--;
    if (e <= 0) continue;
    ll t = 1;
    for (int i=0; i<n; i++) {
      a[n-i-1][j] = t % e;
      t = (t*2) % e;
    }
  }

  vector<ll> sum(2);
  for (int j=0; j<2; j++) {
    ll e = d;
    if (j == 0) e++;
    else e--;
    if (e <= 0) continue;
    for (int i=0; i<n; i++) {
      if (s[i] == '1') (sum[j] += a[i][j]) %= e;
    }
  }

  for (int i=0; i<n; i++) {
    ll e = d;
    ll idx = s[i] - '0';
    ll t = sum[idx];
    if (idx) {
      e--;
      if (e <= 0) {
        cout << 0 << endl;
        continue;
      }
      t = (t + e - a[i][idx]) % e;
    } else {
      e++;
      t = (t + a[i][idx]) % e;
    }
    cout << f(t, __builtin_popcountll(t))+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 14432
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
all_a=[]
def make_a():
  ret=[]
  todo=[[]]
  while todo:
    i=todo.pop()
    if len(i)==n:
      ret.append(i)
      continue
    l=i[-1] if len(i)>0 else 1
    for j in range(l,m+1):
      todo.append(i+[j])
  return ret

all_a=make_a()
ans=0
for an in all_a:
  ansi=0
  for a,b,c,d in abcd:
    if an[b-1]-an[a-1]==c:
      ansi+=d
  ans=max(ans,ansi)
print(ans)

Measured memory_bytes: 22856