akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
const int mod = 1e9+7;
const int Max = 4e6;
int N,K,fac[4001000],Ifac[4001000],f[2020][2020];
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1) res=res*x%mod;x=x*x%mod;y>>=1;} return res;}
inline int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
inline int C(int x,int y){return 1ll*fac[x]*Ifac[y]%mod*Ifac[x-y]%mod;}
inline void Init(){
	fac[0]=Ifac[0]=1;
	for(rint i=1;i<=Max;++i) fac[i]=1ll*fac[i-1]*i%mod;
	Ifac[Max]=ksm(fac[Max],mod-2);
	for(rint i=Max-1;i>=1;--i) Ifac[i]=1ll*Ifac[i+1]*(i+1)%mod;
}
int main(){
	cin>>N>>K;
	if(K==1){
		cout<<1<<endl;
		exit(0);
	}
	Init();
	f[0][0]=1;
	for(rint i=1;i<=N;++i) {
		for(rint j=0;j<=i;++j) {
			f[i][j]=add(f[i][j],f[i-1][j]);
			if(j)
			f[i][j]=add(f[i][j],1ll*(N-j+1)*f[i][j-1]%mod*C(N-i+(K-1)*(N-j+1)-1,K-2)%mod);
		}
	}cout<<f[N][N];
	return 0;
}

Measured memory_bytes: 48704
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const ll inf = 1e9 + 1;

int n, t;
ll f[40];
vector<int> fr;
vector<pii> st;

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline bool cmp(const pii &a, const pii &b) {
	return (ll) (a.second + 1) * b.first < (ll) (b.second + 1) * a.first;
}

int main() {
	int x, y;
	read(n), read(t);
	for (R int i = 1; i <= n; ++i) {
		read(x), read(y);
		if (!x) fr.push_back(y);
		else st.push_back(mp(x, y));
	}
	sort(st.begin(), st.end(), cmp);
	sort(fr.begin(), fr.end());
	for (R int i = 1; i <= 30; ++i) f[i] = inf;
	for (auto &k : st)
		for (R int i = 30; i; --i)
			f[i] = min(f[i], f[i - 1] + 1 + (f[i - 1] + 1) * k.first + k.second);
	int ans = 0;
	for (R int i = 0; i <= 30; ++i) {
		if (f[i] > t) break;
		int num = i;
		for (auto &k : fr) {
			f[i] += k + 1;
			if (f[i] > t) break;
			++num;
		}
		ans = max(ans, num);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int N = 200010;

int n, h[N], where[N];
long long a[N], t[N + N];

void update (int p, long long v) {
  for (t[p += n] = v; p > 1; p >>= 1) {
    t[p >> 1] = max(t[p], t[p ^ 1]);
  }
}

long long query (int l, int r) {
  long long res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = max(res, t[l++]);
    if (r & 1) res = max(res, t[--r]);
  }
  return res;
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", h + i);
    where[h[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
  }
  long long ans = 0;
  for (int i = n; i > 0; --i) {
    int pos = where[i];
    long long cur = a[pos] + query(pos - 1, n);
    ans = max(ans, cur), update(pos - 1, cur);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, a[100000], light = 1,ans = 0;

    std::cin >> n;
    for(int i = 0;i < n;i++){
        std::cin >> a[i];
    }


    while(1){
        
        light = a[light - 1];
        ans++;
        if(light == 2){
            break;
        }
        
        if(ans > n){
            std::cout << -1;
            
            return 0;
        }
    }

    std::cout << ans;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  IN(N,M);

  unordered_set<ll> st;
  ll start=1;
  ll end=N;
  ll count = 0;
  while(count<M){
    if(st.find(end-start)!=st.end()){
      end--;
      continue;
    }
    if(st.find(start+N-end)!=st.end()){
      end--;
      continue;
    }
    if(start+N-end==end-start){
      end--;
      continue;
    }
    printf("%lld %lld\n", start, end);
    count++;
    st.emplace(end-start);
    st.emplace(start+N-end);
    start++;
    end--;
  }

  return 0;
}

Measured memory_bytes: 10948
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using ll = long long;

int main() {

    std::vector<std::vector<int>> c(3, std::vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> c[i][j];
        }
    }

    std::vector<int> a(3), b(3);
    for (int i = 0; i <= c[0][0]; i++) {
        a[0] = i;
        int b1 = c[0][0] - i;
        if (b1 < 0)continue;
        b[0] = b1;
        int b2 = c[0][1] - i;
        if (b2 < 0)continue;
        b[1] = b2;
        int b3 = c[0][2] - i;
        if (b3 < 0)continue;
        b[2] = b3;
        int a2 = c[1][0] - b1;
        if (a2 < 0)continue;
        if (a2 + b2 != c[1][1])continue;
        if (a2 + b3 != c[1][2])continue;
        int a3 = c[2][0] - b1;
        if (a3 < 0)continue;
        if (a3 + b2 != c[2][1])continue;
        if (a3 + b3 != c[2][2])continue;
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
amount, num = map(int, input().split())

hated_digit = list(map(str, input().split()))

while True:
    check = 0
    for hd in hated_digit:
        if hd not in str(amount):
            check += 1

        else:
            amount += 1

    if check == num:
        print(amount)
        break

Measured memory_bytes: 2940
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

long long int count(int n, vector<long long int>&a)
{
     vector<long long int>dp(n+1,0);
    
     dp[2]=abs(a[1]-a[2]);
     for(long long int i=3;i<n+1;i++)
     {   dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),
                              dp[i - 2] + abs(a[i] - a[i - 2]));
     }
     
     return dp[n];
}

int main()
{
   long long int n;
    cin>>n;
    vector<long long int>a(n+1,0);
    for(long long int i=1;i<n+1;i++)
    {
        long long int x;
        cin>>x;
        a[i]=x;
        
    }
    cout<<count(n,a);
    return 0;
}


Measured memory_bytes: 1792
//DivRem Number

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    map<int,int>a;
    int ans = 0;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            a[i];
            a[n/i];
        }
    }
    for(auto i:a){
        if(i.first==1)continue;
        if(n/(i.first-1)==n%(i.first-1)){
            ans+=i.first-1;
        }
    }
    cout<<ans<<nnn;
    return 0;
}


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

