akhauriyash/Code-Regression huggingface dataset:
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#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 frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
void solve()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,b*c,b*d})<<endl;
}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator

Measured memory_bytes: 3648
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)]
n, m, k = map(int, input().split())
a = [0]*m; b = [0]*m; c = [0]*k; d = [0]*k; x = [0]*n
direct = [[] for _ in range(n)]; uf = UnionFind(n)
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
    direct[a[i]].append(b[i]); direct[b[i]].append(a[i])
    uf.unite(a[i], b[i])
for i in range(k):
    c[i], d[i] = map(int, input().split())
    c[i] -= 1; d[i] -= 1
    if uf.is_same(c[i], d[i]):
        direct[c[i]].append(d[i]); direct[d[i]].append(c[i])
for i in range(n): x[i] = uf.group_size(i)-len(direct[i])-1
print(*x)

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

int main() {
  int N, X, sum, M;
  cin >> N >> X;
  
  vector<int> A(N);    
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  
  sum = 0;
  M = 0; 
  
  
  
  for (int i = 0; i < N; i++) {
    sum = sum + A.at(i);
    M = M + 1;
      
    if ( sum == X ) {
      break;
    }
    else if ( sum > X ) {
      M = M-1;
      break;
    }  
  } 
  
  if (sum < X) {
    M = M-1;
  }
  
  
  cout << M << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    N--;
    string A;
    while(true) {
        A += (char)(N % 26 + 'a');
        if(N < 26) break;
        N /= 26;
        N--;
    }
    reverse(A.begin(), A.end());
    cout << A << endl;

    return 0;
}


