akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define MAX 100010
#define int long long
using namespace std;

struct edge {
  int to, cost;
};

typedef pair<int, int> P;

vector<edge> G[MAX];
int d[MAX];
int n;

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + n + 1, 1L << 58);
  d[s] = 0;
  que.push(P(0, s));

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

signed main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge tmp;
    tmp.to = b;
    tmp.cost = c;
    G[a].push_back(tmp);
    tmp.to = a;
    G[b].push_back(tmp);
  }
  int q, k;
  cin >> q >> k;
  dijkstra(k);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 11120
money  = [1000,5000,10000]
n,k = list(map(int,input().split()))

def calc_num(n,y):
    for i in range(n+1):
        for j in range((n+1)-i):
            if money[0]*i + money[1]*j + money[2]*(n-(i+j)) == y and i+j+(n-(i+j)) == n:
                return[n-(i+j),j,i]
    return[-1,-1,-1]

o = calc_num(n,k)
print(o[0],o[1],o[2])

Measured memory_bytes: 3064
#AGC002-A
a,b = map(int,input().split())
if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll n, r;
    cin >> n;
    cin >> r;
    if(n >= 10) {
        cout << r;
    }
    else {
        cout << r + 1000 - 100 * n;
    }
}

Measured memory_bytes: 256
N, D = map(int, input().split())
d = list(map(int, input().split()))
Q = int(input())
q = list(map(lambda x : int(x)-1 , input().split()))

dis = [0 for i in range(N+1)]
dis[0] = D
for i in range(N):
    dis[i+1] = min(dis[i], abs(dis[i] - d[i]))

dp = [0 for i in range(N+1)]
dp[N] = 1
for i in range(N-1, -1, -1):
    if d[i] // 2 >= dp[i+1]:
        dp[i] = dp[i+1]
    else:
        dp[i] = dp[i+1] + d[i]

for qi in range(Q):
    print(["YES", "NO"][dis[q[ qi ]] < dp[q[ qi ] + 1]])

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

const int MAX_N = 101, MAX_M = 1003;
int n, m;
int dist[MAX_N][MAX_N];
int a[MAX_M],b[MAX_M],c[MAX_M];

void init()
{
	memset(dist, 0x3f, sizeof(dist));
	for(int i=0;i<n;++i) dist[i][i]=0;
}

void add_edge(int from, int to, int cost)
{
	dist[from][to]=dist[to][from]=cost;
}

void solve()
{
	for(int k=0;k<n;++k){
		for(int i=0;i<n;++i)for(int j=0;j<n;++j){
			dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		}
	}
	int ans = 0;
	for(int i=0;i<m;++i){
		int from = a[i], to = b[i], cost = c[i];
		bool need=true;
		for(int i=0;i<n;++i)if(i!=from && i!=to){
			if(dist[from][i]+dist[i][to] < cost){
				need=false;
				break;
			}
		}
		if(!need)ans++;
	}
	cout << ans << '\n';
}

int main()
{
	cin >> n >> m;
	init();
	for(int i=0;i<m;++i){
		cin >> a[i] >> b[i] >> c[i];
		add_edge(--a[i],--b[i],c[i]);
	}
	solve();
	return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <algorithm>
using namespace std;
long long cnt;

int n;

void merge(int A[],int left,int mid,int right){
	int L[100005],R[100005];
	int n1=(mid-left);
	int n2=(right-mid);
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=2e9;
	R[n2]=2e9;
	int i,j;
	i=j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
			cnt+=(n1-i);
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(void){
	int a[200005];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	mergeSort(a,0,n);
	printf("%lld\n",cnt);
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << endl;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, pair<vector<T>&, int> v) {
	while (v.second--) {
		T a;
		v.first.push_back(is >> a, a);
	}
	return (is);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

int main() {
	int N;
	int num[105] = {};
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int val = i;
		for (int j = 2; j * j <= val; j++) {
			while (val % j == 0) num[j]++, val /= j;
		}
		if (val > 1) num[val]++;
	}

	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			for (int k = 1; k <= N; k++) {
				if (j != k && k != i) {
					if (num[i] >= 4 && num[j] >= 4 && num[k] >= 2) {
						cnt++;
					}
				}
			}
			if (num[i] >= 14 && num[j] >= 4) cnt++;
			if (num[i] >= 4 && num[j] >= 14) cnt++;
			if (num[i] >= 24 && num[j] >= 2) cnt++;
			if (num[i] >= 2 && num[j] >= 24) cnt++;
		}
		if (num[i] >= 74) cnt++;
	}

	cout << cnt << endl;
    return (0);
}


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

