akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = [input() for _ in range(N)]

Ans = [0] * 4

for s in S:
    if s == 'AC':
        Ans[0] += 1
    elif s == 'WA':
        Ans[1] += 1
    elif s == 'TLE':
        Ans[2] += 1
    else:
        Ans[3] += 1

print('AC x', Ans[0])
print('WA x', Ans[1])
print('TLE x', Ans[2])
print('RE x', Ans[3])


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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	int a, b, m = 0;
	cin >> a >> b;
	if(a == b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
using namespace std;
bool f[100001];
int c[100002];
int N ,L ,R ;
int main ()
{
	for(int i=2; i<=100000; i++) if (!f[i]) for (int j=i+i ;j<=100000; j+=i)
	f[j]= true ;
	for(int i=3; i<=100000; i+=2) if (!f[i]&&!f[(i+1)/2]) c [i]++;
	for(int i=3; i<=100000; i++) c[i]+=c[i-1];
	scanf ("%d",&N);
	while (N--)
	{
		scanf ("%d %d" ,&L ,&R);
		printf ("%d\n", c[R] - c[L-1]);
	}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

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

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

// Range Sum Query
class SegmentTree {
private:
	ll n;
	vector<ll>node;

public:
	void init(ll size) {
		n = 1;
		while (n < size) n *= 2;
		node.resize(2 * n - 1, 0);
	}

	// node[i] += x 
	void update(ll i, ll x) {
		i += n - 1;
		node[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			node[i] = node[2 * i + 1] + node[2 * i + 2];
		}
	}

	// sum([a, b))
	ll get_sum(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) { return 0; }
		if (a <= l && r <= b) { return node[k]; }
		ll vl = get_sum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = get_sum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int main() {
	int a, b;
	cin >> a >> b;
	SegmentTree tree;
	tree.init(a);

	for (int i = 0; i < b; ++i) {
		int n, m, mm;
		cin >> n >> m >> mm; --m;
		if (n == 0) { tree.update(m, mm); }
		else { cout << tree.get_sum(m, mm) << endl; }
	}
}


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

using namespace std;
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  map<int, int> mp;

  vector<int> A(N);

  rep(i, N) cin >> A[i];

  rep(i, N){
    mp[A[i]]++;
  }

  ll total_ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    ll cnt = itr->second;
    total_ans += cnt * (cnt - 1) / 2;
  }

  vector<ll> ans(N);

  rep(i, N){

    ll cnt = mp[A[i]];

    ll sub_ = cnt * (cnt-1)/2 - (cnt-1) * (cnt-2)/2;

    ans[i] = total_ans - sub_;

  }

  rep(i, N){
    cout << ans[i] << endl;
  }






  return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);


int main()
{
	stack<char> sc;
	string s;
	std::cin >> s;
	for (char c : s)
	{
		sc.push(c);
	}
	while (!sc.empty())
	{
		string a;
		for (int i = 0; i < 5; ++i)
		{
			if (!sc.empty()) { a += sc.top(); sc.pop(); }
			else { std::cout << "NO";	return 0; }
		}
		reverse(a.begin(), a.end());
		if(a== "raser"){if(sc.top()!='e' || sc.empty())
		{
			std::cout << "NO";	return 0;
		}
			sc.pop(); 
		}
		else if(a=="eamer")
		{
			if (sc.top() != 'r' || sc.empty())
			{
				std::cout << "NO";	return 0;
			}
			sc.pop();
			if (sc.top() != 'd' || sc.empty())
			{
				std::cout << "NO";	return 0;
			}
			sc.pop();
		}
		else
		{
			if(a!="dream" && a!="erase")
			{
				std::cout << "NO";	return 0;
			}
		}


	}
	std::cout << "YES";

	





}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=3005;
bool poss[N],poss2[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  poss[0]=poss2[0]=true;
  rep(i,0,N)
    {
      if(!poss[i]) continue;
      if(i+c<N) poss[i+c]=true;
      if(i+d<N) poss[i+d]=true;
    }
  rep(i,0,N)
    {
      if(!poss2[i]) continue;
      if(i+100*a<N) poss2[i+100*a]=true;
      if(i+100*b<N) poss2[i+100*b]=true;
    }
  db mx=-1.0;
  int tot=1,sug=0;
  rep(i,1,f+1)
    {
      rep(j,0,i)
	{
	  if(!poss[j] || !poss2[i-j]) continue;
	  db sugar=j;
	  db waterreq=(db)j*100.0/(db)e;
	  db currwater=i-j;
	  if(waterreq>currwater) continue;
	  db dens=100.0*sugar/(db)i;
	  if(dens>mx)
	    mx=dens,tot=i,sug=j;
	}
    }
  cout<<tot<<" "<<sug<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

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

    return 0;
}

Measured memory_bytes: 4844
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,c,k = inpm()
    ans = 0
    ans += min(a,k)
    ans -= max(0,k-a-b)
    print(ans)

if __name__ == "__main__":
    main()

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

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

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	for(int i=1; i< p+1; i++) {
		a = (a * (n - i + 1)) % MOD;
		b = (b * i) % MOD;
	}
	return a * (modPow(b, MOD - 2)) % MOD;
}

