akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , k , c = 0;
    cin >> n >> k;
    int l[n];
    for( int i = 0 ; i < n ; i++ ) cin >> l[i];
    sort( l , l + n );
    for( int i = n - 1 ; i >= n - k ; i-- ) c += l[i];
    cout << c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n,m;
  cin >> n >> m;
  vvi a(n,vi(n,0));
  vvi b(m,vi(m,0));
  rep(i,n) {
    string s;
    cin >> s;
    rep(j,n) {
      if(s.at(j) == '#') a.at(i).at(j) =1;
      else a.at(i).at(j) = 0;
  }
}
  rep(i,m) {
    string s;
    cin >> s;
    rep(j,m) {
      if(s.at(j) == '#') b.at(i).at(j) =1;
      else b.at(i).at(j) = 0;
  }
}

  rep(xs,n) rep(ys,n) {
    bool flag = true;
    rep(i,m) rep(j,m) {
      if(xs+i>=n or ys+j>=n) {
        flag = false;
        continue;
      }
      if(b.at(i).at(j)!=a.at(xs+i).at(ys+j)) {
        flag = false;
        break;
      }
    }
    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


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

#define int long long
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }
    vector<int> mark(n+1, 0);
    int pos = 1;

    bool upto = false;

    for(int i=1; i<=k; i++) {
        if(mark[pos] > 0) {
            k-=(mark[pos]-1);
            k = k%(i-mark[pos]);
            upto = true;
            break;
        }
        mark[pos] = i;
        pos = a[pos];
    }
    //pos = 1;
    if(!upto) {
        pos = 1;
    }
    while(k--) {
        pos = a[pos];
    }
    cout << pos;
    return 0;
}


Measured memory_bytes: 6368
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int *heightTable;
int *widthTable;

void func(int N,int M){
	int h_value[N],w_value[M],h_max = 0,w_max = 0;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&h_value[loop]);
		heightTable[h_value[loop]]++;
		h_max = max(h_max,h_value[loop]);
	}

	for(int loop = 0; loop < M; loop++){
		scanf("%d",&w_value[loop]);
		widthTable[w_value[loop]]++;
		w_max = max(w_max,w_value[loop]);
	}

	int S;

	for(int range = 2; range <= N; range++){

		S = 0;

		for(int right = 0; right < range;right++){
			S += h_value[right];
		}

		h_max = max(h_max,S);
		heightTable[S]++;

		for(int left = 1; left <= N-range; left++){
			S -= h_value[left-1];
			S += h_value[left+range-1];
			heightTable[S]++;
			h_max = max(h_max,S);
		}
	}

	for(int range = 2; range <= M; range++){

		S = 0;

		for(int right = 0; right < range;right++){
			S += w_value[right];
		}

		w_max = max(w_max,S);
		widthTable[S]++;

		for(int left = 1; left <= M-range; left++){
			S -= w_value[left-1];
			S += w_value[left+range-1];
			widthTable[S]++;
			w_max = max(w_max,S);
		}
	}

	int ans = 0;

	for(int i = 1; i <= min(h_max,w_max); i++){
		ans += heightTable[i]*widthTable[i];
	}

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

}

int main(){

	int N,M;

	heightTable = new int[1500001];
	widthTable = new int[1500001];

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i = 0; i <= 1500000; i++){
			heightTable[i] = widthTable[i] = 0;
		}

		func(N,M);
	}

    return 0;
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll ju = pow(10, 9);
	ll x, y, s;
	cin >> s;
	y = (s + ju - 1)/ju;
	x = ju * y - s;
	cout << "0 0 " << y << " 1 " << x << " " << ju << endl;
}


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

int main(){
    int n;
    cin>>n;
    long long int x;
    vector<long long int> a;

    for(int i = 0 ; i < n ; i++){
        cin>>x;
        a.push_back(x);
    }
    long long int output = 0;
    long long int sum = 0;

    for(int i : a){
        sum += i;
    }

    long long int mod = pow(10, 9) + 7;
    for(int i = 0 ; i < a.size() ; i++){
        sum = sum - a[i];
        // cout<<sum<<endl;
        int z = ((a[i] % mod) * (sum % mod)) % mod;
        // cout<<z<<endl;
        output = (output + z) % mod;
        // cout<<output<<endl;
    }

    cout<<output%mod;
}

Measured memory_bytes: 4960
def choose(n,a,mod):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

