akhauriyash/Code-Regression huggingface dataset:
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[2000005];
  scanf("%s", s);
  ll n = strlen(s);
  ll a = -1, z;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A')
    {
      while (a < 0)
      {
        a = i;
      }
    }
    if (s[i] == 'Z')
    {
      z = i;
    }
  }
  printf("%lld\n", z - a + 1);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;
typedef pair<int,int>PAIR;//(ダメージ量)&(宿番号*1000+残金)
int main(){
    
	/*
	AOJ2151
	[宿屋(1~100)]に[残金(0~100)]を持って
	最低ダメージでたどり着くようにして
	解けばよい？
	
	
	*/
	
	int N,M,L;
	while(cin>>N>>M>>L,N){
		int load[101][101][2];//AからBへの/距離(=支払い)/襲われる数(=ダメージ量)
		memset(load,-1,sizeof(load));
		bool flag[101][101]={0};//宿屋//金//すでに最低ダメージでたどり着いているならフラグを立てる
		
		for(int i=0,A,B,D,E;i<M;i++){
			cin>>A>>B>>D>>E;
			load[A][B][0]=load[B][A][0]=D;
			load[A][B][1]=load[B][A][1]=E;
		}
		priority_queue<PAIR,vector<PAIR>,greater<PAIR> > Q;
		Q.push(make_pair(0,1000+L));
		
		for(int dam,pos,mon;!Q.empty();){
			
			dam=Q.top().first;
			pos=Q.top().second/1000;
			mon=Q.top().second%1000;
			Q.pop();
			if(pos==N){
				cout<<dam<<endl;
				break;
			}
			
			if(flag[pos][mon]==0){
				flag[pos][mon]=1;
				for(int i=1;i<=N;i++){
					if(load[pos][i][0]>0){//道がある
						
						if(flag[i][mon]==0){//雇わずに襲われる場合
							Q.push(make_pair(dam+load[pos][i][1],i*1000+mon));
						}
						if(load[pos][i][0]<=mon){//雇うお金がある場合
							if(flag[i][mon-load[pos][i][0]]==0){
								Q.push(make_pair(dam,i*1000+mon-load[pos][i][0]));
							}
						}
					}
				}
			}
			
		}
		
	}
	
	return 0;
}


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

bool test = true;
int tt = 1;
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(s) (int)(s.size())

struct fio
{
    fio()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(10);
    }
} fio;

int main() 
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c, b*d))) << "\n";
}

Measured memory_bytes: 3652
n = int(input())
h = list(map(int, input().split()))

INF = 10 ** 10
dp = [INF] * n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(n - 2):
    dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1]))

print(dp[n - 1])

Measured memory_bytes: 52208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<list>

using namespace std;

int main() {
	int k, ans;
	int num;
	while(cin >> k) {
		ans = 1;
		num = 7;

		while(num%k != 0 && ans < 1000000) {
			num %= k;
			num = num*10+7;
			ans++;
		}
		if(ans != 1000000)
			cout << ans << endl;
		else
			cout << "-1" << endl;
	}
}

Measured memory_bytes: 3624
public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {

        System.out.println("DENIED");
        return;
      }
    }
    System.out.println("APPROVED");

  }

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

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

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

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

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

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

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

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

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

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

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

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



Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[100000];
set<int> st;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
	}
	cout << (int)st.size() << endl;
}



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