int main() {
    // input, ready
    ll n,a,b;
    cin >> n >> a >> b;
    ll comball = modPow(2, n);
    ll comba = comb(n,a);
    ll combb = 0;
    if (a != b) combb = comb(n,b);

    ll ans = ((comball - comba - combb - 1) % MOD + MOD) % MOD;

    // output
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<string> s(n);
    vector<string> t;
    map<string,lint>ma;
    REP(i,n){
        cin>>s[i];
        ++ma[s[i]];
    }
    lint max = 0;
    for(auto e:ma){
        if(max<e.second) max = e.second;
    }
    for(auto e:ma){
        if(e.second==max) print(e.first); 
    }
    return 0;
}

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
int level[100005]={0},parent[100005]={0},coin[100005]={0},visited[100005]={0};
int main()
{
    int a[100]={0};
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int count=0,sum=0;
    for(int i=n-1;count<k&&i>=0;i--)
    {
        sum+=a[i];
        count++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	long double a, b, c;
	cin >> a >> b >> c;
	
	a /= 65536.0;
	b /= 65536.0;
	c /= 65536.0;
  
	cout << (((a+b-c) + 2.0*sqrt(a*b) < 0) ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	public void run() throws Exception {
		FastIO file = new FastIO();
		char[] c = file.next().toCharArray();
		if (c[0] == c[1] && c[2] == c[3] && c[0] != c[2]) {
			System.out.println("Yes");
		}
		else if (c[0] == c[2] && c[1] == c[3] && c[0] != c[1]) {
			System.out.println("Yes");
		}
		else if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


Measured memory_bytes: 21076
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  S = str(N)
  div = 0
  for c in S:
    div += int(c)
  if N % div == 0:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()

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

using namespace std;

int main(void){
    int H, W;
    cin >> H >> W;
    int K;
    cin >> K;
    vector<string> s(H);
    for(int i = 0; i < H; i++) cin >> s[i];
    vector<int> c(H, 0);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '#') c[i]++;
        }
    }
    vector<vector<int>> a(H, vector<int>(W, 0));
    int i;
    for(i = 0; i < H; i++){
        if(c[i] == 0) continue;
        break;
    }
    int k = 1;
    int kk = 0;
    for(int j = 0; j < W; j++){
        // cout << i << " " << j << " " << kk << endl;
        if(s[i][j] == '#'){
            kk++;
        }
        a[i][j] = max(k, kk);
        // cout << a[i][j] << endl;
    }
    k = kk;
    int ii;
    for(ii = 0; ii < i; ii++){
        for(int j = 0; j < W; j++) a[ii][j] = a[i][j];
    }

    for(i++; i < H; i++){
        if(c[i] == 0){
            for(int j = 0; j < W; j++){
                a[i][j] = a[i - 1][j];
            }
        }else{
            k++;
            for(int j = 0; j < W; j++){
                if(s[i][j] == '#'){
                    kk++;
                }
                a[i][j] = max(k, kk);
            }
            k = kk;
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << a[i][j] << (j == W - 1 ? "\n" : " ");
        }
    }
    return 0;
}


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

int main() {
    int n;cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)cin >> x[i];
    int ener_min = 99999999;
    for (int i = 0; i < 101; i++)
    {
        int ener = 0;
        for (int j = 0; j < n; j++)
        {
            ener += (x[j] - i)*(x[j] - i);
        }
        ener_min = min(ener_min, ener);
    }
    cout << ener_min << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int i,w,h,n,x,y,a;
int j[4];
int main()
{
  for(cin>>w>>h>>n>>x>>y>>a,j[0]=0,j[1]=w,j[2]=0,j[3]=h;i<n;cin>>x>>y>>a,i++){
    if(a==1)j[0]=max(x,j[0]);
    if(a==2)j[1]=min(x,j[1]);
    if(a==3)j[2]=max(y,j[2]);
    if(a==4)j[3]=min(y,j[3]);
  }
  cout<<max(j[1]-j[0],0)*max(j[3]-j[2],0);
}

Measured memory_bytes: 256
from math import log2

# print(log2(4))
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


a = int(input())
if a ==1:
    print(1)
    exit()
a = int(log2(a))
# print(a)

res = 4*(pow_k(2,a-1))-1
print(res)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#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 vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6 + 8;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
void f_io(){
    IOS;
    // #ifndef ONLINE_JUDGE
    // FRE
    // #endif
}


int32_t main(){
    f_io();
    int tc = 1;
    //cin>>tc;
    while(tc--){
        map<string, int> cnt;
        int n; cin >> n;
        for(int i = 0; i < n; i++){
            string s; cin >> s;
            cnt[s]++;
        }
        cout << "AC x " << cnt["AC"] << endl;
        cout << "WA x " << cnt["WA"] << endl;
        cout << "TLE x " << cnt["TLE"] << endl;
        cout << "RE x " << cnt["RE"] << endl;
    }
}


Measured memory_bytes: 3560
S = input()
n = len(S)
ret = int(S[0:3])
for idx, x in enumerate(S,1):
    tmp = S[idx:idx+3]
    if len(tmp) != 3:
        break
    if abs(753 - int(tmp)) < abs(753 - ret):
        ret = int(tmp)

print(abs(753 - ret))

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N, K, ans;
vector<int> a;

void solve() {
    cin >> N >> K;
    a.resize(N);
    for (auto& i : a) cin >> i;
    
    
    for (int leftTake = 0; leftTake <= min(N, K); leftTake++) {
		int tmp = 0;
		multiset<int> lq, rq;
		for (int i = 0; i < leftTake; i++) {
			lq.insert(a[i]);
			tmp += a[i];
		}
		for (int rightTake = 0; rightTake + leftTake <= min(N, K); rightTake++) {
			int rtmp = tmp;
			for (int i = 1; i <= rightTake; i++) {
				rq.insert(a[N - i]);
				rtmp += a[N - i];
			}
			
			auto lp = lq.begin(), rp = rq.begin();
			for (int i = 0; i < K - leftTake - rightTake; i++) {
				bool lv = (lp != lq.end() && *lp < 0), rv = (rp !=  rq.end() && *rp < 0);
				if (lv && rv) {
					if (*lp < *rp) {
						rtmp -= *lp;
						lp++;
					} else {
						rtmp -= *rp;
						rp++;
					}
				} else if (lv) {
					rtmp -= *lp;
					lp++;
				} else if (rv) {
					rtmp -= *rp;
					rp++;
				} else break;
			}
			
			// cout << leftTake << " " << rightTake << " " << rtmp << "\n";
			chmax(ans, rtmp);
			rq.clear();
		}
		lq.clear();
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

typedef pair<char,ll> pcl;
typedef vector<pcl> vpcl;
vpcl rle(string s) {
  vector<pair<char,ll>> res;
  char temp=s[0];
  ll count=0;
  for(ll i=0;i<s.size();i++) {
    if(temp==s[i]) {
      count++;
    }
    else {
      res.push_back(pair<char,ll>(temp,count));
      temp=s[i];
      count=1;
    }
    if(i==s.size()-1) {
      res.push_back(pair<char,ll>(temp,count));
    }
  }
  return res;
}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n=s.size();
  vpcl check=rle(s);
  ll ans=0;
  if(check.size()==1) {
    cout << n*k/2 << endl;
    return 0;
  }
  for(auto p:check) {
    ans+=p.second/2;
  }
  ans*=k;
  if(check[0].first==check[check.size()-1].first) {
    ans-=(k-1)*(check[0].second/2+check[check.size()-1].second/2-(check[0].second+check[check.size()-1].second)/2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let R:i64 = 1_000_000_007;
    input!{
        n: usize, m: usize,
        a: [i64; m],
    }
    let mut oks: Vec<bool> = vec!(true; n + 1);
    for i in 0..m{
        oks[a[i] as usize] = false;
    }
    let mut dp = vec!(0;500000);
    dp[0] = 1;
    for now in 0..n{
        for next in (now + 1)..(min(n + 1, now + 3)){
            if oks[next]{
                dp[next] += dp[now];
                dp[next] %= R;
            }
            
        }
    }
    println!("{}", dp[n]);

}

Measured memory_bytes: 8444
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
    var n = o.a();
    var h = o.l();
    var ans = 0;
    var mx = 0;
    for(var i = 0; i < n; i++){
        if(mx <= h[i])mx = h[i], ans++;
    }
    return ans;
}

Measured memory_bytes: 7372
a=list(map(int,input().split()))
ans=abs(a[0]-a[1])+abs(a[0]-a[2])
ans=min(ans,abs(a[1]-a[0])+abs(a[1]-a[2]))
ans=min(ans,abs(a[2]-a[1])+abs(a[0]-a[2]))
print(ans)

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

l=[N//K+1 if i<N%K else N//K for i in range(K)]

ans=0
for a in range(1,K+1):#1,3
    b=(K-a)%K#あまり
    c=(K-a)%K
    if (b+c)%K==0:
        ans+=l[a-1]*l[b-1]*l[c-1]
    else:
        continue

print(ans)

Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool ans = false;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (i * j == N) {
        ans = true;
      }
    }
  }
  if (ans == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string Map[h];
  int black=0;
  for(int i=0;i<h;i++){
    cin>>Map[i];
    for(int j=0;j<w;j++){
      if(Map[i][j]=='#')
	black++;
    }
  }
  bool used[h][w]={};
  queue<pair<pair<int,int>,int> >que;
  que.push(mp(mp(0,0),0));
  int vx[4]={0,-1,0,1};
  int vy[4]={1,0,-1,0};
  bool flag=false;
  int cn=-1;
  while(!que.empty()){
    int cnt=que.front().S;
    pair<int,int>now=que.front().F;
    que.pop();
    if(now.F==h-1&&now.S==w-1){
      cn=cnt+1;
      flag=true;
      break;
    }
    for(int i=0;i<4;i++){
      int a=now.F+vx[i];
      int b=now.S+vy[i];
      if(a>=0&&b>=0&&a<h&&b<w&&!used[a][b]&&Map[a][b]!='#'){
	used[a][b]=true;
	que.push(mp(mp(a,b),cnt+1));
      }
    }
  }
  if(flag){
    cout<<h*w-cn-black<<endl;
  }else
    cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    H, W = (int(_) for _ in input().split())
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    # a_dict = dict()
    # for i in range(N):
    #     a_dict[i+1] = a[i]

    # a_dict_sorted = dict()
    # for k, v in sorted(a_dict.items(), key=lambda x: -x[1]):
    #     a_dict_sorted[k] = v

    Grid = []
    for i in range(H):
        Grid.append(list ( -1 for j in range(W)))
        
    a_index = 0
    a_cnt = a[a_index]
    for h in range(H):
        for w in range(W):
            Grid[h][w] = a_index+1
            if a_cnt - 1 <=0:
                a_index +=1
                if(a_index == N):
                    break
                a_cnt = a[a_index]
            else:
                a_cnt -=1
                
    for h in range(H):
        if h % 2 ==1:
            Grid[h] = Grid[h][::-1]
    for h in range(H):
        print(' '.join(str(_) for _ in Grid[h]))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 4124
a,b=map(int,input().split())
ans=0

for i in range(1,42):
    count=0
    v,mod1=divmod(a,2**i)
    w,mod2=divmod(b,2**i)
    if v==w:
        
        if mod2<2*(i-1):
            pass
        if mod2>=2**(i-1) and mod1<2**(i-1):
            count+=mod2+1-2**(i-1)
        if mod2>=2**(i-1) and mod1>=2**(i-1):
            count+=mod2-mod1+1
    if v<w:
        
        count+=2**(i-1)*(w-v-1)
        if mod1<2**(i-1):
            count+=2**(i-1)
        if mod1>=2**(i-1):
            count+=(2**i-mod1)
        if mod2<2**(i-1):
            pass
        if mod2>=2**(i-1):
            count+=mod2+1-2**(i-1)


    if count%2!=0:
        ans+=2**(i-1) 

print(ans)
            

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

int main()
{
    int A,B,C,D,E,F;
    std::cin >> A >> B >> C >> D >> E >> F;
    long double max_noudo = -1;
    int fir = A,sec = 0;

    for(int a = 0; a <= F; a += (A * 100)){
        
        for(int b = 0; a + b <= F; b += (B * 100)){

            int lim = ((a + b) / 100) * E;

            for(int c = 0; c <= lim; c += C){

                for(int d = 0;c + d <= lim; d += D){

                    if(a + b + c + d > F)continue;
                    if(((long double)(100 * (c + d))) / ((long double)(a + b + c + d)) >= max_noudo){
                        max_noudo = ((long double)(100 * (c + d))) / ((long double)(a + b + c + d));
                        fir =  a + b + c + d;
                        sec = c + d;
                    }
                }
            }
        }
    }
    if(max_noudo == -1)assert(0);
    std::cout << fir << " " << sec << std::endl;


}

Measured memory_bytes: 256
import bisect


q = int(input())

S = []


for _ in range(q):

    command, *list_num = input().split()
    x = int(list_num[0])

    index = bisect.bisect_left(S, x)

    if   command == "0":
        # insert(x)
        x = int(list_num[0])
        if ((index == len(S)) or
            (S[index] != x)):
            S.insert(index, x)
        print(len(S))
    elif command == "1":
        # find(x)
        x = int(list_num[0])
        if ((index < len(S)) and
            (S[index] == x)):
            print(1)
        else:
            print(0)
    elif command == "2":
        # delete(x)
        x = int(list_num[0])
        if ((index < len(S)) and
            (S[index] == x)):
            del S[index]
    elif command == "3":
        # dump(L, R)
        L = x
        R = int(list_num[1])

        index_left = bisect.bisect_left(S, L)
        index_right = bisect.bisect_right(S, R)
        
        for element in S[index_left:index_right]:
            print(element)
    else:
        raise



Measured memory_bytes: 15648
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a,b;
  cin>>a>>b;
  int x;
  x=(a+b)/2;
  if(x*2!=(a+b)){
    cout<<(x+1)<<endl;
  }else{
    cout<<x<<endl;
  }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n;
  vector<int> t(n);
  rep(i,n) cin >> t[i];
  cin >> m;
  
  int sum = 0;
  rep(i,n) sum += t[i];
  int temp = sum;
  
  rep(i,m){
    int p,x;
    cin >> p >> x;
    sum = temp + x-t[p-1];
    cout << sum << endl;
  }
  
}

Measured memory_bytes: 256
N = gets.to_i
ary = gets.split.map(&:to_i).sort

nums = Hash.new(0)
ans = Array.new(ary.last+1, 0)
ary.each do |i|
  nums[i] += 1
  ans[i] = 1
end
res = 0
ary.each do |j|
  next if ans[j] == 0
  res += 1 if nums[j] == 1
  j.step(ary.last, j) do |k|
    ans[k] = 0
  end
end
p res

Measured memory_bytes: 46344
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){ if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=s.nextInt(),k=s.nextInt();
       s.nextLine();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
       	Arrays.sort(arr);
       long mod=(long)1e9+7;
       f=new long[n+1];f[0]=1;
       for(int i=1;i<=n;i++){f[i]=(f[i-1]*i)%mod;}
       	long min=0,max=0;
       	for(int i=0;i<n;i++){
       		min=(min+arr[i]*nck(n-i-1,k-1,mod)+mod)%mod;
       		max=(max+arr[i]*nck(i,k-1,mod))%mod;
       	}
          out.write((max-min+mod)%mod+" ");
        out.flush();
  }
}


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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	string a; cin>>a;
	if('a' <= a[0] && a[0] <= 'z'){
		cout<<'a'<<endl;
	}else{
		cout<<'A'<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    ll dist = abs(a-b);
    ll ad = t*v, bd = w*t;
    
    if (bd>ad) {
        puts("NO");
        return 0;
    }

    ll dist2 = abs(ad-bd);

    if (dist2>=dist) puts("YES");
    else puts("NO");


    return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *prev;
  struct node *next;
  long key;
};
typedef struct node * NP;
NP MN(long);
void IN(NP);
void DN(NP);
void FI(long);
NP dummy;

