akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())
XY=[[0]*2 for i in range(n)]
X=[0]*n
Y=[0]*n
Z=[i for i in range(1,n+1)]
for i in range(n):
  X[i],Y[i]=map(int,input().split())
  XY[i]=[X[i],Y[i]]
X.sort()
Y.sort()
XX=dict(zip(X,Z))
YY=dict(zip(Y,Z))
XXX=dict(zip(Z,X))
YYY=dict(zip(Z,Y))
A=[[0]*n for i in range(n)]
for i in range(n):
  A[XX[XY[i][0]]-1][YY[XY[i][1]]-1]+=1
C=[[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    C[i][j]=C[i-1][j]+C[i][j-1]-C[i-1][j-1]+A[i-1][j-1]
ans=10**20
for i in range(1,n):
  for j in range(i+1,n+1):
    for s in range(1,n):
      for t in range(s+1,n+1):
        if C[j][t]-C[j][s-1]-C[i-1][t]+C[i-1][s-1]<k:
          continue
        a=(XXX[j]-XXX[i])*(YYY[t]-YYY[s])
        if a<ans:
          ans=a
print(ans)

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

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	bool isWhite[W][H];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			isWhite[j][i] = true;
		}
	}
	for (int i = 0; i < N; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		switch (a) {
			case 1:
				for (int j = 0; j < H; j++) {
					for (int k = 0; k < x; k++) {
						isWhite[k][j] = false;
					}
				}
				break;
			case 2:
				for (int j = 0; j < H; j++) {
					for (int k = x; k < W; k++) {
						isWhite[k][j] = false;
					}
				}
				break;
			case 3:
				for (int j = 0; j < y; j++) {
					for (int k = 0; k < W; k++) {
						isWhite[k][j] = false;
					}
				}
				break;
			case 4:
				for (int j = y; j < H; j++) {
					for (int k = 0; k < W; k++) {
						isWhite[k][j] = false;
					}
				}
				break;
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (isWhite[j][i]) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

//????????????(??????)
const int INF=1000;

//??????????????§
int n,m;
int s1[INF];
int s2[INF];

int tarouSum;
int hanakoSum;

int main() {
	while (true) {
		//?????????
		tarouSum=0;
		hanakoSum=0;

		//??\???1
		std::cin>>n>>m;
		//???????????¶
		if(n==0 && m==0)break;
		
		//??\???2
		for(int i=0;i<n;i++) {
			std::cin >> s1[i];
			hanakoSum+=s1[i];
		}
		for(int i=0;i<m;i++){
			std::cin >> s2[i];
			tarouSum+=s2[i];
		}
		//?????¬??????????????°
		int needPoint=hanakoSum-tarouSum;

		//???????\???°????????????????????????
		if (needPoint % 2 != 0) {
			std::cout<<-1<<std::endl;
			continue;
		}
		//????????¶??°?????¨??????????????????????????????????????????????????????????????????????????????
		needPoint/=2;
		bool ansExist=false;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s1[i] - s2[j] == needPoint) {
					std::cout<<s1[i]<<" "<<s2[j]<<std::endl;
					ansExist=true;
					break;
				}
			}
			if(ansExist)break;
		}
		if(!ansExist)std::cout<<-1<<std::endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,m,dep[55],par[55];
vector<int>g[55],gr[55];
void dfs(int x,int pars,int depth){
	dep[x]=depth,par[x]=pars;
	for (int i=0;i<g[x].size();i++) if (g[x][i]!=pars) dfs(g[x][i],x,depth+1);
}
void lca(int u,int v,int id){
	if (dep[u]>dep[v]) swap(u,v);
	while (dep[v]>dep[u]) gr[v].push_back(id),v=par[v];
	while (u!=v) gr[u].push_back(id),gr[v].push_back(id),u=par[u],v=par[v];
}
ll dp[55][1049000];
int main(){
	read(n);
	for (int i=0;i<n-1;i++){
		int x,y;read(x),read(y);
		g[x].push_back(y),g[y].push_back(x); 
	}
	dfs(1,-1,0);
	read(m);
	for (int i=0;i<m;i++){
		int u,v;read(u),read(v);
		lca(u,v,i);
	}
	dp[1][0]=1;
	for (int i=2;i<=n;i++)
		for (int j=0;j<(1<<m);j++){
			dp[i][j]=dp[i][j]+dp[i-1][j];
			int go=j;
			for (int k=0;k<gr[i].size();k++) go|=(1<<gr[i][k]);
			dp[i][go]=dp[i][go]+dp[i-1][j];
		}
	write(dp[n][(1<<m)-1]);
}

Measured memory_bytes: 405760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
struct Find {
    Find(const T &s, const T &t) : m(t.size()), o(m * 2), a(o + s.size()) {
        int j = a[0] = -1;
        for (int i = 0; i < m; a[++i] = ++j) {
            while (j >= 0 && t[i] != t[j]) j = a[j];
        }
        int n = s.size(), l = a.size() - 1, h = 0;
        for (int i = m; i < l; a[++i] = ++j) {
            while (j >= 0 && (j == m || s[h] != t[j])) j = a[j];
            if (++h == n) h -= n;
        }
    }
    int operator[](int i) const {
        return a[o + i] == m;
    }
    const int m, o;
    vector<int> a;
};

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n), d(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    c[0] = a[n - 1] ^ a[0];
    d[0] = b[n - 1] ^ b[0];
    for (int i = 1; i < n; i++) {
        c[i] = a[i - 1] ^ a[i];
        d[i] = b[i - 1] ^ b[i];
    }

    Find<vector<int>> u(c, d);

    for (int i = 0; i < n; i++) {
        if (u[i]) cout << i << ' ' << (a[i] ^ b[0]) << '\n';
    }

    return 0;
}

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

