akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll a = x/100;
    ll b = x%100;
    b = b/5+(b%5+3)/4;
    if (a >= b) PRINT(1);
    else PRINT(0);
}


Measured memory_bytes: 256
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

int Greatest_Common_Divisor(int a, int b) {

	while (a != 0 && b != 0) {
		if (a > b) {
			a = a - b;
		}
		else {
			b = b - a;
		}
	}
	return(a + b);
}
int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	int a = 0, b = 0;
	std::cin >> a >> b;
	std::cout << Greatest_Common_Divisor(a, b) << std::endl;

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    for(int i = 0; i < n - k; i++) {
        if(a[i] >= a[i + k]) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 3996
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 16 22:14:05 2019

@author: Yamazaki Kenichi
"""
import sys

N = int(input())
n = ((8*N+1)**0.5 - 1)/2
if n % 1 != 0:
    print('No')
    sys.exit()
else:
    n = int(n)
    print('Yes')
    print(n+1)

S = [[n] + [-1 for i in range(n)] for i in range(n+1)]

tmp = 1
for i in range(1,n+1):
    for j in range(i):
        S[j][i] = tmp
        S[i][j+1] = tmp
        tmp += 1
for i in range(n+1):
    print(' '.join(map(str,S[i])))

Measured memory_bytes: 8944
#include<iostream>
#include<string>
#include<vector> 
#include<algorithm>
#include<map>
using namespace std;


int main() {
	long long  m, n;
	long long sum = 0, sumen = 0;
	cin >> n >> m;
	vector<pair<long long, long long>>x(n);
	for (long long i = 0; i < n; i++) {
		cin >> x[i].first >> x[i].second;
	}
	sort(x.begin(), x.end());

	for (long long i = 0; i < n;i++) {
		if (sum + x[i].second >= m) {
			sumen += x[i].first*(m - sum);
			break;
		}
		else {
			sumen += x[i].first*x[i].second;
			sum += x[i].second;
		}
		
	}
	cout << sumen << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define trav(a, x) for(auto& a: x)
 
 template<class T>
 void print (vector<T>& v, bool spaced = true) {
     int n = v.size();
     string space = (spaced ? " ": "");
     for (int i = 0; i < n; ++i) {
         cout << v[i] << space;
     }cout << '\n';
 }
 
int main () {
 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
 
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<bool> dp(k + 1, false);
    for (int i = 1; i < k + 1; ++i) {
        for (auto num: a) {
            if (i >= num && !dp[i - num]) {
                dp[i] = 1;
            }
        }
    }

    cout << (dp[k] ? "First": "Second") << '\n';

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
	int a, b, c, min, center, max;
	scanf("%d%d%d", &a, &b, &c);
	min = a;
	center = b;
	max = c;

	if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (min >= center))
	{
		min = b;
		center = a;
		if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (center >= max))
		{
			center = c;
			max = a;
			if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (min >= center))
			{
				min = c;
				center = b;
			}
		}
	}
	else
		if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (center >= max))
		{
			center = c;
			max = b;
			if ((1 <= a) && (1 <= b) && (1 <= c) && (a <= 10000) && (b <= 10000) && (c <= 10000) && (min >= center))
			{
				min = c;
				center = a;
			}
		}
	printf("%d %d %d\n",min,center,max);
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
// #include <bits/stdc++.h>
#include <vector>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <random>
#include <queue>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <cstring>
#include <deque>

 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<cd> vcd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vl> vvl;


#define FOR(i,a,b) for (int i=a; i<b; i++)
#define F0R(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = b; i > a; i--)
#define F0Rd(i,a) for (int i = a; i > -1; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define que queue
#define pa pair
#define ex(m,i) m.find(i)!=m.end()
#define nex(m,i) m.find(i)==m.end()
#define ms(arr,i) memset(arr,i,sizeof(arr))

#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy
const double epsilon = 1e-12;
const int ds[4][2] = {
    {-1,0},
    {1,0},
    {0,-1},
    {0,1}
};

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

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    
    vi vc(3,0);
    cin >> vc[0] >> vc[1] >> vc[2];
    sort(all(vc));
    if(vc[0]==5&&vc[1]==5&&vc[2]==7){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    
    return 0;
}

Measured memory_bytes: 2860
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int N, Q;
vector<i64> X;
vector<set<int>> edge;

void recursive(int p, int before, i64 x) {
    if(before >= 0) edge[p].erase(before);
    X[p] += x;
    x = X[p];
    for(auto e : edge[p]) {
        recursive(e, p, x);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    X = vector<i64>(N, 0);
    edge = vector<set<int>>(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].insert(b);
        edge[b].insert(a);
    }
    for(int q = 0; q < Q; q++) {
        int p, x;
        cin >> p >> x;
        p--;
        X[p] += x;
    }
    recursive(0, -1, 0);
    for(int i = 0; i < N; i++) {
        cout << (i ? " " : "") << X[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 44544
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,a[3],b,c,d,k;
string s,x,y;
int main()
{
  cin>>a[0]>>a[1]>>a[2]>>k;
  sort(a,a+3);
  cout<<a[0]+a[1]+a[2]*pow(2,k);
}

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


template <class ForwardIterator>
void dumpList(ForwardIterator first, ForwardIterator last){
    for(auto i=first; i != last; i++){
        cout << *i << "; ";
    }
    cout << endl;
}

template <class ForwardIterator>
void dumpList(ForwardIterator first, ForwardIterator last, auto f){
    for(auto i=first; i != last; i++){
        cout << f(*i) << "; ";
    }
    cout << endl;
}

void solve(long long N, std::vector<long long> X, std::vector<long long> L){
    vector<pair<long long, long long>> intervals;
    for(int i=0; i < N; i++){
        intervals.push_back(pair<long long, long long>(X[i]-L[i], X[i]+L[i]));
    }
    auto f = [](pair<long long, long long> a, pair<long long, long long > b){
        if(a.second < b.second){
            return true;
        }else if(a.second > b.second){
            return false;
        }else{
            if(a.first < b.first){
                return true;
            }
        }
        return false;
    };
    sort(intervals.begin(), intervals.end(), f);
    // dumpList(intervals.begin(), intervals.end(), [](pair<long long, long long> p){
    //     char x[100];
    //     sprintf(x, "(%lld, %lld)", p.first, p.second);
    //     return string(x);
    // });
    int res = 0;
    long long current_end = intervals[0].first - 1;
    for(auto iter: intervals){
        if(current_end <= iter.first){
            res++;
            current_end = iter.second;
        }
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


Measured memory_bytes: 3956
n,c=map(int,input().split())
d=[list(map(int,input().split()))for _ in range(c)]
l=[[i for i in[0]*c]for _ in range(3)]
for i in range(n):
  t=list(map(int,input().split()))
  for j in range(n):
    l[(i+j)%3][t[j]-1]+=1
a=10**18
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i==j or j==k or k==i:continue
      a=min(a,sum(d[x][i]*l[0][x]+d[x][j]*l[1][x]+d[x][k]*l[2][x]for x in range(c)))
print(a)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long l[n + 10];
    for (int i = 0; i < n + 10; i++) {
        if (i == 0 || i == 1) l[i] = 2 - i;
        else l[i] = l[i - 1] + l[i - 2];
    }
    cout << l[n] << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())

if n <= 599:
  print(8)
elif n <= 799:
  print(7)
elif n <= 999:
  print(6)
elif n <= 1199:
  print(5)
elif n <= 1399:
  print(4)
elif n <= 1599:
  print(3)
elif n <= 1799:
  print(2)
elif n <= 1999:
  print(1)

Measured memory_bytes: 9188
n, q = map(int,input().split())
score = [0]*n
parent = [-1]*n
edge_list = [[] for i in range(n)]
ope = [0]*n
ans = [0]*n
for i in range(n-1):
    a, b = map(int,input().split())
    edge_list[a-1].append(b-1)
    edge_list[b-1].append(a-1)

for i in range(q):
    p, x = map(int, input().split())
    ope[p-1] += x
stack = [0]
ans[0] += ope[0]
while stack != []:
    par = stack.pop()
    if edge_list[par]:
        for i in edge_list[par]:
            if parent[i] == -1 and i > 0:
                parent[i] = par
                ans[i] = ans[par] + ope[i]
                stack.append(i)
    else:
        stack.pop()
print(*ans)



Measured memory_bytes: 64988
s = input().strip()

cnt = [1]
for i in range(20):
    cnt.append(sum(cnt))
ans = 0
for i in range(len(s)):
    for f in range(i + 1, len(s) + 1):
        num = int(s[i:f])
        ans += num * cnt[i] * cnt[len(s) - f]
print(ans)


Measured memory_bytes: 61740
import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a==b){
            System.out.println("a == b");
        }else{
            if(a>b){
                System.out.println("a > b");
            }else{
                System.out.println("a < b");
            }
        }
    }
}


Measured memory_bytes: 26084
n = int(input())

a = [1, n]

for i in range(1, int(n**0.5)+1):
    j = n // i
    if n % i == 0 and a[0] + a[1] > i + j:
        a = [i, j]

print(a[0] - 1 + a[1] - 1)

Measured memory_bytes: 3060
def abc():
    n, m = map(int, input().rstrip().split())
    fav = {}
    for i in range(n):
        f = list(map(int, input().rstrip().split()))
        for x in f[1:]:
            fav[x] = fav.get(x, 0) + 1
    print(len([k for k, v in fav.items() if v == n]))


abc()


Measured memory_bytes: 2940
from itertools import product, compress
from collections import Counter

N = int(input())
Ss = input()

S1s = Ss[:N]
ptn1s = [''.join(compress(S1s, sels)) for sels in product(range(2), repeat=N)]
cnt1 = Counter([(red, blue) for red, blue in zip(ptn1s, reversed(ptn1s))])

S2s = Ss[N:][::-1]
ptn2s = [''.join(compress(S2s, sels)) for sels in product(range(2), repeat=N)]
cnt2 = Counter([(red, blue) for red, blue in zip(ptn2s, reversed(ptn2s))])

ans = 0
for ptn1, num1 in cnt1.items():
    ans += num1 * cnt2[ptn1]
print(ans)


Measured memory_bytes: 111924
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int tmp;
    cin >> tmp;
    n -= tmp;
  }
  cout << max(-1,n) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<list>
#include<cstring>

using namespace std;

const int MAX = 20;

list<int> l;

int main()
{
	int n;
	while(~scanf("%d", &n))
	{
		while(n--)
		{
			char s[MAX];
			scanf("%s", s);
			if(!strcmp(s, "insert"))
			{
				int tmpnum;
				scanf("%d", &tmpnum);
				l.push_back(tmpnum);
			}
			else if(!strcmp(s, "delete"))
			{
				int tmpnum;
				scanf("%d", &tmpnum);
				int len = l.size();
				list<int>::iterator iter = l.end();
				iter--;
				for(;len >= 1; iter--, len--)
				{
					if((*iter) == tmpnum)
					{
						l.erase(iter);
						break;
					}
				}
			}
			else if(!strcmp(s, "deleteFirst"))
			{
				list<int>::iterator it = l.end();
				it--;
				l.erase(it);
			}
			else
			{
				list<int>::iterator it = l.begin();
				l.erase(it);
			}
		}
		int len = l.size();
		for(list<int>::reverse_iterator it = l.rbegin(); it != l.rend(); it++, len--)
		{
			printf("%d", *it);
			if(len == 1)
				printf("\n");
			else
				printf(" ");
		}
	}
	return 0;
}



Measured memory_bytes: 33872
#include <cstdio>
#include <cstring>

const int MAXK = 100005;
const int MAXD = 105;
const int MOD = 1000000007;

char K[MAXK];
int f[MAXK][MAXD][2], len, d;

int dp(int curr, int sum, int lim) {
    if (curr == len) return sum == 0;
    if (f[curr][sum][lim] != -1) return f[curr][sum][lim];

    int &F = f[curr][sum][lim];
    F = 0;

    if (lim) {
        F += dp(curr + 1, (sum + K[curr] - '0') % d, 1);
        F >= MOD ? F -= MOD : 0;
    }
    for (int i = 0; i < (lim ? K[curr] - '0' : 10); i++) {
        F += dp(curr + 1, (sum + i) % d, 0);
        F >= MOD ? F -= MOD : 0;
    }

    return F;
}

int main() {
    scanf("%s %d", K, &d);
    len = std::strlen(K);
    std::memset(f, -1, sizeof (f));

    int ans = dp(0, 0, 1) - 1;
    ans < 0 ? ans += MOD : 0;
    printf("%d\n", ans);
    
    return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int n;
int dfs(string s){
    if(s.size()>9) return 0;
    if(!s.empty() && stoi(s) > n) return 0;
    string number = s;
    sort(ALL(number));
    number.erase(unique(ALL(number)),number.en());
    int ret = 0;
    if( number.size() == 3 &&
        number[0] == '3' &&
        number[1] == '5' &&
        number[2] == '7') ret++;
    
    ret += dfs(s+"3");
    ret += dfs(s+"5");
    ret += dfs(s+"7");
    return ret;
}

int main(){
    cin>>n;

    cout<<dfs("")<<endl;
    return 0;
}

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

int main()
{
    long long n,m;
    scanf("%lld%lld",&n,&m);
    long long r = max(n,m);
    long long c = min(n,m);
    if(r==1&&c==1)
        printf("1\n");
    else if(c==1)
        printf("%lld\n",r-2);
    else
        printf("%lld\n",(c-2)*(r-2));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> L(2*N);
    for(int i=0;i<2*N;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    long long sum=0;
    for(int i=0;i<2*N;i+=2){
        sum += L[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int A[n];

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

	int q, b, m, e;

	cin >> q;

	for (int j = 0; j < q; j++) {
		cin >> b >> m >> e;
        rotate(A+b, A+m, A+e);
	}

	for (int l = 0; l < n; l++) {
		if(l == 0) cout << A[l];
		else cout << " " << A[l];
	}
	cout << endl;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 3005;
int n,k;
int main()
{
    scanf("%d%d", &n, &k);
    int x[n],ans[n];
    For(i,n)
    {
        ans[i] = 1e9;
        scanf("%d", &x[i]);
    }
    ans[0] = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = i;j>=max(0,i-k);j--)
            ans[i] = min(ans[i],ans[j] + abs(x[i] - x[j]));
    }
    cout<<ans[n - 1];
}

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

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}



D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}



int main(){
    Line L;
    cin>>L;
    int Q;cin>>Q;
    while(Q--){
        Point p;
        cin>>p;

        Point w=L.p1+projection(L.p2-L.p1,p-L.p1);
        cout<<w<<endl;
    }

    return 0;
}

Measured memory_bytes: 3304
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    set<int> s;
    for(int i=0; i<3; ++i){
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;

    return 0;
}

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

int main(){
	int num;
	int x[100];
	int y[100];
	int i;
	double re[4]={0.0, 0.0, 0.0, 0.0};

	scanf("%d", &num);
	for(i=0; i< num; i++){
		scanf("%d", &x[i]);
	}
	for(i=0; i<num; i++){
		scanf("%d", &y[i]);
	}

	for(i=0; i< num; i++){
		re[0] += fabs((double)x[i] - y[i]);
		re[1] += ((double)x[i] - y[i])*(x[i] - y[i]);
		re[2] += fabs((double)x[i] - y[i]) * fabs((double)x[i] - y[i]) * fabs((double)x[i] - y[i]);
		if(i==0){
			re[3] = fabs((double)x[i] - y[i]);
		}
		else{
			if(re[3] < fabs((double)x[i] - y[i])){
				re[3] = fabs((double)x[i] - y[i]);
			}
		}
	}

	re[1] = sqrt(re[1]);
	re[2] = pow(re[2], 1.0/3.0);

	for(i=0; i< 4; i++){
		printf("%lf\n", re[i]);
	}
	return 0;

}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, m; cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n-m+1) rep(j, n-m+1) {
    bool ok = true;
    rep(x, m) rep(y, m) {
      if(b[x][y] != a[i+x][j+y]) ok = false; 
    }
    if(ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    double ans = 0;
    for (int i = 0; i < N; i++) {
        string x, u;
        cin >> x >> u;
        if (u == "JPY") {
            int jpy = stoi(x);
            ans += jpy;
        } else {
            double btc = stod(x);
            ans += btc * 380000;
        }
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 50;
long long h, w;
 
int main() {
	cin >> h >> w;
	if(h==1 || w==1) {
		cout << 1 << endl;
	}else {
		long long tmp = h*w;
		cout << (tmp/2) + (tmp&1) << endl;
	}
	
	
	return 0;
} 


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n,m;cin>>n>>m;
  int x[m+10];rep(i,0,m)cin>>x[i];
  sort(x,x+m);

  int dis[m+10];
  if(n>=m){out(0);return 0;}
  else{
    rep(i,0,m-1){
      dis[i]=x[i+1]-x[i];
    }
  }

  sort(dis,dis+m-1,greater<int>());
  int sum=x[m-1]-x[0];
  rep(i,0,n-1){
    sum-=dis[i];
  }

  out(sum);

  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        long N = cin.nextint;
        long M = cin.nextint;
        long D = cin.nextint;

        //long X = 2 * D;
        //if(N - 2 * D - 1 > 0)
        //{
        //    X += 2 * (N - 2 * D - 1);
        //}
        //WriteLine(2 * N / (double)(M - 1));
        

        long X = 0;
        if (2 * D > N)
        {
            X = 2 * (N - D);
        }
        else if (2 * D == N)
        {
            X = N;
        }
        else if (2 * D < N)
        {
            X = 2 * N - 2 * D;
        }

        if (D == 0) X = N;
        //WriteLine(X);
        
        //double ans = (double)X / (N * N - X);
        //WriteLine(ans.ToString("F7"));


        long ans = X * (M - 1);

 
        WriteLine(((double)ans / N / N).ToString("F7"));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')
        

Measured memory_bytes: 2940
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define Mx 1e10
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,mn=0,mx=0,x,i,t=0,j=0,k=0;
    	set<ll>s;
    	cin>>n;
    	ll a[n],c[n],g[n];
    	f(i,n)
    	{
    	    cin>>a[i];
    	}
        sort(a,a+n);
        for(i=n-1;i>=0;i--)
        {
            if(a[i]==a[i-1]&&a[i-1]==a[i-2]&&a[i-2]==a[i-3])
            {
                t=max(t,a[i]*a[i]);
            }
            else if(a[i]==a[i-1]&&mx==0)
            {
                mx=a[i];
            }
            else if(a[i]==a[i-1]&&mx!=a[i]&&a[i]>mn)
            {
                mn=a[i];
            }
            if(mx>0&&mn>0)
                k=max(k,mx*mn);
        }
         cout<<max(k,t)<<endl;
}






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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll n;
    in(n);
    ll k = 1;
    ll ans = 0;
    floop(i, n)
    {
        ll a;
        in(a);
        if (a == k)
        {
            k++;
        }
        else
        {
            ans++;
        }
    }
    if (ans != n)
    {
        out(ans);
    }
    else
    {
        out("-1");
    }
}

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

class Main {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        long x, y;
        x = in.nextLong();
        y = in.nextLong();
        if(Math.abs(x - y) > 1L) {
            System.out.println("Alice");
        } else {
            System.out.println("Brown");
        }
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}


Measured memory_bytes: 23508
#include<stdio.h>
#include<stdlib.h>

int main()
{
        long X;
        long K;
        long D;
        long i;
        long n;
        scanf("%ld %ld %ld",&X,&K,&D);
        n = X/D;
        if (n < 0) n=-n;
        if (K > n)
        {
                if (X>0)
                {
                        X = X - n * D;
                        if ((K-n)%2 == 1) X = X - D;
                }else{
                        X = X + n*D;
                        if ((K-n)%2 ==1) X = X + D;
                }
        }else{
                if (X > 0)
                {
                        X = X - K*D;
                }else{
                        X = X + K*D;
                }
        }
        if (X<0) X=-X;
        printf("%ld\n",X);
        return 0;
}


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

int main(){
  vector<int> counter(4);
  for (int i = 0; i < 3 ; i++){
    int a, b;
    cin >> a >> b;
    counter.at(a-1)++;
    counter.at(b-1)++;
  }
  sort(counter.begin(),counter.end());
  reverse(counter.begin(),counter.end());
  if (counter.at(0) >=3){
    cout << "NO" << endl;
    return 0;
  }else{
    cout << "YES" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    a=a-b;
    if(a>c){
        cout<<0;
    }
    else{
        cout<<c-a;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A == B)
    printf("%d\n",C);
  if(B == C)
    printf("%d\n",A);
  if(A==C)
    printf("%d\n",B);
  return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using lint = long long;

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

    std::priority_queue<lint> que;
    for (int i = 0; i < n; ++i) {
        lint a;
        std::cin >> a;
        que.push(a);
    }

    for (int i = 0; i < m; ++i) {
        lint a = que.top();
        que.pop();
        que.push(a / 2);
    }

    lint ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }

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


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

int main() {
  int N;
  cin >> N;
  vector< vector<int> > A;
  A = vector< vector<int> >(2, vector<int>(N, 0));
  
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  
  int max = 0, tmp;
  for(int i = 0; i < N; i++) {
    tmp = 0;
    for(int j = 0; j < N; j++) {
      if(j < i) {
        tmp += A[0][j];
      } else if(j == i) {
        tmp += A[0][j];
        tmp += A[1][j];
      } else {
        tmp += A[1][j];
      }
    }
    if(tmp > max) {
      max = tmp;
    }
  }
  cout << max << endl;
}


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

using namespace std;

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

    int x = to_string(b).size();
    int c = a * pow(10, x) + b;
    bool flag = false;
    for (int i = 1; i <= sqrt(c); i++)
    {
        if(i*i==c)
        {
            flag = true;
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main() {
  int n, Q;
  cin >> n >> Q;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  for (int i = 0; i < Q; ++i) {
    long long x; cin >> x;

    long long res = 0;

    int right = 0;
    long long sum = 0;
    for (int left = 0; left < n; ++left) {
      while (right < n && sum + a[right] <= x) {
        sum += a[right];
        right ++;
      }
      res += right - left;

      if (left == right) right ++;
      else sum -= a[left];
    }

    cout << res << endl;
  }
}



Measured memory_bytes: 3600
n = int(input())
cards = [int(input()) for _ in range(n)]
ans = 0

for i in range(n):
    if i == n-1:
        ans += cards[i] // 2
        cards[i] = cards[i] % 2
    else:
        ans += cards[i] // 2
        cards[i] = cards[i] % 2
        if cards[i] == 1 and cards[i+1] > 0:
            cards[i] -= 1
            cards[i+1] -= 1
            ans += 1
        
print(ans)

Measured memory_bytes: 7072
#include <iostream>

using namespace std;

int main()
{
    long long a,b,x;
    cin >> a >> b >> x;
    bool f = 0;
    if(a > 0)
    {
        a--;
        f = 1;
    }
    long long k = b/x;
    long long ans = a/x;
    ans = k - ans;
    if(a == 0 && !f)
        ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> cnt(4, 0);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if(s[i]=="AC"){
      cnt[0]++;
    }else if(s[i]=="WA"){
      cnt[1]++;
    }else if(s[i]=="TLE"){
      cnt[2]++;
    }else{
      cnt[3]++;
    }
  }
  cout << "AC x " << cnt[0] << endl;
  cout << "WA x " << cnt[1] << endl;
  cout << "TLE x " << cnt[2] << endl;
  cout << "RE x " << cnt[3] << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
	long long n, a, b;
	cin >> n >> a >> b;

  if( a > b )
    cout << 0 << endl;
  else if( a == b )
    cout << 1 << endl;
  else if( n == 1 )
    cout << 0 << endl;
  else if( n == 2 )
    cout << 1 << endl;
  else
    cout << ( ( b - a ) * ( n - 2 ) + 1 ) << endl;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def main():
    a = input()
    if a.isupper():
        print("A")
    else:
        print("a")
    
if __name__ == "__main__":
    main()

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

#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    
    int n,k;
    cin>>n>>k;
    
    int cost[n+1];
    bool reachable[n+1];
    int total[n+1];
    
    for(int i = 1;i <= n; i++){
        cin>>cost[i];
        reachable[i] = false;
        total[i] = INT_MAX;
    }
    
    total[1] = 0;
    
    reachable[1] = true;
    for(int i = 1; i <= n; i++){
        if(!reachable[i])
        continue;
        
        for(int j = 1; j<=k; j++){
            if(i+j>n)
            break;
            
            reachable[i+j] = true;
            total[i+j] = min(total[i+j], total[i] + abs(cost[i+j] - cost[i]));
        }
        
    }
    
    
    cout<<total[n]<<endl;
    
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int p,q,r;
    cin>>p>>q>>r;
    vector<int>vec={p,q,r};
    sort(vec.begin(), vec.end());
    int l=vec.at(0)+vec.at(1);
    cout<<l<<endl;
    
    
  
  }
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  if(B-A+1>2*K){
    for(int i=A;i<A+K;i++){
      cout << i << endl;
    }
    for(int i=B-K+1;i<=B;i++){
      cout << i << endl;
    }
  }else{
    for(int i=A;i<=B;i++){
      cout << i << endl;
    }
  }
}

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

const int T = 4,S = 9;
int num[1000],p[1000],q[1000],r[1000];
int P,Q,R,C;
queue<int> ans[100];

int main()
{
	int i,j;
	int N;
	for(i = 0; cin >> N ;i++){
		if( N == 0 )
			break;
		for(j = 0;j < N;j++)
		{
			cin >> num[j] >> p[j] >> q[j] >> r[j];
		}
		cin >> P >> Q >> R >> C;
		for(j = 0;j < N;j++){
			if( p[j]  <= P && q[j]  <= Q && r[j]  <= R && (p[j]+r[j])*T+q[j]*S <= C)
			{
				ans[i].push( num[j] );
			}
		}
	}
	for( j = 0;j < i;j++){
		if( ans[j].empty() )
			cout << "NA" << endl;
		else{
			while( !ans[j].empty() ){
				cout << ans[j].front() << endl;
				ans[j].pop();
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1292
#include <iostream>
using namespace std;
    int main(void){
        int N, L, sum;
            cin >> N >> L;
                sum = 0;
            
        for(int i = 0; i < N; i++){
            sum += L;
            sum += i;
        }
            if(L < 0){
                if(-L + 1 <= N){
                    cout << sum;
                        return 0;
                }else{
                    cout << sum - (L + N -1);
                        return 0;
                }
            }
            if(L >= 0){
                cout << sum - L;
                    return 0;
            }
            cout << sum;
    return 0;}


Measured memory_bytes: 256