long long exponentiation_by_squaring(long long a, long long b){
    if(b == 0) return 1;
    if(b % 2 == 1){
        return exponentiation_by_squaring(a, b - 1) * a;
    }else{
        long long tmp = exponentiation_by_squaring(a, b / 2);
        return tmp * tmp;
    }
}

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

    long long h;
    cin >> h;

    long long cnt = 0, ans = 0;
    while(true){
        h /= 2;
        ans += exponentiation_by_squaring(2, cnt);
        cnt++;
        if(h == 0){
            break;
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 0

divisors = make_divisors(N)
for d in divisors:
    m = d - 1
    if m and (N // m == N % m):
        ans += m


print(ans)

Measured memory_bytes: 39024
#include <cstdio>

const int N = 2e5 + 5;

int n, A, B, C, D;
char s[N];

bool check(int x, int y) {
	for (int i = x + 1; i < y; i++) {
		if (s[i] == '#' && s[i + 1] == '#') return false;
	}
	return true;
}
bool Check(int x, int y) {
	for (int i = x; i <= y; i++) {
		if (s[i] == '.' && s[i - 1] != '#' && s[i + 1] != '#') return true;
	}
	return false;
}
int main() {
	scanf("%d%d%d%d%d%s", &n, &A, &B, &C, &D, s + 1);
	if (C < D) {
		printf("%s\n", check(A, C) && check(B, D) ? "Yes" : "No");
	} else {
		printf("%s\n", check(A, C) && Check(B, D) && check(B, D) ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll dc(ll a)
{
    int k=0;
    ll n=a;
    if (n==1)
    return 1;
    else
    while (n>=1)
    {
        n/=10;
        k++;
    }
    return k;
}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
int main ()
{
    ll n,i,a[1001];
    ld s=0,ans=0;
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        s+=1.0/a[i];
    }
    ans=1.0/s;
    cout<<ans;
}
       
        
    


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

int main() {
    // int w, h, x, y, r;
    // cin >> w >> h >> x >> y >> r;
    
    int num;
    int i = 1;
    while (true) {
        cin >> num;
        if (num == 0) break;
        cout << "Case " << i << ": " << num << endl;
        i++;
    }
    
    
    // cout << answer << endl;
}


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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        int w,h;
        cin >> w >> h;
        vector<vector<bool> > map(h+1,vector<bool>(w+1,false));
        for(int i=0; i<n; i++){
            int x,y;
            cin >> x >> y;
            map[y][x]=true;
        }

        int s,t;
        cin >> s >> t;

        int tmax=0;
        for(int y=1; y<=h-t+1; y++){
            for(int x=1; x<=w-s+1; x++){
                int cnt=0;
                for(int i=y; i<y+t; i++){
                    for(int j=x; j<x+s; j++){
                        if(map[i][j]) cnt++;
                    }
                }
                tmax = max(tmax, cnt);
            }
        }
        cout << tmax << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
main()
{
while(1)
{
int a, b,r;
char c;
scanf("%d %c %d", &a, &c, &b);
switch(c){case'+':r=a+b;break;case'-':r=a-b;break;case'/':r=a/b;break;case'*':r=a*b;break;}
if (c == '?')break;
    printf("%d\n", r);
}}


Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int


// quoted from beet-aizu
template <typename T, typename F>
struct SegmentTree{
    // using F = typename<T(T, T)>
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,T ti):f(f),ti(ti){}
    void init(int n_){    
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void set_val(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
    }
    T get_val(int k){
        return dat[k+n];
    }
    T query(int a,int b){
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }
    
    
    /* TODO わからない 聞く 
    template<typename C>
    int find(int a,int b,C &check,int k,int l,int r){
        if(!check(dat[k])||r<=a||b<=l) return -1;
        if(k>=n) return k-n;
        int m=(l+r)>>1;
        int vl=find(a,b,check,(k<<1)|0,l,m);
        if(~vl) return vl;
        return find(a,b,check,(k<<1)|1,m,r);
    }
    template<typename C>
    int find(int a,int b,C &check){
        return find(a,b,check,1,0,n);
    }
    */
};

signed main(){
    
    int n, q; cin >> n >> q;
    auto f = [](int a, int b){ return a + b; };
    SegmentTree<int, decltype(f)> sg(f, 0);
    sg.build(vector<int>(n, 0));

    for(int i = 0; i < q; i++){
        int com, x, y; cin >> com >> x >> y;
        if(!com) sg.set_val(x - 1, sg.get_val(x - 1) + y);
        else cout << sg.query(x - 1, y) << endl;
    }

    return 0;
}



Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
string s,pre,suf;
int flag=1;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	int q;
	cin>>q;
	while(q--)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			swap(pre,suf);
			flag=3-flag;
		}
		else
		{
			int f;
			string c;
			cin>>f>>c;
			if(f==1) pre+=c;
			else suf+=c;
		}
	}
	reverse(pre.begin(),pre.end());
	if(flag==2)
		reverse(s.begin(),s.end());
	pre+=s;
	pre+=suf;
	cout<<pre<<endl;
	return 0;
}


Measured memory_bytes: 1300
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll M_MAX = 100000;
const ll C_I_MAX = 1000000000;

ll N, M;

priority_queue<ll, vector<ll>, greater<ll> > que;
ll ans=0;
vector<ll> v;
void input() {
	scanf("%lld%lld", &N, &M);

	rep(i, N) {
		ll a;
		cin >>a;
		que.push(a);
		ans+=a;
	}
	vector<pair<ll,ll>> pa(M);
	rep(i,M){
		cin >>pa[i].first>>pa[i].second;
	}
	sort(all(pa), [](const pair<ll,ll> &x, const pair<ll,ll> &y) {
		return x.second > y.second;
	});

	v.assign(N,0);
	ll k=0;
	[&]{
		rep(i,M){
			rep(j,pa[i].first){
				v[k]=pa[i].second;
				//v.push_back(pa[i].second);
				k++;
				if(k==N)return;
			}
		}
	}();
}

void solve(){
	ll i=0;
	while(1){
		ll qq=que.top();
		ll vv=v[i];
		if(qq<vv){
			que.pop();
			que.push(vv);
			ans+=vv-qq;
			i++;
			if(i==N)break;
		}else{
			break;
		}	
	}



	/*
	while(!que.empty()){
		ll t=que.top();que.pop();
		ans+=t;
	}
	*/
	printf("%lld\n", ans);
}

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


Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>

#define M 10000000

void hashInsert(int);
int hashSearch(int);
int change(char);

int mozi[M];
char mozi2[12];

int main( ){

  int n,n1,i,j=0,m,key=0,p,key2,hantei;
  char meirei[6];
  
  scanf("%d",&n);

  /*if(n == (int)6){
    printfn("hogehogehogeh");
    }*/
  
  n1=n;
  
  //n = 6;
  //printf("%d\n",n);

  for(i=0;i<M;i++){

    mozi[i]=0;

    }
  
  for(i=0;i<n1;i++){

    //printf("debug1: %d\n", n);

    scanf("%s %s",meirei,mozi2);

    p=1;
    key=0;

    //printf("wa-i1\n");
    
    for(m=0;mozi2[m]!=NULL;m++){
      key2=change(mozi2[m]);
      key+=key2*p;
      p*=5;

      // printf("making key = %d\n",key);
    }

    //printf("debug2: %d\n", n);

    //printf("wa-i2\n");

    if(strcmp(meirei,"insert")==0){

      // printf("wa-i3\n");
      
      hashInsert(key);
      

      //printf("wa-i4\n");
      
    }
    else if(strcmp(meirei,"find")==0){

      //printf("wa-i40\n");
      
      hantei=hashSearch(key);
      
      
      if(hantei==1)printf("yes\n");
      else printf("no\n");
    }
    //printf("wa-i10\n");    

  }

  //printf("wa-i11\n");
  
  return 0;
  
}

void hashInsert(int key){

  int i=0,j;

  while(1){

    // printf("wa-i5\n");

    j=((key%M)+i*(1+key%(M-1)))%M;

    //printf("wa-i6\n");

    if(mozi[j]==NULL){mozi[j]=key;
      // printf("Insert mozi[j]=%d\n",mozi[j]);
      //printf("Insert j=%d\n",j);
      //printf("Insert key=%d\n",key);
      
      // printf("wa-i7\n");
      break;
    }
    else i++;    

  }  
  
}

int hashSearch(int key){

  int i=0,j;

  while(1){
    
    j=((key%M)+i*(1+key%(M-1)))%M;

    //printf("find key=%d\n",key);
    //printf("find j=%d\n",j);
    // printf("find mozi[j]=%d\n",mozi[j]);

    
    if(mozi[j]==key) return 1;
    else if(mozi[j]==NULL || i>=M) return 0;
    else i=i+1;

  }
}


int change(char mozi){

  if(mozi=='A') return 1;
  else if(mozi=='C') return 2;
  else if(mozi=='G') return 3;
  else if(mozi=='T') return 4;

}







  

  

Measured memory_bytes: 39644
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3) << endl;
}

