akhauriyash/Code-Regression huggingface dataset:
N=int(input())

for h in range(1,3501):
    for n in range(1,3501):
        x=4*n*h-n*N-h*N
        if x==0:
            continue
        w=h*n*N/x
        if w<=0:
          continue
        if N/int(w)+N/h+N/n==4:
            print(n,h,int(w))
            exit()

Measured memory_bytes: 40684
N,K = gets.split.map(&:to_i)
KK = 2*K

$tot = [0,0]
$elvis = (0..1).map{ (0..K).map{ Array.new(K+1,0) } }
N.times{  
  x,y,c = gets.split
  x,y = [x,y].map{ |r| r.to_i % KK }
  c = c == "B" ? 0 : 1
  if x >= K
    x %= K; c ^= 1
  end
  if y >= K
    y %= K; c ^= 1
  end
  $elvis[c][x][y] += 1
  $tot[c] += 1
}

def C(color, x, y)
  return 0 if x < 0 || y < 0
  $elvis[color][x][y]
end

$sum = (0..1).map{ |color|
  lastline = Array.new(K+1, 0)
  (0..K).map{ |y|
    linesum = 0
    lastline = (0..K).map{ |x|
      linesum += C(color, x, y)
      lastline[x] + linesum
    }
    lastline
  }
}

#p $elvis[0], $sum[0]
#p $elvis[1], $sum[1]

def S(color, x, y)
  return 0 if x < 0 || y < 0
  $sum[color][x][y]
end
#exit
ans = 0
(0..K).each{ |x|
  (0..K).each{ |y|
	bb = 2*S(0, x-1, y-1) - S(0, K, y-1) - S(0, x-1, K)
	ww = 2*S(1, x-1, y-1) - S(1, K, y-1) - S(1, x-1, K)
    ans = [ans, bb+$tot[0]-ww, ww+$tot[1]-bb].max
    #p ans
  }
}
puts ans

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

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

	vector<int> a(n);
	for (int i=0;i<n;++i)
	{
		cin >> a[i];
	}
	sort(a.begin(),a.end());

	int sum=0;
	for (int i=0;i<k;++i)
	{
		sum+=a[i];
	}
	cout << sum << endl;
}







Measured memory_bytes: 3632
"""
2 * a + 4 * 2 * (X - a) = Y
2a + 8X - 8a = Y
8X - 6a = Y


2 * turu + 4 * kame = Y
turu + kame = X
turu = X - kame

2(X - kame) + 4kame = Y
2X - 2kame + 4kame = Y
2X + 2kame = Y
2kame = Y - 2X
kame = (Y - 2X) / 2
"""


X, Y = input().split()
X = int(X)
Y = int(Y)

a = (Y - 2 * X) / 2

if a >= 0 and X >= a and a == int(a):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9116
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
int gcd(int x, int y) {
	/*最大公約数 O(log MAX_X)*/
	if (y == 0) return x;
	return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {

	int n;
	int k;
	cin >> n >> k;

	int p[1010];
	rep(i, n) cin >> p[i];

	sort(p, p + n);
	int sum = 0;
	rep(i, k) {
		sum += p[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int i, j, k;
	int n;
	int x;
	int cnt;
	
	while(1)
	{
		n = 0;
		x = 0;
		cnt = 0;
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0)
		{
			break;
		}
		
		for(i = 1; i <= n - 2; i++)
		{
			for(j = i + 1; j <=n - 1; j++)
			{
				for(k = j + 1; k <= n; k++)
				{
					if(i != j && j != k && i != k && x == (i + j + k))
					{
						cnt ++;
						//printf("%d,%d,%d\n", i , j, k);
					}
				}
			}
		}
		printf("%d\n", cnt);
		
	}

	return 0;
}

Measured memory_bytes: 600
n,m=[int(e) for e in input().split()]
a=[int(e) for e in input().split()]
count = 0
sum = 0
for i in range(n):
    sum += a[i]
for i in range(n):
    if a[i] >= sum / (4*m):
        count +=1
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  long long int N;
  cin >> N;
  long long int kane=100;
  int count=0;
  while(kane<N){
    kane*=1.01;
    count++;
  }
  cout << count;
  cout << endl;
  return 0;
}


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

using namespace std;

#define COUT_PRECISION 10

namespace abreto
{

typedef long long int ll;

void main(void)
{
    ll X;
    cin >> X;
    ll hap = 0ll;
    hap += (X / 500) * 1000;
    X -= (X / 500) * 500;
    hap += (X / 5) * 5;
    cout << hap << '\n';
}

} // namespace abreto

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toInt)
    var arr = Array(M,{0})
    (0..N-1).map{i->
        var input = readLine()!!.split(" ").map{x->x.toInt()}
        (1..input.size-1).map{ j->
            arr[input[j]-1] += 1
        }
    }
    var c = 0
    arr.map{x -> if(x == N) c++ }
    println(c)
}