int main(){
  long int val,i,n;
  char op[12];
  NP roop;

  scanf("%ld",&n);
  dummy = MN(0);

  for(i=0;i<n;i++){
    scanf("%s",op);
    
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      DN(dummy->next);
    }
    else if(strcmp(op,"deleteLast") == 0){
      DN(dummy->prev);
    }
  }

  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");

  return 0;
}


void FI(long value){ // find item
  NP n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
    
}


void DN(NP th){ //delete node
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}


void IN(NP newn){ //insert node
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}

NP MN(long key){ //make node
  NP no = (NP)malloc(sizeof(struct node));
  //n = new struct node();
  no->prev = no;
  no->next = no;
  no->key = key;
  return no;
} 

Measured memory_bytes: 15000
#include <bits/stdc++.h>
#include <numeric>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

ll gcd(ll a, ll b)
{
if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
return a * b / gcd(a, b);
}

long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

ll A,B;
ll ans ;
int main(){
    cin >> A >> B;

    cout << lcm(A,B) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys

sys.setrecursionlimit(20000)

matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]
h = 0
w = 0

def dfs(x,y,fruit):
  #visited.append((x,y))
  visited[y][x] = 1
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if nx in xrange(w) and ny in xrange(h):
      if visited[ny][nx]==0 and matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)
  return 0