Measured memory_bytes: 4244
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{
	auto line = readln().split(); 
	if (line.length < args.length) return;
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
//------------------------------
const coin = [10,50,100,500];
void main(){	
	int total;
	for(read(total); total ; read(total), write(total ? "\n":"")){
		auto have = new int[4];
		readArray(have);
		int howMany = int.max; 
		auto uses = new int[4];
		//0,0,0,0 ~ i0,i1,i2,i3 ?????§??????
		foreach(i0;iota(have[0]+1)){
			foreach(i1;iota(have[1]+1)){
				foreach(i2;iota(have[2]+1)){
					foreach(i3;iota(have[3]+1)){
						auto tmpuses = [i0,i1,i2,i3];
						auto pay = coin.dotProduct(tmpuses);	
						if (pay < total) continue;
						int tmpHowMany = have.sum + howManyCoins(pay - total) - tmpuses.sum;
						if (tmpHowMany < howMany ){
							howMany = tmpHowMany;
							uses = tmpuses;
						}
					}
				}
			}
		}
		foreach(i,u;uses){if(u >0)writeln(coin[i]," ",u);}
	}
}
int howManyCoins(int pay){
	int res;
	foreach_reverse(c;coin){
		while(pay >= c){ 
			pay -= c;res ++;
		}
	} 
	return res;
}

Measured memory_bytes: 3192
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	N := readInt()
	i := readInt()
	println(N - i + 1)
}

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


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