int solve(string s, string t) {
  int ss = s.size();
  int tt = t.size();
  vector<vector<int> > dp(ss+1, vector<int>(tt+1, 0));
  s.insert(0, " ");
  t.insert(0, " ");
  
  int ret = 0;
  rep(i, 1, ss+1) {
    rep(j, 1, tt+1) {
      if(s[i] == t[j])
        dp[i][j] = dp[i-1][j-1] +1;
      else
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      ret = max(ret, dp[i][j]);
    }
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int q;
  cin >> q;
  rep(aa, 0, q) {
    string x, y;
    cin >> x >> y;
    cout << solve(x, y) << "\n";
  }
}


Measured memory_bytes: 6844
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	ll sum = 0;
	vl a(n); rep(i,n) cin >> a[i], sum += a[i];
	ll mn = inf;
	rep(i,n) chmin(mn,abs(sum-n*a[i]));
	rep(i,n){
		if(mn==abs(sum-n*a[i])){
			cout << i << endl;
			return 0;
		}
	}
}

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

int main()
{
 char ch[200000],a='A',z='Z';
 int i=0,f=0,l=0,sub=0;
 scanf("%s",ch);
 while(ch[i] != '\0'){
     if(ch[i] == a){
          f = i-1;\

          break;
     }
    i++;
 }
 while(ch[i]!='\0'){

    if(ch[i] == z){
        l = i;
     }
     i++;
 }
 sub = l-f;
 printf("%d\n",sub);
return 0;}


Measured memory_bytes: 384
module A
  sub Main(byval args() as string)
    dim arr() as string =split(console.readline())
    dim n,m,res as integer
    n=arr(0):m=arr(1):res=0
    if n>1 then res += n * (n-1) / 2
    if m>1 then res += m * (m-1) / 2
    console.writeline(res)
  end sub
end module

Measured memory_bytes: 13532
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, d, a[MAXN], b[MAXN];
LL ans;

int main()
{
    scanf("%d%d", &n, &d);
    for(rint i=1; i<=n; ++i)
    {
	scanf("%d", &a[i]);
	b[i]=a[i];
	ans+=a[i];
    }
    for(rint i=2; i<=n; ++i) b[i]=min(b[i], b[i-1]+d);
    for(rint i=n-1; i>=1; --i) b[i]=min(b[i], b[i+1]+d);
    ans+=1LL*(n-1)*d;
    for(rint i=2; i<n; ++i) ans+=b[i];
    printf("%lld\n", ans);
    return 0;
}


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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,K,Q; cin>>n>>K>>Q;
	
	ll a[n]{};
	forn(i,0,n) a[i]=K-Q;
	forn(i,0,Q){
		int x; cin>>x; x--;
		a[x]++;
	}
	
	forn(i,0,n){
		if(a[i]>0) cout<<"Yes\n";
		else cout<<"No\n";
	}
	
	return 0;
}