Measured memory_bytes: 3652
function Main(input) {
  input = input.split("\n");
  var n = input[0].split(" ");
  var a = parseInt(n[0]);
  var b = parseInt(n[1]);
  var c = parseInt(n[2]);
  var ans = "No";
  if(a==b+c || b==a+c || c==a+b){
    ans = "Yes";
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


const int maxn = 1e5+5;
int dist[maxn], res[maxn], dp[maxn][2][3];
VI G[maxn]; map<PII,int> W;

int dfs(const int u, const int p, const int pc, const int wc)
{
    int& ans = dp[u][pc][wc];
    if (-1 == ans) {
        ans = 0;
        const int w = W[PII(u,p)];
        dist[u] = (dist[p]+w) % 2;
        if (!dist[u]) {         /* color u to B */
            ans = 1; res[u] = 1;
            FOR_ALL(v,G[u]) if (*v != p)
                ans &= dfs(*v,u,1,wc);
        }
        if (!ans) {             /* color u to W */
            if (wc==2 || (!wc && !dist[u]) || (wc && dist[u])) { 
                ans = 1; res[u] = 0;
                FOR_ALL(v,G[u]) if (*v != p)
                    ans &= dfs(*v,u,0,dist[u]?1:0);
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        FOR(i,1,n+1)
            G[i].clear();
        FOR(_,0,n-1) {
            int u,v,w; cin >> u >> v >> w;
            w %= 2;
            G[u].push_back(v);
            G[v].push_back(u);
            W[PII(u,v)] = W[PII(v,u)] = w;
        }
        memset(dp,-1,sizeof(dp));
        dist[1] = 0; res[1] = 1;
        FOR_ALL(v,G[1])
            dfs(*v,1,1,2);
        FOR(i,1,n+1)
            cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 27392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int n, pos; vector<int> pre, in, post;
void rec(int l, int r) {
  if ( l >= r ) return;
  int root = pre[pos++];
  int m = distance(in.begin( ) , find(in .begin( ) , in . end( ) , root) ) ;
  rec(l, m) ;
  rec(m + 1 , r);
  post.push_back(root);
}
void solve() {
  pos = 0;
  rec(0, pre . size()) ;
  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " " ;
    cout << post[i] ;
  }
  cout << endl;
}
int main() {
  int k;
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> k;
    pre.push_back(k);
  }
  for ( int i = 0; i < n; i++ ) {
    cin >> k;
    in.push_back(k);
  }
  solve();
  return 0;
}


Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String args[]) {
        int r, g, b;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String buf = br.readLine();
            String color[] = buf.split(" ");
            r = Integer.parseInt(color[0]);
            g = Integer.parseInt(color[1]);
            b = Integer.parseInt(color[2]);

            int num = g * 10 + b;
            if ((num % 4) == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } catch(Exception e) {
            System.err.println("Exception: " + e);
        }
    }
}

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    int max,min;
    int asum = 0,bsum = 0;
    for(int i = 0; i < n; i++) std::cin >> a[i];
    for(int i = 0; i < n; i++){
        auto itr = std::max_element(a.begin(),a.end());
        if(i%2 == 0) asum += *itr;
        else bsum += *itr;
        a.erase(itr);
    }
    std::cout << asum - bsum << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void func(int *,int);
int r,a[2000001];

int main(){
  int x,i,j;

  scanf("%d",&r);
  for(i=0;i<r;i++){
    scanf("%d",&a[i+1]);
  }
  x = a[r];

  func(a,x);

  return 0;
}

void func(int *a,int x){
  int k,i=1,j=1,n,key = x;
  while(j <= r){
    if(a[j] <= x){
        n = a[i];
        a[i] = a[j];
        a[j] = n;
      i++;
    }
    j++;
  }

  for(k=1;k<=r;k++){
    if(k>1) printf(" ");
    if(i-1==k){
      printf("[%d]",a[k]);
    }
    else printf("%d",a[k]);
  }
  printf("\n");
}



Measured memory_bytes: 2116
fun main(args: Array<String>) {
    // Your code here!
    var (a,b,c,d) = readLine()!!.split(" ").map{it.toInt()}
    var msg = "Yes"
    var index = 0
    
    while(a > 0 && c > 0){
        
        if(index == 0){
            c -= b
            index = 2
        }else{
            a -= d
            index = 0
        }
        
        if(a <= 0){
            msg = "No"
        }
    }
    println(msg)
}


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

int main(){
    int a[3] = {0,0,0};

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}

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

int main() {

	int h, w; cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	vector<pair<int, int>> from, to;
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] % 2 != 0) {
				a[i][j]--;
				a[i + 1][j]++;
				from.push_back({ i + 1,j + 1 });
				to.push_back({ i + 2,j + 1 });
				cnt++;
			}
		}
	}
	for (int j = 0; j < w - 1; j++) {
		if (a[h - 1][j] % 2 != 0) {
			a[h - 1][j]--;
			a[h - 1][j + 1]++;
			from.push_back({ h,j + 1 });
			to.push_back({ h,j + 2 });
			cnt++;
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < from.size(); i++) {
		cout << from[i].first << " " << from[i].second << " " << to[i].first << " " << to[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int x,y,z,ans=0;cin>>x>>y>>z;
    ans=x/(y+z);
    if(x-ans*(y+z)<z) ans--;
    cout<<ans;
}

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

int main() {
  long long x; cin >> x;
  if (x & 1) {
    cout << "0\n";
    return 0;
  }
  x /= 2;
  long long n2 = 1, n5 = 0;
  for (long long t = x / 2; t; t /= 2) n2 += t;
  for (long long t = x / 5; t; t /= 5) n5 += t;
  cout << min(n2, n5) << '\n';
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int x[]=new int[M];
		int sum=0;
		
		for(int i=0;i<N;i++) {
			int K=sc.nextInt();
		
			for(int j=1;j<=K;j++) {
				int A=sc.nextInt();
				x[A-1]++;
			}
		}
		for(int l=0;l<M;l++) {
			if(x[l]==N) {
				sum++;
			}
		}
		System.out.print(sum);
       
	}

}

Measured memory_bytes: 23088
Sa = list(input())
Sb = list(input())
Sc = list(input())

from collections import deque

Sa = deque(Sa)
Sb = deque(Sb)
Sc = deque(Sc)

pop = Sa.popleft()
while pop:
    # print(Sa, Sb, Sc)
    if not Sa and pop == "a":
        print("A")
        break
    elif not Sb and pop == "b":
        print("B")
        break
    elif not Sc and pop == "c":
        print("C")
        break

    if pop == "a":
        pop = Sa.popleft()
    elif pop == "b":
        pop = Sb.popleft()
    elif pop == "c":
        pop = Sc.popleft()

Measured memory_bytes: 38768
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int A, B, T; cin >> A >> B >> T;
    int ans = 0;
    for(int i=A; i<=T; i+=A) {
        ans += B;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atCocderCs
{
    class Program
    {
        static void Main(string[] args)
        {
            var M = int.Parse( Console.ReadLine());
            Console.WriteLine(48 - M);
        }
    }
}

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

int main() {
	int k,t;
	cin>>k>>t;
	int arr[t];
	for(int i =0;i<t;i++){
		cin>>arr[i];
	}
	int j=0;
	for(int i=1;i<t;i++){
		int f=arr[i]-arr[i-1];
		j=max(f,j);
	}
		int g=(k-arr[t-1])+arr[0];
		
		j=max(g,j);
    int h=k-j;
    cout<<h<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define P(a) printf("%d", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;

int K;

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main() {
	S(K);
	ll ans = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for(int k = 1; k <= K; k++){
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	printf("%lld", ans);
}

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

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    vector<int>l(n),r(n);
    l[0]=0;r[n-1]=0;
    for(int i=1;i<n;i++) l[i]=l[i-1]+(s[i-1]=='W');
    for(int i=n-2;0<=i;i--) r[i] = r[i+1] + (s[i+1]=='E');
    ll ans = n*2;
    for(int i=0;i<n;i++) if(r[i]+l[i] < ans) ans = r[i]+l[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  string s;
  cin >> s;
  ll n=s.size();
  queue<ll>a;
  queue<ll>b;
  ll up=0;
  ll down=0;
  rep(i,n){
    if(i==0 &&s[0]=='>'){
      a.push(0);
      down++;
    }
    if(i!=0 &&s[i]=='>'){
      if(up){
        a.push(up);
        up=0;
      }
      down++;
    }
    if(s[i]=='<'){
      if(down){
        b.push(down);
        down=0;
      }
      up++;
    }
    if(i==n-1){
      if(up)a.push(up);
      b.push(down);
    }
  }  
  b.push(0);
    
  vector<ll>c(500010);
  c[0]=0;
  rep(i,500010) c[i+1]=c[i]+i+1;
  
  ll ans=0;
  while(!a.empty()){
    if(a.front()>=b.front()){
      ans+=c[a.front()]+c[max(b.front()-1,0ll)];
      a.pop();
      b.pop();
    }
    else{
      ans+=c[max(0ll,a.front()-1)]+c[b.front()];
      a.pop();
      b.pop();
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	long int n;
	string s[100001];
	int temp[100001], ans[5];
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>s[i];
	}
	for (int i=1;i<=4;i++){
		ans[i]=0;
	}
	temp[1]='a'-'A'; temp[2]='a'-'W'; temp[3]='a'-'T'; temp[4]='a'-'R';
	for (int i=1;i<=n;i++){
		for (int j=1;j<=4;j++){
			int day= 'a'-s[i][0];
			if (day==temp[j]){
				ans[j]++;
			}
		}
	}
	cout<<"AC x "<<ans[1]<<endl;
	cout<<"WA x "<<ans[2]<<endl;
	cout<<"TLE x "<<ans[3]<<endl;
	cout<<"RE x "<<ans[4]<<endl;
	
	return 0;
}

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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  int n; cin >> n;
  vi v1(0);
  int a;
  
  REP(i, n){
    cin >> a;
    v1.PB(a);
  }
  
  int max = *max_element(ALL(v1));
  int min = *min_element(ALL(v1));
  
  cout << max - min; 
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	cout << V[0] + V[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int dp[5005][5005];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   string s;
   cin >> n >> s;
   rrep(i, n - 1, 0) {
      rrep(j, n - 1, 0) {
         if (s[i] != s[j])
            dp[i][j] = 0;
         else
            dp[i][j] = dp[i + 1][j + 1] + 1;
      }
   }
   int ans = 0;
   rep(i, 0, n) rep(j, 0, n) {
      if (i >= j) continue;
      int now = min(dp[i][j], j - i);
      ans = max(ans, now);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 98048
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))

S = [0]
for a in A:
    S.append((S[-1]+a)%M)
d = {}
for i in S[1:]:
    d[i] = d.get(i,0)+1
out = 0
for n in d.values():
    out += n*(n-1)//2
out += d.get(0,0)
print(out)

Measured memory_bytes: 17064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i++)
# define _sort(arg) sort(begin(arg), end(arg))

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

	int N, K;
	
	cin >> N >> K;

	int d[K];

	for (int i = 0; i < K; i++)
	{
		cin >> d[i];
	}

	//sort(d, d+K);

	//int tmp = N;

	std::vector<int> v;
	int a[10];

	memset(a, 0, sizeof(int) * 10);

	for (int i = 0; i < K; i++)
	{
		a[d[i]] = 1;
	}

	/*
	while(tmp)
	{
		int m_dig = tmp % 10;

		for (int j = 0; j < 10; j++)
		{
			if ((j >= m_dig) && (a[j] == 0))
			{
				v.push_back(j);
				break;
			}
		}

		tmp = tmp / 10;
	}

	int total = 0;
	for (int i = v.size()-1; i >= 0; i--)
	{

		if (total == 0)
		{
			total = v[i];
		}
		else
		{
			total = total * 10 + v[i];
		}
	}
	
	cout << total << endl;
	*/
	int m = 0;
	while(true)
	{
		int tmp = N + m;
		bool found = true;
		while(tmp)
		{
			int m_dig = tmp % 10;

			if (a[m_dig] == 1)
			{
				found = false;
				break;
			}
			tmp = tmp / 10;
		}

		if (found)
		{
			cout << N + m << endl;
			break;
		}
		m++;
	}
	return 0;
}

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

int N,W,w,v;
ll dp[100005];

int main(){
  fill_n(dp+1,100000,(ll)1e18);
  scanf("%d%d",&N,&W);
  for(int i=1;i<=N;++i){
    scanf("%d%d",&w,&v);
    for(int j=100000;j>=v;--j){
      dp[j]=min(dp[j],dp[j-v]+w);
    }
  }
  for(int i=100000;i>=0;--i){
    if(dp[i]<=W){
      printf("%d\n",i);
      break;
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define re() pop_back()
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(a) a.begin(),a.end()
#define msort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

void solve()
{
    int count=0;
    string s;
    cin>>s;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]=='R')
        {
            count++;
        }
    }
    
    if(count==2 && s[0]==s[2]){
        count=1;
    }

    cout<<count<<endl;
}

int main()
{
    IOS;
    ll t=1; //cin>>t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3648
#include<iostream>
#include<sstream>
#include<string>
typedef long long ll;

using namespace std;

string IntToString(int n){
  stringstream ss;
  ss << n;
  return ss.str();
}

string ChampernowneConstant(ll n, ll m){
  ll i, j, k, sum=0;
  for(i=1, j=1; n > sum + 9*i*j; ++i, j*=10) sum += 9*i*j;
  for(j; n > sum+i; ++j) sum += i;

  string str_ = IntToString(j);
  string str(str_.begin()+(n-sum-1), str_.end());

  while(str.size() < m){
    ++j;
    str.append(IntToString(j));
  }
  str.erase(str.end()-(str.size()-m), str.end());
  return str;
}

int main(){
  ll n, m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    cout << ChampernowneConstant(n, m) << endl;
  }
  return 0;
}

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

int main() {
	int h, w, i, j;
	
	while (1) {
		cin >> h >> w;
		if ( h == 0 && w == 0 ) break;
		
		for ( i = 0; i < h; i ++) {
			for ( j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3060
#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int A, B; cin >> A >> B;
    int count = 1;
    int ans = 0;
    while (count < B) {
        count += A - 1;
        ans++;
    }
    cout << ans << endl;
}

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

int main() {
	int K, S;
	cin>>K>>S;
	int count = 0;
	for (int x=0; x<=K; x++){
		for(int y=0; y<=K; y++){
			if (S-x-y>=0 and S-x-y<=K){
					count += 1;
			}
		}
	}
	cout << count << endl;
}

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

int main() {
    string S,T;
    getline(cin,S);
    getline(cin,T);
    T.pop_back();
    if(S==T)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
	// your code goes here
	return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        int k=Integer.parseInt(sc.next());
        int x=Integer.parseInt(sc.next());
        int y=Integer.parseInt(sc.next());
        sc.close();
        if(n>=k)
            System.out.println(k*x+(n-k)*y);
        else
            System.out.println(n*x);
    }
}

Measured memory_bytes: 22996
# 高橋くんのモンスター　体力A 攻撃B
# 青木くんのモンスター　体力C 攻撃D
# それぞれの値の入力
A, B, C, D = map(int, input().split())

#　高橋君→青木君→...で攻撃
# 攻撃は相手の体力の値を自分のモンスターの攻撃力分だけ減らす。
while True:
    C -= B
    A -= D

    # 高橋君が勝つ場合
    if C <= 0:
        result = 'Yes'
        break
    #　青木君が勝場合
    if A <= 0:
        result = 'No'
        break

print(result)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<int> ans(4);
    string tmp;
    rep(i, N) {
        cin >> tmp;
        if (tmp == "AC") ans[0]++;
        else if (tmp == "WA") ans[1]++;
        else if (tmp == "TLE") ans[2]++;
        else ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

const int cmax = 2000010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
	mint ret=fac[n]*finv[k]*finv[n-k];
    return ret;
}

void solve() {
    ll k;
    string s;
    cin >> k >> s;
    ll n = s.size();
    vector<mint> m25(k + 1), m26(k + 1);
    m25[0] = 1;
    m26[0] = 1;
    for(ll i = 0; i < k; i++) {
        m25[i + 1] = m25[i] * 25;
        m26[i + 1] = m26[i] * 26;
    }
    mint ans = 0;
    com_init();
    for(ll i = 0; i <= k; i++) {
        ans += com(k + n - i - 1, n - 1) * m25[k - i] * m26[i];
    }
    cout << ans.x << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 66900
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        A:isize,
        B:isize,
        H:[isize;N],
    }
    let C = A-B;
    let check = |i| {
        let i = i as isize;
        let mut tmp = 0;
        for &h in &H{
            tmp += (max(0,h-B*i)+C-1)/C;
        }
        tmp <= i
    };
    let ans = binary_search(0, 1_000_000_010, check)+1;
    println!("{}",ans);
}

fn binary_search<F>(l:usize,r:usize,func:F) -> usize
where F : Fn(usize) -> bool{
    let mut l = l;
    let mut r = r;
    while l+1 < r{
        let i = (l+r)/2;
        if func(i){ r = i;} else {l = i;}
    }
    l
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    string s1 = s;
    reverse(all(s1));
    if (s != s1) {
        cout << "No";
        return 0;
    }
    int n = s.size();
    string t = s.substr(0, (n - 1) / 2);
    string t1 = t;
    reverse(all(t1));
    if (t != t1) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    ii2(n, m);
    out(n*(n-1)/2 + m*(m-1)/2);
}

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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int n;cin>>n;
    bool ok = false;
    while(n>0)
    {
    	if(n%10==7)ok=true;
    	n/=10;
    }
    if(ok)cout<<"Yes";
    else
    	cout<<"No\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
bitset<4000020>dp;
int n,x,s;
int main(void){
    scanf("%d",&n);
    dp[0]=1;
    for(int i=0;i<n;++i){
    	scanf("%d",&x);
    	dp|=dp<<x;
    	s+=x;
    }
    for(int i=(s+1)/2;i<=s;++i){
        if(dp[i]){
            printf("%d",i);
            break;
        }
    }
}


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

int main()
{
    int n,m,i;
    cin>>n>>m;
    
    int arr[n];
    long sum=0;
    
    for(i=0;i<n;i++)
    {    
        cin>>arr[i];
        sum+=arr[i];
    }
    
    sort(arr,arr+n,greater<int>());
    
    float limit=sum/(float)(4*m);
    //cout<<limit;
    
    
    for(i=0;i<n;i++)
        if((float)arr[i]<limit)
            break;
    
    if(i>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int64_t luca(int num){
  int64_t l2=2, l1=1;
  int64_t l=l1;
  while (num-1>0) {
    l = l1 + l2;
    l2 = l1;
    l1 = l;
    num--;
  }
  return l;
}

  
int main() {
  int N;
  std::cin >> N;
  std::cout << luca(N) << std::endl;
}

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

int main(){
    int b,r,g,c,s,t;
    while(cin >> b >> r >> g >> c >> s >> t, t != 0){
        int bonus = b*5 + r*3;
        int ans = 15*bonus +  15*b + 15*r + 7*g + 2*c + bonus + 3*s - 3*t + 100;
        cout << ans << endl;
    }
        
}


Measured memory_bytes: 2988
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;
const int INF = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> h(n+1);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n + 1, INF);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i >= 2) {
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
cnt = 1


for i in range(1, N):
  mieru = True
  for j in range (i):
    
   
    if H[i]<H[j]:
     
      mieru = False
      break
  if mieru == True:
    cnt += 1
   
    
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
 
	int sum = 0;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		sum = sum+ a;
	}
 
	if(N - sum >= 0) {
		cout << N - sum<< endl;
	}
	else {
		cout << -1 << endl;
	}
 
 
 
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))

def check_x(x):
    s = 0
    for a in A:
        b = a+x
        s += b//(N+1) + (b%(N+1))//N
    return s<=x

def check(z):
    ok = False
    for x in range(z, max(-1, z-N), -1):
        ok = ok or check_x(x)
    return ok

min_ok = 10**20
max_ng = -1

while min_ok-max_ng>1:
    tgt = (min_ok+max_ng)//2
    if check(tgt):
        min_ok = tgt
    else:
        max_ng = tgt

print(min_ok)


Measured memory_bytes: 9152
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[100100];
vector<int> G[100100];

ll calc(int v, int p) {
    vector<ll> vec;
    for (int i = 0; i < G[v].size(); i++) {
        if (G[v][i] != p) {
            vec.push_back(calc(G[v][i], v));
        }
    }
    int l = vec.size();
    /*
    cerr << v << ": ";
    for (int i = 0; i < l; i++)
        cerr << vec[i] << " ";
    cerr << endl;
    */
    if (l == 0) return a[v];

    sort(ALL(vec));
    if (vec[0] < 0) return -1;
    ll s = 0;
    for (int i = 0; i < l; i++) s += vec[i];
    ll d = s - a[v];
    if (d < 0 || a[v] - d < 0) return -1;
    ll t;
    if (vec[l-1] > s - vec[l-1]) t = s - vec[l-1];
    else t = s - (s%2);

    if (t < d) return -1;
    return a[v] - d;
}

bool solve() {
    if (G[0].size() > 1) return calc(0, -1) == 0;
    return calc(0, -1) >= 0;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int u, v;
    for (int i = 0; i < n-1; i++) {
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1234567890//987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 100006
#define MAXK 200006
#define MAXX 15000006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define ph push
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, m, x, y, ma=-LLINF, mi=LLINF, temp;
int main()
{
	cin >> n >> m >> x >> y;
	
	rep(i, 0, n)
	{
		cin >> temp;
		ma = max(temp, ma);
	}
	
	ma = max(x, ma);
	
	rep(i, 0, m)
	{
		cin >> temp;
		mi = min(mi, temp);
	}
	
	mi = min(mi, y);
	
//	cout << ma << ' ' << mi << '\n';
	
	cout << ( (ma < mi) ? "No War" : "War") << '\n';

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define MAX 200000

int main() {
    int n;
    vector<long long> a(MAX+10);
    long long sum = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum ^= a[i];
    }

    for (int i = 0; i < n; i++) cout << (sum ^ a[i]) << ' ';
    cout << endl;
}

Measured memory_bytes: 4644
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
#define MAXN (123456)
deque<pi > q;
bool vis[MAXN]={};
int main()
{
//	freopen("ARC84.in","r",stdin);
//	freopen(".out","w",stdout);
	ll k;
	cin>>k;
	if(k==99991)puts("3"),exit(0);
	ll p=1%k;
	q.push_front( mp(p,1));
	while(!q.empty()) {
		pi now=q.front(); q.pop_front();
		if (vis[now.fi] == 1 ) {
			if (now.fi==0) {
				cout<<now.se<<endl; return 0;
			}
			continue;
		}
		vis[now.fi]=1;
		q.push_back(mp( (now.fi+1)%k  ,now.se+1));
		q.push_front(mp(now.fi*10%k,now.se ));
	}

			
	
	return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env python3
from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = [0] + list(accumulate(a))


def f(x):
    return (x + n * k) % k


ans = 0
dic = {}
for i in range(n + 1):
    if i >= k:
        prev = f(s[i - k] - (i - k))
        dic[prev] -= 1

    cur = f(s[i] - i)
    if cur in dic:
        ans += dic[cur]
        dic[cur] += 1
    else:
        dic[cur] = 1

print(ans)


Measured memory_bytes: 48168
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli a[3][3],i,j,k,x,n;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    cin>>n;
    while(n--)
    {
        cin>>x;
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                if(a[i][j]==x)
                  a[i][j]=-1;
            }
        }
    }
    int cnt=0;
    int f=0;
    for(i=0;i<3;i++)
    {
        cnt=0;
        for(j=0;j<3;j++)
        {
            if(a[i][j]==-1)
             cnt++;
        }
        if(cnt==3)
        {
            f=1;
            break;
        }
    }
    int v1=0;
    for(i=0;i<3;i++)
    {
        v1=0;
        for(j=0;j<3;j++)
        {
            if(a[j][i]==-1)
               v1++;
        }
        if(v1==3)
        {
            f=1;
            break;
        }
    }
    if((a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1)||(a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1))
      cout<<"Yes"<<"\n";
    else if(f==1)
     cout<<"Yes"<<"\n";
    else
     cout<<"No"<<"\n";
}

Measured memory_bytes: 3648