akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

struct Edge { int src,dst,weight; };

struct Data {
  int cur,weight;
  bool operator < ( const Data &data ) const {
    if( weight != data.weight ) return weight > data.weight;
    return cur > data.cur;
  }
};

const int IINF = INT_MAX;
const int MAX_V = 100010;
int V,E,mindist[MAX_V];
vector<Edge> G[MAX_V];

void dijkstra(int source){
  for(int i=0;i<V;i++) mindist[i] = IINF;
  mindist[source] = 0;
  priority_queue<Data> Q;
  Q.push((Data){source,0});
  while( !Q.empty() ){
    Data data = Q.top(); Q.pop();
    if( mindist[data.cur] < data.weight ) continue;
    for(int i=0;i<(int)G[data.cur].size();i++){
      int next = G[data.cur][i].dst;
      if( mindist[next] > data.weight + G[data.cur][i].weight ){
	mindist[next] = data.weight + G[data.cur][i].weight;
	Q.push((Data){next,mindist[next]});
      }
    }
  }
}

int main(){
  int source;
  cin >> V >> E >> source;
  for(int i=0;i<E;i++){
    int src,dst,weight;
    cin >> src >> dst >> weight;
    G[src].push_back((Edge){src,dst,weight});
    //G[dst].push_back((Edge){dst,src,weight}); // undirected graph
  }
  dijkstra(source);
  for(int i=0;i<V;i++) {
    if( mindist[i] == IINF ) puts("INF");
    else printf("%d\n",mindist[i]);
  }
  return 0;
}

Measured memory_bytes: 13716
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