typedef pair<pair<int, int>, int> PP;
const int MAXN = 1e4 + 16;
const int INF = 1e8;

struct edge
{
    int to, d, c;
};

int N, M;
pair<int, int> dist[MAXN];
vector<edge> G[MAXN];

int main() {
    //freopen("2249.txt", "r", stdin);
    while (~scanf("%d%d", &N, &M) && (N | M)) {
        fill(G + 1, G + N + 1, vector<edge>());
        fill(dist + 1, dist + N + 1, make_pair(INF, INF));
        int u, v, d, c;
        for (int i = 0; i < M; i++) {
            scanf("%d%d%d%d", &u, &v, &d, &c);
            edge e1 = {v, d, c}, e2 = {u, d, c};
            G[u].push_back(e1);
            G[v].push_back(e2);
        }


        priority_queue<PP, vector<PP>, greater<PP> > que;
        que.push(make_pair(make_pair(0, 0), 1));
        dist[1] = make_pair(0, 0);
        while (que.size()) {
            PP next = que.top(); que.pop();
            pair<int, int> cost = next.first;
            int to = next.second;
            if (cost > dist[to]) continue;
            for (int i = 0; i < G[to].size(); ++i) {
                edge e = G[to][i];
                pair<int, int> n_cost = make_pair(cost.first + e.d, e.c);
                if (n_cost < dist[e.to]) {
                    dist[e.to] = n_cost;
                    que.push(make_pair(n_cost, e.to));
                }
            }
        }
        int tt = 0;
        for (int i = 1; i <= N; i++) {
            tt += dist[i].second;
        }
        printf("%d\n", tt);
    }
}