while True:
  h,w = map(int,raw_input().split())
  if h == 0 and w == 0:
    break
#  print h,w
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
    visited.append([0]*w)
  for i in xrange(h):
    for j in xrange(w):
      #if not (j,i) in visited:
      if visited[i][j] == 0:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans

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

int main(){
  int64_t W,H,x,y;
  cin >> W >> H >> x >> y;
  double area=(W*H)/2.0;
  bool flag;
  if((x==W/2.0)&&(y==H/2.0)){
    flag=true;
  }else{
    flag=false;
  }
  //cout << fixed << setprecision(6);
  cout << area << " " << flag << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;

  set<string> Set;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    Set.insert(s);
  }

  cout << Set.size() << endl;
  return 0;
}


Measured memory_bytes: 19256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int dp[300][300][4];
int main(){
	int n;
	while(cin>>n,n){
		vi dp(10000);
		dp[0]=1;
		while(n--){
			int a,b;
			cin>>a>>b;
			for(int i=9999;i>=0;i--)if(dp[i]){
				loop(j,1,b+1)dp[i+j*a]+=dp[i];
			}
		}
		cin>>n;
		while(n--){
			int a;
			cin>>a;
			cout<<dp[a]<<endl;
		}
	}
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(){
  int i,j,k,a,n,u,v[101][101]={};
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&a);
      v[u][a]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",v[i][j]);
      if(j==n)break;
      printf(" ");
    }
    printf("\n");
  }
  return 0;
}

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

