akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<string>w(3);
    w[0]="Sunny";
    w[1]="Cloudy";
    w[2]="Rainy";
    string str;
    cin>>str;
    for(int i=0;i<3;i++){
        if(w[i]==str){
            i=(i+1)%3;
            cout<<w[i];
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

int main(){

	int A, B ,X;
	cin >> A >> B >> X;

	if( A>X ){
		cout << "NO" <<endl;
	}

	else if((A+B)<X){
		cout << "NO" <<endl;
	}
  	else{
      cout << "YES" <<endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#define int long long
using namespace std;
int INF = 1000000000;
struct SegmentTree{
private:
  int n;
  vector<int> node;
public:
  SegmentTree(vector<int> v){
    int sz = v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1,0);
    for(int i = 0; i < sz; ++i) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; --i) node[i] = max(node[2*i+1],node[2*i+2]);
  }
  void update(int x, int val){
    x += (n-1);
    node[x] = val;
    while(x > 0){
      x = (x-1)/2;
      node[x] = max(node[2*x+1],node[2*x+2]);
    }
  }
  int getmax(int a, int b, int k = 0, int l = 0, int r = -1){
    if(r < 0) r = n;
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return node[k];
    int vl = getmax(a,b,2*k+1,l,(l+r)/2);
    int vr = getmax(a,b,2*k+2,(l+r)/2,r);
    return max(vl,vr);
  }
};
signed main(){
//int main(){
  int n, s = 0;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; ++i){
    cin >> x[i];
    s += x[i];
  }
  SegmentTree st(vector<int>(n+1,0));
  for(int i = 0; i < n; ++i){
    int t = st.getmax(0,x[i]);
    //cout << x[i] << " " << t << endl;
    st.update(x[i],t+x[i]);
  }

  cout << s - st.getmax(0,n+1) << endl;
  return 0;
}

Measured memory_bytes: 6520
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int64_t n;
  cin>>n;
  int64_t result=0;

  int64_t m=1;

  while(m<n){
    if(n%m!=0&&(n%m)%(n/m)==0){
      result+=m+((n%m)/(n/m)-1);
    }
    m+=(n%m)/(n/m)+1;
  }

  cout<<result<<endl;



  return 0;
}


Measured memory_bytes: 888
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

sum_a = sum(A)

d = Counter(A)

for _ in range(int(input())):
    b, c = map(int, input().split())
    temp = d[b]         
    d[b] -= temp
    d[c] = d.get(c, 0) + temp
    sum_a += (c - b) * temp
    print(sum_a)

Measured memory_bytes: 24116
#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>;

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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;
  }
};