Measured memory_bytes: 5200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		string S = GetString();  // S.Length % 2 == 0
		for(int len = S.Length - 2; ; len -= 2)
		{
			int halfLen = len/2;
			string firstStr = S.Substring(0, halfLen);
			string secondStr = S.Substring(halfLen, halfLen);
			if(firstStr.Equals(secondStr))
			{
				Console.WriteLine(len);
				return;
			}
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int m[1001][1001] = {0};
bool in[1000][1000];

int GetVal(int x, int y) {
	if (x < 0 || y < 0) return 0;
	return m[y][x];
}

int main() {
	int n;
	while ( cin >> n, n ) {
		for (int y = 0; y < n; ++y) {
			string str; cin >> str;
			for (int x = 0; x < n; ++x) {
				m[y][x] = in[y][x] = str[x] == '*';
			}
		}
		for (int y = 0; y < n; ++y) {
			for (int x = 0; x < n; ++x) {
				m[y][x+1] += m[y][x];
			}
		}
		for (int y = 0; y < n; ++y) {
			for (int x = 0; x < n; ++x) {
				m[y+1][x] += m[y][x];
			}
		}
//		for (int y = 0; y < n; ++y) {
//			for (int x = 0; x < n; ++x) {
//				cout << m[y][x] << " ";
//			}
//			cout << endl;
//		}
		int l = 0, r = n+1;
		while ( r - l > 1 ) {
			int M = (l + r) / 2;
			bool f = false;
			for (int y = 0; y < n-M+1; ++y) {
				for (int x = 0; x < n-M+1; ++x) {
					int v = x == 0 || y == 0 ? 0 : m[y-1][x-1];
					if ( !in[y][x] && !in[y+M-1][x+M-1]
						&& GetVal(x+M-1, y+M-1) == GetVal(x-1, y+M-1) + GetVal(x+M-1, y-1) - GetVal(x-1, y-1) ) {
						f = true;
						break;
					}
				}
				if (f) break;
			}
			if (f) {
				l = M;
			}
			else {
				r = M;
			}
		}
		cout << l << endl;
	}
}

Measured memory_bytes: 6096
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(string s) {
    long ans = 0; // int だと overflow
    int a = 0; // a の個数
    int p = 0;
    while (p < s.length) {
        if (s[p] == 'A') {
            a++;
            p++;
        }
        else if (s[p] == 'B') {
            if (a > 0 && p + 1 < s.length && s[p + 1] == 'C') {
                ans += a;
                p += 2;
            }
            else {
                a = 0;
                p++;
            }
        }
        else {
            a = 0;
            p++;
        }
    }
    return ans;
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string &str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }


int main() {

	INPUT_INT(a);
	INPUT_STR(s);

	OUTPUT(a >= 3200 ? s : string("red"))

	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=(int)s.size();
    string k;
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=n-i;j++){
            bool flg=true;
            k=s.substr(i,j);
            for(char c:k){
                if(c!='A'&&c!='C'&&c!='G'&&c!='T'){
                    flg=false;
                }
            }
            if(flg){
                ans=max(j,ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int k = cin.Int();

			int ans = 0;
			while (n > 0) {
				++ans;
				n /= k;
			}

			Console.WriteLine(ans);
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n ;
	int A[n+1],B[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin >> A[i];
	}
	
	for (int i = n; 0<i; i--)
	{
		if (A[i] == 0)
		{
			int c = 0;
			for (int j = 2*i; j <= n; j+=i)
			{
				if (B[j]==1)
				{
					c++;
				}
			}
			B[i]=c%2;
		}
		else
		{
			int c = 0;
			for (int j = 2*i; j <= n; j+=i)
			{
				if (B[j]==1)
				{
					c++;
				}
			}
			B[i]= 1 - c%2;
		}
	}
	int s = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (B[i]==1)
		{
			s++;
		}
	}
	cout << s <<endl;
	for (int i = 1; i <= n; ++i)
	{
		if(B[i]==1)
		{
			cout << i <<" ";
		}
	}
	return 0;
}

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

int n, x, y, dist[2020], k[2020];

void bfs(int s)
{
    int ret = 0;
    rep(i, n) dist[i] = -1;
    dist[s] = 0;
    queue<int> que;
    que.push(s);
    while(que.size())
    {
        int t = que.front();
        //cerr << dist[t] << " ";
        que.pop();
        if(t < n && dist[t + 1] == -1)
        {
            que.push(t + 1);
            dist[t + 1] = dist[t] + 1;
        }

        if(t > 0 && dist[t - 1] == -1)
        {
            que.push(t - 1);
            dist[t - 1] = dist[t] + 1;
        }

        if(t == x && dist[y] == -1)
        {
            que.push(y);
            dist[y] = dist[t] + 1;
        }
    }
    for(int i = s; i < n; i++)
    {
      //cerr << dist[i] << " ";
      k[dist[i]]++;
    }

}

int main()
{
    cin >> n >> x >> y;
    x--; y--;
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        bfs(i);
        //cerr << "\n";
    }
    
    for (int i = 1; i < n; i++)
    {
        cout << k[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n=input()
c=0
f1=1;f2=1;f3=1
m=10**9+7
for i in range(n):
  f1*=10;f2*=9;f3*=8
  f1%=m;f2%=m;f3%=m
print (f1-2*f2+f3)%m
  


Measured memory_bytes: 66408
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	xm := make(map[rune]bool)
	for _, r := range s {
		xm[r] = true
	}
	if xm['N'] == xm['S'] && xm['E'] == xm['W'] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	int n,l;
	cin >> n >>l;
	string s[105];
	for(int i=1;i<=n;i++)
		cin >> s[i-1];
	sort(s,s+n);
	for(int i=1;i<=n;i++)
		cout << s[i-1];
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;

	//入力
	cin >> A >> B >> C >> D;

	//面積を求める
	int S1 = A * B;
	int S2 = C * D;

	if (S1 > S2) {
		cout << S1 << endl;
	}
	else if (S1 < S2) {
		cout << S2 << endl;
	}
	else {
		cout << S1 << endl;
	}

}

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

 
int main() {
    int S,W;
    cin >> S >> W;
    if (W>=S) { cout << "unsafe" << endl; }
    else { cout << "safe" << endl; }    
}


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

#[test]
fn test() {
    assert_eq!(power_socket(4, 10), 3);
    assert_eq!(power_socket(8, 9), 2);
    assert_eq!(power_socket(8, 8), 1);
    assert_eq!(power_socket(2, 1), 0);
}

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

fn power_socket(a: u8, b: u8) -> u8 {
    let mut ans = 0;
    let mut cnt = 1;
    while cnt < b {
        ans += 1;
        cnt += a-1;
    }
    ans
}

fn main() {
    let a: u8 = read();
    let b: u8 = read();
    println!("{}", power_socket(a, b));

}



Measured memory_bytes: 4352
# Aizu Problem 00123: Speed Skating Badge Test
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


grades = ["AAA", "AA", "A", "B", "C", "D", "E", "NA"]
limits = [[35.5, 71], [37.5, 77], [40, 83], [43, 89], [50, 105],
          [55, 116], [70, 148], [99999999, 999999999]]

for line in sys.stdin:
    t1, t2 = [float(_) for _ in line.split()]
    for k in range(8):
        if t1 < limits[k][0] and t2 < limits[k][1]:
            print(grades[k])
            break

Measured memory_bytes: 8064
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


count = 0
n = II()
for i in range(1, n+1, 2):
    yaku = 0 
    for j in range(1, n+1):
        if i % j == 0:
            yaku += 1
    if yaku == 8:
        count += 1
print(count)


Measured memory_bytes: 5640
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 2e5 + 10;
int n, k, j;
char s[N];
int a[N];
int main() {
	scanf("%d%d",&n,&k);
	scanf("%s",s + 1);
	rep(i,1,n) if (s[i] == 'A') a[i] = 1; else a[i] = 0;
	int cnt = 0, d = 0;
	rep(i,1,n) {
		if (a[i] ^ d) cnt++, a[i] ^= 1;
		if (cnt == k) {
			bool flag = false; 
			for(int j = i; j != i || !flag; j = j % n + 1, flag = true) 
				if (a[j] ^ d) putchar('A'); else putchar('B');
			return 0;
		}
		cnt++, d ^= 1;
		if (cnt == k) {
			bool flag = false;
			for(int j = i % n + 1; j != i % n + 1 || !flag; j = j % n + 1, flag = true)
				if (a[j] ^ d) putchar('A'); else putchar('B');
			return 0;
		}
	}
	k -= cnt;
	k %= 2 * n;
	int j = 1;
	rep(i,1,k) {
		if (a[j] ^ d) a[j] ^= 1;
		else d ^= 1, j = (j % n + 1);
	}
	int S = j; bool flag = false;
	for(;j != S || !flag; j = j % n + 1, flag = true)
		if (a[j] ^ d) putchar('A'); else putchar('B');
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
    while(true){
        int x , y;
        cin >> x >> y;
        if(x ==0 && y==0) break;
        if(x < y){
            cout << x << " " << y << endl;
            }else{
                cout << y <<" " << x << endl;
            }
    }
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long N = Long.parseLong(s.next());
        long A = Long.parseLong(s.next());
        long B = Long.parseLong(s.next());
        if (A == 0) {
            System.out.println(0);
            return;
        }
        long L = A + B;
        long count = N / L;
        long mo = N % L;
        mo = mo <= A ? mo : A;
        System.out.println(count * A + mo);
    }
}

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

using namespace std;

long long int A, a, n, m, y, s;
string str_1, str_2, str_3;


long long int gcd(int m, int n){
	while (true) {
		if (m%n == 0)return n;
		m %= n;
		if (n%m == 0)return m;
		n %= m;
	}
}



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

	y = gcd(n, m);

	for (int i = 0; i < y; i++) {
		if (str_1[i*n / y] != str_2[i*m / y]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << n * m / y << '\n';
	return 0;
}


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

using namespace std;

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

    string str;
    cin >> str;
    int n = count(str.begin(), str.end(), 'N');
    int s = count(str.begin(), str.end(), 'S');
    int w = count(str.begin(), str.end(), 'W');
    int e = count(str.begin(), str.end(), 'E');
    if ((n > 0) ^ (s > 0)) cout << "No\n";
    else if ((w > 0) ^ (e > 0)) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, h, w;
    cin >> n >> h >> w;

    cout << (n - h + 1) * (n - w + 1) << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

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

  ll ans = 1;

  for(ll i : a){
    if(i==0){
      ans = 0;
      break;
    }
    else if(i>1000000000000000000/ans){
      ans = -1;
      break;
    }
    else ans *= i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3912
N = gets.to_i
divisors = []
(1..(Math.sqrt(N).to_i)).each do |m|
  if N % m == 0
    divisors.push(m)
    divisors.push(N / m) if (m * m != N)
  end
end
ans = 0
divisors.each do |n|
  m = n - 1
  if m > 0 && N / m == N % m
    ans += m
  end
end
puts ans


Measured memory_bytes: 1788
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new B().doIt();
    }
    class B{
        int map[][];
        void doIt(){
            while(true){
                int n = sc.nextInt();
                int m = sc.nextInt();
                int a = sc.nextInt();
                if(n+m+a == 0)break;
                map = new int [1001][n+1];
                for(int i = 0;i < m;i++){
                    int d = sc.nextInt();
                    int c1 = sc.nextInt();
                    int c2 = sc.nextInt();
                    map[d][c1] = c2;
                    map[d][c2] = c1;
                }
                for(int i = 1000;i > 0;i--){
                    if(map[i][a] != 0)a = map[i][a];
                }
                System.out.println(a);
            }
        }
    }
}

Measured memory_bytes: 73944
using System;

public class hello
{
    public static void Main()
    {
        string s;
        for (; (s = Console.ReadLine()) != null;)
        {
            getJOI(s);
            getIOI(s);
        }
    }
    static void getIOI (string s)
    {
        var sL = s.Length;
        var p = 0;
        var count = 0;
        while (p < sL - 2)
        {
            var t = s.IndexOf("IOI", p);
            if (t >= 0) count++;
            else break;
            p = t + 2;
        }
        Console.WriteLine(count);
    }
    static void getJOI (string s)
    {
        var sL = s.Length;
        var p = 0;
        var count = 0;
        while (p < sL -2)
        {
            var t = s.IndexOf("JOI", p);
            if (t >= 0) count++;
            else break;
            p = t + 3;
        }
        Console.WriteLine(count);
    }
}



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

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    fastio(); 

    // int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int K;
    cin >> K;

    string S;
    cin >> S;

    int length = S.length();
    for (int i = 0; i < K and i < length; ++i) cout << S[i];
    
    if (length > K) cout << "...";
    cout << "\n";
} 

Measured memory_bytes: 3628
import java.util.Scanner;
class Main{
public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 
 long X = scan.nextLong();
 double azuke = 100;
 double N = 0;
 double rishi = 0.01;
 int count = 0;
  
 
   for (int i = 0; i < 10000; i++){
       if (azuke < X){
  		  N = azuke * 1.01;
          azuke = Math.floor(N);
    	  count += 1;
    	 }
  	   else{
         System.out.println(count);
         break;
   }
  } 
 }
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
long long V;
int n,m,P,a[N];
int cmp(int x,int y){
	return x>y;
}
int check(int x){
	long long now=V;
	for (int i=P;i<=n;i++)
		if (a[x]+m<a[i])return 0;
		else now-=max(0,a[i]-a[x]);
	return now>=0;
}
int main(){
	scanf("%d%d%lld%d",&n,&m,&V,&P);
	V=n-V;V*=m;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	if (check(n)){
		printf("%d\n",n);
		return 0;
	}
	int l=P,r=n;
	while (l<r){
		int mid=(l+r+1)/2;
		if (check(mid))l=mid;
		else r=mid-1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

template<typename T>//コストの型(いじる必要なし)
struct Kruskal{
  
    struct edge{
        int from,to;
        T cost;
        int used;
        edge(int from,int to,T cost):
        from(from),to(to),cost(cost),used(0){}
        bool operator<(const edge& e) const{
            return cost<e.cost;
        }
    };

    int n;
    vector<int> siz,par;
    vector<edge> es;
    Kruskal(){}
    Kruskal(int n):n(n),siz(n,1),par(n){
        iota(par.begin(),par.end(),0);
    }
    
    //UF
    int root(int x){
        return (x==par[x]?x:(par[x]=root(par[x])));
    }
    bool sameParent(int x,int y){
        return (root(x)==root(y));
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y) return;
        if(siz[x]<siz[y]) swap(x,y);
        siz[x]+=siz[y];par[y]=x;
    }

    void add_edge(int u,int v,T c){
        es.emplace_back(u,v,c);
    }
    T build(){
        sort(es.begin(),es.end());
        T res=0;
        for(auto &e:es){
            if(!sameParent(e.from,e.to)){
                //どんな最小全域木か知るならここをいじる
                //cout<<"--adding edge--"<<endl;
                //cout<<e.from<<" to "<<e.to<<" cost:"<<e.cost<<endl;
                res+=e.cost;
                unite(e.from,e.to);
                e.used=1;
            }
        }
        return res;
    }
};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;cin>>n>>m;
    Kruskal<ll> kr(n);
    rep(i,m){
        int s,t,c;cin>>s>>t>>c;
        kr.add_edge(s,t,c);
    }
    cout<<(kr.build())<<endl;
    return 0;
}



Measured memory_bytes: 6068
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
int mod;
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 2020
int n,ans,F[M*3][M],C[M*3][10];
int main(){
	n=read(),mod=read(),F[0][0]=1,C[0][0]=1;
	for(int i=1;i<=n*3;i++) for(int j=C[i][0]=1;j<10;j++) C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	for(int i=0;i<n*3;i++) for(int j=0;j<=i&&j<=n;j++)
		for(int k=1;k<=3;k++) upd(F[i+k][j+(k>1)],mul(F[i][j],C[i+k-1][k-1]*max(1,k-1)));
	for(int i=0;i<=n;i++) upd(ans,F[n+n+n][i]);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 47104
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int dp[301][301][300];
int cost_list[301][301][300] = {};//左残i段,右残j段,k番目
char obj[300][302] = {};

int saiki(int i,int j,int c,int H){
    if (dp[i][j][c] != -1) return dp[i][j][c];
    
    int l,r;
    if (i + 1 > H) l = INF;
    else l = saiki(i+1,j,c,H) + cost_list[i+1][j][c];
    
    if (j + 1 > H) r = INF;
    else r = saiki(i,j+1,c,H) + cost_list[i][j+1][c];
    
    dp[i][j][c] = min(l,r);

    return dp[i][j][c];
}

void cost_decide(int H, int W){
    REP1(c,W-1){
        REP2(i,1,H){ //i(1 -> H) , j = H
            int si = i - 1;
            int sj = H - 1;
            
            int org_cost = 0;
            
            REP1(t,i){//沈めていない状況の計算
                if (obj[si - t][c] == obj[sj - t][c + 1]) {
                    org_cost++;
                }
            }
            
            REP1(t,i){//沈めていく
                cost_list[i-t][H-t][c] = org_cost;
                if (obj[si - t][c] == obj[sj - t][c + 1]){
                    org_cost--;
                }
            }
        }
        RREP2(j,H-1,1){ //i = H , j(H -> 1)
            int si = H - 1;
            int sj = j - 1;
            
            int org_cost = 0;
            
            REP1(t,j){//沈めていない状況の計算
                if (obj[si - t][c] == obj[sj - t][c + 1]) {
                    org_cost++;
                }
            }
            
            REP1(t,j){//沈めていく
                cost_list[H-t][j-t][c] = org_cost;
                if (obj[si - t][c] == obj[sj - t][c + 1]){
                    org_cost--;
                }
            }
        }
    }
}

void rec(int H, int W){
    cost_decide(H,W);
    
    int sum = 0;
    
    REP1(c,W-1){
        sum += saiki(0,0,c,H);
    }
    cout << sum << endl;
}

int main(){
    INT(H);INT(W);
    REP1(i,H) cin >> obj[i];

    REP1(i,H+1){
        REP1(j,H+1){
            REP1(c,W-1){
                dp[i][j][c] = -1;
            }
        }
    }
    REP1(c,W-1){
        dp[H][H][c] = 0;
    }
    rec(H,W);

    return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

void solve(ll N) {
  mint a = 10;
  a = a.pow(N);
  mint b = 9;
  b = b.pow(N);
  mint c = 8;
  c = c.pow(N);

  cout << a - b - b + c << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    int h;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>h;
        if(h>=k){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc069/tasks/arc080_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int dp[101][101];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector<pii> v(n);
    REP(i, n) {
        int t;
        cin >> t;
        v[i] = {t, i + 1};
    }
    sort(ALLR(v));
    deque<int> g;
    for (auto &x : v) {
        REP(i, x.first) g.push_back(x.second);
    }
    REP(i, h) REP(j, w) {
        dp[i][(i % 2 == 0 ? j : w - j - 1)] = g.front();
        g.pop_front();
    }
    REP(i, h) { REP(j, w) cout << dp[i][j] << (j == w - 1 ? '\n' : ' '); }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	int k, l, a[100000], m = 0;
	std::cin >> k >> l;
	for (int i = 0;i < l;i++) {
		std::cin >> a[i];
		m = max(m, a[i]);
	}
	std::cout << max(0, (m - 1 - (k - m))) << std::endl;
	}

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

#define lli long long int;

int main()
{
  int n;
  bool contain = false;
  scanf("%d", &n);
  while (n > 0)
  {
    if (n % 10 == 7)
      contain = true;
    n /= 10;
  } 
  printf("%s\n", contain ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((2 * g + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using Int = long long;

//未完
int main() {

	Int N, K;
	std::cin >> N >> K;

	std::vector<Int> Ball(N);
	for (Int i = 0; i < N; i++)std::cin >> Ball[i];

	std::vector<Int> num(N+1,0);//バケット法
	for (Int i = 0; i < N; i++) {
		num[Ball[i]]++;
	}

	Int res = 0;
	//最初何種類の数字があるか
	for (Int i = 0; i < N+1; i++) {

		if (num[i])res++;
	}

	std::sort(num.begin(), num.end());

	Int ans = 0;
	Int flag = 0;

	if (res > K) {
		for (Int i = 0; i < N+1; i++) {
			if ((num[i]>0) && (flag < res - K)) {
				ans += num[i];
				flag++;
			}
			if (flag >= res - K)break;
		}
		std::cout << ans << std::endl;
	}
	else std::cout << 0 << std::endl;

}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

ll INF=LLONG_MAX;

vector<ii>adj[20];
bool check(int x, int y, int vis[]){
	if(vis[x]==-1)return 1;
	if(vis[x]==y)return 1;
	return 0;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	int a;
	for(int i=0; i<n; i++){
		cin >> a;
		int x,y;
		for(int j=0; j<a; j++){
			cin >> x >> y;
			x--;
			adj[i].eb(ii(x,y));
		}
	}
	int ans = 0;
	for(int bt=0; bt<(1<<n); bt++){
		int vis[n];
		memset(vis,-1,sizeof(vis));
		bool ok = 1;
		for(int i=0; i<n && ok; i++){
			if(bt&(1<<i)){ // i is kind
				if(check(i,1,vis)){
					vis[i]=1;
				}else{
					ok = 0;
					break;
				}
				for(ii j:adj[i]){
					int x = j.fi;
					int y = j.se;
					if(check(x,y,vis)){
						vis[x]=y;
					}else{
						ok=0;
						break;
					}
				}
			}else{
				if(check(i,0,vis)){
					vis[i]=0;
				}else{
					ok=0;
					break;
				}
			}
		}
		if(ok){
			int sum = 0;
			for(int i=0; i<n; i++)sum+=vis[i];
			ans = max(sum,ans);
		}
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll x,y;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>x>>y;
    if(abs(x-y)>1){
        print("Alice");
    }else{
        print("Brown");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, ans = INF;
int main() {
	cin >> n;
	REPO(i, n - 1) {
		ll now = 0;
		ll a = i, b = n - i;
		string aa = to_string(a), bb = to_string(b);
		REP(j, aa.size()) {
			now += aa[j] - '0';
		}
		REP(j,bb.size()) {
			now += bb[j] - '0';
		}
		ans = min(now, ans);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int x;
cin >> x;
cout << 10 - (x/200) << endl;

return 0;
}

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

int main()
{
    int N,D,X,A[110];

    cin >> N >> D >> X;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int sum = X;

    for(int i=0; i<N; i++){
        for(int j=0; A[i]*j+1 <= D;  j++){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256