Measured memory_bytes: 4428
# coding: utf-8

# https://atcoder.jp/contests/abc119


def main():
    N = int(input())
    x, u = [None] * N, [None] * N

    for i in range(N):
        line = input().split()
        x[i], u[i] = float(line[0]), line[1]
    
    jpy = 0
    btc = 0.0
    for i in range(N):
        if u[i] == "BTC":
            btc += x[i]
        else:
            jpy += x[i]
    
    return jpy + 380000.0 * btc


print(main())


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

using namespace std;

const int maxn = 2e5 + 7;
typedef long long LL;

int a[maxn];
LL sum[maxn];
int n;
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i)
		scanf("%d",&a[i]),sum[i] = sum[i - 1] + a[i];
	LL ans = 1e18;
	for(int div = 1; div < n; ++div){
		LL A = sum[div],B = sum[n] - sum[div];
		ans = min(ans,llabs(A - B));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val pn: Vector[Int] =
    (1 until n).foldLeft[Vector[Int]](io.StdIn.readLine().split(" ").map(_.toInt).toVector)
      {(acc, _) =>
        val Array(_, b): Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
        acc :+ b
    }
  println(matrixChainOrder(pn))

  def matrixChainOrder(p: Vector[Int]): Int = {
    val n: Int = p.length - 1
    val cache: Array[Array[Int]] = Array.fill(n+1, n+1)(Int.MaxValue)
    for (i <- 1 to n) cache(i)(i) = 0
    for (l <- 2 to n)
      for (i <- 1 to n-l+1; j = i+l-1)
        for (k <- i until j) {
          val q: Int =
            cache(i)(k) + cache(k+1)(j) + p(i-1) * p(k) * p(j)
          if (q < cache(i)(j)) {
            cache(i)(j) = q
          }
        }
    cache(1).last
  }
}


Measured memory_bytes: 46600
#include <iostream>
using namespace std;
int main() {
    int town[5] = {0};
    int sans = 0;
    int cans = 0;
    for (int i = 0; i < 3; ++i) {
        int a,b;
        cin >> a >> b;
        town[a]++;
        town[b]++;
    }
    for (int j = 1; j < 5; ++j) {
        if(town[j] == 1){
            sans++;
        }
        if(town[j] == 2){
            cans++;
        }
    }
    if(sans == 2 && cans == 2){
        cout << "YES";
    } else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
// @skylag
//I am into me now ;)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
int power(int a,int n,int m)
{
    int res=1;
    while(n)
    {
        if(n&1)
        {
            res=((res)*(a));
            n--;
        }
        else
        {
            a=((a)*(a));
            n/=2;
        }
    }
    return res;
}

void solve(int t)
{
    
    int n;
    cin>>n;
    int money=1000;
    int a[n];
    for(auto &it: a)
        cin>>it;
    for(int i=0;i<n-1;i++)
    {
        int buy=0;
        if(a[i]<a[i+1])
        {
            buy=(money)/a[i];
        }
        money+=(a[i+1]-a[i])*buy;
        
    }
    cout<<money;

}
int32_t main()
{
    SKY;
    //freopen("/Users/skylags/Desktop/input.txt","r",stdin);
    //freopen("/Users/skylags/Desktop/output.txt","w",stdout);
    int t=1;
    //cin>>t;
    int flag=1;
    while(t--)
    {
        solve(flag);
        flag++;
    }
}
/*Codechef July Lunchtime (Div.2)*/
//cout<<"Case #"<<t<<":"<<"\n";
//int n;
//cin>>n;
//vector<pair<int,int>> v(n);
//for(int i=0;i<n;i++)
//{
//    cin>>v[i].F>>v[i].S;
//}
//int ans=0;
//int temp=0;
//sort(ALL(v));
//int start=0;
//unordered_map<int,int> forward,backward;
//for(int i=0;i<n;i++)
//{
//
//}
//while(1)
//{
//    int temp=0;
//    for(int i=start;i<n;i++)
//    {
//        temp+=v[i].S;
//
//    }
//}
//ans=max(ans,v[n-1].S);
//cout<<ans<<"\n";


Measured memory_bytes: 3560
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    if(s=="SUN")cout<<7<<endl;
    if(s=="MON")cout<<6<<endl;
    if(s=="TUE")cout<<5<<endl;
    if(s=="WED")cout<<4<<endl;
    if(s=="THU")cout<<3<<endl;
    if(s=="FRI")cout<<2<<endl;
    if(s=="SAT")cout<<1<<endl;
}