const char * color = "RYGB";

int main() {
    int h, w, d; cin >> h >> w >> d;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int d1 = i + j;
            int d2 = i - j + (w - 1);
            int c = d1 / d % 2 + d2 / d % 2 * 2;
            //cout << d1 << ' ' << d2 << ' ' << c << endl;
            cout << color[c];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  printf("%.8lf",sqrt(((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1))));
}


Measured memory_bytes: 3204
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = input()


if int(N[-1]) in [2,4,5,7,9]:
    print("hon")
elif int(N[-1]) in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9632
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int findSumOfDigits(int);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int s;
    s = findSumOfDigits(n);
    if(n % s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 100

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;

#define maxn 500005

class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 200000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}



int dis[1005][1005] , dp[1005][1005] ;

int main()
{
    preprocess() ;

    int n , a , b , c , d ;

    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d) ;

    dis[0][0] = 1 ;

    for(int i=1; i<=n ; i++)
    {
        for(int j=1 ; j<=n ; j++)
        {
            if( i%j != 0 ) continue ;
            int k = i/j ;

            dis[i][j] = (1LL*C(i-1,k-1)*dis[i-k][j-1])%mod ;
          //  printf("%d %d: %d\n",i,j,dis[i][j]) ;
        }
    }

    for(int i=0 ; i<=n ; i++) dp[0][i] = 1 ;
//    dp[0][0] = 1 ;


    for( int i=1 ; i<=n ; i++ )
    {
        for(int j=a ; j<=b ; j++)
        {
            dp[i][j] = dp[i][j-1] ;

            for(int k=c ; k*j<=i && k<=d ; k++)
            {
                int ret = (1LL*C(i,k*j)*dis[k*j][k])%mod ;

                dp[i][j] = ( dp[i][j] + 1LL*dp[i-k*j][j-1]*ret )%mod ;
            }
       //     printf("---- %d %d: %d\n",i,j,dp[i][j]) ;
        }
    }

    printf("%d\n" , dp[n][b] ) ;

    return 0 ;
}


