akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();
		boolean f = true;

		int nowx = 0;
		int nowy = 0;
		int nowt = 0;

		for (int i = 0; i < n; i++) {
			int t = ni();
			int x = ni();
			int y = ni();

			int td = t - nowt;
			int xd = Math.abs(x - nowx);
			int yd = Math.abs(y - nowy);

			if (xd + yd > td) {
				f = false;
				break;
			} else if (td % 2 != (xd + yd) % 2) {
				f = false;
				break;
			}

			nowt = t;
			nowx = x;
			nowy = y;

		}

		if (f) {
			out(Y);
		} else {
			out(N);
		}

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if( a=="5" && b=="5" && c=="7" ){
    cout << "YES" << endl;
  }else if( a=="5" && b=="7" && c=="5" ){
    cout << "YES" << endl;
  }else if( a=="7" && b=="5" && c=="5" ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  ll res = 0;
  rep(i, n){
    cin >> v[i];
    if(v[i] >= k) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 640
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n, k=I()
h = l()
h.sort(reverse=True)

print(sum(h[k:]))

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

int main(){
	long long N;
	cin>>N;
	long ans[N+1],function;
	for(int i=1;i<=N;i++)ans[i]=0;
	for(int x=1;x<=100;x++){
		for(int y=1;y<=100;y++){
			for(int z=1;z<=100;z++){
				function = x*x + y*y + z*z + x*y + y*z + z*x ;
				if(function<=N)ans[function]+=1;
			}
		}
	}
	for(int i=1;i<=N;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n,m;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}



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

	cin >> n >> m;
	cout << (n*(n - 1) / 2 + m*(m - 1) / 2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long LL;

const int MAXN = 1e05 + 10;
const int MAXM = 1e05 + 10;

int N, M;
LL que[MAXM]= {0};
int tail = 0;

LL suffix[MAXM]= {0};
int value[MAXM]= {0};
int findpos (int limit, LL delta) {
	if (delta < que[1]) return delta;
	int posi = upper_bound (que + 1, que + limit, delta) - que - 1;
	LL add = delta / que[posi], rest = delta % que[posi];
	suffix[posi] += suffix[limit] * add;
	return findpos (limit, rest);
}
LL subsum[MAXN]= {0};
void solve () {
	value[1] = que[1], suffix[tail] = 1;
	for (int i = tail; i >= 2; i --) {
		int val = findpos (i, que[i]);
		value[i] = val;
	}
	for (int i = tail; i >= 1; i --)
		subsum[value[i]] += suffix[i];
	for (int i = N - 1; i >= 1; i --)
		subsum[i] += subsum[i + 1];
}

template<typename T>
T getnum () {
	T num = T ();
	char ch = getchar ();

	while (! isdigit (ch))
		ch = getchar ();
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return num;
}
inline void write (LL x) {
	if (x >= 10) write (x / 10);
	putchar (x % 10 + '0');
}
inline void println (LL x) {
	write (x), puts ("");
}

int main () {
	N = getnum<int> (), M = getnum<int> ();
	que[++ tail] = N;
	for (int i = 1; i <= M; i ++) {
		LL posi = getnum<LL> ();
		while (tail >= 1 && que[tail] >= posi) tail --;
		que[++ tail] = posi;
	}
	solve ();
	for (int i = 1; i <= N; i ++)
		println (subsum[i]);

	return 0;
}

/*
5 3
6
4
11
*/

/*
10 10
9
13
18
8
10
10
9
19
22
27
*/

/*
10 10
15
22
12
18
16
2
18
18
10
18
*/

/*
10 10
6
26
2
12
12
2
8
10
6
20
*/

/*
10 10
10
24
2
18
18
18
16
18
6
4
*/

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500 + 7;

string s[N];

int main()
{
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	for (int i=0; i<n; i++)
		cin >> s[i];
	
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
			if (i < n-1 && (i == 0 || j % 2 == 0 || s[i][j] == '#'))
				cout << '#';
			else
				cout << '.';
		cout << "\n";
	}
	cout << "\n";
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
			if (i > 0 && (i == n-1 || j % 2 == 1 || s[i][j] == '#'))
				cout << '#';
			else
				cout << '.';
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fastin ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int n,u,v,m,vis[200010];
vector<int> g[200010];
void dfs(int now,int& tot){
	vis[now]=1;
	tot++;
	for(auto to:g[now]){
		if(!vis[to]){
			dfs(to,tot);
		}
	}
}
int main(){
	cin>>n>>m;
	rep(i,1,m){
		scanf("%d%d",&u,&v);
		g[u].pb(v);
		g[v].pb(u);
	}
	int ans=0;
	rep(i,1,n){
		if(!vis[i]){
			int tot=0;
			dfs(i,tot);
			ans=max(ans,tot);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 24780
#include <iostream>
using namespace std;
int main()
{
int n,m,a[100][100],i,j,sw[31],js=0,b;
cin>>n>>m;
for(i=1;i<=n;i++)
{
	cin>>b;
	for(j=1;j<=b;j++)
	{
	cin>>a[i][j];
	sw[a[i][j]]++;
}
}
for(i=1;i<=m;i++)
{
	if(sw[i]==n)
	js++;
}
cout<<js;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long
const int maxn = 1e3 + 3;
const int INF = 1e18;

char grid[maxn][maxn];

bool visited[maxn][maxn];



int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};




int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(grid, '#', sizeof(grid));




	//memset(dist, INF, sizeof(dist));

	int h, w;
	cin >> h >> w;

	pair<int, int>start;
	pair<int, int>end;
	cin >> start.first >> start.second;
	cin >> end.first >> end.second;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> grid[i][j];
		}
	}

	deque<pair<int, int>>q;

	vector<vector<int>>dist(h + 1, vector<int>(w + 1, INF));

	q.push_front(start);

	dist[start.first][start.second] = 0;

	while (!q.empty()) {

		pair<int, int>v = q.front();

		q.pop_front();

		//visited[v.first][v.second] = true;
		bool nxt = false;

		for (int i = 0; i < 4; i++) {

			if (v.first + dx[i] >= 1 && v.second + dy[i] >= 1  && v.first + dx[i] <= h && v.second + dy[i] <= w && grid[v.first + dx[i]][v.second + dy[i]] != '#' ) {

				if (dist[v.first][v.second] < dist[v.first + dx[i]][v.second + dy[i]]) {

					dist[v.first + dx[i]][v.second + dy[i]] = dist[v.first][v.second];

					q.push_front({v.first + dx[i], v.second + dy[i]});





				}



			}

		}





		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {

				if (v.first + i >= 1 && v.second + j >= 1  && v.first + i <= h && v.second + j <= w && grid[v.first + i][v.second + j] != '#' ) {

					if (dist[v.first][v.second] + 1 < dist[v.first + i][v.second + j]) {
						q.push_back({v.first + i, v.second + j});
						dist[v.first + i][v.second + j] = dist[v.first][v.second] + 1;


					}



				}
			}




		}

	}


	//debug() << imie(dist);


	if (dist[end.first][end.second] == INF) {
		cout << -1 << endl;
		return 0;
	}


	cout << dist[end.first][end.second] << endl;









}


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

int main(){
   int a, b, c;
   cin >> a >> b >> c;
   if(a + b + c >= 22){
       cout << "bust" << endl;
       return 0;
   }
   else{
       cout << "win" << endl;
       return 0;
   }
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n, m1, m2, us = 1;
vector<int> g[2][MAXN];
int U[2][MAXN];

bool read() {
    if (!(cin >> n >> m1 >> m2))
        return false;

    return true;
}

void dfs(int i, int v) {
    U[i][v] = us;

    for (auto to : g[i][v])
        if (U[i][to] != us)
            dfs(i, to);
}

void solve() {
    while (m1 --> 0) {
        int u, v;
        cin >> u >> v;
        g[0][u].pb(v);
        g[0][v].pb(u);
    }

    for (int v = 1; v <= n; ++v, ++us)
        if (!U[0][v])
            dfs(0, v);

    while (m2 --> 0) {
        int u, v;
        cin >> u >> v;
        g[1][u].pb(v);
        g[1][v].pb(u);
    }

    us = 1;

    for (int v = 1; v <= n; ++v, ++us)
        if (!U[1][v])
            dfs(1, v);

    map< pair<int, int>, int> M;

    for (int v = 1; v <= n; ++v)
        ++M[mp(U[0][v], U[1][v])];

    for (int v = 1; v <= n; ++v)
        cout << M[mp(U[0][v], U[1][v])] << ' ';

    cout << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 70400
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = map(int, input().split())
# 

N = int(input())
S = input()

pre = "1"
ans = 0
for c in S:
    if c != pre:
        ans += 1
        pre = c
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<int> q(Q), F(Q);
    vector<char> C(Q);
    int cnt = 0;
    rep(i, Q) {
        int a;
        cin >> a;
        if(a == 1) {
            q[i] = a;
        } else {
            q[i] = a;
            int f;
            char c;
            cin >> f >> c;
            F[i] = f;
            C[i] = c;
            cnt++;
        }
    }
    vector<char> str(S.size() + cnt, '#');
    int rev = 0;
    int l = 0, r = str.size() - 1;
    for(int i = Q - 1; i >= 0; i--) {
        if(q[i] == 1) {
            rev = 1 - rev;
        } else {
            if(F[i] == 1) {
                if(rev) {
                    str[r] = C[i];
                    r--;
                } else {
                    str[l] = C[i];
                    l++;
                }
            } else {
                if(rev) {
                    str[l] = C[i];
                    l++;
                } else {
                    str[r] = C[i];
                    r--;
                }
            }
        }
    }
    int now = (rev ? S.size() - 1 : 0);
    rep(i, str.size()) {
        if(str[i] == '#') {
            str[i] = S[now];
            if(rev)
                now--;
            else
                now++;
        }
    }
    for(int i = 0; i < str.size(); i++) {
        cout << str[i];
    }
    cout << endl;
    // if(rev) {
    //     for(int i = str.size() - 1; i >= 0; i--) {
    //         cout << str[i];
    //     }
    //     cout << endl;
    // } else {

    // }
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll ans=1;
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(ans*a.at(i)==1000000000000000000)
      ans=ans*a.at(i);
    else if(log10(ans)+log10(a.at(i))>=18){
      cout << -1 << endl;
      return 0;
    }
    else
      ans=ans*a.at(i);
  }
    cout << ans << endl;
}




Measured memory_bytes: 4000
// https://atcoder.jp/contests/abc088/tasks/abc088_a
"use strict"
function Main(input) {
  const params = input.split('\n').map(Number);
  const n = params[0];
  const a = params[1];
  const fraction = n % 500;

  if (fraction <= a) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    
    int n;

    vector<long long int> v, highest;

    cin >> n;

    long long int maxVal = 0, ans = 0;

    for (int i = 0; i < n; i++)
    {
        v.push_back(0);
        cin >> v[i];

        if (v[i] > maxVal){
            highest.push_back(v[i]);
            maxVal = v[i];
        }

        else
        {
            highest.push_back(maxVal);
        }

        if (highest[i] > v[i]){
            ans += highest[i]-v[i];
        }
    }

    cout << ans << endl;
    

    

    return 0;
}

Measured memory_bytes: 6552
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    n = im.inputSingle()
    w = im.inputMultiple(aslist=True)
    # Logic ############################################################################################################
    minimum = 9999999999
    for i in range(n - 1):
        sub = abs(sum(w[i + 1:n]) - sum(w[0:i + 1]))
        if sub < minimum:
            minimum = sub
    # Output ###########################################################################################################
    print(minimum)
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 22796
#include<stdio.h>

int main(void)
{
	int a[9],b[9],c[9],d[19];
	double at[9],bt[9],ct[9],dt[19];
	int i,j,tempint;
	double tempdb;
	
	for(i=0;i<8;i++) scanf("%d %lf",&a[i],&at[i]);
	for(i=0;i<8;i++) scanf("%d %lf",&b[i],&bt[i]);
	for(i=0;i<8;i++) scanf("%d %lf",&c[i],&ct[i]);
	for(i=0;i<8;i++)
	{
		for(j=i+1;j<8;j++)
		{
			if(at[i]>at[j])
			{
				tempdb = at[i];
				at[i] = at[j];
				at[j] = tempdb;
				tempint = a[i];
				a[i] = a[j];
				a[j] = tempint;
			}
			if(bt[i]>bt[j])
			{
				tempdb = bt[i];
				bt[i] = bt[j];
				bt[j] = tempdb;
				tempint = b[i];
				b[i] = b[j];
				b[j] = tempint;
			}
			if(ct[i]>ct[j])
			{
				tempdb = ct[i];
				ct[i] = ct[j];
				ct[j] = tempdb;
				tempint = c[i];
				c[i] = c[j];
				c[j] = tempint;
			}
		}
	}
	for(i=0;i<18;i++)
	{
		if(i<6)
		{
			d[i] = a[i+2];
			dt[i] = at[i+2];
		}
		else if(i<12)
		{
			d[i] = b[i-4];
			dt[i] = bt[i-4];
		}
		else
		{
			d[i] = c[i-10];
			dt[i] = ct[i-10];
		}
	}
	for(i=0;i<18;i++)
	{
		for(j=i;j<18;j++)
		{
			if(dt[i]>dt[j])
			{
				tempdb = dt[i];
				dt[i] = dt[j];
				dt[j] = tempdb;
				tempint = d[i];
				d[i] = d[j];
				d[j] = tempint;
			}
		}
	}
	for(i=0;i<2;i++) printf("%d %.2f\n",a[i],at[i]);
	for(i=0;i<2;i++) printf("%d %.2f\n",b[i],bt[i]);
	for(i=0;i<2;i++) printf("%d %.2f\n",c[i],ct[i]);
	for(i=0;i<2;i++) printf("%d %.2f\n",d[i],dt[i]);
	return 0;
}

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

int main()
{
    long long N, A, B;
    string S;
    long long pass = 0;
    long long for_pass = 0;
    cin >> N >> A >> B;
    cin >> S;

    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a')
        {
            if (pass < A + B)
            {
                puts("Yes");
                pass++;
            }
            else
                puts("No");
        }
        else if (S[i] == 'b')
        {
            if (pass < A + B && for_pass < B)
            {
                puts("Yes");
                for_pass++;
                pass++;
            }
            else
                puts("No");
        }
        else
        {
            puts("No");
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a = 0;
    cin >> a;
    int b = 0;
    cin >> b;
    int ans = 0;
    int x = b-a;
    int i = 0;
    for(i=1;i<x;i++){
        ans += i;
    }
    cout << ans-a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,ans=1e9,num=0,suma=0,sumb=0,sumc=0;
    cin>>n>>a>>b>>c;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int r=1<<(n*2);
    for(int i=0;i<r;i++){
        int v;
        int w=i;
        for(int j=0;j<n;j++){
            v=w%4;
            w/=4;
            if(v==0){
                if(suma){
                    num+=10;
                }
                suma+=l[j];
            }
            else if(v==1){
                if(sumb){
                    num+=10;
                }
                sumb+=l[j];         
            }
            else if(v==2){
                if(sumc){
                    num+=10;
                }
                sumc+=l[j];
            }
        }
        num+=(abs(a-suma)+abs(b-sumb)+abs(c-sumc));
        if(suma&&sumb&&sumc){
            ans=min(ans,num);
        }
        num=suma=sumb=sumc=0;
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,p
    integer(int64), allocatable:: a(:)
    integer(int64):: cg,ck,i

    read*, n,p
    allocate(a(n))
    read*, a(:)

    cg=0;ck=0

    do i=1,n
        if (mod(a(i),2) == 0) then
            cg=cg+1
        else
            ck=ck+1
        end if
    end do

    if (p==1) then
        print'(i0)', 2**n - (2**(cg+max(0,ck-1)))
    else
        print'(i0)', (2**(cg+max(0,ck-1)))
    end if
end program name

Measured memory_bytes: 512
def is_unique2(seq):#後のwhile文でのループ脱出のため
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
while True:
    iCount = 0#問のiの部分の値です
    n = input().split()
    if int(n[1]) == 0:#入力の終わりを受けとった時breakする
        break
    a0 = n.pop(0)#a0は問のa0の値を受け取ってます
    L = int(n[0])#Lは問のLの値を受け取ってます
    numStr = list(a0)#a0を一文字ずつ分けてnumStrのリストに入れてます
    while len(numStr) < L:#桁数が足りないとき、一番大きな位に０を入れてます
        numStr.insert(0, "0")
    numInt = [int(numStr[l]) for l in range(L)]#strからintへ型を変えてnumStrをnumIntに入れてます
    A0 = "".join([str(k) for k in numInt])#numIntのリストの一文字ずつの数字を全部繋げてstr型としてA0に入れます(数値的にはa0と同値です)
    count = []#a0,a1,a2,a3...ai(i < 20)の値を入れるcountリストを作ります
    count.append(A0)#そのcountリストの中にまずA0を入れます
    answer = "False"
    while answer:#answerがTrueを受け取ったときこのループを抜けます
        numInt.sort()#numIntのリストの中の数字が昇順に並び替えられます
        Min = "".join([str(j) for j in numInt])#numIntのリストの一文字ずつの数字を全部繋げてstr型としてMinに入れます(数値的には並び替えてできる最小の整数)
        numInt.reverse()#numIntのリストの中の数字が降順に並び替えられます
        Max = "".join([str(i) for i in numInt])#numIntのリストの一文字ずつの数字を全部繋げてstr型としてMaxに入れます(数値的には並び替えてできる最大の整数)
        ax = str(int(Max) - int(Min))#MaxからMinを引いてAx(x=1~20)の値をstr型でaxに入れます
        numStr = list(ax)#axを一文字ずつ分けてnumStrのリストに入れてます(numStrではなく別の関数でも良いが、解りやすい為numStrに入れてます)
        while len(numStr) < L:#桁数が足りないとき、一番大きな位に０を入れてます
            numStr.insert(0, "0")
        numInt = [int(numStr[g]) for g in range(L)]#strからintへ型を変えてnumStrをnumIntに入れてます(whileのループ処理のためnumIntに入れてます)
        Ax = "".join([str(h) for h in numInt])#numIntのリストの一文字ずつの数字を全部繋げてstr型としてAx(x=1~20)に入れます(数値的にはax(x=1~20)と同値です)
        count.append(str(Ax))#a0,a1,a2...aiの値を入れるcountリストの中にAxを入れます
        answer = is_unique2(count)#countリスト内に同じ値が二つあるとき、answerはTrueを受け取り、while文のループから抜け出します
        iCount += 1#今Ax番目の計算を行ったことを示し、answerがTrueを受け取った際は、それがAi番目となる
    print(count.index(count[-1]) ,end=" ")#Ajのjの値を出力(スペース開けて改行しない)
    print(int(count[-1]) ,end=" ")#Aiの値を出力(スペース開けて改行しない)
    print(str(iCount - count.index(count[-1])))#Aiのi-Ajのjの値を出力


Measured memory_bytes: 5624
import bisect
n = int(input())
x = list(map(int, input().split()))

cp = sorted(x, reverse=False)
for i in range(n):
    s = bisect.bisect_left(cp, x[i])
    if s + 1 <= n // 2:
        print(cp[n // 2])
    else:
        print(cp[(n // 2) - 1])


Measured memory_bytes: 25628
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define de(x) cout << #x << " = " << x << ", "
#define dl(x) cout << #x << " = " << x << endl
#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 setI freopen("input.txt", "r", stdin);
#define setIO freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 2e5 + 5;

int main()
{
	#ifdef LOCAL
//		setI;
	#endif
//	ios::sync_with_stdio(false);
	int a[5];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	sort(a, a + 3);
	if (a[0] == a[1])  printf("%d\n", a[2]);
	else  printf("%d\n", a[0]);

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
using namespace std;
int  v[102][101], n;
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j > 1) cout << " ";
			cout << v[i][j];
		}
		cout << endl;
	}	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N;
	scanf("%d", &N);
	int *A = new int[N];
	for (int i = 0; i < N; i++) scanf("%d", A + i);
	std::pair<int, int>*p = new std::pair<int, int>[N];
	for (int i = 0; i < N; i++) {
		p[i].first = A[i];
		p[i].second = i + 1;
	}
	std::sort(p, p + N);
	for (int i = 0; i < N; i++)printf("%d ", p[i].second);
	return 0;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int[] tmps = new int[d];
        for (int i = 0; i < d; i++) {
            tmps[i] = sc.nextInt();
        }
        Cloth[] cloths = new Cloth[n];
        for (int i = 0; i < n; i++) {
            cloths[i] = new Cloth(sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        int[][] dp = new int[d + 1][101];
        Arrays.fill(dp[0], Integer.MIN_VALUE);
        dp[0][0] = 0;
        for (int i = 1; i <= d; i++) {
            Arrays.fill(dp[i], Integer.MIN_VALUE);
            for (int j = 0; j < n; j++) {
                if (cloths[j].left > tmps[i - 1] || cloths[j].right < tmps[i - 1]) {
                    continue;
                }
                if (i == 1) {
                    dp[i][cloths[j].value] = 0;
                    continue;
                }
                for (int k = 0; k <= 100; k++) {
                    dp[i][cloths[j].value] = Math.max(dp[i][cloths[j].value], dp[i - 1][k] + Math.abs(k - cloths[j].value));
                }
            }
        }
        int max = Integer.MIN_VALUE;
        for (int i = 0; i <= 100; i++) {
            max = Math.max(max, dp[d][i]);
        }
       System.out.println(max);
    }
    
    static class Cloth {
        int left;
        int right;
        int value;
        
        public Cloth(int left, int right, int value) {
            this.left = left;
            this.right = right ;
            this.value = value;
        }
    }
}



Measured memory_bytes: 30220
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else cout<<1000-(n%1000)<<endl;
    return 0;
}



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

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Rainy"){
        cout<<"Sunny"<<endl;
    }
    else{
        cout<<"Rainy"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int H,A; cin >> H >> A;
    cout << (H+A-1)/A << endl;
    return 0;
}


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	cout<<((n-2*m)<=0?0:(n-2*m));
    return 0;
}
//.........

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next();
        int count = 0;

        while(true){
            String T = scan.next();

            if(T.equals("END_OF_TEXT")){
                break;
            }

            String[] str = T.split(" ");
            for(int i=0; i<str.length; i++){
                if(str[i].equalsIgnoreCase(W)){
                    count++;
                }
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 26196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    int ans = 0;
    ll n, t;
    ll sum_a = 0, sum_b = 0;

    vector<ll> a, b;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> t;
        sum_a += t;
        a.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        cin >> t;
        sum_b += t;
        b.push_back(t);
    }

    if (sum_a < sum_b) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        if ( a[i] < b[i] ) {
            ans++;
        }
    }
    if ( !ans ) {
        cout << ans << endl;
        return 0;
    }

    vector<ll> diff;
    ll sum_diff = 0;
    for (int i = 0; i < n; i++) {
        if ( a[i] <= b[i] ) {
            sum_diff += b[i] - a[i]; 
            continue;
        }
        diff.push_back(a[i] - b[i]);
    }

    sort(diff.begin(), diff.end(), greater<ll>());


    for (int i = 0; i < diff.size(); i++) {
        sum_diff -= diff[i];
        ans++;
        if (sum_diff <= 0) {
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    map<int, ll> coupr;
    int n, k;
    cin >> n >> k;
    int sumpr = 0;
    ll ans = 0;
    coupr[0] = 1;
    vector<int> prefs(1, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        --a;
        sumpr += a;
        sumpr %= k;
        prefs.push_back(sumpr);
        if (i - k + 1 >= 0) {
            //cout << i - k + 1 << " ";
            --coupr[prefs[i - k + 1]];
        }
        if (coupr.count(sumpr) > 0) {
            ans += coupr[sumpr];
            ++coupr[sumpr];
        } else {
            coupr[sumpr] = 1;
        }
        //cout << sumpr << " " << ans << '\n';
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 13556
#include <iostream>

using namespace std;

int main()
{
    int sum=0;
    int x;
    cin>>x;
    
    if(x%2==0)
    {
        for(int i=1;i<=x;i++)
    {
        if(i%2==1)
        {;
        sum =sum+i;}
        
        
            
            
        
        
    } 
    
    
    }
    
    
    else if(x%2==1)
    {
        for(int i=1;i<=x;i++)
    {
        if(i%2==0)
        {
        sum =sum+i;}
        
        
            
            
        
        
    } 
        
    }
   
    cout<<sum;

    return 0;
}

Measured memory_bytes: 256
n,k = list(map(int, input().split()))
lst = list(map(int, input().split()))

count = {}
for i in lst:
    if i in count.keys():
        count[i]+=1
    else:
        count[i]=1
count_sorted = sorted(count.items(), key=lambda x:x[1])
# print(count_sorted)

ans = 0
for i in range(len(count_sorted)-k):
    ans += count_sorted[i][1]
print(ans)


Measured memory_bytes: 39068
nm = list(map(int,input().split()))
a = list(map(int,input().split()))

soutouhyousuu = sum(a)
l = []
for i in range(len(a)):
    if a[i] >= soutouhyousuu / (4 * nm[1]):
        l.append(a[i])

if len(l) >= nm[1]:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3060
from sys import stdin
N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
#N, A, B = map(int, input().split())
n_list = [0]
#digit3_max = min(int(N / 100), 9)
digit_N = len(str(N))

def setDigit(N_max, sum_min, sum_max, digit):
    n_max = int(N_max / (10 ** (digit - 1)))
    for i in range(min(n_max, sum_max, 9) + 1):
        if digit == 1 and i >= sum_min:
            n_list.append(N - N_max + i)
            #print(N_max, i)
        elif digit == 1 and i < sum_min: continue
        else:
            #print(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)
            setDigit(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)


setDigit(N, A, B, digit_N)
'''
for digit3 in range(digit3_max + 1):
    tmp1 = N - digit3 * 100
    digit2_max = min(int(tmp1 / 10), 9)
    for digit2 in range(digit2_max + 1):
        tmp2 = tmp1 - digit2 * 10
        digit1_max = min(tmp2, 9)
        for digit1 in range(digit1_max + 1):
            if (digit1 + digit2 + digit3) >= A and (digit1 + digit2 + digit3) <= B:
                n_list.append(digit3 * 100 + digit2 * 10 + digit1)
'''

print(sum(n_list))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(n - (n / (a + b)) * (a + b), a) << endl;
}

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

int main(){
    //input
    int A,B;
    cin >> A >> B;
    //calculate
    int answer;
    answer = (B+A-3)/(A-1);//ceil(p/q)==floor((p+q-1)/q), p=B-1, q=A-1
    //output
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////


int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    for(int i=0; i<=n; i++) cin >> a[i];
    vector<int> b(n);
    for(int i=0; i<n; i++) cin >> b[i];
    long long cnt = 0;
    for(int i=0; i<n; i++) {
        if(a[i] >= b[i]) {
            a[i] -= b[i];
            cnt += b[i];
            b[i] = 0;
            continue;
        }else{
            b[i] -= a[i];
            cnt += a[i];
            a[i] = 0;
        }

        if(a[i+1] >= b[i]) {
            a[i+1] -= b[i];
            cnt += b[i];
            b[i] = 0;
        }else{
            b[i] -= a[i+1];
            cnt += a[i+1];
            a[i+1] = 0;
        }
    }
    cout << cnt << endl;
    
    return 0;
}

// EOF



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int a,b;
  cin>>a>>b;
  
  if(a>=13){
	cout<<b<<endl;
  }else if(a>=6){
	cout<<b/2<<endl;
  }else{
	cout<<0<<endl;
  }

}
   
  


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

int main () {
    bool d = true;
    int n;
    int a[300000];
    cin>>n;
    map <int, int> c;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        c[a[i]]++;
        if (c[a[i]] == 2) {
            d = false;
        }
    }
    if (d == false) {
        cout<<"NO";
    }
    else cout<<"YES";
    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main(void)
{
    double n, d, x, y;
    int i, count = 0;
    scanf("%lf %lf", &n, &d);

    for (i = 0; i < n; i++)
    {
        scanf("%lf %lf", &x, &y);

        if (x * x + y * y <= d * d)
        {
            count++;
        }
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
int a[4];
char b[4];

bool dfs(int i, int cul){
    if(i == 4) return cul == 7;

    if(dfs(i + 1, cul + a[i])){
        b[i] = '+';
        return true;
    }

    if(dfs(i + 1, cul - a[i])){
        b[i] = '-';
        return true;
    }

    return false;
}

int main(void){
    int num; cin >> num;
    a[3] = num % 10;
    num /= 10;
    a[2] = num % 10;
    num /= 10;
    a[1] = num % 10;
    num /= 10;
    a[0] = num;
    
    bool ans = dfs(0, 0);
    if(ans) cout << a[0] << b[1] << a[1] << b[2] << a[2] << b[3] << a[3] << "=7" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [int(input()) for _ in range(n)]
ssub = sorted([i for i in s if i % 10 != 0], reverse=True)

summary = sum(s)
while summary % 10 == 0 and len(ssub):
    summary -= ssub.pop()

if summary % 10 == 0:
    print(0)
else:
    print(summary)


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

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, AB):
    g = defaultdict(set)

    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    def dfs(s):
        stack = [s]
        done = {s: 0}

        while stack:
            u = stack.pop()
            for v in g[u]:
                if v not in done:
                    done[v] = done[u] + 1
                    stack.append(v)
        l = (-0, 0)
        for k, v in done.items():
            if l[1] < v:
                l = (k, v)
        return l

    v, _ = dfs(1)
    _, l = dfs(v)
    return 'First' if l % 3 != 1 else 'Second'


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N-1)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


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

int main(){

  int N, M;
  cin >> N >> M;
  
  vector<int> score(N);
  for(int i = 0; i < N; i++){
    cin >> score.at(i);
  }
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += score.at(i);
  }
  
  int count = 0;
  
  for(int i = 0; i < N; i++){

    if(score.at(i) >= sum /(4.0 * M)){
      count++;}
  }
  
  if (count >= M){

    cout << "Yes" << endl;}
  
  else { 
    cout << "No"<<endl;
  }
}
  

Measured memory_bytes: 256