Measured memory_bytes: 36064
#include <bits/stdc++.h>
#define maxn 110000
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
typedef long long ll;
int n,k,x;
ll f[maxn],g[maxn];
int main()
{
    cin>>n>>k;
    f[0] = 1;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        int sum = 0;
        for(int j=0;j<=x;j++)
        {
            sum+=f[j];
            sum%=mod;
            g[j] = sum;
        }
        for(int l=0,r=x+1;r<=k;l++,r++)
        {
            sum += f[r]-f[l];
            sum%=mod;
            sum+=mod;
            sum%=mod;
            g[r]= sum;
        }
        memcpy(f,g,sizeof(f));
    }
    printf("%d",f[k]);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<int> ans(n);
	rep(_, n - 1) {
		int a;
		cin >> a;
		ans[a - 1]++;
	}
	for (int i : ans) cout << i << '\n';
}

Measured memory_bytes: 3984
#include <iostream>
#include <string>
using namespace std;
int m[8][3] = {
  {0,0,0}, {0,0,0xff}, {0,0xff,0}, {0,0xff,0xff},
  {0xff,0,0}, {0xff,0,0xff}, {0xff,0xff,0}, {0xff,0xff,0xff},
};
string s[8] = {
  "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white",
};
int conv(string s)
{
  int n=0,i;
  for(i=0;i<2;i++){
    n *= 16;
    if('0' <= s[i] && s[i] <= '9') n += s[i] - '0';
    else n += s[i] - 'a' + 10;
  }
  return n;
}
int main()
{
  string i;
  for(;;){
    cin >> i;
    if(i=="0") break;
    int r,g,b;
    r = conv(i.substr(1,2));
    g = conv(i.substr(3,2));
    b = conv(i.substr(5,2));
    int d,e=0x1fffffff,j,k;
    for(j=0;j<8;j++){
      d = (r-m[j][0])*(r-m[j][0])+(g-m[j][1])*(g-m[j][1])+(b-m[j][2])*(b-m[j][2]);
      if(e>d) {
	e = d;
	k = j;
      }
    }
    cout << s[k] << endl;
  }
  return 0;
}

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

int main () {
    string s;
    cin >> s;
    
    int a = s.size() - 2;
    
    cout << s.at(0) << a << s.at(s.size()-1) << endl;
} 

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

int main() {
	int n;	
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		int size=4;
		std::string a, b;
		std::vector<int> va, vb, out;
		std::cin >> a >> b;
		for (std::string::iterator aitr = a.begin(); aitr != a.end(); aitr++) {
			va.push_back((int)*aitr - '0');
		}
		for (std::string::iterator bitr = b.begin(); bitr != b.end(); bitr++) {
			vb.push_back((int)*bitr - '0');
		}
		std::reverse(va.begin(), va.end()); std::reverse(vb.begin(), vb.end());
		out.push_back(0);
		size = va.size() > vb.size() ? va.size() : vb.size();
		for (int i = 0; i < size; i++) {
			out[i] = out[i] + (i < va.size() ? va[i] : 0) + (i < vb.size() ? vb[i] : 0);
			if (out[i] > 9) {
				out[i] = out[i] % 10;
				out.push_back(1);
			}
			else {
				out.push_back(0);
			}
		}
		if (out.back() == 0) out.pop_back();
		if (out.size() > 80) std::cout << "overflow" << std::endl;
		else {
			std::reverse(out.begin(), out.end());
			for (std::vector<int>::iterator itr = out.begin(); itr != out.end(); itr++) {
				std::cout << *itr;
			}
			std::cout << std::endl;
		}
	}
}

Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)