Measured memory_bytes: 256
def merge(a, left, mid, right):
    global count
    l = a[left:mid] + [sentinel]
    r = a[mid:right] + [sentinel]
    i = j = 0
    for k in range(left, right):
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1
    count += right - left


def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

sentinel = 10 ** 9 + 1

n = int(input())
a = list(map(int, input().split()))
count = 0
merge_sort(a, 0, len(a))
print(*a)
print(count)

Measured memory_bytes: 84280
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

// 文字列を圧縮する。first に文字、second に個数
map<char, int> run_length(string &s) {
    map<char, int> ans;
    for (int i = 0; i < s.size(); i++) {
        ans.count(s[i]) ? ans[s[i]]++ : ans[s[i]] = 1;
    }
    return ans;
}

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

    string s;
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        print(-1);
        return 0;
    }
    if (s.size() < 26) {
        auto len = run_length(s);
        REP(i, 26) {
            char x = i + 'a';
            if (!len.count(x)) {
                print(s + x);
                return 0;
            }
        }
    }
    string ans(s);
    next_permutation(ALL(ans));
    while (s < ans.substr(0, (int)ans.size() - 1)) {
        ans.pop_back();
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

#include <list>
#include <queue>
#include <algorithm>

#define INF 1000000000

using namespace std;
using ll = long long;

int main(void)
{
    string S, T;
    cin >> S >> T;

    int ans = T.size();

    for (int start = 0; start <= S.size() - T.size(); start++) {
        int diff = 0;
        for (int i = 0; i < T.size(); i++) {
            if (T[i] != S[start + i]) diff++;
        }
        ans = min(diff, ans);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3496
#include <iostream>
#include <vector>
#include <cmath>

#define ll long long
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];

    ll sum = 0;
    for (int i = 0; i < n; i++)sum += v[i];

    for (int i = 1; i < n; i += 2)sum -= v[i] * 2;
    vector<ll> ret(n);
    ret[0] = sum;
    for (int i = 1; i < n; i++)ret[i] = v[i - 1] * 2 - ret[i - 1];

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    return 0;
}

Measured memory_bytes: 2816
S = input()
len_S = len(S)-1
ans = 0
for s in range(1<<len_S):
  now = ""  
  now += S[0]  
  for i in range(len_S):    
    if s & (1<<i): # 間に"+"を入れる
      now += "+"
    now += S[i+1]    
  ans += eval(now)
print(ans)  

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

const int MAX = 100 + 5;

int h, w;
char map[MAX][MAX];
bool vis[MAX][MAX];

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

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

void dfs(int x, int y){
	vis[x][y] = true;
	for (int i = 0; i < 4; i++){
		int xx = x + dx[i];
		int yy = y + dy[i];
		if(in(xx, yy) && !vis[xx][yy] && map[xx][yy] == map[x][y]){
			dfs(xx, yy);
		}
	}
}

int main(){
	while(cin >> h >> w && h && w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}
		int ans = 0;
		memset(vis, false, sizeof(vis));
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if(!vis[i][j]){
					dfs(i, j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	} 
	return 0;
} 


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    string s;
    int res = 0;
    cin >> s;
    if (s[1] == 'S') {
        if (s[0] == 'R' || s[2] == 'R')
            res = 1;
        else
            res = 0;
    }
    else if (s[0] == s[2]) {
        if (s[0] == 'S')
            res = 1;
        else
            res = 3;
    }
    else
        res = 2;
    cout << res;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
C = list(map(int, input().split(" ")))
point = 0
last_index = -1
for a in A:
    point += B[a - 1]
    if last_index == a - 1:
        point += C[a-2]
    last_index = a

print(point)


Measured memory_bytes: 3060
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, M, Q = map(int, input().split())
    LR = [LI_() for _ in range(M)]
    pq = [LI_() for _ in range(Q)]

    cnt = [[0]*N for _ in range(N)]
    for i in LR:
        cnt[i[0]][i[1]] += 1

    acc = [[0]*(N+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(N):
            acc[i+1][j+1] = acc[i+1][j] + cnt[i][j]
    for i in range(N):
        for j in range(N):
            acc[i+1][j+1] += acc[i][j+1]

    for i in pq:
        p = i[0]
        q = i[1]
        ans = acc[q+1][q+1] - acc[p][q+1] - acc[q+1][p] + acc[p][p]
        print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 60460
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        int n,k;
        cin >> n >> k;
        string s;
        cin >> s;
        int ans = 0;
        for(int i=0;i<n-1;i++){
            if(s[i]==s[i+1])ans++;
        }
        while(k--){
            ans+=2;
        }
        cout << min(ans,n-1) << endl;
        return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#define INF 1e+9
using namespace std;

struct edge{ int to,cost; };

int mi,dist[800];
vector<edge> G[800];

void dfs(int v,int prev){
	if(G[v].size() == 1){
		dist[v] = 0;
		return;
	}
	for(int i = 0;i < G[v].size();i++){
		int to = G[v][i].to;
		if(to == prev) continue;
		dist[to] = dist[v] + G[v][i].cost;
		dfs(to,v);
	}
}

int main(){
	int n;
	while(cin >> n,n){
		int p[800],d[800],sum = 0,res;
		mi = INF;
		for(int i = 0;i < n - 1;i++){
			scanf("%d",&p[i]);
			p[i]--;
		}
		for(int i = 0;i < n - 1;i++){
			scanf("%d",&d[i]);
			sum += d[i];
			G[i + 1].push_back({p[i],d[i]});
			G[p[i]].push_back({i + 1,d[i]});
		}
		res = sum;
		for(int i = 0;i < n;i++) if(G[i].size() == 1) res -= G[i][0].cost;
		for(int i = 0;i < n;i++){
			if(G[i].size() == 1) continue;
			dist[i] = 0;
			dfs(i,-1);
			int ma = 0;
			for(int j = 0;j < n;j++) ma = max(ma,dist[j]);
			mi = min(mi,sum + res * 2 - ma);
		}
		cout << mi << endl;
		for(int i = 0;i < n;i++) G[i].clear();
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int a, b;

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b;
  ll c = lcm(a, b);
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string s;
    cin >> s;
    map<string, int> m = {
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1}
    };
    cout << m[s] << endl;
    return 0;
}

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

const int m = 1000001;

int dp[2][1000001];

int main() {

    rep(i, 2)rep(j, m)dp[i][j] = j;

    for(int i=1,a;a=i*(i+1)*(i+2)/6,a<m;i++)
        rep(k, m-a) {
            if(dp[0][k]< dp[0][k+a])dp[0][k+a] = dp[0][k] + 1;
            if(a%2 && dp[1][k] < dp[1][k+a])dp[1][k+a] = dp[1][k] + 1;
        }

    for(int n;cin>>n,n;)cout<<dp[0][n]<<' '<<dp[1][n]<<endl;

    return 0;
}


Measured memory_bytes: 10872
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
vector<int>a(10);
vector<int>b(10);
int main(){
  int n;
  double sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    cin>>b[i];
  }
  /*vector<int>v(n);
  for(int i=0;i<n;i++)
    v[i]=i+1;
  do{
    for(int j=0;j<n-1;j++){
      sum+=ans(v[j],v[j+1]);
    }
  }while(next_permutation(v.begin(),v.end()));*/
  double xx,yy;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      xx=a[i]-a[j];
      yy=b[i]-b[j];
      sum+=pow(xx*xx+yy*yy,0.5);
    }
  }
  cout<<fixed<<setprecision(10)<<sum*2/n;
  return 0;      
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int sum;
	while (in >> sum) {
		if (!sum)break;
		int a, b = 0;
		REP(i, 9) {
			in >> a;
			b += a;
		}
		out << sum - b << endl;
	}
	return 0;

}

Measured memory_bytes: 2932
#include<iostream>
#include<string>
#include<algorithm>

int main(){
  int N;
  std::string S;
  std::cin >> N >> S;
  int max = 0, sum = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'I') sum++;
    else sum--;
    max = std::max(max, sum);
  }
  std::cout << max << std::endl;
}