Measured memory_bytes: 11264
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
int s,w;
  cin>>s>>w;
  string ans="safe";
  if(w>=s) ans="unsafe";
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int N, Q; string S;
char c[200009], p[200009], d[200009];

int simulation(int pos) {
	for (int i = 1; i <= Q; i++) {
		if (pos == 0) return 1;
		if (pos == N + 1) return 3;

		if (d[pos] == c[i]) {
			if (p[i] == 'L') pos--;
			else pos++;
		}
	}

	if (pos == 0) return 1;
	if (pos == N + 1) return 3;
	return 2;
}

int main() {
	cin >> N >> Q >> S;
	for (int i = 1; i <= N; i++) d[i] = S[i - 1];
	for (int i = 1; i <= Q; i++) cin >> c[i] >> p[i];

	int L1 = 1, R1 = N + 1, M1, maxn = 0;
	for (int i = 0; i < 25; i++) {
		M1 = (L1 + R1) / 2;
		int Z = simulation(M1);
		if (Z == 1) { maxn = max(maxn, M1); L1 = M1; }
		else { R1 = M1; }
	}

	int L2 = 1, R2 = N + 1, M2, minx = N + 1;
	for (int i = 0; i < 25; i++) {
		M2 = (L2 + R2) / 2;
		int Z = simulation(M2);
		if (Z == 3) { minx = min(minx, M2); R2 = M2; }
		else { L2 = M2; }
	}

	cout << N - (maxn + (N + 1 - minx)) << endl;
	return 0;
}

Measured memory_bytes: 1156
import sys
import bisect
import heapq
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def sump(x, y, z, t):
    ans = z
    for i in range(t):
        ans += x[i] * y[i]

    return ans

def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    count =0
    for j in range(N):
        A = list(map(int,input().split()))
        if sump(A,B,C,M) >0:
            count +=1

    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 65412
#include <bits/stdc++.h>
using namespace std;
#define INFTY 1000000000