int gcd(int x, int y);

const int INF = 1001001001;

/*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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    int x;
    cin >> x;
    int n = x / 100;
    int need = x % 100;
    int ans = 0;
    
    if (need <= 5 * n) {
        cout << 1 << endl;
        return 0;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

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

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

    int ans = 0;
    int check = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == check){
            check++;
        }else{
            ans++;
        }
    }

    if(ans == n){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define GC getchar
#define fi first
typedef int INT;
#define int long long
#define se second
#define SZ(x) ((int)(x).size())
#define FOR(i,a,b) for(int i=(a),__l=(b);i<=__l;++i)
#define DEP(i,a,b) for(int i=(a),__l=(b);i>=__l;--i)
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int inf=1000000005;
const int _L=1<<21;char _Buf[_L],*__S,*__T;
inline char Fast_getchar(){
if(__S==__T){__T=(__S=_Buf)+fread(_Buf,1,_L,stdin);if(__S==__T)return EOF;}return *__S++;}
template <class __T> inline void read_string(__T s[]){
	char c;for(c=GC();c<33||c>126;c=GC());
	for(;33<=c&&c<=126;*s++=c,c=GC());*s=0;}
template <class __T> inline void read(__T& x){
	x=0;char c=GC();int f=1;
	for(;!isdigit(c);c=GC())c=='-'?f=-1:0;
	for(;isdigit(c);c=GC())x=(x<<1)+(x<<3)+(c^'0');f<0?x=-x:0;}

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

const int N=1200005;
int n,a[N],sum[N];
int qsum(int l,int r){return sum[r]-sum[l-1];}
int D(int s,int m,int r) {
	return abs(qsum(s,m)-qsum(m+1,r));
}
int getp(int s,int t) {
	int l=s,r=t-1,m1,m2,res;
	while(l<=r) {
		m1=l+(r-l)/3;
		m2=r-(r-l)/3;
		if(D(s,m1,t) <= D(s,m2,t)) res=m1,r=m2-1;
		else res=m2,l=m1+1;
	}return res;
}

bool check(int li) {
	FOR(i,2,n-2) {
		int lp=getp(1,i),rp=getp(i+1,n);
		int mi=min ( min(qsum(1,lp),qsum(lp+1,i)),min(qsum(i+1,rp),qsum(rp+1,n)) );
		int mx=max ( max(qsum(1,lp),qsum(lp+1,i)),max(qsum(i+1,rp),qsum(rp+1,n)) );
		if(mx-mi<=li) return true;
	}return false;
}


INT main() {
//	freopen("in.in","r",stdin);
	read(n);
	FOR(i,1,n) read(a[i]),sum[i]=sum[i-1]+a[i];
	int l=0,r=(*max_element(a+1,a+n+1)),mid,res;
	while(l<=r) {
		mid=l+r>>1;
		if(check(mid)) res=mid,r=mid-1;
		else l=mid+1;
	}
	cout << res << '\n';
	return 0;
}


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




int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  bool ans = true;
  if (n % 3 == 0 and 
      count(A.begin(), A.begin() + n / 3, A[0]) == 
      count(A.begin() + n / 3, A.begin() + n * 2 / 3, A[n/3])
  and count(A.begin(), A.begin() + n / 3, A[0]) == n / 3
  and count(A.begin(), A.begin() + n / 3, A[0]) == 
      count(A.begin() + 2 * n / 3, A.end(), A[2 * n/3])) {
    ans &= ((A[0] xor A[n / 3] xor A[n / 3 * 2]) == 0);
  }
  else ans = false;
  if (count(A.begin(), A.end(), 0) == n) ans = true;
  cout << (ans ? "Yes" : "No") << '\n';
}



Measured memory_bytes: 640
using System;

namespace Procon_{
	  class Program
    {
        static void Main(string[] args)
        {
            int R= int.Parse(Console.ReadLine());
            if (R < 1200)
            {
                Console.WriteLine("ABC");
            }
            else if (R < 2800)
            {
                Console.WriteLine("ARC");

            }
            else Console.WriteLine("AGC");
        }
    }
}

Measured memory_bytes: 11092
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

a = input()
if(digitSum(a)%9 == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	ll ans=k;
	rep(i,n-1) ans*=k-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(v):
    print(v, file=sys.stderr)


N, K = map(int, input().split())

mod = 10**9 + 7
log(mod)
ans = 0
for i in range(K, N + 2):
    max = (N - i + 1 + N) * i // 2
    min = (i - 1) * i // 2
    ans += max - min + 1
    ans %= mod
print(ans)


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

int main() {
   int n;
   cin >> n;
   int sum=0,w[110];
   rep(i,n){
      cin >> w[i];
      sum+=w[i];
   }
   int ans=1e9,l=0;
   rep(i,n){
      l+=w[i];
      ans=min(abs(l-(sum-l)),ans);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  string a,b,c;
  cin>>a;
  cin>>b;
  cin>>c;
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i]&&b[i]==c[i]) continue;
    else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]){
      ans++;
    }else ans+=2;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

// 半分全探索
// 解説AC(けんちょんさん)
// 前半部分は赤と青を入れ替える
// 後半部分は反対から読む
// そうすると赤青の組合せが前半と後半で同じになる
int main() {
    int n;
    string s;
    cin >> n >> s;
    map<pair<string, string>, ll> mp;
    rep (bit, 0, 1 << n) {
        string a = "", b = "";
        rep (i, 0, n) {
            if (bit & 1 << i) {
                a += s[i];
            } else {
                b += s[i];
            }
        }
        mp[{a, b}]++;
    }
    ll ans = 0;
    rep (bit, 0, 1 << n) {
        string a = "", b = "";
        per (i, 0, n) {
            if (bit & 1 << i) {
                a += s[i + n];
            } else {
                b += s[i + n];
            }
        }
        // cout << a << " " << b << mp[{b, a}] << "\n";
        ans += mp[{b, a}];
    }
    cout << ans << "\n";
}

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

using namespace std;

int main() {
    ios :: sync_with_stdio(0);
    cin.tie(nullptr);
    int n, v[21];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int s = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (v[i] - x > 0) {
            s += v[i] - x;
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
//Volume5-0524
import java.util.ArrayList;
import java.util.Scanner;

class Star {
	public int x,y;
	Star (int x,int y){
		this.x=x; this.y=y;
	}
	public boolean equals(Object o){
		Star s = (Star)o;
		return this.x==s.x&&this.y==s.y;
	}
}

class Main {

	private static ArrayList<Star> target = new ArrayList<Star>(),
			                       map    = new ArrayList<Star>();

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		while(true){
			target.clear();
			map   .clear();
			int m = sc.nextInt();
			if(m==0){break;}
			for(int i=0;i<m;i++){target.add(new Star(sc.nextInt(),sc.nextInt()));}
			int n = sc.nextInt();
			for(int i=0;i<n;i++){map.   add(new Star(sc.nextInt(),sc.nextInt()));}
			Star    match_1 = target.get(0),
					match_2;
			int     diff_x,
			        diff_y;
			boolean flg;
			String  result = "";
			for(int i=0;i<map.size();i++){
				match_2 = map.get(i);
				diff_x  = match_2.x - match_1.x;
				diff_y  = match_2.y - match_1.y;
				flg     = true;
				for(int j=1;j<target.size();j++){
					Star t = target.get(j);
					if (!(map.contains(new Star(t.x + diff_x,t.y + diff_y)))){
						flg = false;
						break;
					}
				}
				if(flg){result = diff_x + " " + diff_y; break;}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 34296
N = int(input())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

seq = [i for i in range(N)]
import itertools
tar = list(itertools.permutations(seq))

ans = 0
for t in tar:
    s = 0
    p_x = -1
    p_y = -1
    for i, x in enumerate(t):
        x, y = items[x]
        if i != 0:
            tmp = (abs(p_x - x) ** 2 + abs(p_y - y) ** 2) ** 0.5
            ans += tmp
        p_x = x
        p_y = y
div = 1
for i in range(1, N+1):
    div *= i

print(ans / div)


Measured memory_bytes: 8180
from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

#### START
n = int(input())
a = list(map(int,input().split()))

ans = 10**100
res = np.cumsum(a)

print(min([abs(res[-1]-res[i]-res[i]) for i in range(len(res)-1)]))

Measured memory_bytes: 33020
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	llint n,m,a,sum=0;
	cin >> n >> m;
	rep(i,m){
      cin >> a;
      sum = a+sum;
    }
    if(n-sum>=0){
		cout << n-sum;
    } else{
     	cout << -1; 
    }
	return 0;
}

Measured memory_bytes: 3636
# import numpy as np
# import time

def main():
    s = input()
    # s = '<>>><<><<<<<>>><' # test
    # s = '>>>>>>>'
    n_list = [0] * (len(s)+1)
    # n_list = np.zeros(len(s)+1)

    for i in range(1, len(s)):
        if s[i-1] == '<':
            n_list[i] = n_list[i-1]+1
        else: # i = >
            if s[i] == '>':
                continue
            # j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 1, -1):
                if s[j-1] == '<':
                    n_list[j] = max(n_list[j-1], n_list[j+1])+1
                    break
                n_list[j-1] = k
                k+=1
    
    if s[-1] == '<':
        n_list[-1] = n_list[-2]+1
    elif s[-1] == '>':
        # j = i # jは左側の                           文字のインデックス
        k = 1                     
        for j in range(len(s), 1, -1):
            if s[j-1] == '<':
                n_list[j] = max(n_list[j-1], n_list[j+1])+1
                break
            n_list[j-1] = k
            k+=1
    if s[0] == '>':
        n_list[0] = n_list[1]+1
            
        # print('i={} {}'.format(i, n_list))    
 
    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    # start = time.time()
    main()    
    # elapsed_time = time.time() - start
    # print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")


Measured memory_bytes: 49004
A = [0 for _ in range(32)]
A[0] = 1
for i in range(1, 32):
    A[i] = A[i-1]
    if i > 1:
        A[i] += A[i-2]
        if i > 2:
            A[i] += A[i-3]

while True:
    n = int(input())
    if n ==0:
        break
    else:
        print(A[n]//3650 + 1)
    





Measured memory_bytes: 5600
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
using namespace std;

int main()
{
    map<long long int,long long int>mp;
    long long int n,i,a;cin>>n;
    for(i=0;i<n-1;i=i+1){cin>>a;mp[a]++;}
    for(i=1;i<=n;i=i+1){cout<<mp[i]<<endl;}
    
}


Measured memory_bytes: 16096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		
		int count[] = new int[26];
		
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
			
			
			while(true) {
				String input = br.readLine();
				
				if(input == null || input.equals("")) break;
				
				for(int i = 0; i < input.length(); i++) {
					char c = input.charAt(i);
					if(isUpperCase(c)) {
						count[c - 'A']++;
					}
					if(isLowerCase(c)) {
						count[c - 'a']++;
					}
				}
			}
			
			StringBuilder sb = new StringBuilder();
			
			for(int i = 0; i < 26; i++) {
				char c = (char) (i + 'a');
				sb.append(c + " : " + count[i]);
				sb.append("\n");
			}
			
			System.out.print(sb.toString());
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private static boolean isUpperCase(char c) {
		return 'A' <= c && c <= 'Z';
	}
	
	private static boolean isLowerCase(char c) {
		return 'a' <= c && c <= 'z';
	}
}


Measured memory_bytes: 24284
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
int perm[10]={1,2,3,4,5,6,7,8,};

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

    int N,P[10],Q[10];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        cin>>Q[i];
    }
    int count=0;
    int p,q;
    do{
        count++;
        for(int i=0;i<N;i++){
            if(perm[i]!=P[i]) break;
            if(i==N-1) p=count;
        }
        for(int i=0;i<N;i++){
            if(perm[i]!=Q[i]) break;
            if(i==N-1) q=count;
        }
    }while(next_permutation(perm,perm+N));
  //上の場合だと2と3が入れ替わるだけで処理終了
  cout<<abs(p-q)<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		cout<<'x';
    return 0;
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, k; cin >> n >> k;
    string s; cin >> s;

    vi v;
    // 1, 0, ... , 1の数を記録する
    if(s[0] == '0') v.push_back(0);
    REP(i, s.size()) {
        int j = i;
        while(j < s.size() && s[i] == s[j]) ++j;    // 同じ数を圧縮するため数える
        v.push_back(j-i);
        i = j - 1;
    }
    if(s.back() == '0') v.push_back(0);

    vi sums((int)v.size() + 1, 0);
    REP(i, v.size()) sums[i + 1] = sums[i] + v[i]; // sum[0] が 0 だと端を特別扱いしなくて良い．

    int ans = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + 2 * k + 1;
        if(right >= sums.size()) right = (int)sums.size() - 1;
        ans = max(ans, sums[right] - sums[left]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1272
h, w = map(int, input().split())
a0 = '.' * w
r0 = range(w)
for i in range(h):
  a = input()
  r = [i]
  for x, y, z, u in zip(a0, '.' + a, a, r0):
    r.append(min(u + (x + z == '.#'), r[-1] + (y + z == '.#')))
  a0 = a
  r0 = r[1:]
print(r[-1])

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static List<List<Integer>> switchList;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Set<Integer> brokenTyles = new HashSet();
        for (int i = 0; i < M; i++) {
            brokenTyles.add(Integer.parseInt(sc.next()));
        }
        sc.close();

        long[] patterns = new long[N + 1];
        patterns[0] = 0;
        if (brokenTyles.contains(1)) {
            patterns[1] = 0;
        } else {
            patterns[1] = 1;
        }

        if (N > 1) {
            if (brokenTyles.contains(2)) {
                patterns[2] = 0;
            } else {
                patterns[2] = patterns[1] + 1;
            }
        }

        long baseVal = (long) Math.pow(10, 9) + 7;

        for (int i = 3; i <= N; i++) {
            if (brokenTyles.contains(i)) {
                patterns[i] = 0;
            } else {
                patterns[i] = (patterns[i - 1] + patterns[i - 2]) % baseVal;
                if (patterns[i] == 0) {
                    patterns[N] = 0;
                    break;
                }
            }
        }

        long val = patterns[N];
        System.out.println(val);
    }

}


Measured memory_bytes: 46740
n = gets.to_i
nums = gets.split.map(&:to_i).sort.reverse
sum_a = 0
sum_b = 0

n.times do |i|
  if (i%2).zero?
    sum_a += nums[i]
  else
    sum_b += nums[i]
  end
end

puts sum_a - sum_b

Measured memory_bytes: 1788
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,h,w=map(int,input().split())
    ans=0
    for i in range(n):
        a,b=map(int,input().split())
        if a>=h and b>=w:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int buk[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	for(int i=nxi(); i; --i)
		++buk[nxi()];
	int ans=0;
	for(int i=1; i<1e5; ++i)
		apx(ans,buk[i-1]+buk[i]+buk[i+1]);
	printf("%d\n",ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, C, c;
    cin >> N >> C;
    vector<vector<int> > cost(C, vector<int>(C)), color(N, vector<int>(N));
    for (int i = 0; i < C; i++) for (int j = 0; j < C; j++) cin >> cost[i][j];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
        cin >> c; color[i][j] = c - 1;
    }
    vector<map<int, int> > mp(3);
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)
        mp[(i + j) % 3][color[i][j]]++;

    int minC = INF;
    for (int c1 = 0; c1 < C - 2; c1++) {
        for (int c2 = c1 + 1; c2 < C - 1; c2++) {
            for (int c3 = c2 + 1; c3 < C; c3++) {
                vector<int> p{c1, c2, c3};
                do {
                    int tmp = 0;
                    for (int i = 0; i < 3; i++) {
                        int ncolor = p[i];
                        for( auto it = mp[i].begin(); it != mp[i].end() ; ++it )
                            tmp += cost[it->first][ncolor] * it->second;
                    }
                    minC = min(tmp, minC);
                } while(next_permutation(p.begin(), p.end()));
            }
        }
    }
    cout << minC << '\n';
}


Measured memory_bytes: 1280
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   string s;
   cin>>s;
   set<char>t;
   for(int i=0;i<4;i++)
   	t.insert(s[i]);
   if(t.size()==2)
   	cout<<"Yes";
   else
   	cout<<"No";
}

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

int main() {
  int n;
  std::cin >> n;
  std::set<int> d;
  for (int i = 0; i < n; i++) {
    int p;
    std::cin >> p;
    d.insert(p);
  }

  std::cout << d.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
l1 = tuple(map(int,input().split()))
l2 = tuple(map(int,input().split()))
l = [(i+1) for i in range(n)]
x = list(itertools.permutations(l))
s,e = 0,0
for i in range(len(x)):
	if x[i] == l1:
		s = i+1
for i in range(len(x)):
	if x[i] == l2:
		e = i+1
print(abs(e-s))

Measured memory_bytes: 79736
import collections
import itertools
import sys
import time

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

def get_primes(max_val):
    is_prime = [True] * (max_val + 1)
    for i in range(2, max_val+1):
        if not is_prime[i] or i * i > max_val:
            continue
        for j in range(i*i, max_val+1, i):
            is_prime[j] = False
    res = []
    for i in range(2, len(is_prime)):
        if is_prime[i]:
            res.append(i)
    return res

def get_prime_factor(n, primes):
    if n == 1:
        return (1, 1)
    res = []
    for p in primes:
        if p * p > n:
            break
        c = 0
        while not n % p:
            n //= p
            c += 1
        if c:
            res.append((p, c))
    if n != 1:
        res.append((n, 1))
    return res

primes = get_primes(1000000)

n=getint()
if n == 1:
    print("1")
    sys.exit(0)

factors = collections.defaultdict(int)
for i in range(2,n+1):
    tmp = get_prime_factor(i,primes)
    for p, c in tmp:
        factors[p] += c

res = 1
for p,c in factors.items():
    res *= c + 1
    res %= 10**9+7

print(res)

Measured memory_bytes: 14420
def solve():
    N, M = map(int, input().split())
    if N == 1:
        return 1
    if M == 1:
        return 1
    
    if N % 2 == 0:
        return M * N // 2
    else:
        a = N // 2 * M
        if M % 2 == 0:
            return a + M//2
        else:
            return a + (M//2 + 1)

print(solve())

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int all_xor = 0;
    REP(i, N) {
        cin >> a[i];
        all_xor ^= a[i];
    }
    REP(i, N) {
        cout << (a[i] ^ all_xor) << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3968
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (W, H, x, y) = read!(i64, i64, i64, i64);
    let center = W % 2 == 0 && x == W / 2 && H % 2 == 0 && y == H / 2;
    println!(
        "{} {}",
        (W as f64 * H as f64) / 2.0,
        if center { '1' } else { '0' }
    );
}


Measured memory_bytes: 4352
using System;

namespace ABC079_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = new long[87];
            num[0] = 2;
            num[1] = 1;
            for(var i=2;i<=n;i++)
            {
                num[i] = num[i - 1] + num[i - 2];
            }
            Console.WriteLine(num[n]);
        }
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  int mx=0;
  ll ans=0;
  cin >> n;
  REP(i,n){
    int a;
    cin >> a;
    if(i==0){
      mx=a;
    }else{
      if(mx > a){
        ans += mx-a;
      }else{
        mx = a;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3596
import sys

str_n = input()
N = [int(i) for i in str_n]

OPS = ['+', '-']

for op1 in OPS:
    for op2 in OPS:
        for op3 in OPS:
            ans = N[0]
            if op1 == '+':
                ans += N[1]
            else:
                ans -= N[1]
            if op2 == '+':
                ans += N[2]
            else:
                ans -= N[2]
            if op3 == '+':
                ans += N[3]
            else:
                ans -= N[3]
            if ans == 7:
                print(str_n[0] + op1 + str_n[1] + op2 + str_n[2] + op3 + str_n[3] + '=7')
                sys.exit()


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  char C[100][100];
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      cin >> C[i][j];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      printf("%c", C[i][j]);
    }
    printf("\n");
    for (int j = 0; j < W; j++) {
      printf("%c", C[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 504
#include <iostream>
int main (void)
{
	int w;
	std::cin >> w;
	int m = 100000;
	while(0 < w)
	{
		m *= 1.05;
		if (m % 1000 != 0)
		{
			m -= m % 1000;
			m += 1000;
		}
		w--;
	}
	std::cout << m << std::endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vii;
typedef vector<ll> vll;

#define X first
#define Y second
#define rep(i,n) for(ll i=0; i<(n); i++)
#define repp(i,ed,b) for(ll i=ed; i<=(b); i++)
#define repp2(i,b,ed) for(ll i=b; i>=(ed); i--)
#define fill(ed,val) memset(ed, (val), sizeof(ed))
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define uni(c) c.resize(distance(c.begin(), unique(all(c))))
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define IO(input_file_name) ifstream cin(input_file_name);ofstream cout("output.txt")
#define sc(n) scanf("%lld",&n)

ll mod= 1e9 + 7, mod1=1e9+9;
const ll N=100005;
ll in=0;
ll an=0;
ll n,k;
ll par[N];
vii ed[N];
ll solve(ll in, ll h){
    
    ll tmp=0;
    for(auto x:ed[in]){
        tmp=max(tmp,1+solve(x,h+1));
    }
    if(tmp==k-1 && par[in]!=1){an++,tmp=-1;}
    return tmp;
}

int main()
{   
    io;
    
    
    cin>>n>>k;
    rep(i,n){
        ll x;
        cin>>x;
        if(i==0){in=x;continue;}
        ed[x].pb(i+1);
        par[i+1]=x;
    }
    
    par[1]=1;
    if(in!=1)an++;
    
    solve(1,0);
    cout<<an;
    return 0;
}


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

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

    if (s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;
using namespace __gnu_pbds;

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

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n), s(n + 1, 0);

    REP(i, n) {
        cin >> a[i];
        s[i + 1] = s[i] + a[i];
    }

    tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> t;

    REP(i, n + 1) {
        s[i] -= k * i;
        t.insert(s[i]);
    }

    ll ans = 0;
    REP(i, n + 1) {
        auto itr = t.upper_bound(s[i]);
        t.erase(itr);

        ans += t.size() - t.order_of_key(s[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n,ans=0;
    cin >> n;
    vector<vector<ll>> v(n + 1, vector<ll>(n-1));
    rep(i, n) rep(j, n - 1)
    {
        cin >> v[i+1][j];

        if (j == n - 2){
            reverse(all(v[i + 1]));

        }
    }

    while (1)
    {

        set<ll> se;
        bool f=true;
        ll cnt=0;

        for (int i = 1; i <= n; i++)
        {
            if(siz(v[i])==0){
                cnt++;
                continue;
            }

            if (v[v[i].back()].back() == i && !se.count(i) && !se.count(v[i].back()))
            {
                f=false;
                //cout<<"DE"<<endl;
                se.insert(i);
                se.insert(v[i].back());
                v[v[i].back()].pop_back();
                v[i].pop_back();
            }
        }

        if(cnt==n){
            break;
        }
        if(f){
            cout<<-1<<endl;
            return 0;
        }
        se.clear();
        ans++;
    }
    
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x = a - b;
    int ans = max(0, c-x);
    cout << ans << endl;

}

Measured memory_bytes: 256