akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vld heads = vld();
	heads.pb(-1);
	rep(i, n){
		ld p; cin >> p;
		heads.pb(p);
	}
	// dp[i][j] = prob of getting j heads with first i coins
	// dp[i][j] = P(ith coin heads and j-1 heads with i-1 coins) + 
	//            P(ith coin tails and j heads with i-1 coins)
	vvld dp = vvld(n+1, vld(n+1, 0));
	dp[1][0] = 1 - heads[1];
	dp[1][1] = heads[1];
	for(int i = 2; i < n + 1; i++){
		for(int j = 0; j <= i; j++){
			if (j > 0){
				dp[i][j] += heads[i]*dp[i-1][j-1];				
			}
			dp[i][j] += (1-heads[i])*dp[i-1][j];
		}
	}
	ld ans = 0;
	int mid = n/2;
	for(int j = 0; j <= n; j++){
		if (j > mid){
			ans += dp[n][j];
		}
	}
	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 144208
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")

using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
int a[maxn];
int main(){
    int n,m;
    scanf("%d%d",&m,&n);
    rep(i,1,n) scanf("%d",&a[i]);
    int cm=0;
    rep(i,2,n){
        cm=max(cm,a[i]-a[i-1]);
    }
    cm=max(cm,a[1]+m-a[n]);
    printf("%d\n",m-cm);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define ll long long int
int main(){
	int n;
	cin>>n;
	ll ls[n],ls2[n];
	for(int i=0;i<n;i++)
	cin>>ls[i];
	for(ll x:ls)
	ls2[ls[x-1]-1]=x;
	for(ll x:ls2)
	cout<<x<<" ";
return 0; 
}  



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

struct StronglyConnectedComponents
{
	int V;
	const vector<vector<int>> &g;
	int num_of_comp;
	vector<int> comp;
	vector<vector<int>> dag;
	vector<vector<int>> group_set;

	vector<vector<int>> rg;
	vector<int> order;
	vector<bool> used;

	StronglyConnectedComponents(const vector<vector<int>> &g) : V(g.size()), g(g) {}

	void calc() {
		num_of_comp = 0;
		comp.assign(V, -1);
		used.assign(V, false);
		order.reserve(V);
		rg.resize(V);
		for (int i = 0; i < V; i++) {
			for (int e : g[i]) {
				rg[e].push_back(i);
			}
		}
		for (int i = 0; i < V; i++) {
			if (!used[i]) dfs1(i);
		}
		for (int i = V-1; i >= 0; i--) {
			const int v = order[i];
			if (comp[v] == -1) {
				dfs2(v);
				num_of_comp++;
			}
		}
		dag.resize(num_of_comp);
		group_set.resize(num_of_comp);
		for (int i = 0; i < V; i++) group_set[comp[i]].push_back(i);
		for (int i = 0; i < V; i++) {
			for (int e : g[i]) {
				const int x = comp[i], y = comp[e];
				if (x != y) dag[x].push_back(y);
			}
		}

	}

	void dfs1(int v) {
		used[v] = true;
		for (int nv : g[v]) {
			if (used[nv]) continue;
			dfs1(nv);
		}
		order.push_back(v);
	}

	void dfs2(int v) {
		comp[v] = num_of_comp;
		for (int nv : rg[v]) {
			if (comp[nv] != -1) continue;
			dfs2(nv);
		}
	}
};

struct TwoSAT
{
	int n;
	bool ok;
	vector<bool> ans;

	vector<vector<int>> g;

	TwoSAT(int n) : n(n), g(2*n) {}

	void add_clause(int i, bool bool_i, int j, bool bool_j) {
		g[2*i + !bool_i].push_back(2*j + bool_j);
		g[2*j + !bool_j].push_back(2*i + bool_i);
	}

	void calc() {
		StronglyConnectedComponents scc(g);
		scc.calc();
		ok = false;
		for (int i = 0; i < n; i++) {
			if (scc.comp[2*i] == scc.comp[2*i + 1]) return;
		}
		ok = true;
		ans.resize(n);
		for (int i = 0; i < n; i++) {
			ans[i] = scc.comp[2*i] < scc.comp[2*i + 1];
		}
	}
};

int main() {
	int n, d;
	cin >> n >> d;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x[i], &y[i]);
	}
	TwoSAT sat(n);
	for(int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (abs(x[i]-x[j]) < d) sat.add_clause(i, 1, j, 1);
			if (abs(x[i]-y[j]) < d) sat.add_clause(i, 1, j, 0);
			if (abs(y[i]-x[j]) < d) sat.add_clause(i, 0, j, 1);
			if (abs(y[i]-y[j]) < d) sat.add_clause(i, 0, j, 0);
		}
	}
	sat.calc();
	if (sat.ok) {
		cout << "Yes" << endl;
		for (int i = 0; i < n; i++) {
			if (sat.ans[i]) cout << y[i] << '\n';
			else cout << x[i] << '\n';
		}
	} else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char str[20];
    int i,count=0;
    scanf("%s",str);
    for(i=0;str[i]!='\0';i++)
        count++;
    for(i=count-1;i>=0;i--)
        printf("%c",str[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;

ll solve(ll n){
	ll cnt=0;
	for(ll i=1; i<=sqrt(n); i++){
		if(n%i==0){
			if(n/i==i) cnt++;
			else cnt+=2;
		}
	}
	return cnt;
}

int main(){
	ll n;
	cin>>n;
	for(ll i=1; i<=n; i++){
		if(i%2!=0) {
			flag=solve(i);
			if(flag==8) ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        x.append(b)
    if b==n:
        x.append(a)
l=len(x)
if len(set(x))==l:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


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

using namespace std;

typedef long long ll;

ll A[101010], B[101010], D[101010];
vector <ll> S;
ll n;

int main()
{
	ll i, j;
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld", A + i);
		B[i] = A[i];
	}
	
	for(i=n; i>=1; i--){
		for(; !S.empty() && A[S.back()] <= A[i]; S.pop_back());
		S.push_back(i);
	}
	
	S.push_back(0);
	
	sort(B + 1, B + n + 1);
	
	for(i=0, j=n; i<S.size()-1; i++){
		D[S[i]] += (n - j) * (A[S[i]] - A[S[i + 1]]);
		for(; j>=1 && B[j]>A[S[i + 1]]; j--){
			D[S[i]] += (B[j] - A[S[i + 1]]);
		}
	}
	
	for(i=1; i<=n; i++){
		printf("%lld\n", D[i]);
	}
	
	return 0;
}

Measured memory_bytes: 4340
package main

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

type ship struct {
	a, b int
}

func main() {
	n := getInt()
	m := getInt()

	ss := make([]ship, m)
	for i := range ss {
		ss[i].a = getInt()
		ss[i].b = getInt()
	}

	checker := make([]bool, n)
	for _, s := range ss {
		if s.a == 1 {
			checker[s.b-1] = true
		}
	}

	ans := "IMPOSSIBLE"
	for _, s := range ss {
		if s.b == n && checker[s.a-1] == true {
			ans = "POSSIBLE"
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 5888
a,h=map(int, input().split())
b,i=map(int, input().split())
c,j=map(int, input().split())
d,k=map(int, input().split())
e,l=map(int, input().split())
f,m=map(int, input().split())
g,n=map(int, input().split())
if a < h or b < i or c < j or d < k or e < l or f < m or g < n :
    pass
else :
    print(a-h)
    print(b-i)
    print(c-j)
    print(d-k)
    print(e-l)
    print(f-m)
    print(g-n)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <list>

using namespace std;
#define ul unsigned long

//#define DEBUG

int main() {
	ul a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;

#ifdef 	DEBUG
	cout << a << " " << b << " " << c << " " << x << " " << y << endl;
#endif

	ul rv=0, smaller=x<y?x:y, bigger=x>y?x:y;

	if ((a+b) >= 2*c) {
		rv+=smaller * 2*c;
		x-=smaller;
		y-=smaller;
		smaller=0;
		bigger=bigger-smaller;
	}

	if (a >= 2*c) {
		rv+=x * 2*c;
		x=0;
	} else {
		rv+=x * a;
		x=0;
	}

	if (b >= 2*c) {
		rv+=y * 2*c;
		y=0;
	} else {
		rv+=y * b;
		y=0;
	}

	cout << rv << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[3005][3005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a, b, t = "";
    cin >> a >> b;
    for (int i = 1; i <= a.size(); i++)
        for (int j = 1; j <= b.size(); j++)
            if (a[i - 1] == b[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    int i = a.size(), j = b.size();
    while (dp[i][j])
    {
        if (dp[i][j] == dp[i - 1][j])
            i--;
        else if (dp[i][j] == dp[i][j - 1])
            j--;
        else if (dp[i][j] > dp[i - 1][j - 1])
            i--, j--, t += a[i];
    }
    reverse(t.begin(), t.end());
    cout << t;
}
/*#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
int dp[1005][1005];
int main()
{
    string s, t;
    cin >> s >> t;
    int len1 = s.size(), len2= t.size();
    for(int i = 0; i < len1 ; i++){
        for(int j = 0; j < len2; j++){
            if(s[i] == t[i]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else {
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }cout << dp[len1 ] [len2] ;
}*/

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

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int val = S-i-j;
                if (val >= 0 && val <= K) count ++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int f(long long x) {
    int res = 0;
    for(; x / 10; x /= 10) res += x % 10;
    res += x;
    return res;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    long long x; cin >> x;
    cout << (x % f(x) == 0 ? "Yes" : "No");
}


Measured memory_bytes: 256
n = int(input())
a = map(int, input().split())

l = []
for i in a:
    if (i % 2 == 0):
        l.append(i)

if len(l) > 0:
    x = 0
    for i in l:
        if (i % 3 == 0) or (i % 5 == 0):
            x += 1
    if len(l) == x:
        print('APPROVED')
    else:
        print('DENIED')
else:
    print('APPROVED')


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

// long long int chmin(long long int a, long long int b)
// {
// 	if (a > b)
// 		return b;
// 	else
// 		return a;
// }

long long int chmin(long long int a, long long int b)
{
	if (a > b)
		return b;
	return a;
}

int main(int argc, char const *argv[])
{
	long long int n;
	scanf("%lld", &n);
	long long int *dp = malloc(n * sizeof(long long int));
	long long int *h = malloc(n * sizeof(long long int));
	for (int i = 0; i < n; i++)
	{
		dp[i] = 1000000;
		scanf("%lld", h+i);
	}
	dp[0] = 0;
	dp[1] = llabs(h[1] - h[0]);
	for (int i = 2; i < n; ++i)
	{
		dp[i]=chmin(dp[i - 2] + llabs(h[i] - h[i - 2]), dp[i - 1] + llabs(h[i] - h[i - 1]));
	}
	free(h);
	printf("%lld", dp[n-1]);
	free(dp);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
  int h, w, n;
  cin >> h >> w >> n;
  int ans;
  if (h > w)
  {
    ans = n / h;
    if(n%h!=0){
      ans++;
    }
  }else{
    ans = n / w;
    if(n%w!=0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
 
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
 
		Arrays.sort(a);
		long l = 0;
		long r = 100000 * 2 + 1;
		while (r - l > 1) {
			long mid = (l + r) / 2;
			long count = 0;
 
			for (int i = a.length - 1; i >= 0; i--) {
				int index = lowerBound(a, mid - a[i]);
				count += (a.length - index);
				if (count > m) break;
			}
 
			if (count >= m) {
				l = mid;
			} else {
				r = mid;
			}
		}
 
		long[] s = new long[n + 1];
		s[n - 1] = a[n - 1];
		for (int i = n - 2; i >= 0; i--) {
			s[i] = s[i + 1] + a[i];
		}
		//System.out.println(l);
		long answer = 0;
		long c = 0;
		for (int i = a.length - 1; i >= 0; i--) {
 
			int index = lowerBound(a, l - a[i]);
			answer += s[index];
			answer += (n - index) * a[i];
			c += (n - index);
		}
 
		if (m < c) {
			answer -= (c - m) * l;
		}
 
		System.out.println(answer);
	}
 
	private static int lowerBound(long[] a, long x) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (a[m] >= x) {
				r = m;
			} else {
				l = m;
			}
		}
		return r;
	}
}

Measured memory_bytes: 60472
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, k;
    vector<int> K;
    while (cin >> N && N != 0) {
        K.clear();
        bool possible = false;
        for (int i=0; i<N; ++i) {
            cin >> k;
            if (k != 0) {
                K.push_back(k);
            }
            if (k >= 2) {
                possible = true;
            }
        }
        if (possible) {
            cout << K.size() + 1  << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1316
from collections import defaultdict
n, k = map(int, input().split())
m = defaultdict(int)

for _ in range(k):
  input()
  for x in input().split():
    m[int(x)] += 1

result = 0
for i in range(1, n+1):
  if m[i] == 0:
    result += 1
print(result)

Measured memory_bytes: 9368
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=1e17;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
// double dp[100005];
 
// bool cmp
vector<lli> v[2005];
lli vis[2005];
lli dp[2005][2005];
void bfs(lli i,lli pp)
{
    queue<ll> q;
    q.push({i,0});
    while(!q.empty())
    {
        ll p=q.front();
        q.pop();
        lli x=p.first;
        lli y=p.second;
        if(vis[x])
        continue;
        vis[x]=1;
        dp[pp][x]=y;
        for(auto &j: v[x])
        {
            q.push({j,y+1});
        }
    }
}
int main()
{

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

 for(int i=1;i<=n;i++)
 {
    mem1(vis,0);
    bfs(i,i);
 }
 map<lli,lli> ml;
 for(int i=1;i<=n;i++)
 {
    for(int j=i+1;j<=n;j++)
    {
        ml[dp[i][j]]++;
    }
 }

 for(int i=1;i<n;i++)
 {
    cout<<ml[i]<<"\n";
 }
}

Measured memory_bytes: 31872
public class Main {

  private static void solve() {
    int n = ni();

    dfs(0, new char[n], n, 0);
  }

  private static void dfs(int i, char[] s, int max, int x) {
    if (i == max) {
      out.println(s);
      return;
    }

    if (i == 0) {
      s[i] = 'a';
      dfs(i + 1, s, max, 1);
    } else {
      for (int j = 0; j <= x; j++) {
        s[i] = (char) ('a' + j);
        dfs(i + 1, s, max, Math.max(j + 1, x));
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 25524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,Q;cin>>N>>K>>Q;
  vector<int> P(N,K);
  for(int i=0;i<Q;i++){
    int a;cin>>a;
    P[a-1]+=1;
  }
  for(int i=0;i<N;i++){
    //cout<<P[i]-Q<<endl;
    if(P[i]-Q<=0){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

long long int lcm(long long int A, long long int B);
long long int gcd(long long int A, long long int B);

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	vector<int> A, B;
	cin >> N;
	for(int i=0; i<N+1; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}

	for(int i=0; i<N; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}

	long long int ans = 0;
	for(int i=0; i<N; i++) {
		if(A[i] > 0) {
			ans += min(A[i], B[i]);
			B[i] -= min(A[i], B[i]);
		}
		if(B[i] > 0) {
			ans += min(A[i+1], B[i]);
			A[i+1] -= min(A[i+1], B[i]);
		}
	}

	cout << ans;
	return 0;
}


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

namespace AOJ_DPL_2_A_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var VE = ReadInt();
            V = VE[0];
            int E = VE[1];

            d = new long[V, V];
            for (int i = 0; i < V; i++)
            {
                for (int j = 0; j < V; j++)
                {
                    d[i, j] = INF;
                }
            }

            for (int i = 0; i < E; i++)
            {
                var input = ReadInt();
                int s = input[0];
                int t = input[1];
                int d2 = input[2];
                d[s, t] = d2;
            }

            //bitDP
            dp = new long[1 << V, V];
            long ans = Tsp(1, 0);

            if (ans != INF) Console.WriteLine(ans);
            else Console.WriteLine(-1);
            Console.ReadKey();
        }

        static int V;   　 //頂点数
        static long[,] d;　//頂点行列 頂点ない部分はlong.MaxValue / 4で初期化
        static long[,] dp; //DP
        static long INF = long.MaxValue / 2;
        /// <summary>
        /// 巡回セールスマン問題
        /// </summary>
        /// <param name="S">bit訪れた場所のbit</param>
        /// <param name="v">現在の頂点</param>
        /// <returns></returns>
        static long Tsp(int S = 1, int v = 0)
        {
            if (dp[S, v] != 0) return dp[S, v];
            if (S == (1 << V) - 1) return d[v, 0];

            long ret = INF;
            for (int i = 0; i < V; i++)
            {
                if ((S & (1 << i)) > 0) continue;
                if (d[v, i] == INF) continue;
                ret = Math.Min(ret, d[v, i] + Tsp(S | (1 << i), i));
            }

            return dp[S, v] = ret;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



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

#define o(output) cout << output << endl

using namespace std;

string s;
int a,b,c,d;
char A,B;

int main(){
  cin >> A>> B;
  if(A>B){
    o(">");
  }else if(A==B){
    o("=");
  }else{
    o("<");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;

//template
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

ll calc(V<ll> v) {
    ll n = v.size();
    ll ans = 0;
    while (true) {
        ll sm = 0;
        for (ll d: v) {
            sm += d / n;
        }
        if (sm == 0) break;
        ans += sm;
        for (ll &d: v) {
            d = (d % n) + sm - d / n;
        }
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    V<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    cout << calc(v) << endl;
    return 0;
}


Measured memory_bytes: 256
let print_chess h w = (for i = 1 to h do
                         for j = 1 to w do
                           if i mod 2 = 1 then
                             begin
                               print_char (if j mod 2 = 1 then '#' else '.')
                             end
                           else
                             begin
                               print_char (if j mod 2 = 1 then '.' else '#')
                             end 
                         done;
                         print_newline()
                       done) ;;

let rec f() = Scanf.scanf "%d %d\n" (fun h w -> if h > 0 && w > 0 then
                                                  begin
                                                    print_chess h w;
                                                    print_newline();
                                                    f()
                                                  end) ;;
f() ;;


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

int main(){
  int a;
  cin >> a;
  if (a==25){cout << "Christmas" << endl;}
  if (a==24){cout << "Christmas Eve" << endl;}
  if (a==23){cout << "Christmas Eve Eve" << endl;}
  if (a==22){cout << "Christmas Eve Eve Eve" << endl;}
}

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

int main()
{
  char field[8][8];

  while (cin >> field[0]){
  
    for (int j = 1; j < 8; j++){
      cin >> field[j];
    }
  
  
    bool judge = false;
    for (int i = 0; i < 8; i++){
      for (int j = 0; j < 8; j++){
        if (field[i][j] == '1'){
          if (field[i + 3][j] == '1'){
            cout << 'B';
          }
          else if (field[i][j + 3] == '1'){
            cout << 'C';
          }
          else if (field[i + 2][j - 1] == '1'){
            cout << 'D';
          }
          else if (field[i + 1][j + 2] == '1'){
            cout << 'E';
          }
          else if (field[i + 2][j + 1] == '1'){
            cout << 'F';
          }
          else if (field[i + 1][j - 1] == '1'){
            cout << 'G';
          }
          else {
            cout << 'A';
          }
          judge = true;
        }
        if (judge)  break;
      }
      if (judge)  break;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1132
#if defined(LOCAL)
#define PROBLEM_NAME "A"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(b); a > l(c); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

void solve(istream& in, ostream& out) {
  l n;
  while (in >> n) {
    vl v(n); F(i, 0, n) in >> v[i];
    vvl dp(n + 1, vl(10));
    F(j, 1, 10) dp[0][j] = -INF;
    F(i, 0, n) {
      l x = v[i];
      dp[i + 1] = dp[i];
      F(j, 0, 10) {
        dp[i + 1][(x + j) % 10] = max(dp[i + 1][(x + j) % 10],
                                      dp[i][j] + x);
      }
    }
    l answer = 0;
    F(j, 1, 10) answer = max(answer, dp[n][j]);
    out << answer << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, M, C, a, b, f, g, h;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;
    C = N * M / __gcd(N, M);
    a = C / N;
    b = C / M;
    f = a * b / __gcd(a, b);
    g = f / a;
    h = f / b;
    for (int i = 0; i < N; i++) {
        if(i * g >= N || i * h >= M) break;
        if(s[i*g] != t[i*h]){
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n", C);

}

Measured memory_bytes: 3860
import java.util.*;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cntA=0; int cntB=0; int cntO=0; int cntAB=0;
		while(sc.hasNext()){
			String t = sc.next();
			String[] temp = t.split(",");
			if(temp[1].equals("A")) cntA++;
			if(temp[1].equals("B")) cntB++;
			if(temp[1].equals("O")) cntO++;
			if(temp[1].equals("AB")) cntAB++;
		}
		System.out.printf("%d%n%d%n%d%n%d%n",cntA,cntB,cntAB,cntO);
	}

}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            
            Console.WriteLine(N == new string(N.Reverse().ToArray()) ? "Yes" : "No");
        }
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1,0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    bool iflag = false, dflag = false;
    int ans = 0;

    for(int i = 0; i < N -1 ; i++){
        if(A[i] < A[i+1]){
            if(dflag){
                ans++;
                dflag = false;
                continue;
            }
        iflag = true;
        dflag = false;
        } else if(A[i] > A[i+1]){
            if(iflag){
                ans++;
                iflag = false;
                continue;
            }
        dflag = true;
        iflag = false;
        }
    }
    cout << ans + 1 << endl;


}

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

int main(){
  int a,b,h;
  scanf("%d %d %d", &a, &b, &h);

  printf("%d\n", (a + b)*h/2);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>

using namespace std;
typedef long long signed int ll;
constexpr ll inf = INT64_MAX / 4;

map<int, map<int, ll>> path;
int n, q, k;
ll d[100001];

void dfs(int node, int from) {
	for (auto& e : path[node]) {
		if (from == e.first) continue;
		d[e.first] = d[node] + e.second;
		dfs(e.first, node);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i <= n; i++) d[i] = inf;
	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		path[a][b] = c;
		path[b][a] = c;
	}
	cin >> q >> k;
	d[k] = 0;
	dfs(k, 0);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}
}

Measured memory_bytes: 32256
N, K = map(int, input().split())
S = input()
assert len(S) == N


def count_unhappy():
    tcnt = 0
    consecutive = False
    for c in S:
        if c != S[0]:
            consecutive = True
        elif consecutive:
            tcnt += 1
            consecutive = False
    if consecutive:
        tcnt += 1
    unhappy = 2 * tcnt + (0 if S[-1] != S[0] else 1)
    return max(unhappy - 2 * K, 1)


print(N - count_unhappy())


Measured memory_bytes: 3316
input = int(input())

total = 0
i = 357

while i <= input:
  
  target = list(map(int, str(i)))
  
  three = 0
  five = 0
  seven = 0
  error = 0
  
  for j, char in enumerate(target):
    
    char = int(char)
    
    if char != 3 and char != 5 and char != 7:
      keta = len(target) - j
      i += pow(10,keta-1)   
      error += 1

      break
    
    if char == 3:
      three += 1
    elif char == 5:
      five += 1
    elif char == 7:
      seven += 1
      
  if error > 0:
    continue
  
  if three > 0 and five > 0 and seven > 0:
    total += 1
  
  i += 1
    
print(total)

Measured memory_bytes: 3064
#include<stdio.h>

#define MAX 2000000

int H , A[MAX+1];
int temp;

void maxHeapify( int i ){
	int l , r , largest;
	l = 2 * i;
	r = 2 * i + 1;
	
	if( l <= H && A[l] > A[i] ) largest = l;
	else largest = i;
	if( r <= H && A[r] > A[largest] ) largest = r;
	
	if( largest != i ){
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(largest);
	}
}

int main( void ){
	
	scanf( "%d" , &H );
	
	for( int i = 1; i <= H; i++ ){ scanf( "%d" , &A[i] ); }
	
	for( int i = H/2; i >= 1; i-- ){ maxHeapify(i); }
	
	for( int i = 1; i <= H; i++ ){
		printf( " %d" , A[i] );
	}
	printf( "\n" );
	
	return 0;

}


Measured memory_bytes: 3688
<?php
    $num =intval(trim(fgets(STDIN)));

    $a=1;
    $b=1;

    for($j=2;$j<=$num;$j+=2){
        $a+=$b;
        $b+=$a;
    }
    
    if($num%2==0){
        echo $a;
    }else{
        echo $b;
    }
    echo "\n";
?>


Measured memory_bytes: 9196
def main():
    A, B, C = map(int, input().split())
    if (A == 5 and B == 7 and C == 5) or (A == 7 and B == 5 and C == 5) or (A == 5 and B == 5 and C ==7):
        print('YES')
    else:
        print('NO')
main()

Measured memory_bytes: 9088
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] n = new int[3];
    for(int i = 0;i<3;i++){
      n[i] = sc.nextInt();
    }
    if(n[0]==n[1]&&n[1]==n[2]){
      System.out.println("No");
    }else if(n[0]==n[1]||n[1]==n[2]||n[2]==n[0]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int h,w;
	cin >> h >> w;
	char s[h][w];
	rep(i,h) rep(j,w) cin >> s[i][j];
	
	int ans = 0;
	queue<P> que;
	for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			if(s[y][x] != '#'){
				int cnt[h][w] = {},flag[h][w] = {};
				que.push(P(x,y));
				flag[y][x] = 1;
				while(que.size()){
					P p = que.front(); que.pop();
					for(int k = 0; k < 4; k++){
						int nx = p.first+mx4[k];
						int ny = p.second+my4[k];
						if(0 <= nx && nx < w && 0 <= ny && ny < h && flag[ny][nx] == 0 && s[ny][nx] != '#'){
							que.push(P(nx,ny));
							flag[ny][nx] = 1;
							cnt[ny][nx] = cnt[p.second][p.first]+1;
							ans = max(ans,cnt[ny][nx]);
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define endl '\n'
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
int n,m,ans=0;
int main(){
cin>>n>>m;
int k,s;
vector<vector<int> >G(m);

rep(i,m){
    cin>>k;
    rep(j,k){
        cin>>s;
        G[i].push_back(s);
    }
}
vector<int>p;
rep(i,m){
    cin>>s;
    p.push_back(s);
}
for(int bit=0;bit<(1<<n);bit++){
    bool flag=true;
    vector<int>on;
    for(int i=0;i<n;i++){//onになっている電球をリストアップ
        if(bit & (1<<i)){
            on.push_back(i+1);
        }
    }

    rep(i,m){
        int count=0;
        rep(j,G[i].size()){
            count+=(int)binary_search(ALL(on),G[i][j]);
        }
        if(count%2!=p[i]){
            flag=false;
            break;
    }
}
if(flag)ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
def inv(x):
    return pow(x, MOD-2, MOD)

def C(n, r):
    if r>n:
        return 0
    return fact[n]*inv_table[r]*inv_table[n-r]

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
MOD = 10**9+7

fact = [1]

for i in range(1, N+1):
    fact.append(fact[-1]*i%MOD)
    
inv_table = [-1]*(N+1)

for i in range(N+1):
    inv_table[i] = inv(fact[i])

for i in range(N):
    ans += A[i]*(C(i, K-1)-C(N-i-1, K-1))
    ans %= MOD

print(ans)

Measured memory_bytes: 64808
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
d = [0] * (10 ** 5 + 1)
for i in range(N):
  a, b = map(int, input().split())
  d[a] += b
for i in range(10 ** 5 + 1):
  if d[i] >= K:
    print(i)
    exit(0)
  else:
    K -= d[i]

Measured memory_bytes: 41452
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	int n; cin >> n;
	for (int i = 1; ; i++) {
		if (i * 100 > n) break;
		if (n >= i * 100 && n <= i * 105) {
			cout << 1;
			return 0;
		}
	}
	cout << 0;
}

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

ll x = 1e9 + 7;
ll mat[1000][1000];

ll paths(int m, int n, vector<vector<char>>& v){

    ll dp[m][n] ;
    dp[0][0] = 1;
    for(int i = 1; i < n; i++) (v[0][i] == '.') ? dp[0][i] = dp[0][i-1] : dp[0][i] = 0;
    for(int i = 1; i < m; i++) (v[i][0] == '.') ? dp[i][0] = dp[i-1][0] : dp[i][0] = 0;
    
    for(int i = 1; i < m; i++){
        for(int j = 1; j < n; j++){
            if(v[i][j] == '.') dp[i][j] = dp[i-1][j] + dp[i][j-1];
            else dp[i][j] = 0;
            dp[i][j] %= x;
        }
        
    }
    return dp[m-1][n-1] % x;
    
}

int main(){
    int m,n ; cin >> m >> n;
    vector<vector<char>> v(m, vector<char>(n));
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cin >> v[i][j];
        }
    }
    
    
    cout << paths(m,n,v) ;
    return 0;
}

Measured memory_bytes: 12380
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    int A,B,C,X; cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i=0;i<A+1;i++){
        for(int j=0;j<B+1;j++){
            for(int k=0;k<C+1;k++){
                if((i*500 + j*100 + k*50) == X) {ans++;}
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;



int main()
{
    int64_t N;
    std::cin >> N;

    if (N < 10) {
        std::cout << N << std::endl;
        return 0;
    }

    auto S = boost::lexical_cast<std::string>(N);

    int sum = 0;
    int prev = S[0] - '0'; // prev != 0
    for (size_t i = 1; i < S.size(); ++i) {
        int n = S[i] - '0';
        if (prev + n <= prev -1 + 9) {
            // 繰り下げ発生により以下すべて9
            std::cout << sum + prev -1 + (S.size() - i) * 9 << std::endl;
            return 0;
        }
        sum += prev;
        prev = S[i] - '0';
    }
    sum += prev;

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[100100][3];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    auto abc = make_v<ll>(n,3);
    rep(i,n) rep(j,3) cin >> abc[i][j];
    rep(i,n){
      rep(j,3){
        rep(k,3){
          if(j == k) continue;
          chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
        }
      }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

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

using ll = long long;

int main() {
  char alpha;
  cin >> alpha;
  if ('a' <= alpha && alpha <= 'z')
    cout << "a" << endl;
  else if ('A' <= alpha && alpha <= 'Z') {
    cout << "A" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#define N 500005
typedef long long ll;
using namespace std;
int main(){
    char a[N],b[N];
    char x,y;
    cin>>a;
    cin>>b;
   for (int i=0;i<strlen(a);i++)
      for (int j=i+1;j<strlen(a);j++)
        if (a[j]<a[i])
   {
       x=a[i];
       a[i]=a[j];
       a[j]=x;
   }
     for (int i=0;i<strlen(b);i++)
      for (int j=i+1;j<strlen(b);j++)
        if (b[j]>b[i])
   {
       y=b[i];
       b[i]=b[j];
       b[j]=y;
   }
   if (strcmp(a,b)<0)
    cout << "Yes" << endl;
   else
    cout << "No" << endl;
     return 0;
}


Measured memory_bytes: 256
program prob1
    implicit none
    integer :: n
    integer :: a, b
    integer :: i
    character(200005) :: s
    read(*,*) s
    n = len_trim(s)
    do i = 1, n
        if(s(i:i) == 'A') then
            a = i
            exit
        end if

    end do
    do i = 1, n
        if(s(n-i+1:n-i+1) == 'Z') then
            b = n-i+1
            exit
        end if
    end do
    write(*,*) b-a+1


    stop
contains
end program prob1

Measured memory_bytes: 3196