k = int(input())
n = len(input())
mod = pow(10,9)+7
start = 1
ans = start*pow(26,k,mod)
for i in range(1,k+1):
    start *= (i+n-1)*pow(i,mod-2,mod)
    start %= mod
    ans += (start*pow(25,i,mod)*pow(26,k-i,mod))
    ans %= mod
print(ans)

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

int c,s;
int flag[10];

void solve(int k,int a,int b){
    if(k==0&&a==s){
        c++;
        return;
    }
    if(k==0)return;
    for(int i=0;i<10;i++){
        if(!flag[i]){
            flag[i]=1;
            solve(k-1,a+i*b,b+1);
            flag[i]=0;
        }
    }
    return;
}

int main(void){
    int n;
    while(cin>>n>>s){
        c=0;
        memset(flag,sizeof(flag),0);
        solve(n,0,1);
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
//  Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 5005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

const i64 MOD = 1e9 + 7;
const i64 LIM = 5000;
i64 fact[LIM + 5];
i64 finv[LIM + 5];
i64 N, K, dpR[MAX], dpB[MAX];

i64 fastpow( i64 b , i64 e )
{
    i64 ans = 1;
    while( e > 0 )
    {
        if( e & 1 )
            ans = ( ans * b ) % MOD;
        
        b = ( b * b ) % MOD;
        e >>= 1;
    }
    return ans;
}

i64 nCk( i64 n , i64 k )
{
    return ( fact[n] * ( ( finv[k] * finv[n - k] ) % MOD ) ) % MOD;
}

int main() {
    optimiza_io
    fact[0] = finv[0] = 1;
    for( i64 i = 1; i <= LIM; i ++ )
        fact[i] = ( fact[i - 1] * i ) % MOD;
    
    finv[LIM] = fastpow( fact[LIM] , MOD - 2 );
    
    for( i64 i = LIM - 1; i >= 1; i -- )
        finv[i] = ( finv[i + 1] * ( i + 1 ) ) % MOD;
    
    cin >> N >> K;
    N -= K;
    if( ! N )
        dpR[0] = 1;
    for( i64 i = 1; i <= N; i ++ ) {
        // Haz i grupos
        dpR[i] = nCk( N - 1 , i - 1 );
    }
    
    if( ! K )
        dpB[0] = 1;
    for( i64 i = 1; i <= K; i ++ ) {
        // Haz i grupos
        dpB[i] = nCk( K - 1 , i - 1 );
    }
    
    for( i64 i = 1; i <= K; i ++ ) {
        i64 ans = ( dpB[i] * ( ( dpR[i - 1] + 2 * dpR[i] + dpR[i + 1] ) % MOD ) ) % MOD;
        cout << ans << "\n";
    }
    
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 384
<?php
/*
    Problem URL : http://agc002.contest.atcoder.jp/tasks/agc002_c

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d", $N, $L);
$a = explode(" ", trim(fgets(STDIN)));
$p = null;
$mmax = 0;

for ($i = 0; $i < $N - 1; $i++) {
    $tmp = $a[$i] + $a[$i+1];
    $mmax = max($mmax, $tmp);
    if ($tmp >= $L) {
        $p = $i;
    }
}

if ($mmax >= $L) {
    echo "Possible\n";
} else {
    exit("Impossible\n");
}

$arr1 = $p > 0 ? range(1, $p) : array();
$arr2 = range($N-1, $p+1);
echo implode(PHP_EOL, array_merge($arr1, $arr2)) . PHP_EOL;


Measured memory_bytes: 45872
#include<stdio.h>
int n[1000000]={0};
int main(){
  char p[1000000]={1,1};
  int i,j,c;
  for(i=2;i*i<1000000;i++){
    if(p[i])continue;
    for(j=2;i*j<1000000;j++){
      p[i*j]=1;
    }
  }
  for(i=c=0;i<1000000;i++){
    if(p[i]==0)c++;
    n[i]=c;
  }
  while(scanf("%d",&i)!=EOF)printf("%d\n",n[i]);
  return 0;
}

Measured memory_bytes: 5484
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int m,n,i;
    cin>>n>>m;
    vector<ll> a(m,0);
    rep(i,m)cin>>a[i];
    vector<ll> dp(n+100,0);
    dp[0]=0;
    dp[1]=1;
    dp[2]=2;
    rep(i,m)dp[a[i]]=-1;
    // rep(i,n)cout<<dp[i]<<" ";
    for(i=1;i<n+10;i++){
        if(dp[i]==-1)dp[i]=0;
        else if(i==1)dp[1]=1;
        else if(i==2&&dp[1]==0)dp[2]=1;
        else if(i==2)dp[2]=2;
        else{
            
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=P;
            // cout<<"i:"<<i<<" "<<dp[i]<<endl;
        }
    }
    cout<<dp[n]<<endl;
//////////////////////////////////////////////////////
return 0;}







Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int calc(const char *buf, char al);

int main(int argc, char *argv[])
{
    char buf[512];
    int al[32] = {0};
    int i, j, min = 100;

    fgets(buf, sizeof(buf), stdin);
    for ( i = 0; buf[i] != '\0'; i++ ){
        if ( buf[i] == '\r' || buf[i] == '\n' ){
            buf[i] = '\0';
            break;
        }
        for ( j = 0; j < 26; j++ ){
            if ( buf[i] == (j+'a') ){
                al[j]++;
            }
        }
    }

    for ( i = 0; i < 26; i++ ){
        if ( al[i] == 0 ){
            continue;
        }
        j = calc(buf, i+'a');
        if ( min > j ){
            min = j;
        }
    }

    printf("%d\n", min);
    return 0;
}
static int calc(const char *buf, char al)
{
    char from[512], to[512];
    int i, len = strlen(buf), c = 0;

    strcpy(from, buf);
    do{
        for ( i = 0; i < len; i++ ){
            if ( from[i] != al ){
                break;
            }
        }
        if ( i == len ){
            return c;
        }
        c++;
        for (i = 0; i < len-1; i++ ){
            if (from[i]==al){
                to[i] = al;
            } else {
                to[i] = from[i+1];
            }
        }
        strcpy(from, to);
        len -= 1;
        from[len] = '\0';
    } while(len>0);
    return 100;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    OP(n / 3);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int n;
  std::cin >> n;
  
  std::set<int> s;
  
  for(int i = 0; i < n; i++){
    int a;
    std::cin >> a;
    if(s.count(a)) s.erase(a);
    else s.insert(a);
  }
  
  std::cout << s.size() << std::endl;
  
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<int32> x(n), y(n), t(n);
	rep(i, 0, n)
		std::cin >> t[i] >> x[i] >> y[i];
	int32 xnow = 0, ynow = 0, tnow = 0;
	rep(i, 0, n) {
		int32 d = std::abs(xnow - x[i]) + std::abs(ynow - y[i]);
		if (t[i] - tnow < d) {
			std::cout << "No\n";
			return 0;
		}
		if ((t[i] - tnow-d) % 2 == 1) {
			std::cout << "No\n";
			return 0;
		}
		tnow = t[i];
		xnow = x[i];
		ynow = y[i];
	}
	std::cout << "Yes\n";

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  ll ans = 0;
  rep(i, 0, n) {
    rep(j, i + 1, n) { ans += v[i] * v[j]; }
  }

  cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  bool b = true;
  int l = 0, r = 0, eli = 0;
  for (int i = 0; i < N; i++) {
    if (!b && s[i] == 'S') {
      b = true;
      int p = min(l,r);
      eli += 2*p;
      l -= p; r = 0;
    }
    if (s[i] == 'S') l++;
    if (s[i] == 'T') {
      b = false;
      r++;
    }
  }
  eli += 2*min(l,r);
  cout << N - eli << endl;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    vector<ll> al(26, 0);
    ll n = s.size();
    ll ans = (n * (n-1))/2;
    REP(i, 0, n){
        al[s[i]-'a']++;
    }
    REP(i, 0, 26){
        ans -= (al[i] * (al[i]-1))/2;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<iomanip>
#include<bitset>
#include<math.h>
#include<stack>
#include<set>
using namespace std;
#define int long long
int mod = 1e9 + 7;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int n, m;
	cin >> n >> m;
	vector<vector<int> > g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> q;
	vector<int> used(n, -1);
	q.push(0);
	used[0] = 0;
	while (!q.empty()) {
		int a = q.front();
		q.pop();
		for (int i = 0; i < g[a].size(); i++) {
			int to = g[a][i];
			if (used[to] == -1) {
				used[to] = a;
				q.push(to);
			}
		}
	}
	for (int i = 1; i < n; i++) {
		if (used[i] == -1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << used[i]+1 << endl;
	}
}
	

Measured memory_bytes: 12964
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

//素数ならtrue
bool prime[1000000];
int dp[100010];

signed main(void)
{
  int q;
  cin >> q;

  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i * i <= 1000000; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= 1000000; j += i) {
        prime[j] = false;
      }
    }
  }

  FOR(i, 1, 100010) {
    if(i%2 && prime[i] && prime[(i+1)/2]) {
      dp[i] = 1;
    }
  }

  FOR(i, 1, 100010) dp[i] += dp[i-1];

  REP(i, q) {
    int l, r;
    cin >> l >> r;
    cout << dp[r] - dp[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
  if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstdio>
using namespace std;
typedef long long ll;

int main() {
	ll n;
	ll m;
	cin>>n>>m;
	ll x=pow(2,m);
	ll ans=(1900*m+100*(n-m))*x;
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
  int a[8][8] = {
    {1,2,1,2,1,4,1,4},
    {1,2,1,4,1,4,1,2},
    {1,4,1,2,1,2,1,4},
    {1,4,1,4,1,2,1,2},
    {2,1,2,1,4,1,4,1},
    {2,1,4,1,4,1,2,1},
    {4,1,2,1,2,1,4,1},
    {4,1,4,1,2,1,2,1}}; 

    int b[8];

  while(~scanf("%d" ,&b[0])){
    int ans[8],min_ = (1<<29);
    for(int i = 1 ; i < 8 ; i++){
      scanf("%d" ,b + i);
    }
    
    for(int i = 0 ; i < 8 ; i++){
      int npas = 0;
      for(int j = 0 ; j < 8 ; j++){
	if(a[i][j] < b[j]){
	  npas += b[j] - a[i][j];
	}
      }
      if(min_ > npas){
	min_ = npas;
	for(int j = 0 ; j < 8 ; j++){
	  ans[j] = a[i][j]; 
	}
      }
    }

    for(int i = 0 ; i < 8 ; i++){
      if(i != 7){
	printf("%d " ,ans[i]);
      }else{
	printf("%d\n" ,ans[i]);
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    int A,B,C,D;
    int rec1,rec2;
    cin>>A>>B>>C>>D;
    rec1=A*B;rec2=C*D;
    if(rec1>rec2){cout<<rec1;}
    else{cout<<rec2;}
}

Measured memory_bytes: 256
// its_me_abhi
#include<bits/stdc++.h>
#define ll long long 
#define inf 1e18
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define I insert
#define E erase
#define tonp for(int i=0;i<n;i++)
#define ton for(int i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
#define desall(v) v.begin(),v.end(),greater<int>()
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define wh(t) ll t;cin>>t;while(t--)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool cmp(int a,int b) {return a>b;}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}
int main()
{
	FIO
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;

vector<int> ra(MX,0);
vector<int> par(MX,0);
using P = pair<int, int>;
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { 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 find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x==y) return;
    if(ra[x]<ra[y]) {
        par[x] = y;
    }else {
        par[y] = x;
        if(ra[x]==ra[y]) {
            ra[x]++;
            
        }
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int a[MX];
int c[10][1000];
signed main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool isrev = false;
    deque<char> queue;
    rep(i,s.length()) queue.push_back(s[i]);
    rep(i,q) {
        int com;
        cin >> com;
        if(com == 1) isrev = !isrev;
        else {
            int pos;
            cin >> pos;
            char c;
            cin >> c;
            if(isrev) pos = (pos)%2+1;
            if(pos==1) queue.push_front(c);
            else queue.push_back(c);
        }
    }
    if(isrev) reverse(queue.begin(), queue.end());
    rep(i,queue.size()) {
        cout << queue[i] << flush;
    }
    cout << "" << endl;

    return 0;

}



Measured memory_bytes: 16640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)












int main() {
	ll n;
	cin >> n;
	vector<ll> x(n), y(n);
	REP(i, n) {
		cin >> x[i] >> y[i];
	}
	vector<ll> v(n);
	iota(v.begin(), v.end(), 0);
	double sum = 0.0;
	int cnt = 0;
	do {
		cnt++;
		REP(i, n - 1) {
			sum += sqrt((x[v[i]] - x[v[i + 1]]) * (x[v[i]] - x[v[i + 1]]) +
						(y[v[i]] - y[v[i + 1]]) * (y[v[i]] - y[v[i + 1]]));
		}
	} while (next_permutation(v.begin(), v.end()));
	printf("%.8lf\n", sum / (double)cnt);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if min(a, b) == 0:
        return max(a, b)
    while b:
        a, b = b, a % b
    return a

l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[i], a[i]))
    r.append(gcd(r[i], a[n-i-1]))

r = r[::-1]

ans = 0
for i in range(n):
    g = gcd(l[i], r[i+1])
    ans = max(ans, g)

print(ans)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k;
  string s;
  cin >> k >> s;
  int n = sz(s);
  if (n <= k) {
    cout << s << endl;
  } else {
    rep(i, k) cout << s[i];
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func main() {
	var m, n int
	var tmp string
	fmt.Scan(&m, &n)
	x := make([][]int, m)
	for i := 0; i < m; i++ {
		x[i] = make([]int, n)
		fmt.Scan(&tmp)
		for j, r := range tmp {
			switch r {
			case '.':
				x[i][j] = 0
			case '#':
				x[i][j] = 1
			}
		}
	}
	for i := 0; i < m; i++ {
		checker := 0
		for j := 0; j < n; j++ {
			checker += x[i][j] % 2
		}
		if checker == 0 {
			for j := 0; j < n; j++ {
				x[i][j] = 2
			}
		}
	}
	for j := 0; j < n; j++ {
		checker := 0
		for i := 0; i < m; i++ {
			checker += x[i][j] % 2
		}
		if checker == 0 {
			for i := 0; i < m; i++ {
				x[i][j] = 2
			}
		}
	}
	for i := 0; i < m; i++ {
		checker := 0
		for j := 0; j < n; j++ {
			switch x[i][j] {
			case 0:
				fmt.Print(".")
				checker++
			case 1:
				fmt.Print("#")
				checker++
			}
		}
		if checker != 0 {
			fmt.Print("\n")
		}
	}
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    int d;
    cin >> d;
    if (a + b > c + d) {
        cout << "Left" << "\n";
    } else if (a + b < c + d) {
        cout << "Right" << "\n";
    } else {
        cout << "Balanced" << "\n";
    }
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  int a, b;
  REP(i, M) {
    cin >> a >> b;
    --a;
    --b;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  vector<bool> visit(N, false);
  queue<int> q;
  unordered_map<int, int> route;

  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();

    for (int nv : G.at(v)) {
      if (!visit.at(nv)) {
        q.push(nv);
        visit.at(nv) = true;
        route.insert(make_pair(nv, v));
      }
    }
  }

  if (!all_of(visit.begin(), visit.end(), [](bool f) { return f; })) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  REPI(i, 1, N) {
    // cout << i << ":" << route.at(i).size() << endl;
    cout << route.at(i) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 13880
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int t, p, r;
int points[100], pena[100], wacount[100][100];

int main() {
	while (cin >>t >> p >> r&&t&&p&&r) {
		REP(i, 100)points[i] = pena[i] = 0;
		REP(i, 100)REP(j, 100)wacount[i][j] = 0;
		REP(i, r) {
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes[0] == 'C') {
				points[tid]++;
				pena[tid] += wacount[tid][pid] * 1200 + time;
			}
			else {
				wacount[tid][pid]++;
			}
		}
		for (int q = 1; q <= t;q++) {
			int maxnum = -1, maxpos = -1, minpena = INF;
			for (int i = 1; i <= t;i++) {
				if (maxnum < points[i]) {
					maxnum = points[i];
					minpena = pena[i];
					maxpos = i;
				}
				else if (maxnum == points[i]) {
					if (minpena > pena[i]) {
						maxnum = points[i];
						minpena = pena[i];
						maxpos = i;
					}
				}
			}
			cout << maxpos << " " << points[maxpos] << " " << pena[maxpos] << endl;
			points[maxpos] = -INF;
			pena[maxpos] = INF;
		}
	}
}


Measured memory_bytes: 3176
#_______________________________________________________________#
def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x-1)
def lower_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer #index where x is not less than num
def upper_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2

		if li[middle] <= num:
			answer = middle
			start = middle + 1
		
		else:
			end = middle - 1
	return answer #index where x is not greater than num

def abs(x):
	return x if x >=0 else -x
def binary_search(li, val, lb, ub): 
	ans = 0
	while(lb <= ub):
		mid = (lb+ub)//2
		#print(mid, li[mid])
		if li[mid] > val:
			ub = mid-1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
def kadane(x): #maximum sum contiguous subarray
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far,current_sum)
	return sum_so_far
def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

#_______________________________________________________________#
'''
      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
   ▄███████▀▀▀▀▀▀███████▄
░▐████▀▒▒Aestroix▒▒▀██████
░███▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀████
░▐██▒▒▒▒▒KARMANYA▒▒▒▒▒▒████▌         ________________
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌  ? ?   |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░░█▒▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▒▐███▌   ?    |___CM ONE DAY___|
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▒▐███▌     ? ? |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌    ? ?    
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌      ? 
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█     ? ? 
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀       ? 
░░░░▄█████████ ████=========█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
░░░░░████████████████
'''
from math import *
#for _ in range(int(input())):
mod = 1000000007
for _ in range(1):
	n = int(input())
	#p,f = map(int,input().split())
	#d,t,s = map(int,input().split())
	#ws,wa = map(int,input().split())
	#b = list(input())
	#x = int(input())
	#n = len(b)
	#s2 = input()
	#r, g, b, w = map(int,input().split())
	a = list(map(int,input().split()))
	#b = list(map(int,input().split()))
	#s1 = list(st)
	li = pref(a)
	ans = 0
	for i in range(1,n+1):
		ans += a[i-1]*(li[-1]-li[i])
	print(ans%mod)




	


















	






Measured memory_bytes: 107516
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		String A;
		A = sc.next();
    A= A.substring(0,M-1)+A.substring(M-1,M).toLowerCase()+A.substring(M);
    
					System.out.print(A); 	

	}
}




Measured memory_bytes: 21588
#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 = 1e15;
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

ll n, x;
ll a[100100];
ll k[100100];

int main() {
	cin >> n >> x;
	ll ans = INF;
	rep(i, n) {
		cin >> a[i];
		k[i] = a[i];
	}
	rep(i, n) {
		ll num = 0;
		rep(j, n) {
			k[j] = min(k[j], a[(j - i + n) % n]);
			num += k[j];
		}
		ans = min(ans, num + i*x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int N, W;
    while(cin>>N>>W){
        vector<long long> wts(N+1);
        vector<long long> val(N+1);
        long long dp[N+1][W+1];
        memset(dp, 0, sizeof dp);

        for(int i=1; i<=N; i++){
            cin>>wts[i]>>val[i];
        }
        
        for(int i=1; i<=N; i++){
            for(int w = 1; w<=W; w++){
                if(w-wts[i]>=0)
                    dp[i][w] = max(dp[i-1][w], val[i] + dp[i-1][w-wts[i]] );
                else 
                    dp[i][w] = dp[i-1][w];
            }
        }
        
        cout<<dp[N][W]<<endl;
    }

    return 0;
}

Measured memory_bytes: 79104
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
ll N;
ll M;
ll dp[305][305][305];
const ll K = 1E9 + 7 + 1E-5;
vector<pair<int, int>> v[305]; // v[r] = vector{l, x};
bool check(const int r, const int g, const int b) {
  const int k = max({r, b, g});
  for(auto const &pp: v[k]) {
    int ct = 0;
    const int l = pp.first;
    if (r >= l) ct++;
    if (g >= l) ct++;
    if (b >= l) ct++;

    if (ct != pp.second) return false;
  }
  return true;
}

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

  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int l, r, x;
    cin >> l >> r >> x;
    v[r].push_back({l, x});
  }
  dp[0][0][0] = 1;
  ll ret = 0;
  for(int r = 0; r <= N; ++r) {
    for(int g = 0; g <= N; ++g) {
      for(int b = 0; b <= N; ++b) {
        auto c = dp[r][g][b];
        if (!c) continue;

        if (!check(r, g, b)) {
          dp[r][g][b] = 0;
          continue;
        }
      
        int k = max({r, g, b}) + 1;
        if (k - 1 == N) {
          ret += dp[r][g][b];
          ret %= K;
        }
        dp[k][g][b] += dp[r][g][b];
        dp[k][g][b] %= K;
        dp[r][k][b] += dp[r][g][b];
        dp[r][k][b] %= K;
        dp[r][g][k] += dp[r][g][b];
        dp[r][g][k] %= K;

      }
    }
  }

  cout << ret << endl;
}


Measured memory_bytes: 221440
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string s;
    cin >> s;
    ll v[4];
    v[0] = stoll(s.substr(0, 1));
    v[1] = stoll(s.substr(1, 1));
    v[2] = stoll(s.substr(2, 1));
    v[3] = stoll(s.substr(3, 1));
    for(ll i = 0; i < 8; i++) {
        ll ret = v[0];
        rep(j, 3) {
            if (i >> j & 1 == 1) {
                ret -= v[j+1];
            } else {
                ret += v[j+1];
            }
        }
        if (ret == 7) {
            cout << v[0];
            rep(j, 3) {
                if (i >> j & 1 == 1) {
                    cout << "-";
                    cout << v[j+1];
                } else {
                    cout << "+";
                    cout << v[j+1];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, value, prev):
        self.value = value
        self.prev = prev


class Stack:
    def __init__(self):
        self.last = None

    def add(self, value):
        next_node = Node(value, self.last)
        self.last = next_node

    def pop(self):
        if not self.last:
            return -1
        v = self.last.value
        self.last = self.last.prev
        return v


stack = Stack()
s = input().split()
for c in s:
    if c in '+-*':
        a = stack.pop()
        b = stack.pop()
        if c == '+':
            stack.add(a + b)
        elif c == '-':
            stack.add(b - a)
        else:
            stack.add(a * b)
    else:
        stack.add(int(c))

print(stack.pop())



Measured memory_bytes: 5596
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> x(n), y(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i];
    }

    const double eps = 1e-7;
    double lb = 0, ub = 1'000;
    while (ub - lb > eps && (ub - lb) / (ub / 2 + lb / 2) > eps)
    {
        double r = ub / 2 + lb / 2;

        bool c = false;
        rep(i, n)
        {
            for (int j = i + 1; j < n; j++)
            {
                double x0 = x[i], y0 = y[i];
                double x1 = x[j], y1 = y[j];

                double vx = x1 - x0, vy = y1 - y0;
                double d = sqrt(vx * vx + vy * vy);
                if (d > 2 * r)
                    continue;

                double h = sqrt(r * r - d * d / 4);
                double wx = vy / d * h, wy = -vx / d * h;
                double cx0 = x0 + vx / 2 + wx, cy0 = y0 + vy / 2 + wy;
                double cx1 = x0 + vx / 2 - wx, cy1 = y0 + vy / 2 - wy;

                rep(i, 2)
                {
                    bool cc = true;
                    rep(j, n)
                    {
                        cc = cc && (r * r + eps >= pow(x[j] - cx0, 2) + pow(y[j] - cy0, 2));
                    }
                    c = c || cc;
                    swap(cx0, cx1);
                    swap(cy0, cy1);
                }
            }
        }

        (c ? ub : lb) = r;
    }
    cout << fixed << setprecision(7) << ub << endl;

    return 0;
}

Measured memory_bytes: 256
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define fst first
#define snd second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int bf0 = (1<<0);
const unsigned int bf1 = (1<<1);
const unsigned int bf2 = (1<<2);
const unsigned int bf3 = (1<<3);
const unsigned int bf4 = (1<<4);
const unsigned int bf5 = (1<<5);
const unsigned int bf6 = (1<<6);
const unsigned int bf7 = (1<<7);


//#include <boost/format.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
namespace bm = boost::math;

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

int main(void){
  string  S; cin>>S;
  string  R; cin>>R;
  int cnt=0;
  FOR(i,0,S.size()){
    if (S[i]==R[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
    cin>>s;int cnt=0;
  string t="CODEFESTIVAL2016";
  rep(i,16)
    if(s[i]==t[i])
       cnt++;
  cout<<16-cnt<<endl;
}


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

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	int lx = 0;
	int ly = 0;
	int rx = w;
	int ry = h;


	rep(i, n){
		int x, y, a;
		cin >> x >> y >> a;
		if(a == 1) lx = max(lx, x);
		if(a == 2) rx = min(rx, x);
		if(a == 3) ly = max(ly, y);
		if(a == 4) ry = min(ry, y);
	}

	if(lx >= rx || ly >= ry) cout << 0 << endl;
	else cout << (rx-lx) * (ry-ly) << endl;

}

Measured memory_bytes: 256
package main

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

type TupleInt struct {
	first  int
	second int
}

func main() {
	sc := NewScanner()
	_,S := sc.NextInt(),sc.Next()
	R := strings.Count(S, "R")
	B := strings.Count(S, "B")
	if R>B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}




}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type SortInterFace []TupleInt

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].first < s[j].first
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640