Measured memory_bytes: 256
void main() {
	auto N = ri, A = ri;
	(N % 500 <= A ? "Yes" : "No").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

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

  double odd = 0;
  double even = 0;
  for(int i = 1; i <= n; i++) {
    if((i % 2) != 0) {
      odd++; 
    }else{
      even++;
    }
  }

  double ans = (double) odd / n;
  printf("%f",ans);
//  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    store = []
    for i in range(n):
        s, p = input().split()
        #(順番、店名、点数)
        store.append((i+1, s, int(p)))

    #第二キーは降順にしたい場合、キーに-をつける
    store.sort(key=lambda x:(x[1],-x[2]))
    for i in range(n):
        print(store[i][0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

if sum(A)<sum(B):
    print(-1);exit()
s_ab = sorted(list(i-j for i,j in zip(A,B)))
s = 0
c = 0
for i in s_ab:
    if i<0:
        s+=i
        c+=1
    else:
        break
s_ab = s_ab[::-1]
for i in s_ab:
    if s<0:
        s+=i
        c+=1
    else:
        break
print(c)

Measured memory_bytes: 18396
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll x;
    ll ans = 0;
    std::cin >> x;
    if (x < 600) {
        ans = 8;
    } else if (x < 800) {
        ans = 7;
    } else if (x < 1000) {
        ans = 6;
    } else if (x < 1200) {
        ans = 5;
    } else if (x < 1400) {
        ans = 4;
    } else if (x < 1600) {
        ans = 3;
    } else if (x < 1800) {
        ans = 2;
    } else {
        ans = 1;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

ll n, d, x;
ll p[100][100];

ll dp[100][200000];

int main() {
	cin >> n >> d >> x;
	rep(i, d)rep(j, n)cin >> p[i][j];
	rep(i, d - 1) {
		rep(j, 100)rep(k, 100)dp[j][k] = 0;
		rep(j, n) {
			rep(k, x + 1) {
				if (k < p[i][j])dp[j + 1][k] = dp[j][k];
				else dp[j + 1][k] = max(dp[j][k],
					dp[j + 1][k - p[i][j]] + max(p[i + 1][j] - p[i][j], (ll)0));
			}
		}
		x += dp[n][x];
		//cout << x << endl;
	}
	cout << x << endl;
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define FL(i,j,k) for(int i=j;i<k;++i)
#define eat(a) int a;scanf("%d",&a)

using namespace std;
typedef long long ll;
typedef vector<ll> vi;

int main(void)
{
    ll N,M;cin>>M>>N;
    ll T=min(N/2,M);N-=T*2,M-=T;
    cout<<T+N/4;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	int n , m ;
	cin >> n >> m; 
	int ans = 0 ;
	vi v(n);
	rep(i,0,n){
		cin >> v[i];
		ans+=v[i];
	}
	int cnt = 0 ;	
	rep(i,0,n) if(v[i]*4*m>=ans) cnt++;
	if(cnt>=m) cout << "Yes\n";
	else cout << "No\n";
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
double PI = 3.1415926;
int main(){
	double r;
	scanf("%lf", &r);
	
	double area, circumference;
	area = M_PI*pow(r,2);
	circumference = 2*M_PI*r;
	printf("%.6f %.6f\n", area, circumference);
	
	return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,d,x,y,ctr=0;
  double max;
  cin>>n>>d;
  while(n--)
  {
    cin>>x>>y;
    max = sqrt(x*x+y*y);
    if(max<=d)
      ctr++;
  }
  cout<<ctr<<endl;
}


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

using namespace std;

int main(){
	string S,T;
	cin>>S;
	cin>>T;
	int count=0;
	for(int i=0;i<3;i++)
	{
		if(S[i]==T[i]){
			count++;
		}
	}
	cout<<count;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  r(i,n)cin >> v[i];
  r(i,n-1) v[0]=(v[0]^v[i+1]);
  if(v[0]==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B 
import qualified Data.Set as S
import Control.Monad 

main :: IO ()
main = readLn >>= main'
    where
        main' n = replicateM n B.getLine >>= B.putStrLn . solve 

solve :: [B.ByteString] -> B.ByteString
solve (x : xs)
    | check x xs = "Yes"
    | otherwise = "No"
    where
        check p = cf (S.singleton p) p
        cf s p (w : ws)
            | not (S.member w s) && B.last p == B.head w = cf (S.insert w s) w ws
            | otherwise = False
        cf _ _ _ = True

Measured memory_bytes: 508
n, a, b = map(int, input().split())
v = n

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()



c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    exit()


Measured memory_bytes: 3060
N = int(input())
C = list(map(int,input().split()))
for i in range(N):
    C[i] *= -1
C.sort()
for i in range(N):
    C[i] *= -1
mod = 10**9 + 7
ans = 0
for i in range(N):
    ans += C[i]*(i+2)
ans = ans*(4**(N-1))
ans = ans % mod
print(ans)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string s;
  cin >> s;
  bool ok = false;
  rep(i, 0, s.size()) {
    if (s[i] == '7') ok = true;
  }

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
};


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 2001000
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar(); bool flag = false;
  while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
  if (flag) x = -x;
}
using namespace std;
const int P = 1e9 + 7;
int X1, X2, X3, X4, X5, X6;
int Y1, Y2, Y3, Y4, Y5, Y6;
ll jie[N], jieni[N];
inline ll quickpow(ll x, int k) {
  ll res = 1;
  while (k) {
    if (k & 1)  res = res * x % P;
    x = x * x % P;
    k >>= 1;
  }
  return res;
}

inline void init() {
  int up = X6 + Y6;
  jie[0] = jieni[0] = 1;
  for (int i = 1; i <= up; ++i) jie[i] = jie[i - 1] * i % P;
  jieni[up] = quickpow(jie[up], P - 2);
  for (int i = up - 1; i; --i)  jieni[i] = jieni[i + 1] * (i + 1) % P;
}
inline ll get_c(int n, int m) {
  return jie[n] * jieni[m] % P * jieni[n - m] % P;
}
inline ll G(int sx, int sy, int fx, int fy) {
  int x = fx - sx, y = fy - sy;
  return get_c(x + y, x);
}

inline void work() {
  int dx[8] = {X1 - 1, X1 - 1, X2, X2, X5, X5, X6 + 1, X6 + 1};
  int dy[8] = {Y1 - 1, Y2, Y1 - 1, Y2, Y5, Y6 + 1, Y5, Y6 + 1};
  int tp[8] = {1, -1, -1, 1, 1, -1, -1, 1};
  ll ans = 0;
  for (int jzp = 0; jzp < 4; ++jzp) {
    int sx = dx[jzp], sy = dy[jzp];
    for (int zzz = 4; zzz < 8; ++zzz) {
      int fx = dx[zzz], fy = dy[zzz];
      ll res = 0;
      int ntp = tp[jzp] * tp[zzz];
      int x, y;
      for (x = X3, y = Y3; x <= X4; ++x) {
        res = (res - G(sx, sy, x, y - 1) * G(x, y, fx, fy) % P * (x + y)) % P;
      }
      for (x = X3, y = Y3; y <= Y4; ++y) {
        res = (res - G(sx, sy, x - 1, y) * G(x, y, fx, fy) % P * (x + y)) % P;
      }
      for (x = X3, y = Y4; x <= X4; ++x) {
        res = (res + G(sx, sy, x, y) * G(x, y + 1, fx, fy) % P * (x + y + 1)) % P;
      }
      for (x = X4, y = Y3; y <= Y4; ++y) {
        res = (res + G(sx, sy, x, y) * G(x + 1, y, fx, fy) % P * (x + y + 1)) % P;
      }
      ans = (ans + ntp * res) % P;
    }
  }
  printf("%lld\n", (ans % P + P) % P);
}

int main() {
  read(Y1), read(Y2), read(Y3), read(Y4), read(Y5), read(Y6);
  read(X1), read(X2), read(X3), read(X4), read(X5), read(X6);
  init();
  work();
  return 0;
}


Measured memory_bytes: 34416
summer_vacation_day, home_work_number = input().split()
take_time_home_work = input().split()
result  = 0

for i in range(int(home_work_number)):
  result = result + int(take_time_home_work[i])

if int(summer_vacation_day) - result >= 0:
  print(int(summer_vacation_day) - result)
else:
  print('-1')
  

Measured memory_bytes: 9508
#include <cstdio>
#include <vector>
using namespace std;
#define MAXN 100005
vector < int > G[MAXN];
int n, m, result;
int h[MAXN];

bool check ( int u ) {
	for ( int i = 0;i < G[u].size();i ++ ) {
		int v = G[u][i];
		if ( h[v] >= h[u] ) return 0;
	}
	return 1;
}

int main() {
	scanf ( "%d %d", &n, &m );
	for ( int i = 1;i <= n;i ++ )
		scanf ( "%d", &h[i] );
	for ( int i = 1;i <= m;i ++ ) {
		int a, b;
		scanf ( "%d %d", &a, &b );
		G[a].push_back ( b );
		G[b].push_back ( a );
	}
	for ( int i = 1;i <= n;i ++ )
		if ( check ( i ) ) result ++;
	printf ( "%d", result );
	return 0;
}

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

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

    std::vector<long long> a(n + 1);
    a[0] = 2;
    a[1] = 1;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i - 1] + a[i - 2];
    }

    std::cout << a[n] << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  map<int, int> mp;
  for(int i=0; i<n; i++){
    mp[a[i]] = 0;
  }
  for(int i=0; i<n; i++){
    mp[a[i]]++;
  }
  int size = mp.size();
  vector<int> num;
  for(auto p : mp){
    num.push_back(p.second);
  } 
  int ans = 0;
  sort(num.begin(), num.end());
  for(int i=0; i<size - k; i++){
    ans += num[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

ll solve(ll a, ll b, ll c){
    ll d = max(max(a,b),c);
    ll e = min(min(a,b),c);
    return d - e;    
}

int main(){
    ll H,W;
    cin >> H >> W;
    if(H % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    if(W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll m = 1e18;
    ll a = (H/3)*W;
    ll b = (H - H/3)*(W/2);
    ll c = (H - H/3)*(W - W/2);
    m = min(m, solve(a,b,c));
    a = (H/3 + 1)*W;
    b = (H - H/3 - 1)*(W/2);
    c = (H - H/3 - 1)*(W - W/2);
    m = min(m, solve(a,b,c));
    a = (H/3 + 2)*W;
    b = (H - H/3 - 2)*(W/2);
    c = (H - H/3 - 2)*(W - W/2);
    m = min(m, solve(a,b,c));
    a = (W/3)*H;
    b = (W - W/3)*(H/2);
    c = (W - W/3)*(H - H/2);
    m = min(m, solve(a,b,c));
    a = (W/3 + 1)*H;
    b = (W - W/3 - 1)*(H/2);
    c = (W - W/3 - 1)*(H - H/2);
    m = min(m, solve(a,b,c));
    a = (W/3 + 2)*H;
    b = (W - W/3 - 2)*(H/2);
    c = (W - W/3 - 2)*(H - H/2);
    m = min(m, solve(a,b,c));
    cmin(m,H);
    cmin(m,W);
    cout << m << endl;
}


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
                                                //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


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

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////

//main function is here.........

int main()
{
    //ios
ll n,m;
cin>>n>>m;
if(n==m)cout<<"Yes";
else cout<<"No";
}




//Alhamdulillah


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      int n;
      cin >> n;
      int cut=0;
      int g=0;
      int w=0;
      int p=0;
      int y=0;
      rep(i,n){
          char s;
          cin >> s;
         // cout << s << endl;
          if(s=='G' && g==0){
              cut++;
              g++;
          }
            if(s=='P' && p==0){
              cut++;
              p++;
          }
            if(s=='W' && w==0){
              cut++;
              w++;
          }
            if(s=='Y' && y==0){
              cut++;
              y++;
          }
      }
      switch (cut)
      {
      case 3:
      cout << "Three" << endl;
          break;
      
      case 4:
      cout << "Four" << endl;
          break;
      }
  // cout << cut << endl;
      return 0;
  }

Measured memory_bytes: 3604
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
T = [int(input()) for i in range(D)]

satisfaction = 0
last = [0]*26

for i in range(D):
    satisfaction += S[i][T[i]-1]
#     コンテスト開催による満足度増加
    last[T[i]-1] = i+1
#     last 更新

    satisfaction -= sum([C[k]*((i+1)-last[k]) for k in range(26)])
#     開催していない分の満足度降下

    print(satisfaction)

Measured memory_bytes: 9396
while True:
    c=0
    a,b=map(int,input().split())
    for l in range(1,a+1):
        for m in range(1,a+1):
            for n in range(1,a+1):
                if l+m+n==b:
                  if l==m or m==n or l==n:
                    c=c
                  else:
                    c+=1
    if a==0 and b==0:
        break
    print(int(c/6))
    



Measured memory_bytes: 5596