int main() {
    int n;
    cin >> n;
    vector<int> cmin(26, 114514);
    rep(i, n) {
        string s;
        cin >> s;
        int cnt[26] = {0};
        for(char& c : s) cnt[c - 'a']++;
        rep(j, 26) cmin[j] = min(cmin[j], cnt[j]);
    }

    rep(i, 26) {
        cout << string(cmin[i], 'a' + i);
    }
    puts("");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 
map<int,int>m;
int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		m[x]++;
		m[x-1]++;
		m[x+1]++;
	}
	vector<PII>v;
	for(auto g:m){
		v.pb(mp(g.second,g.first));
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	cout<<v[0].first;
	
	
	
	
	
	
	return 0;
}



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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    string alpha = " abcdefghijklmnopqrstuvwxyz";
    string ans = "";
    while(N > 0) {
        ll m = (N % 26 == 0) ? 26 : N % 26;
        ans = alpha[m] + ans;
        N -= m;
        if (N == 0) {
            break;
        } else {
            N /= 26;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
//long long int arr[1000000];
int main()
{
    int a;
    double v,b;
   while(scanf("%lf",&v)==1)
   {
       v/=9.8;
       v=((v*v)*4.90)/5+1;
       a=v;
       b=v-a;
       if(b<0)
       printf("%d\n",a);
       else
       printf("%d\n",a+1);
   }
   return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

ll gcd(ll p, ll q){ 
    while(q != 0){
        ll r=p%q;
        p=q;
        q=r;
    }
    return p;
}

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int>l(q),r(q);
    rep(i,0,q){
        cin>>l.at(i)>>r.at(i);
    }
    vector<int>sum(n,0);
    rep(i,0,n-1){
        if(s.at(i)=='A' and s.at(i+1)=='C')sum.at(i+1)=sum.at(i)+1;
        else sum.at(i+1)=sum.at(i);
    }
    rep(i,0,q){
        cout<<sum.at(r.at(i)-1)-sum.at(l.at(i)-1)<<endl;
    }
return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  REP(x, k+1) REP(y, k+1){
    ll z = s - x - y;
    if(0 <= z && z <= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;


int main()
{
    ll n,wt;
    cin>>n>>wt;
    ll w[n+5];
    ll val[n+5];
    for(ll i=1; i<=n; i++)
    {
        cin>>w[i]>>val[i];
    }
    ll dp[n+1][wt+1];

    for(ll i=0; i<=n; i++)
        for(ll j=0; j<=wt; ++j)
        {

            if(i==0||j==0)
            {
                dp[i][j]=0;
                continue;
            }
            if(j>=w[i])
                dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-w[i]]);
            else
                dp[i][j]=dp[i-1][j];
        }



    cout<<dp[n][wt]<<nn;


}



Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();

  int S=0,N=0,E=0,W=0;
  for(int i=0;i<n;i++){
    if(s[i]=='S') S++;
    else if(s[i]=='N') N++;
    else if(s[i]=='E') E++;
    else if(s[i]=='W') W++;
  }

  int flag=0;
  if(S>0&&N==0) flag=1;
  else if(S==0&&N>0) flag=1;
  else if(E==0&&W>0) flag=1;
  else if(E>0&&W==0) flag=1;
  
  if(flag) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

SA=input()
SB=input()
SC=input()

da=deque()
db=deque()
dc=deque()

for i in range(len(SA)):
    da.append(SA[i])
for i in range(len(SB)):
    db.append(SB[i])
for i in range(len(SC)):
    dc.append(SC[i])


nv="a"
while len(da)>=0 and len(db)>=0 and len(dc)>=0:
    if nv =="a" and len(da)>0:
        nv = da.popleft()
    elif nv =="a":
        print("A")
        exit()
    elif nv =="b" and len(db)>0:
        nv = db.popleft()
    elif nv =="b":
        print("B")
        exit()    
    elif nv =="c" and len(dc)>0: 
        nv = dc.popleft()
    elif nv =="c":
        print("C")
        exit()



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int64_t N;
	cin >> N;

	int64_t rt = sqrt(N);
	for (int64_t i = rt; i > 0; i--) {
		if (N % i == 0) {
			//cout << i << endl;
			int64_t n = N / i;

			int64_t cnt = 0;
			int64_t m = N / i;
			while (m) {
				cnt++;
				m /= 10;
			}

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

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

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

pii a[55];
int par[55];
int n;


int root (int v) {
	return ((par[v] < 0) ? v : par[v] = root(par[v]));
}

void merge (int v, int u) {
	v = root(v);
	u = root(u);
	if (v == u)
		return;
	par[v] = u;
	return;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;	
	for (int i = 0; i < n; i++)
		cin >> a[i].F >> a[i].S;
	int ans = n;
	for (int i = 0; i < n; i++)
		for (int t = i + 1; t < n; t++) {
			memset(par, -1, sizeof par);
			int p, q;
			p = a[i].F - a[t].F;
			q = a[i].S - a[t].S;
			for (int x = 0; x < n; x++)
				for (int y = 0; y < n; y++) {
					if (a[x].F - a[y].F == p && a[x].S - a[y].S == q)
						merge(x, y);
					if (a[y].F - a[x].F == p && a[y].S - a[x].S == q)
						merge(x, y);
				}
			int cnt = 0;
			for (int j = 0; j < n; j++)
				if (root(j) == j)
					cnt++;
			ans = min(ans, cnt);
		}

	cout << ans << "\n";
}


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

int main(){
  std::string s;
  int p;
  std::map<std::string,std::vector<int> > m;
  while(std::cin>>s>>p,!std::cin.eof()){
    m[s].push_back(p);
  }
  std::map<std::string,std::vector<int> >::iterator m_it = m.begin();
  while(m_it!=m.end()){
    std::cout<<(*m_it).first<<std::endl;
    std::sort((*m_it).second.begin(),(*m_it).second.end());
    std::vector<int>::iterator v_it = (*m_it).second.begin();
    while(v_it!=(*m_it).second.end()){
      std::cout<<*v_it;
      v_it++;
      (v_it==(*m_it).second.end())?std::cout<<std::endl:std::cout<<" ";
    }
    m_it++;
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def func1(A):
    ans = 0
    N = len(A)
    m, p = [], []
    for i in range(N):
        if i < N // 2:
            m.append(A[i])
        else:
            p.append(A[i])

    ans -= sum(m) * 2
    ans += sum(p) * 2

    if N % 2 == 0:
        ans += m[-1]
        ans -= p[0]
    else:
        ans -= p[0]
        ans -= p[1]

    return ans


def func2(A):
    ans = 0
    N = len(A)
    m, p = [], []
    for i in range(N):
        if i < N // 2 + 1:
            m.append(A[i])
        else:
            p.append(A[i])

    ans -= sum(m) * 2
    ans += sum(p) * 2

    if N % 2 == 0:
        ans += m[-1]
        ans -= p[0]
    else:
        ans += m[-1]
        ans += m[-2]

    return ans


def solve(A):
    return max(func1(A[:]), func2(A[:]))


def check(A):
    ans = 0
    for p in permutations(A):
        tmp = 0
        for i in range(1, len(p)):
            tmp += abs(p[i] - p[i - 1])

        ans = max(ans, tmp)
    return ans


def main():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    A.sort()

    if N < 5:
        print(check(A))
    else:
        print(solve(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15536
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    vector<int> p;
    cin >> n;
    REP(i, n){
        int x;
        cin >> x;
        p.pb(x);
    }
    // 1 2 3 4 5 6
    int renzoku = 0;
    int cnt = 0;
    REP(i, n){
        if(p[i] == i+1){
            cnt++;
            renzoku++;
            if(renzoku == 2){ cnt--; renzoku = 0;}
        }else{
            renzoku = 0;
        }
    }

    cout << cnt << endl;
}


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

int main(void){
    ll m,d; cin >> m >> d;
    ll cnt=0;
    for(int i=1;i<=d;i++){
        ll a=i%10,b=i/10;
        if(a>=2 && b>=2 && a*b<=m) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())

N = [0]

for _ in range(K):
    i = 0
    while i < len(N) and N[i] == 9:
        i += 1
    while i+1 < len(N) and N[i] == N[i+1]+1:
        i += 1
    if i == len(N):
        N = [0]*len(N) + [1]
    else:
        N[i] += 1
        i -= 1
        while i >= 0:
            N[i] = max(N[i+1]-1,0)
            i -= 1

print(*reversed(N),sep='')


Measured memory_bytes: 3064
x = int(input())

if 400<=x<=599:
    print('8')
elif 600<=x<=799:
    print('7')
elif 800<=x<=999:
    print('6')
elif 1000<=x<=1199:
    print('5')
elif 1200<=x<=1399:
    print('4')
elif 1400<=x<=1599:
    print('3')
elif 1600<=x<=1799:
    print('2')
elif 1800<=x<=1999:
    print('1')


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

int main(){
    int n,m;
    while(cin>>n>>m and n){
        int a[n]={};
        int suma=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            suma+=a[i];
        }
        int b[m]={};
        int sumb=0;
        for(int i=0;i<m;i++){
            cin>>b[i];
            sumb+=b[i];
        }
        int sumc=1000,at=0,bt=0;
        for(int t=0;t<n;t++){
            for(int k=0;k<m;k++){
                if(suma>=sumb && (suma-sumb)%2==0){
                    if(a[t]-b[k]==(suma-sumb)/2 and sumc>=a[t]+b[k]){
                        at=t;
                        bt=k;
                        sumc=a[t]+b[k];
                    }
                }else if(sumb>suma and (sumb-suma)%2==0){
                    if(b[k]-a[t]==(sumb-suma)/2 and sumc>=a[t]+b[k]){
                        at=t;
                        bt=k;
                        sumc=a[t]+b[k];
                    }
                }
            }
        }
        if(sumc!=1000){
            cout<<a[at]<<" "<<b[bt]<<endl;
        }else{
            cout<<-1<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2996
#include <algorithm>
#include <cmath>
#include <iostream>


using namespace std;

int main() {
	int n, m, t = 0;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
	  int a;
		cin >> a;
		t += a;
	}
	cout << max(-1, n - t) << endl;
  return 0;
}


Measured memory_bytes: 3556
# n = int(input())
s = input()

res = 0
res_max = 0
res_s=""
temps = ""
for i in range(len(s)):



    if s[i] in "ACGT":
        # print(s[i])
        res += 1
        temps += s[i]
        if(len(temps) > len(res_s)):
            res_s = temps
            res_max = res
    else:
        res = 0
        temps = ""


print(res_max)

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    long long res = 0;
    for(int bit = 0; bit < (1<<(n-1)); bit++)
    {
        long long tmp = 0;
        for(int i = n-2; i >= 0; i--)
        {
            tmp *= 10;
            tmp += s[n-2-i] - '0';
            if(bit&(1<<i))
            {
                res += tmp;
                tmp = 0;
            }
        }
        tmp *= 10;
        tmp += s.back() - '0';
        res += tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<bits/stdc++.h> 
#include <algorithm>
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<pair<string,int>,int> iii;

pair<vi,int> a[11];

bool sePuede(int conj,int n,int m){
    int aux,b;

    for(int i = 0; i<m; i++){
        aux = 0;
        for(int j = 0; j<a[i].f.size(); j++){
            b = (a[i].f)[j];
            if(( (1<<(b-1)) &conj) >0) aux++;
            //printf("val: %d\n",( (1<<(b-1)) &&conj));
            //printf("i: %d b: %d aux: %d\n",i,b,aux);
        }
        //printf("conj: %d i: %d aux: %d\n",conj,i,aux);
        if( (aux % 2)  != ( a[i].s%2 ) ) return false;
    }
    return true;
}

int main(){
    ofstream out("output.txt");
    
    int n,m;
    cin>>n>>m;
    int k,s,p;
    for(int i = 0; i<m; i++){
        cin>>k;
        for(int j = 0; j<k; j++){
            cin>>s;
            a[i].f.pb(s);
        }
    }
    for(int i = 0; i<m; i++){
        cin>>p;
        a[i].s = p;
    }   
    int cont = 0;
    for(int i = 0; i<(1<<n); i++){

        if(sePuede(i,n,m)) {
            cont++;
            //printf("i: %d\n",i);
        }
    }
    cout<<cont<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a=0,b=0,c=0,d=0;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++)
  {
      cin>>s[i];

      if(s[i]=="AC")
        a++;
      else if(s[i]=="WA")
        b++;
      else if(s[i]=="TLE")
        c++;
      else
        d++;

  }

  cout<<"AC x "<< a<<endl;
  cout<<"WA x "<<b<<endl;
   cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;




    exit(0);
}


Measured memory_bytes: 6736
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long  x; cin >> x;
	long long P = 100;
	int t = 0;
	while (P < x) {
		P += (P / 100);
		t++;
	}

	cout << t;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))
 
int n,cnt,x,cnt2;
 
int main()
{
    cin>>n;
    F(i,1,n)
    {
        cin>>x;
        if(x%4==0) cnt++;
        else if(x%2==0) cnt2++;
    }
    int ans=max(cnt*2+cnt2,cnt*2+1);
    if(ans>=n) puts("Yes");else puts("No");
    return 0;
}

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

struct Restaurant {
    int idx;
    string city;
    int evaluation;
};

bool cmp(Restaurant a, Restaurant b) {
    if (a.city != b.city)
        return a.city < b.city;
    else
        return a.evaluation > b.evaluation;
}

int main() {
    int n;
    cin >> n;
    vector<Restaurant> r(n);

    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        r[i] = {i + 1, s, p};
    }

    sort(r.begin(), r.end(), cmp);

    for (auto e : r) cout << e.idx << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
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; }

signed main(){
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]){
                    ans++;
                    /* cout << i+1 << " " << j+1 << " " << k+1 << endl; */
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
def d_even_relation_dfs(N, Nodes):  # DFSによる
    import sys
    sys.setrecursionlimit(10**6)
    graph = [[] for _ in range(N)]
    for u, v, w in Nodes:  # 0-basedとする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))

    def distance_from_root(parent, current, distance, ret=[0] * N):  # 根(頂点0)から各頂点への距離
        def dfs(p, c, d):
            ret[c] = d
            for next_edge, dist in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge, d + dist)
        dfs(parent, current, distance)
        return ret
    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root(-1, 0, 0))  # 根の親は-1番とする
    return ' '.join(map(str, ans))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print(d_even_relation_dfs(N, Nodes))

Measured memory_bytes: 109680
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
d = list(map(int, input().split()))

d.sort()
# これで小さい順なっているから，真ん中の値と次の値を見て間に入る数を調べる

left = d[N//2 -1]
right = d[N//2]

print(right-left)


Measured memory_bytes: 52684
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
typedef pair<P,int> State;

// s[y][x] := (x,y) にあるスプリンクラーの番号. (何もないときは 0 )
int s[10][10];
// memo[x][y][cnt] := (x,y) に cnt 回目のジャンプが探索済みかどうか
bool memo[10][10][12];

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

// 初期化
void init(){
	for(int y=0 ; y < 10 ; y++ ){
		for(int x=0 ; x < 10 ; x++ ){
			s[y][x] = 0;
			for(int i=0 ; i < 12 ; i++ ){
				memo[x][y][i] = false;
			}
		}
	}
}

// cnt 番目のスプリンクラーの水が (x,y) にかかるかどうか
bool is_fountain(int px, int py, int cnt){
	for(int y = -1 ; y <= 1 ; y++ ){
		for(int x = -1 ; x <= 1 ; x++ ){
			int mx = px + x;
			int my = py + y;
			if( mx < 0 || my < 0 || mx >= 10 || my >= 10 ) continue;
			
			if( s[my][mx] == cnt ){
				return true;
			}
		}
	}
	return false;
}

// 幅優先探索
bool bfs(int sx, int sy, int n){
	State start( P(sx,sy) , 1 );
	queue<State> q;
	q.push( start );
	
	while( !q.empty() ){
		int x = q.front().first.first;
		int y = q.front().first.second;
		int cnt = q.front().second;
		q.pop();
		
		if( memo[x][y][cnt] ) continue;
		memo[x][y][cnt] = true;
		for(int i=0 ; i < 12 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || mx >= 10 || my >= 10 ) continue;
			if( memo[mx][my][cnt] ) continue;
			
			// ゴール(n番目のスプリンクラーの水)に到達したとき.
			if( cnt == n && is_fountain(mx,my,cnt) ){
				return true;
			}
			// ジャンプした先が cnt 番目のスプリンクラーの水だったとき.
			if( is_fountain(mx,my,cnt) ){
				State next( P(mx,my) , cnt+1 );
				q.push( next );
			}
		}
	}
	return false;
}

int main(){
	int n, sx, sy;
	while( cin >> sx >> sy, sx || sy ){
		// 初期化
		init();
		
		cin >> n;
		for(int i=1 ; i <= n ; i++ ){
			int x, y;
			cin >> x >> y;
			s[y][x] = i;
		}
		bool ans = bfs(sx,sy,n);
		cout << (ans? "OK" : "NA") << endl;
	}
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vi p(a),q(b),r(c);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    RSORT(p);
    RSORT(q);
    priority_queue<int> qu;
    rep(i,x)qu.push(p[i]);
    rep(i,y)qu.push(q[i]);
    rep(i,c)qu.push(r[i]);
    int ans=0;
    rep(i,x+y)ans+=qu.top(),qu.pop();
    cout<<ans<<endl;
}

Measured memory_bytes: 8816
/*
hey stop, don't skip the shit till it's solved
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n,k,q;
cin>>n>>k>>q;
int a[n]={};
int h;
int sum=0;
for(int i=0;i<q;i++)
{
cin>>h;
a[h-1]++;
sum++;
}
for(int i=0;i<n;i++)
{
if(k-(sum-a[i])<=0)
{
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
}
}
}

Measured memory_bytes: 3984
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r,d,dp[11];
	cin >> r >> d >> dp[0];
	rep(i,1,11){
		dp[i]=r*dp[i-1] - d;
		cout << dp[i] << "\n";
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,c = LI()
    d = [LI() for _ in range(c)]
    e = [LI() for _ in range(n)]
    a = [[0]*c for _ in range(3)]
    for i in range(n):
        for j in range(n):
            t = (i+j) % 3
            for k in range(c):
                a[t][k] += d[e[i][j]-1][k]
    r = inf
    for i in range(c):
        for j in range(c):
            if i == j:
                continue
            for k in range(c):
                if i == k or j == k:
                    continue
                tr = a[0][i] + a[1][j] + a[2][k]
                if r > tr:
                    r = tr

    return r


print(main())



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

int main(){
  long long a, v, b, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  
  if(w >= v){
    cout << "NO" << endl;
    return 0;
  }
  
  if(abs(a-b) > (v-w) * t){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main() {
    
    int N;
    
    scanf("%d",&N);
    
    int x = N % 10;
    
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
        printf("hon\n");
    }
    if (x == 0 || x == 1 || x == 6 || x == 8){
        printf("pon\n");
    }
    if (x == 3){
        printf("bon\n");
    }
    
    return 0;
}


Measured memory_bytes: 1656
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


signed main()
{
	QUICK_CIN;
	//debug_input;

	int N;
	cin >> N;

	cout << N * 800 - N / 15 * 200 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// 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;}

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,k; cin >> n >> k;
  int a[n];
  FOR(i,0,n-1) cin >> a[i];
  sort(a,a+n);
  mint ans = 0;
  combination c(n+5);

  FOR(i,k-1,n-1){
    ans += c(i,k-1) * a[i];
  }

  sort(a,a+n,greater<int>());
  FOR(i,k-1,n-1){
    ans -= c(i,k-1) * a[i];
  }

  cout << ans.x << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 5;
int h, w, a, b, fact[2*N], ifact[2*N];
int power (int a, int n) {
	int ret = 1;
	while (n > 0) {
		if (n & 1) ret = (ret * 1ll * a) % MOD;
		a = (a * 1ll * a) % MOD;
		n >>= 1;
	}
	return ret;
}
void pre () {
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= h + w; i++) {
		fact[i] = (i * 1ll * fact[i-1]) % MOD;
		ifact[i] = power(fact[i], MOD - 2);
	}
}
int cnt (int i, int j) {
	assert(0 <= i && 0 <= j && i <= h && j <= w);
	int ret = fact[i + j];
	ret = (ret * 1ll * ifact[i]) % MOD;
	ret = (ret * 1ll * ifact[j]) % MOD;
	return ret;
}
int main () {
	cin >> h >> w >> a >> b;
	pre();
	int ans = cnt (h - 1, w - 1);
	for (int j = 1;  j <= b; j++) {
		int cur = (cnt (h - a - 1, j - 1) * 1ll * cnt (a - 1, w - j)) % MOD;
		ans = (ans - cur) % MOD;
		if (ans < 0) ans += MOD;
	}
	cout << ans << '\n';
}

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

int main()
{
	int N;
	ll dp[87];

	dp[0] = 2;
	dp[1] = 1;

	cin >> N;
	for (int i = 2; i <= N; i++) dp[i] = dp[i-1] + dp[i-2];
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 256