int main()
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int m = INFTY;
  // O(max(X, Y))のアルゴリズム
  for (int i = 0; i <= max(X, Y); i++)
  {
    // 2i枚ABピザを買う時の料金
    int tmp = C * (2 * i);
    if (X - i > 0)
    {
      tmp += A * (X - i);
    }
    if (Y - i > 0)
    {
      tmp += B * (Y - i);
    }
    m = min(m, tmp);
  }
  cout << m << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll ans = ston(s,1LL);
  ll S = s.size();
  s += "0";
  REP(i,1,1 << S){
    ll tmp = 0,tmp2 = 0;
    rep(j,S){
      if(i & (1 << j)){
        tmp *= 10;
        tmp += (s[j] -'0') ;
        tmp2 += tmp;
        tmp =0;
      }
      else{
        tmp *= 10;
        tmp += (s[j] -'0') ;
      }
    }
    if(tmp){
      ans += tmp2+tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

ll merge(int A[], int n, int left, int mid, int right)
{
    int i, j, k;
    ll cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for ( i = 0; i < n1; i++ ) {
        L[i] = A[left + i];
    }
    for ( i = 0; i < n2; i++ ) {
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i = 0;
    j = 0;
    for ( k = left; k < right; k++ ) {
        if ( L[i] <= R[j] ) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergeSort(int A[], int n, int left, int right)
{
    int mid;
    ll v1, v2, v3;
    if ( left + 1 < right ) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    return 0;
}

int main(void)
{
    int A[MAX], n, i;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
    }

    ll ans = mergeSort(A, n, 0, n);

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3304
#include <cstdio>
typedef long long ll;

const int P=1000000007;
int n,K,Ans,a[75],Fac[305],Inv[305];
char s[75];

inline int C(int n,int m){return (ll)Fac[n]*Inv[m]%P*Inv[n-m]%P;}

void Check(int num,int sum)
{
    int pos=num+1,res=Fac[num],rnum=0,leftr=0,nxt=0,left=0;
    for(int i=1;i<=K;++i)
        if(s[i]=='r') rnum<num?leftr+=(a[++rnum]>1):(left?--left:0);
        else leftr?(--leftr,left+=a[++nxt]-2):(left?--left:0);
    if(left||rnum<num||leftr) return;
    for(int i=1,j;i<=num;i=j+1)
    {
        for(j=i;j<num&&a[j+1]==a[i];++j);
        res=1LL*res*Inv[j-i+1]%P;
        pos+=(j-i+1)*(a[i]*2-1);
    }
    Ans=(Ans+1LL*res*C(n-sum+pos-1,pos-1))%P;
}
void DFS(int x,int num,int sum)
{
    if(sum>n) return;Check(num,sum);
    for(int i=x;i;--i) a[num+1]=i,DFS(i,num+1,sum+(i>1?i*2-3:1)+(num>0));
}

int main()
{
    scanf("%d%d%s",&n,&K,s+1),Fac[0]=Inv[0]=Fac[1]=Inv[1]=1;
    for(int i=2;i<=300;++i)Fac[i]=(ll)Fac[i-1]*i%P,Inv[i]=ll(P-P/i)*Inv[P%i]%P;
    for(int i=2;i<=300;++i)Inv[i]=(ll)Inv[i-1]*Inv[i]%P;
    return DFS(70,0,0),printf("%d\n",Ans),0;
}


Measured memory_bytes: 128
'''
たのん
DPをDP[i][j](i:前からi文字までをみている、
j:前からi文字みたとき、13で割ったあまりがjとなる数の個数)と定め、
初期値としてDP[0][0]=1とすると、
i番目の文字s[i]が整数のときはDP[i+1][(j*10+s[i])%13]+=DP[i][j]、
i番目の文字s[i]が?のときは各k(=0 to 9)について
DP[i+1][(j*10+k)%13]+=DP[i][j]と更新することで、
DP[-1][5]が求める答えに一致します。
前からi-1文字をみたときの13で割ったあまりがjであるとき、
それに1文字を付け足した数iを13で割ったあまりは、
前からi-1文字をみたときの数をnとすると、
n*10+i≡j*10+i(mod 13)より(j*10+i)%13で求められることから
上記の更新方法が出てきます。
'''
s=input()
l=len(s)
mod=10**9+7
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1 #初期値の設定
for i in range(l):
 if s[i]=='?': #?のときは各値(0～9)について更新する
   for j in range(10):
     for k in range(13):
       dp[i+1][(k*10+j)%13]+=dp[i][k]%mod
 else:
   for k in range(13): #整数のときはその値について更新する
     dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
print(dp[-1][5]%mod) 
#最後まで更新を行ったときのあまりが5となる数の個数が答

Measured memory_bytes: 66268
#include <stdio.h>

int main(){
  int x,y,k;
  
  scanf("%d",&x);
  scanf("%d",&y);
  
  if(x>=y){
    while(x%y != 0){
      k=y;
      y=x%y;
      x=k;
    }
   printf("%d\n",y);
  }

  if(x<y){
    while(y%x != 0){
      k=x;
      x=y%x;
      y=k;
    }
   printf("%d\n",x);
  }

  
   return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);
    rep(i, m) cin >> s[i] >> c[i];
    vector<int> keta;
    rep(i, 1000) {
        int tmp_num = i;
        keta.clear();
        if ( tmp_num == 0 ) keta.push_back(0);
        while ( tmp_num > 0 ) {
            keta.push_back(tmp_num % 10);
            tmp_num /= 10;
        }
        reverse(keta.begin(), keta.end());
        bool ok = true;
        rep(j, m) {
            rep(k, keta.size()){
                if ( s[j] == ( k + 1 ) ) {
                    if ( keta[k] != c[j] ) {
                        ok = false;
                        break;
                    }
                }
            }
            if ( !ok ) break;
        }
        if ( ok ) {
            if ( n == 3 && i >= 100 ) {
                cout << i << endl;
                return 0;
            } 
            if ( n == 2 && i < 100 && i >= 10 ) {
                cout << i << endl;
                return 0;
            }
            if ( n == 1 && i < 10 ) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
#define INF 0x3f3f3f3f
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m, k;
int s[1005][15], a[15][1005], t[15];
vector<int> v;

int solve(){
    int res = 0;
    for(int i = 1; i <= m; i++){
        int flag = 0;
        for(int j = 1; j < v.size(); j++){
            if(s[i][v[j]]-s[i][v[j-1]] > k) return INF;
            t[j] += s[i][v[j]]-s[i][v[j-1]];
            if(t[j] > k) flag = 1;
        }
        if(flag){
            res++;
            for(int j = 1; j < v.size(); j++){
                t[j] = s[i][v[j]]-s[i][v[j-1]];
            }
        }
    }
    return res;
}

int main()
{
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            scanf("%1d", &a[i][j]);
        }
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            s[i][j] = s[i][j-1]+a[j][i];
        }
    }
    int ans = INF;
    for(int i = 0; i < (1<<n-1); i++){
        v.clear();
        v.push_back(0);
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if((i>>j)&1) v.push_back(j+1), cnt++;
        }
        v.push_back(n);
        for(int i = 1; i < v.size(); i++) t[i] = 0;
        cnt += solve();
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

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

b_acm = 0
mod_m_counts = {}
for ai in a:
    b_acm = (b_acm + ai) % m
    mod_m_counts.setdefault(b_acm, 0)
    mod_m_counts[b_acm] += 1

count = 0
for k, v in mod_m_counts.items():
    count += v * (v - 1) // 2
    if k == 0:
        count += v

print(count)


Measured memory_bytes: 16100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
int A[110];


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int M = *max_element(RNG(A, N));
	int m = *min_element(RNG(A, N));

	cout << M-m << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.math.*;

public class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x*2<=y && x*4>=y && y%2==0){
                System.out.println("Yes");

            } else{
                System.out.println("No");

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 32856
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  llong ans = 0;
  llong N;
  cin >> N;
  for(int i=1; i<=N; ++i){
    if(i%3!=0 && i%5!=0) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
s = input()
L = 0
R = len(s)-1
ans = 0
while L < R:
    if s[L] == s[R]:
        L += 1
        R -= 1
    elif s[L] == 'x' and s[R] != 'x':
        ans += 1
        L += 1
    elif s[L] != 'x' and s[R] == 'x':
        ans += 1
        R -= 1
    elif s[L] != s[R] and s[L] != 'x' and s[R] != 'x':
        ans = -1
        break
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


void solve(){
	int a;
	cin>>a;
	if(a<=999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	string s;
	cin >> n;
	ll a[n],b[n],c[n];
	rep(i,n){
		cin >> a[i];
	}
	rep(i,n){
		cin >> b[i];
		ans += b[i];
	}
	rep(i,n-1){
		cin >> c[i];
		// if(a[i+1]==a[i]+1){
		// 	ans += c[i];
		// }
	}

	rep(i,n){
		rep(j,n){
			if(a[j]==i+1 && a[j+1]==i+2){
				ans += c[i];
				//cout << c[i] << endl;
			}
		}
	}

	

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,c;
	cin>>n>>c;
	vvp in(c);
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		c--;
		in[c].pb({a,b});
	}
	vi dp(100010);
	rep(i,c){
		sort(all(in[i]));
		rep(j,in[i].size()){
			if(j+1<in[i].size()&&in[i][j].second==in[i][j+1].first){
				in[i][j+1].first=in[i][j].first;
			}else{
				dp[in[i][j].first-1]++;
				dp[in[i][j].second]--;
			}
		}
	}
	rep(i,100010-1)dp[i+1]+=dp[i];
	int ma=0;
	rep(i,100010)ma=max(ma,dp[i]);
	cout<<ma<<endl;
}







Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <vector>

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

    std::vector<long long> D(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> D[i];
    }

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

    const int idx = N / 2;
    const auto ret = D[idx] - D[idx - 1];
    
    std::cout << ret << std::endl;
}


Measured memory_bytes: 1024