namespace for_contests
{
    class Program
    {
        static void Main()
        {
            string f = ReadLine();
            string s = ReadLine();
            if (f[0] == s[2] && f[1] == s[1] && f[2] == s[0])
                WriteLine("YES");
            else
                WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main()
{
    string str;
    cin >> str;
    int sum = 0;
    for (int i = 0; i < str.length(); i++)
    {
        sum += str[i] - '0';
    }
    (sum % 9 == 0) ? cout << "Yes" << endl : cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
long long int A,B,X,y;
long long int fun(long long int a){
	return a*a*a*a*a;
}
int main()
{
	while(cin>>X)
	{

        int cnt=0;
        for(int i=-1000;i<=1000;i++)
        {
            y=fun(i)+X;
            for(int j=-1000;j<=1000;j++)
            {
                if(fun(j)==y)
                {
                    cout<<j<<" "<<i<<endl;
                    cnt=1;
                    break;
                }
            }
            if(cnt==1)
            {
                break;
            }
        }
	}
	return 0;
}


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

long long gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
long long addgcd(int a, int b, int c)
{
    long long result = gcd(a, b);
    result = gcd(result, c);
    return result;
}

int main()
{
    long long n, m, sum;
    sum = 0;
    cin >> n;
    long long a[n - 1];
    long long b[n] = {0};
    rep(i, n - 1)
    {
        cin >> a[i];
    }
    rep(i, n - 1)
    {
        b[a[i]-1]++;
    }
    rep(i, n)
    {
        cout << b[i] << endl;
    }
}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool> > vec2bool;
typedef vector<vector<int> > vec2int;
typedef vector<vector<double> > vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  cin >> n;
  vecint a(n, 0);
  vecint b(n, 0);
  vecint c(n, 0);
  for (auto& e : a) cin >> e;
  for (auto& e : b) cin >> e;
  for (auto& e : c) cin >> e;
  sort(all(a));
  sort(all(b));
  sort(all(c));
  vecint nab(n, 0), nbc(n, 0);
  REP(i, n) { nab[i] = lower_bound(all(a), b[i]) - a.begin(); }
  REP(i, n) { nbc[i] = c.end() - lower_bound(all(c), b[i] + 1); }
  // REP(i, n) { cout << nab[i] << endl; }
  // REP(i, n) { cout << nbc[i] << endl; }
  ll ans = 0;
  REP(i, n) { ans += (ll)nab[i] * (ll)nbc[i]; }
  cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int get(int n)
{
    int lstDigit;
    while(n)
    {
        lstDigit = n % 10;
         n /= 10;
    }
    return lstDigit;
}
int main()
{
    int n, arr[10][10];
    cin >> n;
    map<pair<int,int>, int> mp;
    for(int i = 1; i <= n; i++)
    {
        int firstDigit = get(i);
        mp[{firstDigit, i % 10}] ++;
    }
    long long ans = 0;
    for(int i = 1; i < 10; i++)
        for(int j = 1; j < 10; j++)
            ans += (mp[{i, j}] * mp[{j, i}]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1000005];
int main()
{
	long long sum=1;
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(!a[i])
		{
			cout<<0;
			return 0;
		}
	}
	for(i=0;i<n;i++)
	{
		if(1000000000000000000ll/sum<a[i]){
			cout<<-1;
			return 0;
		}
		sum*=a[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4380
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	lint A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;

	if (abs(A - B) <= (V - W) * T) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}



Measured memory_bytes: 3668
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		$a = $s[0];
		$b = $s[1];
		$c = $s[2];
		$k = $s[3];

		if(0 == $k){
			/* null */
		}elseif(0 == $k % 2){
			$k = 2;
		}else{
			$k = 1;
		}

		for($i = 0; $i < $k; $i++){
			$bufa = $b + $c;
			$bufb = $a + $c;
			$bufc = $a + $b;
			$a = $bufa;
			$b = $bufb;
			$c = $bufc;
		}
		$ans = $a - $b;

		if(pow(10, 18) <= abs($ans)){
			echo "Unfair";
		}else{
			echo $ans;
		}

	}
}
?>


Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef short int sh;

const int inf=0x3f3f3f3f;
const int MAX=2e5+10;
const int mod=1e9+7;

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        if((a==5&&b==5&&c==7)||(a==5&&c==5&&b==7)||(b==5&&c==5&&a==7))
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}


Measured memory_bytes: 3148
#include "bits/stdc++.h"
//#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define fr(i , a , b) for(int  i = a ; i <= b ; i++)
#define all(v) v.begin() , v.end()
#define mod  1000000007
#define N 300005
#define mod1 1000000007
#define mod2 1000000009
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n" 
#define mid  (s+e)/2
#define MAX 10000007
//const int inf = (int)1e18 + 10;;
int dp[100005] , h[100005];
signed main(){
  fast;
  
  //freopen("input.txt" , "r" , stdin);
  //freopen("output.txt" , "w" , stdout);
  

    int n , k;
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)
          cin >> h[i];



    dp[0] = 0;
    for(int i = 1 ; i <n ; i++){
           dp[i] = dp[i-1] + abs(h[i] - h[i-1]);

           for(int j = 2 ; j<=k && (i-j)>=0 ; j++){
               dp[i] = min(dp[i] , dp[i-j] + abs(h[i] - h[i-j]));
           }

           //cout << "dp["<<i<<"] = "<< dp[i] << endl;
    }

    cout << dp[n-1]<<endl;

   

 }

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (ll i = ll(a); i < ll(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    int mod = 2019;
    ll ans = mod;
    if (R - L <= 5 * mod) {
        REP(i, L, R + 1) {
            REP(j, i + 1, R + 1) {
                ans = min(ans, (i * j) % mod);
            }
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

ll n,az,ro;
cin>>n>>az>>ro;
if(az==0){
    cout<<0<<endl;
}else if(az+ro==n){
    cout<<az<<endl;
}else{
    ll sobra = n%(az+ro);
    ll ocup = (n/(az+ro))*az;
    cout<<ocup + min(sobra,az)<<endl;
}
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  V<> a;
  int t = 1;
  for (int i = 0; i < n; ++i) {
    if (i and s[i] == s[i - 1]) {
      ++t;
    } else {
      t = 1;
    }
    if (i == n - 1 or s[i] != s[i + 1]) {
      a.push_back(t);
    }
  }
  lint k; cin >> k;
  if ((int)a.size() == 1) {
    return cout << (n * k) / 2 << '\n', 0;
  }
  if (s[0] != s.back()) {
    lint res = 0;
    for (int e : a) {
      res += e / 2;
    }
    res *= k;
    return cout << res << '\n', 0;
  }
  int m = a.size();
  lint res = 0;
  for (int i = 1; i < m - 1; ++i) {
    res += a[i] / 2;
  }
  res *= k;
  res += a[0] / 2;
  res += (a[0] + a.back()) / 2 * (k - 1);
  res += a.back() / 2;
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll k, a, b;
	cin >> k >> a >> b;
	ll has = 1;
	if (a + 1 < b) {
		ll need = max(0ll, a - has);
		has += min(need, k);
		k -= min(need, k);
		has += k / 2 * (b - a);
		has += k & 1;
	}
	else
		has += k;
	cout << has << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

int main() {
  int r, g;
  scanf("%d %d", &r, &g);

  g += (g-r);
  printf("%d\n", g);
}


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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int A,B,K,res = 0;
    cin >> A >> B >> K;

    for (int i=min(A,B);i>=0;i--){
        if (A%i==0 && B%i==0){
            res += 1;
            if (res == K){
                cout << i;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAXM = 2e5 + 5, BOUND = 1e7, MOD = 1073741824, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, x, y, d[MAXN], diameter;
vi G[MAXN];
void dfs(int u, int f) {
	int mx = 0;
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (v == f)continue;
		dfs(v, u);
		diameter = max(diameter, mx + d[v] + 1);
		mx = max(mx, d[v] + 1);
		d[u] = max(d[v] + 1, d[u]);
	}
}
int main() {
	cin >> n;
	rep(i, 2, n) {
		cin >> x >> y;
		G[x].push_back(y); G[y].push_back(x);
	}
	dfs(1, 0);
	if (diameter % 3 == 1)cout << "Second\n";
	else cout << "First\n";
	return 0;
}

Measured memory_bytes: 27008
# URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
s = input()
t = input()

sl = len(s)
tl = len(t)

def f(p, q):
    cnt = 0
    for i, j in zip(p, q):
        if i != j:
            cnt +=1
    return cnt

res = 10 ** 100
for i in range(sl - tl + 1):
    ss = s[i:i + tl]
    res = min(res, f(ss, t))
print(res)

Measured memory_bytes: 9056
import sys
from collections import Counter

def most_key(d, f=None):
  k = 0
  num = 0
  for key in d:
    if key == f:
      continue
    if d[key] >= num:
      k = key
      num = d[key]
  return k


def main():
  input = sys.stdin.readline
  n = int(input())
  V = [v for v in map(int, input().split())]
  Vo = [V[i] for i in range(1, n, 2)]
  Ve = [V[i] for i in range(0, n, 2)]
  
  odd = Counter(Vo)
  even = Counter(Ve)
  
  odd_num = most_key(odd)
  even_num = most_key(even)
  
  if odd_num == even_num:
    odd_sec = most_key(odd, odd_num)
    even_sec = most_key(even, even_num)
    
    odd_replace = len(Vo) - odd[odd_num]
    odd_replace_sec = len(Vo) - odd[odd_sec]
    even_replace = len(Ve) - even[even_num]
    even_replace_sec = len(Ve) - even[even_sec]
    
    patern1 = odd_replace + even_replace_sec
    patern2 = odd_replace_sec + even_replace
    
    print(min(patern1, patern2))
  
  else:
    odd_replace = len(Vo) - odd[odd_num]
    even_replace = len(Ve) - even[even_num]
    print(odd_replace + even_replace)


if __name__ == '__main__':
  main()

Measured memory_bytes: 19096
#include <cstdio>
int a[7] = {1, 3, 5, 7, 8, 10, 12};
int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	if(x == 2 || y == 2)
		printf("No\n");
	else {
		int f1 = 0, f2 = 0;
		for(int i = 0; i < 7; i++) {
			if(x == a[i])	f1 ++;
			if(y == a[i])	f2 ++;
		}	
		if(f1 == f2)
			printf("Yes\n");
		else 
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

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 sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

//文字列分割
VS split(string str, char del) {
	VS re;
	string sub;
	for (char c : str) {
		if (c == del) {
			re.pb(sub);
			sub.clear();
		}
		else {
			sub += c;
		}
	}
	re.pb(sub);
	return re;
}

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;
		n++;
		VS line(n); rep(i, n)getline(cin, line[i]);
		char k; cin >> k;

		VS a;
		rep(i, n) {
			VS tmp = split(line[i], ' ');
			a.insert(a.end(), all(tmp));
		}

		vector<pair<int, string>> ans;
		rep(i, sz(a)) {
			if (a[i][0] == k) {

				bool flag = false;
				rep(j, sz(ans)) {
					if (ans[j].second == a[i])ans[j].first++, flag = true;
				}
				if (!flag)ans.pb(mp(1, a[i]));

			}
		}
		rep(i, sz(ans))ans[i].first = 100 - ans[i].first;
		SORT(ans);

		if (ans.empty())puts("NA");
		else {
			rep(i, min(5, sz(ans))) {
				cout << ans[i].second;
				printf(i == min(5, sz(ans)) - 1 ? "\n" : " ");
			}
		}
	}
}


Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[1000],ans=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
       cin>>a[i];
        ans+=a[i];
    }
    cin>>m;
    while(m>0){
    	m--;
        int p,x;
        cin>>p>>x;
        cout<<ans-a[p]+x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


class SegmentTree:
    
    def __init__(self, array):
        self.n = len(array)
        self.array = [0 for _ in array]+array
        for i in range(self.n-1, 0, -1):
            self.array[i] = self.array[i<<1]|self.array[i<<1|1]

    def set(self, i, v):
        p = self.n+i
        self.array[p] = v
        while p > 1:
            p >>= 1
            self.array[p] = self.array[p<<1]|self.array[p<<1|1]

    def count(self, l, r):
        l += self.n
        r += self.n
        answer = 0
        while l < r:
            if l&1:
                answer |= self.array[l]
                l += 1
            if r&1:
                r -= 1
                answer |= self.array[r]
            l >>= 1
            r >>= 1
        return answer


def bit_count(a):
    answer = 0
    while a:
        answer += a&1
        a >>= 1
    return answer


def solve():
    ALPHABETS = 'abcdefghijklmnopqrstuvwxyz'
    N = read_int()
    S = input()
    Q = read_int()
    segment_tree = SegmentTree([1<<(ALPHABETS.index(c)) for c in S])
    for _ in range(Q):
        cmd = input().strip().split(' ')
        if cmd[0] == '1':
            n = 1<<(ALPHABETS.index(cmd[2]))
            segment_tree.set(int(cmd[1])-1, n)
        else:
            l, r = int(cmd[1])-1, int(cmd[2])
            print(bit_count(segment_tree.count(l, r)))


if __name__ == '__main__':
    solve()


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

int main()
{
  int a, b;
  cin >> a >> b;
  int ans = a - 2* b;
  if(ans > 0){
      cout << ans << endl;
  }else {
      cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int a=0,c=0,ac=0;
	char S[11];
	cin>>S;
	for(int i=0;i<strlen(S);i++)
	{
		if(i==0&&S[i]=='A')a++;
		if(i>1&&i<strlen(S)-1&&S[i]=='C')c++;
		if(S[i]-'Z'<=0)ac++;
		//cout<<S[i]-'A'<<endl;
	}
	if(a==1&&c==1&&ac==2)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
	/*cout<<a<<endl;
	cout<<c<<endl;
	cout<<ac<<endl;*/
	}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n,m;
    cin>>n>>m;
    bool vis[3]={};
    string res(n,'0');
    loop(m,i,0){
        int s,c;
        cin>>s>>c;
        if(vis[s-1]&&c!=res[s-1]-'0'){
            cout<<-1<<endl;
            return;
        }
        vis[s-1]=true;
        res[s-1]=char(c+'0');
    }
    if(n==1);
    else if(res.front()=='0'&&vis[0])
        res="-1";
    else if(!vis[0])
        res.front()='1';
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int x;
	std::cin >> x;
	if (x < 1200) {
		std::cout << "ABC" << std::endl;
	}
	else {
		std::cout << "ARC" << std::endl;
	}
		
}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

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

int main()
{
	int count=0;
	string str;
	cin >> str;

	for(int i=0; i<str.length(); i++ )
	{
		if(str[i]=='1')
		{
			count = count + 1;
		}
	}

	cout << count << endl;
	return 0;
}

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

int main()
{
  int N, T, A, H[1010];
  cin >> N >> T >> A;
  for (int i = 1; i <= N; i++)
    cin >> H[i];
  
  double dmin = 1e9, ans = 0;
  for (int i = 1; i <= N; i++)
  {
    double t = T - H[i] * 0.006;
  	double d = abs(A - t);
    if (d < dmin)
    {
      dmin = d;
      ans = i;
    }
  }
  cout << ans << endl;
}

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

int gcd(int a, int b, int c)
{
  int i=c,max;
  
  if(a>=b && a>=c)
  {
    i=a;    
  }
  
  if(b>=a,b>=c)
  {
    i=b;
  }
  
  while(i>0)
  {
    if(a%i==0 && b%i==0 && c%i==0)
    {
      max=i;
      break;
    }
    i--;
  }
  
  return max;
}


int main(void)
{
  int K,i,r,t;
  int sum1=0,sum2=0,sum3=0,sum4=0;
  long sum;
  
  scanf("%d",&K);

  for(i=1;i<=K;i++)
  {
    for(r=1;r<i;r++)
    {
      for(t=1;t<r;t++)
      {
        sum1+=gcd(i,r,t);
      }
    }
  }
  
  for(i=1;i<=K;i++)
  {
    for(r=1;r<i;r++)
    {
      sum2+=gcd(i,r,r);
    }
  }
  
  for(i=1;i<=K;i++)
  {
    for(r=1;r<i;r++)
    {
      sum3+=gcd(i,i,r);
    }
  }  
  
  for(i=0;i<=K;i++)
  {
   sum4+=i;    
  }
  
  sum=sum1*6+sum2*3+sum3*3+sum4;
 // printf("%d %d %d %d %d",sum1,sum2,sum3,sum4,sum);
  printf("%ld",sum);
  return 0;
}


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

#define reps(i,f,n) for(int i = f; i < n; ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

int main(void){
    string a;
    int n;
    int x = 0;
    int y = 0;


    cin >> n;
    cin >> a;

    rep(i, n){
        if(a[i] == 'R'){
            x++;
        }else{
            y++;
        }
    }


    if(x > y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import copy


def count_order(l, r, i):
    global a
    if r == []:
        a.append(i)

    if not l:
        return 1

    sum = 0
    for x in l:
        ll = copy.copy(l)
        rr = copy.copy(r)
        if r is not None and r[0] == x:
            rr.pop(0)
        else:
            rr = None
        ll.remove(x)
        sum += count_order(ll, rr, sum + i)

    return sum


n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
a = []

count_order(list(range(1, n + 1)), p, 0)
count_order(list(range(1, n + 1)), q, 0)
print(abs(a[0] - a[1]))

Measured memory_bytes: 3444
#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 a,b;
  cin >> a >> b;
  
  cout << max(a-b, max(a+b, a*b)) << endl;
  
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/arc080/tasks/arc080_a

n = int(input())
nums = [int(i) for i in input().split()]

fours = 0
twos = 0
odd = 0
for num in nums:
    if num % 4 == 0:
        fours += 1
    elif num % 2 == 0:
        twos += 1
    else:
        odd += 1

if twos == 0 and fours + 1 >= odd:
    print('Yes')
elif fours >= odd:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62576
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N,A,B;
	cin >> N>>A>>B;
	cout << min(B, A * N) << endl;

	
}



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

int main() {
  int n, k; std::cin >> n >> k;
  std::vector<int> p(n);
  for (int i = 0; i < n; ++i) std::cin >> p[i];
  
  std::sort(p.begin(), p.end());
  
  int sum = 0;
  for (int i = 0; i < k; ++i) sum += p[i];
  
  std::cout << sum << std::endl;
  return 0;
}

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

int n, a[5][110], f[5][110];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= 2; ++i){
        for(int j = 1; j <= n; ++j){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i = 1; i <= 2; ++i){
        for(int j = 1; j <= n; ++j){
            f[i][j] = max(f[i - 1][j], f[i][j - 1]) + a[i][j];
        }
    }
    printf("%d\n", f[2][n]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	int x;
	string s;
	cin>>x;
	cin>>s;

	if(x>=3200)
	cout<<s;
	else
	cout<<"red";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
int n, m;
char a[10][10];
int dem = 0;
int main()
{
    //freopen("vao.inp","r",stdin);
    int n, m;
    cin >> n >> m;
    for ( int i = 1; i <= n; i++)
        for ( int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if ( a[i][j] == '#' ) dem++;
        }
    //cout << dem << '\n';
    int x, y;
    x = 1; y = 1;
    for ( int i = 1; i <= n; i++) {
        if ( x > m ) break;
        while ( a[i][x] == '#' ) {
            dem--;
            x++;
        }
        x--;
    }
    if ( dem ) cout << "Impossible";
        else cout << "Possible";
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    vector<pii> work;
    set<int> days;
    for(int i = 0; i <= M; ++i) days.insert(i);
    for(int i = 0; i < N; ++i){
        int A, B;
        cin >> A >> B;
        work.push_back({B, M - A});
    }
    sort(work.rbegin(), work.rend());
    int ans = 0;
    for(auto u : work){
        int val = u.first;
        int ub = u.second;
        auto it = days.upper_bound(ub);
        if(it !=days.begin() && !days.empty()){
            --it;
            days.erase(it);
            ans += val;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6140
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long 
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		vector<int> geko;
		REP(i, n) {
			string s;
			cin >> s;
			geko.push_back(s[0] - 'A');
		}
		int cnt[30] = {};
		int ok = 0;
		for (int i = 0; i < geko.size(); ++i) {
			cnt[geko[i]]++;
			int now_max = 0;
			int now_itr = 0;
			int now_next_max = 0;
			for (int i = 0; i < 27; ++i) {
				if (cnt[i] > now_max) {
					now_next_max = now_max;
					now_max = cnt[i];
					now_itr = i;
				}
				else if (cnt[i] > now_next_max) {
					now_next_max = cnt[i];
				}
			}
			if (now_max > now_next_max + (geko.size() - i - 1LL)) {
				ok = 1;
				cout << (char)(now_itr + 'A') << " " << i + 1 << endl;
				break;
			}
		}
		if (ok == 0) {
			cout << "TIE" << endl;
		}
	}
}



Measured memory_bytes: 3100
#include <iostream>

int main(int argc, const char** argv)
{
	int bills = 0, cost = 0;
  	std::cin >> cost;
  
  	for ( bills = 1;  ; bills++ )
    {
    	if ( 1000 * bills >= cost ) break;
    }

  	std::cout << (1000 * bills) - cost << std::endl;
  	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>


int main(){
   int n;
   scanf("%d",&n);
   for(int i = 1;i <= n;i++){
       if(i % 3 == 0){
           printf(" %d",i);
       } else if(i % 10 == 3){
           printf(" %d",i);
       }
       else{
           int x = i;
           while(x!=0){
               x /= 10;
               if(x % 10 == 3){
                   printf(" %d",i);
                   break;
               }
           }
       }
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 2744
def nCr(n,r,fac,finv):
    mod = (10**9)+7
    ans = fac[n] * (finv[r] * finv[n-r] % mod) % mod
    return ans

n,k = map(int,input().split())
als = list(map(int,input().split()))
als.sort()
ans = 0
mod = (10**9)+7
fac = [1,1]+[0]*n
finv = [1,1]+[0]*n
inv = [1,1]+[0]*n
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

for i in range(n):
    if i >= k-1:
        ans += als[i] * nCr(i,k-1,fac,finv) % mod
        ans = ans % mod
    if i <= n-k:
        ans -= als[i] * nCr(n-i-1,k-1,fac,finv) % mod
        ans = ans % mod

print(ans)
        

Measured memory_bytes: 19920
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

const int mod = 1000000007;

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

//const int dx[8] = {};
//const int dy[8] = {};

using namespace std;

template <class myType>
void p(vector<myType>& v)
{
    for(myType i: v) cout<<i<<" ";
    cout<<endl;
}

template <class myType>
void pv(vector<vector<myType>>& vv)
{
    for(auto& v: vv)
        p(v);
}

template <class myType>
void GetInputV(vector<myType>& v, int n)
{
    v.resize(n);
    for(myType& i: v) cin>>i;
}

template <class myType>
void GetInputVV(vector<vector<myType>>& vv, int m, int n)
{
    vv.resize(m);
    for(vector<myType>& v: vv) GetInputV(v, n);
}

int main()
{

    int n;
    cin>>n;
    vector<int> v, c;

    GetInputV(v, n);
    GetInputV(c, n);

    vector<int> dif(n, 0);

    for(int i = 0; i < n; i ++)
    {
        dif[i] = v[i] - c[i];

    }

    int res = 0;

    for(int i: dif)
    {
        if(i > 0) res += i;
    }


    cout<<res<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m;
  string s;
  while(cin>>n,n){
    char a[n][3],d;
    r(i,n){cin>>a[i][0]>>a[i][1];}
    cin>>m;
    char s[m];
    r(i,m)cin>>s[i];
    r(i,m){r(j,n)if(s[i]==a[j][0]){s[i]=a[j][1];break;}}
    r(i,m)cout<<s[i];
    cout<<endl;
  }
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int [] weight = new int[n + 1];
        int[] value = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            weight[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }
        long [][] result = new long[n + 1][w + 1];
        for (int i = 1; i <= n; ++i) {
            for (int k = 0; k < weight[i]; ++k) {
                result[i][k] = result[i - 1][k];
            }
            for (int k = weight[i]; k <= w; ++k) {
                result[i][k] = Math.max(
                        result[i - 1][k],
                        result[i - 1][k - weight[i]] + value[i]
                );
            }
        }
        System.out.println(result[n][w]);
    }
}


Measured memory_bytes: 126292
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		long x = sc.nextLong();
		long y = sc.nextLong();
		println(Math.abs(x - y) > 1 ? "Alice" : "Brown");
	}
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n;
	string str;
	map<string,int> mp;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> str;
		mp[str]++;
	}
	cout <<"AC x " << mp["AC"] << endl;
	cout <<"WA x " << mp["WA"] << endl;
	cout <<"TLE x " << mp["TLE"] << endl;
	cout <<"RE x " << mp["RE"] << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 3652
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       X:i32
    }

    //println!("{}", R / d);
    //println!("{}", (L + d - 1) / d);
    if X == 7 || X == 5 || X == 3 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2064
a = [ int(i) for i in input().split()]

b = (a[0]*a[1]) % 2019

for i in range (a[0], a[1]):
  for j in range (i+1, a[1]+1):
    b = min (b, (i*j)%2019)
    
    if b == 0:
      break
      
  if b == 0:
    break
    
print(b)      

Measured memory_bytes: 3060
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   string str;
   cin>>str;
   for(ll i=0;i<3;i++){
    if(str[i]==str[i+1]){
        cout<<"Bad"<<endl;
        return 0;
    }
   }
   cout<<"Good"<<endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define lli long long int

using namespace std;

int main(){
	int n, k;
	cin>>n>>k;
	lli a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	lli cost[n];
	fill(cost, cost + n, LLONG_MAX);
	cost[0] = 0;
	for(int i = 0; i < n-1; i++) {
		for(int j = 1; j <= k; j++) {
			if(i + j < n) {
				cost[i + j] = min(cost[i + j], cost[i] + abs(a[i] - a[i + j]));
			}
		}
	}
	cout<<cost[n - 1];
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))
l = []
ave = sum(a)/n

diff = 1000
res = 0

for i in range(len(a)):
    if diff > abs(ave-a[i]):
        res = i
        diff = abs(ave-a[i])
else:
    print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 0x7fffffff
typedef long long ll;
using namespace std;
int n,ans,s6,s9,a;
int com(int x,int y)
{
	int res=0,tot=0;
	while(x)
	{
		res+=x%6;
		x/=6;
	}
	tot=res;
	res=0;
	while(y)
	{
		res+=y%9;
		y/=9;
	}
	return tot+res;
}
int main()
{
	cin>>n;
	if(n<6)
	{
		printf("%d\n",n);
		return 0;
	}
	a=n%6;
	s6=n/6;
	ans=com(s6,0)+a;
	while(s6)
	{
		a+=6;
		s6--;
		if(a>=9)
		{
			a-=9;
			s9++;
		}	
		ans=min(ans,com(s6,s9)+a);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
int main(){
    ll h, n;
    cin >> h >> n;

    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    if(h > sum){
        cout <<"No"<<endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;

}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-


#----------
a,b,c,d = [int(i) for i in input().rstrip().split()]
#----------

Flag = False
if abs(c-a) <= d:
    Flag = True
elif (abs(b-a) <= d) and (abs(c-b) <= d):
    Flag = True

print("Yes" if Flag==True else "No")


Measured memory_bytes: 2940
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


x, a, b = rm()
print('B' if abs(a-x) > abs(b-x) else 'A')










Measured memory_bytes: 27024
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  string s, t, u;
  int snum, tnum;
  cin >> s >> t >> snum >> tnum >> u;
  if(u == s) {
    snum -= 1;
    cout << snum << " " << tnum << endl;
  } else {
    tnum -= 1;
    cout << snum << " " << tnum << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int n, k, arr[101];
int dp[101][100005];
int mod=1e9+7;
int main() {
    fast();
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }
    dp[0][0] = 1;
    for (int j = 1; j <= n; ++j) {
        int sum[k + 1] = {0};
        sum[0] = dp[j - 1][0];
        for (int l = 1; l <= k; ++l) {
            sum[l] = sum[l - 1] + dp[j - 1][l];
            sum[l]%=mod;
        }
        for (int i = 0; i <= k; ++i) {
            int t = sum[i]%mod;
            if (i - arr[j] - 1 >= 0)t =(t -sum[i - arr[j] - 1]+mod)%mod;
            dp[j][i] = t;
            //    cout<<dp[j][i]<<" ";
        }

    }
    cout << dp[n][k];
}

Measured memory_bytes: 39680
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();
      if(n==0){
        break;
      }
      int sum = 0;
      double ave = 0;
      int ans = 0;
      int[] score=new int[n];
      for(int i=0; i<n;i++){
        score[i]=sc.nextInt();
      }
      for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
          if(score[j+1]<score[j]){
            int temp = score[j+1];
            score[j+1] = score[j];
            score[j] = temp;
          }
        }
      }
      score[0]=0;
      score[n-1]=0;
      for(int i=0;i<n;i++){
        sum += score[i];
      }
      ave = (double)sum/(n-2);
      ans = (int)ave;
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 29672
A_Num = 0
B_Num = 0
O_Num = 0
AB_Num = 0
while True:
    try:
        N,Cha = map(str,input().split(","))
        if Cha == "A":
            A_Num += 1
        elif Cha == "B":
            B_Num +=1
        elif Cha == "O":
            O_Num += 1
        else:
            AB_Num += 1
    except EOFError:
        print(A_Num)
        print(B_Num)
        print(AB_Num)
        print(O_Num)
        break

Measured memory_bytes: 7300
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect
from math import factorial, sqrt


def main():
    a, b, c = map(int, input().split())

    right = c - a - b
    if right <= 0:
        print("No")
        return
    right = right ** 2
    left = 4 * a * b

    if right > left:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38336