int main() {
  ll MOD = pow(10, 9) + 7;
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<map<int64_t, int>> factors(N);
  rep(i, N) cin >> A[i];
  rep(i, N) factors[i] = prime_factor(A[i]);
  map<int64_t, int> factor;
  rep(i, N){
    map<int64_t, int> tmp = factors[i];
    for(auto itr = tmp.begin(); itr != tmp.end(); ++itr){
      int64_t key = itr -> first;
      if(factor.find(key) != factor.end()){
        // 設定されている場合 2つのmaxを取って再設定する
        factor[key] = max(factor[key], tmp[key]);
      }else{
        // 設定されていない場合
        factor[key] = tmp[key];
      }
    }
  }
  // 最小公倍数を素因数分解した結果から答えを求める
  mint ans = 0;
  mint lcm = 1;
  for(auto itr = factor.begin(); itr != factor.end(); itr++){
    int64_t key = itr -> first;
    lcm *= mint(key).pow(factor[key]);
  }
  for(auto a: A){
    ans += lcm / a;
  }
  cout << ans.x << endl;
  return 0;
}



Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    int r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    ll ans = 0;
    for(int i=0 ; i<k ; i++){
        vector<ll> tt;
        for(int j=i ; j<t.size() ; j+=k){
            tt.push_back((int)t[j]);
        }
        vector<vector<ll>> dp(tt.size(),vector<ll>(3,0));
        //TLE防止のため
        for(int w=0 ; w<tt.size() ; w++){
            if(w==0){ //最初
                if(tt[0]=='r'){
                    dp[0][2]=p, dp[0][1]=0, dp[0][0]=0;
                }
                if(tt[0]=='s'){
                    dp[0][2]=0, dp[0][1]=0, dp[0][0]=r;
                }
                if(tt[0]=='p'){
                    dp[0][2]=0, dp[0][1]=s, dp[0][0]=0;
                }
                continue;
            }
            for(int j=0;j<3;j++){
               if(j==0){
                    int pre=max(dp[w-1][1],dp[w-1][2]);
                    if(tt[w]==(int)'s') {
                        dp[w][j]=pre+r;
                    }
                    else dp[w][j]=pre;
                }
                if(j==1){
                    int pre=max(dp[w-1][0],dp[w-1][2]);
                    if(tt[w]==(int)'p') {
                        dp[w][j]=pre+s;
                    }
                    else dp[w][j]=pre;
                }
                if(j==2){
                    int pre=max(dp[w-1][0],dp[w-1][1]);
                    if(tt[w]==(int)'r') {
                        dp[w][j]=pre+p;
                    }
                    else dp[w][j]=pre;
                }
            }
        }
        ans+=max({dp[tt.size()-1][0],dp[tt.size()-1][1],dp[tt.size()-1][2]});
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int n = s.size(), ans = 0, i = 0, j = n-1;
	while (i < n / 2) {
		if (s[i] != s[j]) {ans++;}
		i++;
		j--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  map<int, int> m;
  rep(i, h) rep(j, w) m[a[i][j] - 'a']++;
  vector<int> cnt(2, 0);
  if (h % 2 == 1) cnt[0] += w / 2;
  if (w % 2 == 1) cnt[0] += h / 2;
  if (h % 2 == 1 && w % 2 == 1) cnt[1]++;
  rep(i, 26) {
    if (m[i] % 2 == 1) {
      if (cnt[1]-- == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (m[i] % 4 >= 2) {
      if (cnt[0]-- == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;



  return 0;
}

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

int main(){
	string s;
	cin>>s;
	int a[26];
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;i<s.size();i++)a[(int)(s[i]-96)]++;
	for(int i=0;i<26;i++)if(a[i]%2==1){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
from operator import itemgetter
from collections import Counter

N, K = [int(v) for v in input().split()]
sushi = [tuple(int(v) for v in input().split()) for i in range(N)]

sushi = sorted(sushi, key=itemgetter(1), reverse=True)

#
# kind_counter = Counter([s[0] for s in ate_list])
# kind_cnt = len(list(kind_counter))

##
# すでにでてきたかどうかがわかれば良いので Counter を使う必要はない
# (数える必要ない)
##

kind = set()
can_converts = []  # 変更しても良いよリスト
max_pt = 0

for i in range(K):
    if sushi[i][0] in kind:
        can_converts.append(sushi[i])
    else:
        kind.add(sushi[i][0])
    max_pt += sushi[i][1]
max_pt += len(kind) ** 2

# 食べた種類を増やしていくフェーズ
curr_pt = max_pt

for s in sushi[K:]:
    if not can_converts: break
    if s[0] not in kind:
        target = can_converts.pop(-1)
        curr_pt = curr_pt - target[1] + s[1] - len(kind) ** 2 + (len(kind) + 1) ** 2
        max_pt = max(max_pt,curr_pt)

        kind.add(s[0])

print(max_pt)

# kind_cnt_seq = kind_cnt ** 2
# max_pt = sum([s[1] for s in ate_list]) + kind_cnt_seq
#
# if K >= N:
#     print(max_pt)
#     exit()
#
# waiting_sushi = []
# wait_kind = []
# for s in sushi[K:]:
#     if kind_counter[s[0]]:  # すでに食べてる種類
#         continue
#
#     if not s[0] in wait_kind:
#         waiting_sushi.append(s)
#         wait_kind.append(s[0])
#
# # 食べた種類を増やしていくフェーズ
# idx = K - 1
# curr_pt = max_pt
# for s in waiting_sushi:
#     target = None
#     for i in range(idx, -1, -1):
#         # 1個しかないものは交換しない
#         if kind_counter[ate_list[i][0]] > 1:
#             target = ate_list[i]
#             idx = i
#             break
#
#     if not target:
#         break


Measured memory_bytes: 19544
N,M=map(int,input().split())
L=list()
for i in range(M):
  a,b=map(int,input().split())
  A=list([b,a])
  L.append(A)
L=sorted(L)
R=[L[0][0]-1]
for j in range(M):
  if R[-1] not in range(L[j][1],L[j][0]):
    R.append(L[j][0]-1)
print(len(R))

Measured memory_bytes: 89152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;




  static class Solution {
    void solve() throws IOException {
      Scanner sc = new Scanner(System.in);
      while (sc.hasNextInt()) {
        int n = sc.nextInt();
        int cnt = 0;
        
        for (int i = 0; i <= 9; i++) {
          for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
              for (int l = 0; l <= 9; l++) {
                if (i + j + k + l == n) {
                  cnt++;
                }
              } 
            } 
          }
        }
        
        out.println(cnt);
      }
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 26480
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef map<ll, ll> Map;

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

int main(void) {
    ll N;
    cin >> N;
    ll a[100001];
    ll i;
    ll inv[100001];
    ll sinv[100001]={};

    for(i=1; i<=100000; i++) {
        inv[i]=modpow(i, MOD-2);
    }
    
    for(i=1; i<=100000; i++) {
        sinv[i]=(sinv[i-1]+inv[i])%MOD;
    }
    
    for(i=1; i<=N; i++) {
        cin >> a[i];
    }
    
    ll ans=0;
    for(i=1; i<=N; i++) {
        ans=(ans+(a[i]*(sinv[i]+sinv[N-i+1]-sinv[1]+MOD)%MOD)%MOD)%MOD;
    }
    
    for(i=1; i<=N; i++) {
        ans=(ans*i)%MOD;
    }
    
    prin(ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

void solve(double h,double w){
  int c=h*h+w*w,tmp,mini=INF;
  int hh=INF,ww=INF;
  REP(i,1,151){
    REP(j,i+1,151){
      if(i==h&&j==w)continue;
      tmp=i*i+j*j;
      //cout<<i<<" "<<j<<" = "<<tmp<<endl;
      //cout<<i<<" "<<j<<" ---> "<<c<<" < "<<tmp<<" < "<<mini<<endl;
      if(c<tmp&&tmp<mini){
	//cout<<i<<" "<<j<<" = "<<tmp<<endl;
      	hh=i;ww=j;mini=tmp;
      }else if(mini==c&&tmp==c&&(h<i&&i<hh)){
	hh=i;ww=j;mini=tmp;
      }else if(tmp==c&&mini!=c&&h<i){
	hh=i;ww=j;mini=tmp;
      }else if(tmp==mini&&c<i&&i<h){
	hh=i;ww=j;mini=tmp;
      }
    }
  }
  cout<<hh<<" "<<ww<<endl;
}

int main(){
  int h,w;
  while(cin>>h>>w){
    if(h==0&&w==0)break;
    solve(h,w);
  }
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n,ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m;
	cin >> n >> m;
	vector <ll>a(n);
	ll res = 1;
	rep(i, n) {
		cin >> a[i];
		a[i] /= 2;
		res = lcm(res, a[i]);
	}
	bool flag = true;
	rep(i, n) {
		ll res2 = res / a[i];
		if (res2 % 2 == 0)flag = false;
	}
	ll ans = 0;
	if (flag) {
		if (m >= res)ans++;
		ans += (m - res) / (2 * res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}

class test {
    public void solve(FastReader in, PrintWriter out){
       int n=in.nextInt();
       int k=in.nextInt();
       int a[]=new int[n];
       for(int i=0;i<n;i++){
           a[i]=in.nextInt();
       }
       Arrays.sort(a);
       long sum=0;
       for(int i=0;i<k;i++){
           sum+=a[i];
       }
       out.println(sum);
    }
}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 33272
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << endl;
    else if (s[1] == 'R' && (s[0] == 'R' || s[2] == 'R')) cout << 2 << endl;
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int mm,mi;
	mm=-0x3f3f3f3f;
	mi=0x3f3f3f3f;
	for(int i=0;i<n;i++)
	{
		if(a[i]>mm)
			mm=a[i];
		if(a[i]<mi)
			mi=a[i];
	}
	cout<<mm-mi<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;



int main()
{


    string a="";
    string b="";


    ll p,q,i;

    cin>>p>>q;

    for(i=1;i<=p;i++)
    {
        a+=(q+'0');
    }

    for(i=1;i<=q;i++)
    {
        b+=(p+'0');
    }

    if(a<=b)cout<<a<<endl;
    else

        cout<<b<<endl;


    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod=1e9+7;

string x;
int dp[10005][101][2];
int d;

int dfs(int i,int sum, bool smaller){
    if(i==(int)x.size()){
        return (sum%d == 0);
    }
    if(dp[i][sum][smaller] != -1){
        return dp[i][sum][smaller];
    }

    int upper_limit = 9;
    if(!smaller) upper_limit=x[i]-'0';

    int ans=0;
    for(int digit=0; digit<=upper_limit; ++digit){
        int t=x[i]-'0';
        // bool f=smaller;
        // if(digit < t){
        //     f|=1;
        // }
        ans=(ans+dfs(i+1,(sum+digit)%d,smaller||(digit<t)))%mod;
    }
    return dp[i][sum][smaller]=ans;
}

int main() {
    IOS
    cin>>x>>d;
    memset(dp, -1, sizeof(dp));
    cout<<(dfs(0,0,0)-1+mod)%mod;
    return 0;
}

Measured memory_bytes: 12516
#include <stdio.h>
int main()
{
    int a,b;
    int c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b)
    {
    printf("%d",b*c+(a-b)*d);
    }
    if(a<=b)
        printf("%d",a*c);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
using namespace std;
    int d[101];
    int G[101][101]={};
void krusta(int n){
    int color[101],l,m;
    for(int i=0;i<n;i++){
        d[i]=1000000;
        color[i]=0;
    }
    d[0]=0;
    while(1){
        m=1000000;
        for(int i=0;i<n;i++){
            if(color[i]!=1 && d[i]<m){
                m=d[i];
                l=i;
            }
        }
        color[l]=1;
        if(m==1000000){
            break;
        }
        for(int i=0;i<n;i++){
            if(color[i]!=1 && G[l][i]!=0 && G[l][i]+d[l]<d[i]){
                d[i]=G[l][i]+d[l];
            }
        }
    }
}
int main(){
    int n,v,k,c,u;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            G[u][v]=c;
        }
    }
    krusta(n);
    for(int i=0;i<n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define lll pair<ll,ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define ppb() pop_back()
#define mkp(a,b) make_pair(a,b)
#define vs vector<string>
#define vc vector<char>
#define deb1(a) cout<<#a<<" "<<a<<"\n"
#define deb2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n"
#define mms0(a) memset(a,0,sizeof(a))
#define mms1(a) memset(a,-1,sizeof(a))
#define FOR(a,b,c) for(int i=(a);i<(b);i+=(c))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define _ 0
using namespace std;




void solve(){
   int N;
   cin>>N;

   ll dp[N+1][4];
   mms0(dp);

   for(int i=1;i<=N;i++){
      int A,B,C;
      cin>>A>>B>>C;
      dp[i][1] = A + max(dp[i-1][2],dp[i-1][3]);
      dp[i][2] = B + max(dp[i-1][1],dp[i-1][3]);
      dp[i][3] = C + max(dp[i-1][1],dp[i-1][2]); 
   }

   cout<<max(dp[N][1],max(dp[N][2],dp[N][3]));
}




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

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

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

ll N, K, R, S, Pap;
string T;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N >> K >> R >> S >> Pap >> T;

    vector<string> P(K + 2);
    for(ll i = 0; i < K; ++i)
        for(ll j = i; j < N; j += K)
            P[i].pb(T[j]);
    //for(auto &x: P) cout << x << endl;
    
    ll top = 0;
    for(ll i = 0; i < P.size(); ++i){
        ll len = 1;
        for(ll j = 0; j < P[i].length(); ++j){
            char c = P[i][j];
            if(j + 1 < P[i].length() and P[i][j+1] == c){ len++; continue; }
            else{
                ll puan;
                if(c == 'r') puan = Pap;
                if(c == 's') puan = R;
                if(c == 'p') puan = S;
                if(len&1){ top += ((len>>1)+1)*puan; }
                else top += (len>>1)*puan;
                len = 1;
            }
        }
    }
    cout << top << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 5200
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  cin>>n;
  for(int i=-200;i<=200;i++)
    for(int j=-200;j<=200;j++){
      ll tt = i * (ll)i * i * i * i;
      ll tt2 = j * (ll)j * j * j * j;
      if(tt - tt2 == n){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
  string L;
  cin >> L;
  if(L[0]=='7'||L[1]=='7'||L[2]=='7'){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  long a[n + 1];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int count = 0;
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i++) {
    a[i] += a[i - 1];
    if (a[i] * 2 < a[i + 1])
      count = i;
  }
  cout << (n - count) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	cout << (1000-(n%1000))%1000;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3800
n = gets.to_i

if n == 0
  puts 0
  exit
end

hash = { '10' => '00', '11' => '01', '00' => '10', '01' => '11' }
puts ("%b" % (n + ('10' * 64).to_i(2))).chars.each_slice(2).map { |s| s.join.sub(/../, hash) }.join.gsub(/^0*/, '')

Measured memory_bytes: 1788
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var number = "0123456789";
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        if (s.Length != a + b + 1) { Console.WriteLine("No"); goto end; }
        if (s[a] != '-') { Console.WriteLine("No"); goto end; }
        for (int i = 0; i < a; i++)
            if (!number.Contains(s[i])) { Console.WriteLine("No"); goto end; }
        for (int i = a + 1; i <  a + b + 1; i++)
            if (!number.Contains(s[i])) { Console.WriteLine("No"); goto end; }
        Console.WriteLine("Yes");
        end:;
    }
}

Measured memory_bytes: 13268
#include <stdio.h> 
int main(void){
  long long int k,a,b;
  long long int i,bis,h;
  scanf("%lld %lld %lld",&k,&a,&b);
  bis = 1;
  h = 1;
  for(i=0;i<k;i++){
    if(b-a>2 && k-i>=2 && a<=bis){
      bis=bis-a+b;
      i++;
      h++;
    }else{
      bis++;
    }  
  } 
  printf("%lld\n",bis);
  
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>

using namespace std;

int main()
{
    int A, B, C, D, E, F;
    if (scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F) < 6) return 0;

    set<int> sugar;
    for (int i = 0; i <= F; i++)
    {
        for (int j = 0; j <= F; j++)
        {
            int s = C * i + D * j;
            if (s <= F) sugar.insert(s);
        }
    }

    set<int> water;
    for (int i = 0; i <= F; i++)
    {
        for (int j = 0; j <= F; j++)
        {
            int w = 100 * (i * A + j * B);
            if (w <= F) water.insert(w);
        }
    }

    float conc = 0.0F;
    int sw = 0;
    int sg = 0;
    for (auto s = sugar.begin(); s != sugar.end(); s++)
    {
        for (auto w = water.begin(); w != water.end(); w++)
        {
            float now = 0.0F;
            if (0 < *s + *w) now = (float) *s / (*s + *w);
            if (*s + *w <= F
                && now <= (float) E / (100.0F + E)
                    && conc <= now)
            {
                conc = now;
                sw = *s + *w;
                sg = *s;
            }
        }
    }

    printf("%d %d", sw, sg);
    return 0;
}


Measured memory_bytes: 384
import math
a,b,x = map(int,input().split())
V = a**2*b
if x >= V//2:
  rest_V = V-x
  tan = 2*rest_V/(a**3)
  print(math.degrees(math.atan(tan)))
  
else:
  rest_V = x
  tan = a*(b**2)/(rest_V*2)
  print(math.degrees(math.atan(tan)))


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

int main(){
    int n;cin >> n;
    int m;cin >> m;
    vector<pair<int,int> > a(m) ;
    for(int i=0;i<m;i++){
        cin >> a[i].second >> a[i].first;
    }
    sort(a.begin(),a.end());
    int ans = 1;
    int last = a[0].first;
    for(int i=0;i<m;i++){
        if(a[i].second >= last){
            ans ++;
            last = a[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
import sys

raw_input = sys.stdin.readline

f = lambda : raw_input().rstrip()    
f1 = lambda : f().split()
f2 = lambda t: map(t,f1())

def main1():
    a,b = f2(int)
    if (a+b)%2 == 0:
       print (a+b)/2
    elif a == b:
       print 0
    else:
       print "IMPOSSIBLE"

def main2():
    n = int(f())
    a = f2(int)
    b = sorted(a)
    m = 0
    for i in xrange(n):
        if a[i] != b[i]:
            m = m + 1
    if m<=2:
        print "YES"
    else:
        print "NO"

def main3():
    n = int(f())
    a = f2(int)
    b = f2(int)
    ans = 0
    for k in xrange(n):
        if a[i] >= b[i]:
            ans = ans + b[i]
        elif a[i] < b[i] :
            ans = ans + a[i]
            b[i] = b[i] - a[i]
            ans = ans + min(a[i+1], b[i])
            a[i+1] = a[i+1] - b[i]  
    print ans 
 
def main4():
    pass
    
    
if __name__ == "__main__":
    main2()

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;



int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >>n;
    vector < int > v(n);

    f0(i,n){
        cin >> v[i];
    }

    sort(all(v));

    ll ans = 0LL;
    ans+=((v[n-1])/2);
    f0(i,n-1){
        ans+=v[i];
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  rep(i, H){
    cin >> s.at(i);
  }
  vector<int> dx = {1,0,-1,0};
  vector<int> dy = {0,1,0,-1};
  bool pos = true;
  
  rep(i, H){
    rep(j, W){
      if(s.at(i).at(j) == '#'){
        rep(k, 4){
          if(0 <= i+dx.at(k) && i+dx.at(k) < H && 0 <= j+dy.at(k) && j+dy.at(k) < W){
            if(s.at(i+dx.at(k)).at(j+dy.at(k)) == '#'){
              break;
            }
          }
          if(k == 3){
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin>>n>>t;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int> d(n);
    int m=inf;
    for(int i=0;i<n;i++){
        m=min(m,a[i]);
        d[i]=a[i]-m;
    }
    sort(All(d),greater<int>());
    int res=0,M=d[0];
    for(int i=0;i<n;i++){
        if(d[i]==M)res++;
        else break;
    }
    cout<<res<<endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
  int s,w;
  cin>>s>>w;
  if(s<=w)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  long t[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &t[i]);
  }
  int m;
  scanf("%d", &m);
  int p[m];
  long x[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %ld", &p[i], &x[i]);
  }

  long all = 0;
  for (int i = 0; i < n; i++) {
    all += t[i];
  }
  for (int i = 0; i < m; i++) {
    printf("%ld\n", all-t[p[i]-1]+x[i]);
  }

  return 0;
}

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

int S[100010],T[100010],n,P[100010];

long long int  ans;
int main(){
  
	cin >> n;
  
	int p[100010];
	for (int i=1;i<=n;i++)
		cin>> p[i];
  
  for(int i=1;i<=n;i++){
		P[p[i]]=i;
    
		S[i]=i-1;
    
		T[i]=i+1;
	}
	
	for (int i=1;i<=n;i++){
      
		int b=S[P[i]],a=S[b];
      
		int c=T[P[i]],d=T[c];
      
		if (b!=0) ans += 1ll*(b-a)*(c-P[i])*i;
		if (c!=n+1) ans += 1ll*(d-c)*(P[i]-b)*i;
		
		S[c]=b;
		T[b]=c;
	}
	
	cout<< ans << endl;
	
}


Measured memory_bytes: 1792
n = int(input())
tbl = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]

for i in range(n):
    b, f, r, v = map(int,input().split())
    tbl[b-1][f-1][r-1] += v
    
for k in range(4):
    for j in range(3):
        for i in range(10):
            print(" {}".format(tbl[k][j][i]),end="")
        print()
    if k!=3:
        print("####################")


Measured memory_bytes: 5624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 1000000007;
const int cons = 100001;
const double pi = 3.141592653589793;
const int sqrtMax = 317;
const int blocks = cons / 3;

int a[30001];
int b[30001];

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

	for (int i = 1; i <= n; i++)
	{
		a[i] = 10000 + (i - 1) * 30000;
	}

	for (int i = 1; i <= n; i++)
	{
		b[n - i + 1] = 10000 + (i - 1) * 30000;
	}

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

	for (int i = 1; i <= n; i++)
	{
		printf("%d ", a[i]);
	}puts("");
	for (int i = 1; i <= n; i++)
	{
		printf("%d ", b[i]);
	}

	return 0;
}

Measured memory_bytes: 768
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a in A:
    tmp = 0
    for i in range(m):
        tmp += a[i] * B[i]
    tmp += c
    if tmp > 0:
        ans += 1
print(ans)


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

int main() {
    int num;
    long long tmp1, tmp2;
    long long kosu = 0;

    cin >> num;

    // 締め切り, 工数
    vector<pair<long long, long long>> p(num);

    for (int i = 0; i < num; i++) {
        cin >> tmp1 >> tmp2;
        p.at(i) = make_pair(tmp2, tmp1);
    }

    sort(p.begin(), p.end());

    for (int i = 0; i < num; i++) {
        long long a, b;
        tie(b, a) = p.at(i); // 工数、締め切り(上で反転した分を元に戻す) 

        kosu += a;

        if (kosu > b) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<ll> l(n + 2, 0), r(n + 2, 0);
  REP(i, n) {
    l[i + 1] = gcd(l[i], a[i]);
    r[n - i] = gcd(r[n - i + 1], a[n - 1 - i]);
  }

  ll ans = 0;
  FOR(i, 1, n + 1) {
    ll t = gcd(l[i - 1], r[i + 1]);
    ans = max(ans, t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
char dat[100011];
bool zz[100011];
int main()
{
	int n;
	cin >>n;
	cin >>dat;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	{
		zz[0]=i;
		zz[1]=j;
		for(int k=1;k<n-1;k++)
		zz[k+1]=zz[k-1]^zz[k]^(dat[k]=='x');
		if(((dat[n-1]=='x')==(zz[n-2]^zz[n-1]^zz[0]))&&((dat[0]=='x')==(zz[n-1]^zz[0]^zz[1])))
		{
			for(int k=0;k<n;k++)
			cout <<(zz[k]?'W':'S');
			cout <<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<LL> X(N); cin >> X;
  vector<LL> X2 = X;
  sort(X2.begin(), X2.end());

  int mid = N/2;
  for (int i = 0; i < N; ++i) {
    if (X[i] < X2[mid]) cout << X2[mid] << endl;
    else                cout << X2[mid-1] << endl;
  }
}


Measured memory_bytes: 6256
/*#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int SIZE = 1e6+5;
char str[SIZE];
ll l[SIZE];
ll r[SIZE];
ll rsum[SIZE];
ll rr[SIZE];
int main(){
    int n;scanf("%d",&n);
    scanf("%s",str+1);
    int q;scanf("%d",&q);
    for(int i = 1;i <= n;i++){
        if(str[i]=='D'){
            l[i] = l[i-1]+1;
            r[i] = r[i-1];
            rsum[i] = rsum[i-1];
            rr[i] = rr[i-1];
        }
        else if(str[i]=='M'){
            l[i] = l[i-1];
            r[i] = l[i-1];
            rsum[i] = rsum[i-1]+r[i];
            rr[i] = rr[i-1]+1;
        }
        else{
            l[i] = l[i-1];
            r[i] = r[i-1];
            rsum[i] = rsum[i-1];
            rr[i] = rr[i-1];
        }
    }


    while(q--){
        int k;scanf("%d",&k);
        ll res = 0;
        for(int i=1;i<=n;i++){
            if(str[i]=='C'){
                if(i>k)res += rsum[i]-rsum[i-k]-l[i-k]*(rr[i]-rr[i-k]);
                else res += rsum[i];
            }
        }
        printf("%lld\n",res);




    }
}

*/

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
ll a[1010];
ll ass[1010];
ll as[500050];
int bit[65];
int main()
{
    //cout<<(((1<<(4-1))&8))<<endl;
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        ass[i]=a[i]+ass[i-1];
    }
    int tot=0;
    ll maxn=-1;
    for(int i=0;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            as[++tot]=ass[j]-ass[i],maxn=max(maxn,as[tot]);
           // cout<<as[tot]<<endl;
        }

    }
    //cout<<"maxn="<<maxn<<endl;
    n=tot;
    int st=0,x=maxn;
    for(int i=0;i<64;i++)
    {
        if(x<pow(2,i)) break;
       // if(((1<<(i−1))&x)>0)
       // {
        //    st=i;
        //}
        if((((1ll*1)<<(i))&x)>0)
            st=i;
    }
    //cout<<"st="<<st<<endl;
    ll asum=0;
    for(ll i=40;i>=0;i--)
    {

        int tsum=0;
        for(int j=1;j<=n;j++)
        {
            if(as[j]==-1) continue;
            if(((1ll*1)<<i)>as[j]) continue;
            if((((1ll*1)<<(i))&as[j])>0)
            {
                tsum++;
            }
        }
        if(tsum>=k)
        {
             for(int j=1;j<=n;j++)
             {
                if(as[j]==-1) continue;
                if((((1ll*1)<<(i))&as[j])<=0)
                {
                    as[j]=-1;
                }
               // else cout<<pow(2,i)<<" "<<as[j]<<endl;
             }
             asum+=(1ll*1)<<i;
            // cout<<i<<" "<<tsum<< " "<<pow(2,i)<<endl<<endl;
        }

    }
    printf("%lld\n",asum);
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

bool pairCompare(const pair<string, ll>& firstElof, const pair<string, ll>& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    ll n;
    cin >> n;
    string s[n];
    std::vector<string> v;
    rep(i, n) {
        cin >> s[i];
        v.push_back(s[i]);
    }
    Sort(v);

    vector<pair<string, ll> > pairs;
    string temp = v[0];
    ll count = 0;
    rep(i, n) {
        if ( i != 0 ) {
            if ( temp == v[i] ) {
                count++;
            } else {
                pairs.push_back( make_pair(temp, count) );
                count = 0;
                temp = v[i];
            }
        }
    }
    pairs.push_back( make_pair(temp, count) );
    sort(ALL(pairs), pairCompare);
    reverse(ALL(pairs));
    ll num = pairs[0].second;
    std::vector<string> v2;
    rep(i, n) {
        v2.push_back(pairs[i].first);
        if ( i != n-1 && num != pairs[i+1].second ) {
            break;
        }
    }
    Sort(v2);
    rep(i, v2.size()) {
        cout << v2[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 23532