void warshall_floyd(vector<vector<ll>>& cs)
{
    for (ll i = 0; i < 10; ++i) {
        for (ll j = 0; j < 10; ++j) {
            for (ll k = 0; k < 10; k++) {
                cs[j][k] = min(cs[j][k], cs[j][i] + cs[i][k]);
            }
        }
    }
}

void main_()
{
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> cs(10, vector<ll>(10));
    for (auto&& c : cs) {
        copy_n(istream_iterator<ll>(cin), 10, begin(c));
    }
    vector<vector<ll>> As(H);
    for (ll i = 0; i < H; i++) {
        copy_n(istream_iterator<ll>(cin), W, back_inserter(As[i]));
    }

    warshall_floyd(cs);

    ll ans = 0;
    for (ll i = 0; i < H; i++) {
        ans += accumulate(
            begin(As[i]), end(As[i]),
            0LL, [&cs](auto acc, auto n) {
                return acc + ((n < 0) ? 0 : cs[n][1]);
            });
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 640
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int n, m; cin>>n>>m;

   vi a(m);

   int s = 0;
   for(int & x : a)cin>>x,s += x;

   cout<<((n >= s) ? n-s : -1)<<"\n";

   



}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main(){
	char s[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	char m[26]={'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C'};
	char bm[1024],bs[1024];
	int i,j;
	scanf("%s",bm);
	strcpy(bs,bm);
	for(i=0;i<strlen(bm);i++){
		for(j=0;j<26;j++){
			if(m[j]==bm[i]){
				bs[i]=s[j];
				break;
			}
		}
	}
	printf("%s\n",bs);
	return 0;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

string s;
vector<int> g[256];

int main() {
	megaRandom();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	for(int i = 0; i < sz(s); i ++) 
		g[s[i]].pb(i);
	ll res = 1ll * sz(s) * (sz(s) - 1) / 2 + 1;
	for(int i = 'a'; i <= 'z'; i ++) {
		int x = sz(g[i]);
		res -= 1ll * x * (x - 1) / 2;		
	}
	cout << res;
	return 0;         
}


Measured memory_bytes: 1936
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0;
	auto appl = [&](int x) {
		vector<int> keks;
		for (auto t : a) {
			t %= x;
			if (t) keks.push_back(t);
		} 
		sort(keks.begin(), keks.end());
		int osum = 0;
		for (auto t : keks) {
			osum += t;
		}
		int csum = 0;
		for (int i = 0; i <= (int)keks.size(); i++) {
			if ((csum) == (((int)keks.size() - i) * x - (osum - csum))) {
				if (csum <= k) ans = max(ans, x);
			}
			if (i < (int)keks.size()) csum += keks[i];
		}
	};
	int s = 0;
	for (auto t : a) {
		s += t;
	}
	for (int i = 1; i * i <= s; i++) {
		if (s % i == 0) {
			appl(i);
			appl(s / i);
		}
	}
	// appl(7);
	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
edge = {}
inl = [0]*(n+1)
for _ in range(n-1+m):
    a,b = map(int, input().split())
    if a not in edge:
        edge[a] = []
    edge[a].append(b)
    inl[b] += 1

s = []
for v in range(1,n+1):
    if inl[v]==0:
        s.append(v)

l = []
res = [0]*(n+1)
while len(s)>0:
    v = s.pop()
    l.append(v)
    if not v in edge:
        continue
    for u in edge[v]:
        inl[u] -= 1
        if inl[u]==0:
            res[u] = v
            s.append(u)

for i in range(1,n+1):
    print(res[i])


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

#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string ans = "";
    string abc = "abcdefghijklmnopqrstuvwxyz";

    for (int i = 0; i < 13; i++)
    {
        n--;
        ans = abc[n % 26] + ans;
        n /= 26;
        if (n == 0)
            break;
    }

    cout << ans << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3644
import sys
input = sys.stdin.buffer.readline
import bisect

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    MOD = 10**9+7
    
    num = 0
    for i in range(N):
        for j in range(i+1,N):
            if a[i] > a[j]:
                num += 1

    if M == 1:
        print(num%MOD)
    else:
        num *= M
        num %= MOD
        a += a
        count = 0
        for i in range(N):
            for j in range(N,2*N):
                if a[i] > a[j]:
                    count += 1

        count *= ((M*(M-1))//2)
        count %= MOD
        num += count
        print(num%MOD)
    
if __name__ == "__main__":
    main()


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

int main() {
  int n,t; cin>>n>>t;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  int tmp=-1000000;
  int cnt=1;
  int l=a[0];
  rep(i, n-1) {
    l=min(l, a[i+1]);
    if (tmp<a[i+1]-l) cnt=1;
    if (tmp==a[i+1]-l) cnt++;
    tmp=max(tmp, a[i+1]-l);
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 768