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

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  vector<char> cvec{'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'};
  map<char,ll> cmap;
  for (ll i = 0; i < 26; ++i) cmap[cvec[i]] = i;
  string ans;
  for (ll i = 0; i < S.size(); ++i) {
    const ll index = cmap[S[i]];
    const ll newindex = (index+N)%26;
    const char cnew = cvec[newindex];
    ans+= cnew;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n;

ll get(ll n) {
    ll ret = 1;
    for (int i = 1; i <= 20; i++) {
        if ( n >= (1 << i) - 1) {
            ret++;
        }
    }
    return ret - 1;
}

ll get2(ll n) {
    for (int i = 0; i <= 20; i++) {
        if ( (1 << i) > n) {
            return i;
        }
    }
    return -1;
}

vector<pair<pair<ll,ll>,ll>> res;

void MAIN(int tc) {
    cin >> n;
    n--;
    ll x = get(n);
    for (int i = 1, k = 1; i <= x; i++, k *= 2) {
        res.push_back({{i, i + 1}, 0});
        res.push_back({{i, i + 1}, k});
    }

    ll val = 1 << x;
    n -= ((1 << x) - 1);
    while (n > 0) {
        ll y = get2(n);
        res.push_back({{y, x + 1}, val});
        y--;
        val += (1 << y);
        n -= (1 << y);
    }

    deb2(x + 1, res.size())
    for(auto [a, b]: res){
        deb3(a.f, a.s, b);
    }

}

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

    int test_cases = 1;
    //cin>>test_cases;
    for (int i = 1; i <= test_cases; i++) {
        MAIN(i);
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }
    int mc=0;
    REP(i,N){
        if(A[i]<0){
            mc++;
        }
    }
    ll sum=0;
    REP(i,N){
        if(A[i]<0){
            A[i]*=-1;
        }
        sum+=A[i];
    }
    if(mc%2!=0){
        int min=A[0];
        int mini=0;
        REP(i,N){
            if(A[i]<min){
                min = A[i];
                mini = i;
            }
        }
        sum = sum-(A[mini]*2);
    }

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

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define FOR(i,n) for(i=0;i<n;++i)
int i,j;
int main(void){
    
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<" "<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<s[12]<<" "<<s[14]<<s[15]<<s[16]<<s[17]<<s[18];
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool tc[200],c[200];
int n;
char res[400];
bool vr(int x)
{
	if(x>=n) return !vr(x-n);
	if(!c[x])
	{
		printf("?");
		for(int i=x;i<n+x;i++) printf(" %d",i+1);
		printf("\n");
		fflush(stdout);
		char ch[15];
		scanf("%s",ch);
		if(ch[0]=='B') tc[x]=false;
		else tc[x]=true;
		c[x]=true;
	}
	return tc[x];
}
int main()
{
	scanf("%d",&n);
	int l=0,r=n; vr(0); vr(n);
	while(r!=l+1)
	{
		int s=(l+r)/2;
		vr(s);
		if(vr(s)==vr(r)) r=s;
		else l=s;
	}
	//printf("%d %d\n",l,r);
	if(vr(l)) {res[l]='R'; res[l+n]='B';}
	else {res[l]='B'; res[l+n]='R';}
	for(int i=1;i<n;i++)
	{
		printf("?");
		for(int j=0;j<=n;j++) if(i!=j) printf(" %d",j+l+1);
		printf("\n");
		fflush(stdout);
		char ch[15];
		scanf("%s",ch);
		if(ch[0]=='B') res[i+l]='R';
		else res[i+l]='B';
	}
	for(int i=1;i<n;i++)
	{
		printf("?");
		for(int j=0;j<=n;j++) if(i!=j) printf(" %d",(j+l+n)%(2*n)+1);
		printf("\n");
		fflush(stdout);
		char ch[15];
		scanf("%s",ch);
		if(ch[0]=='B') res[(i+l+n)%(2*n)]='R';
		else res[(i+l+n)%(2*n)]='B';
	}
	printf("! ");
	for(int i=0;i<2*n;i++) printf("%c",res[i]);
	printf("\n");
	fflush(stdout);
}

Measured memory_bytes: 724
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int64 memo[1000000];

int64 sol(int64 xx, int64 mod)
{
	if(xx < 0)
	{
		return 0;
	}
	if(memo[xx] == -1)
	{
		int64 tmp = sol(xx - 1, mod);
		tmp += sol(xx - 2, mod);
		memo[xx] = tmp;
		memo[xx] %= mod;
		return memo[xx];
	}
	else
	{
		return memo[xx];
	}
	return 0;
}

int main()
{
	int64 nn, mm, tmp, ans, mod = 1000000007;
	cin >> nn >> mm;
	for(int64 ii = 0;ii <= nn;ii++)
	{
		memo[ii] = -1;
	}
	for(int64 ii = 0;ii < mm;ii++)
	{
		cin >> tmp;
		memo[tmp] = 0;
	}
	memo[0] = 1;
	ans = sol(nn, mod);
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7504
#include <iostream>
#include<string>

using namespace std;

int main()
{
	int h,w,i,k;
    string ss;

    while (1)
    {
        cin >> h >> w;
        if (w == 0 && h == 0){
            break;
        }
        for (i = 0; i < h; i ++){
            if (i == 0 || i == h-1){
                for (k = 0; k < w; k++) cout << "#";
            }
            else {
                cout << "#";
                for (k = 2; k < w; k++) cout << ".";
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;


}


Measured memory_bytes: 3064
/*
                   _ooOoo_
                  o8888888o
                  88" . "88　AC!AC!
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
int main(){
    ll n;cin>>n;
    ll dp[110][5][5][5];
    rep(i,n+10)rep(j,5)rep(k,5)rep(l,5)dp[i][j][k][l]=0;
    dp[0][0][0][0]=1;
   // cout<<dp[n][1][1][1]<<endl;
    rep(i,n)rep(j,5)rep(k,5)rep(l,5)rep3(m,1,5){
        if (j == 1 && k == 2 && m == 3) continue;
        if (j == 1 && l == 2 && m == 3) continue;
        if (k == 1 && l == 2 && m == 3) continue;
        if (k == 2 && l == 1 && m == 3) continue;
        if (k == 1 && l == 3 && m == 2) continue;
        dp[i+1][k][l][m]+=dp[i][j][k][l];
      //  cout<<
        dp[i+1][k][l][m]%=MOD;
    }
   // cout<<dp[n][1][1][1]<<endl;
    ll res=0;
    rep(i,5)rep(j,5)rep(k,5){
        res+=dp[n][i][j][k];
       // cout<<res<<endl;
        res%=MOD;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<string.h>

int main() {
	char val[5];
	std::cin >> val;

	int arr[4];
	for (int i = 0; i < 4; i++)arr[i] = val[i] - '0';

	char equation[10];

	for (int i = 0; i < 1 << 3; i++) {
		int temp = arr[0];
		for (int j = 0; j < 3; j++) {
			temp += i >> j & 1 ? arr[j + 1] : (-1)*arr[j + 1];
		}
		if (temp == 7) {
			equation[0] = arr[0] + '0';
			for (int j = 0; j < 3; j++) {
				if (i >> j & 1)equation[2 * j + 1] = '+';
				else equation[2 * j + 1] = '-';
				equation[2 * j+2] = arr[j + 1] + '0';
			}
			strcpy(&equation[7], "=7\0");
		}
	}


	printf("%s\n", equation);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<bool> dp1(k + 1, false);
    vector<bool> dp2(k + 1, false);
    for (int i = 0; i < n; ++i) {
        dp1[a[i]] = true;
        dp2[a[i]] = true;
    }
    for (int i = 1; i <= k; ++i) {
        for (int aa : a) {
            if (aa <= i && !dp1[i - aa]) {
                dp2[i] = true;
                break;
            }
        }
        for (int aa : a) {
            if (aa <= i && !dp2[i - aa]) {
                dp1[i] = true;
                break;
            }
        }
    }
    if (dp1[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
    }
    ll ans =0;
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            if(i!=j) ans += (v[i]*v[j]);
        }
    }
    cout <<ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  char x; cin >> x;
  cout << char(x+1) << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
n, k = map(int,input().split())
a = np.array(input().split(), np.int64)
f = np.array(input().split(), np.int64)

a.sort()
f.sort()
f=f[::-1]
a_sum = a.sum()
low, high = -1, max(a)*max(f)
while low + 1 < high:
  mid = (low + high) // 2
  if np.minimum(a, mid // f).sum() >= a_sum - k:
    high = mid
  else:
    low = mid
print(high)

Measured memory_bytes: 37224
n = int(input())
h = list(map(int, input().split()))
che = h[len(h)-1]+1
for i in h[len(h)-2::-1]:
    if che < i :
        print("No")
        break
    if che != i+1:
        if che == i:
            che = i
        else: 
            che = i+1
else:
    print("Yes")

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

int main(void){
    int k, a, b;
    int x;
    cin >> k;
    cin >> a >> b;
    x = b / k;
    if (x * k >= a) {
        cout << "OK" << endl;
    }else {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
struct grid{
    ll t,y;
};
int main(){
    init();
	inl(n,k);
  if(n%k==0) out(0);
  else out(1);
}


Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
sump=sum(p[0:k])
max=sump
ans=0
for i in range(n-k):
    sump=sump-p[i]+p[i+k]
    if sump>max:
        max=sump
ans=(max+k)/2
print(ans)

Measured memory_bytes: 24808
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double l;

    cin >> l;

    l /= 3;

    printf("%.10f\n", l * l * l);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = 1e18;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k % 2 != 0) {
    if ( b - a > INF) cout << "Unfair" << endl;
    else cout << b - a << endl;
  } else {
    if (a - b > INF) cout << "Unfair" << endl;
    else cout << a - b << endl;
  }
  return 0;
} 

Measured memory_bytes: 3616
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	string a, b, c, d;

	a = s[5];
	b = s[6];
	c = s[8];
	d = s[9];

	cout << "2018/" << a << b << "/" << c << d;
}

Measured memory_bytes: 768
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int num = sc.nextInt();
			int[] num_arr = new int[num];
			
			for(int i = 0; i < num; i++) {
				num_arr[i] = sc.nextInt();
			}
			for(int i = num - 1; i >= 0; i--) {
				System.out.print(num_arr[i]);
				if(i!=0)
					System.out.print(" ");
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 26244
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			int n=sc.nextInt();
			if(n==0)
				break;
			int[] s=new int[n];
			for(int j=0; j<n; j++){
				int sum=0;
				for(int i=0; i<n; i++){
					int d=sc.nextInt();
					print(String.format("%5d", d));
					sum+=d;
					s[i]+=d;
				}
				println(String.format("%5d", sum));
			}
			int sum=0;
			for(int i=0; i<n; i++){
				print(String.format("%5d", s[i]));
				sum+=s[i];
			}
			println(String.format("%5d", sum));

		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;

int main()
{
	cin >> a >> b;
	cout << (a + b) % 24 << endl;

	return 0;
}


Measured memory_bytes: 256
def to_key(s)
  s.gsub!('A', '1')
  s.gsub!('C', '2')
  s.gsub!('G', '3')
  s.gsub!('T', '4')
  s.to_i
end
def hash(key, i)
  (h1(key) + i * h2(key)) % 1046527
end
def h1(key)
  key % 1046527
end
def h2(key)
  1 + (key % (1046527 - 1))
end

class Dict
  def initialize
    @arr = []
  end
  def insert(s)
    key = to_key(s)
    i = 0
    loop do
      h = hash(key, i)
      if @arr[h] == s
        return
      elsif @arr[h].nil?
        @arr[h] = s
        return
      end
      i = i + 1
    end
  end
  def find(s)
    key = to_key(s)
    i = 0
    loop do
      h = hash(key, i)
      if @arr[h] == s
        return true
      elsif @arr[h].nil?
        return false
      end
      i = i + 1
    end
    false
  end
end

n = STDIN.gets.to_i

dict = Dict.new
n.times.each {
  ss = STDIN.gets.split(' ')
  if ss[0] == 'insert' then
    dict.insert(ss[1])
  else
    if dict.find(ss[1]) then
      puts 'yes'
    else
      puts 'no'
    end
  end
}




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

/*
int main(void){
	int32 N;
	cin >> N;
	vector<int64> v(N);
	REP(i, N) cin >> v[i];

	int64 maxi = 0;
	int64 res = 0;
	REP(i, N){
		int64 cnt = (v[i]-1)/(maxi+1);
		if(cnt){ res += cnt; chmax(maxi, 1); }
		else maxi = v[i];
	}
	cout << res << endl;
}
*/

int64 A[112345];
deque<PLL> deq[301];

int main(void){
	int32 M, N, K;
	cin >> N >> M >> K;
	REP(i, N) cin >> A[i];

	REP(i, N){
		for(int32 j = K-1;j >= 1;j--){
			while(deq[j-1].size() && i-deq[j-1].front().sc > M) deq[j-1].pop_front();
			if(deq[j-1].empty()) continue;
			int64 val = deq[j-1].front().fs+A[i]*(j+1);
			while(deq[j].size() && val > deq[j].back().fs) deq[j].pop_back();

			deq[j].push_back(PLL(val, i));
		}
		while(deq[0].size() && A[i] > deq[0].back().fs) deq[0].pop_back();
		deq[0].push_back(PLL(A[i], i));
	}

	cout << deq[K-1].front().fs << endl;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A == B) {
    cout << "Draw" << endl;
  }
  else if (A != 1 && B != 1) {
    if (A > B) {
      cout << "Alice" << endl;
    }
    else {
      cout << "Bob" << endl;
    }
  }
  else if (A == 1) {
    cout << "Alice" << endl;
  }
  else {
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        k: usize,
        s: Chars,
    }
    if s.len() <= k {
        println!("{}", s.iter().collect::<String>());
    } else {
        println!("{}...", s[0..k].iter().collect::<String>());
    }
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);
#define tc(x) int x; cin >> x; while(x--)


int main()
{
    BeatMeScanf;
   
    int n;
    cin >> n;
    int ans = 0;
    while(n>0)
    {
        int temp = n / 500;
        ans += (temp*1000);
        n %= 500;
        temp =  n/5;
        ans += (temp*5);
        if(n % 5 != 0)
            break;
    } 
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s,s1;
  cin >> s;
  s1 = s;
  int n = s.size();
  
  int ans = 0;
  
  int i = 0,j = n-1;
  while(1){
    if(s[i] == 'A'){
      break;
    }
    i++;
  }
  while(1){
    if(s[j] == 'Z'){
      break;
    }
    j--;
  }  

  ans = j-i+1;
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<char>> A(N, vector<char>(N));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }

    vector<vector<char>> B(M, vector<char>(M));
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> B[i][j];
        }
    }

    for (int i_shift = 0; i_shift <= N - M; ++i_shift) {
        for (int j_shift = 0; j_shift <= N - M; ++j_shift) {
            bool match = true;
            for (int i = 0; i < M && match; ++i) {
                for (int j = 0; j < M && match; ++j) {
                    if (B[i][j] != A[i + i_shift][j + j_shift]) {
                        match = false;
                    }
                }
            }
            if (match) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ls = [0]*(N+1)
for i in range(N):
  p = int(input())
  ls[p] = i
ID = -1
count = 0
ans = 0
for a in range(1,N):
  if ls[a+1]>ls[a]:
    count += 1
  else:
    if count>ans:
      ans = count
    count = 0
if count>ans:
  ans = count
print(N-ans-1)

Measured memory_bytes: 12148
# 棒の本数
n = gets.to_i
# 棒の長さ
a = gets.split.map(&:to_i).sort
# 答えの変数
sum = 0
# 全探索
(0...(n - 2)).each do |i|
  ((i + 1)...(n - 1)).each do |j|
    next if a[i] == a[j]
    ((j + 1)...n).each do |k|
      next if a[i] + a[j] <= a[k] || a[j] == a[k]
      sum += 1
    end
  end
end
puts sum

Measured memory_bytes: 14260
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long A = scan.nextInt();
        long B = scan.nextInt();

        long l = 0;
        long r = 1000000001;

        long h[] = new long[N];

        for (int i = 0; i < N; i++) {
            h[i] = scan.nextInt();
        }

        while (l < r - 1) {
            long m = (l + r) / 2;
            long temp[] = new long[N] ;
            for(int i=0; i<N; i++){
                temp[i]=h[i];}


            for (int i = 0; i < N; i++) {
                temp[i] -= B * m;
            }
            long x = 0;
            for (int i = 0; i < N; i++) {
                if (temp[i] > 0) {
                    if (temp[i] % (A - B) == 0) {
                        x += temp[i] / (A - B);
                    } else {
                        x += (temp[i] / (A - B)) + 1;
                    }
                }
            }
            if (x > m)
                l = m;
            else
                r = m;

        }

        System.out.println(l+1);
    }
}








Measured memory_bytes: 63240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,p,b,q,i;
    string str,str1;
    cin>>a>>b;
    for(i=0;i<a;i++)
    {
        str+=to_string(b);
    }
    for(i=0;i<b;i++)
    {
        str1+=to_string(a);
    }
    if(a<b)
    {
        p=b;
        q=a;
    }
    else
    {
        p=a;
        q=b;
    }
    for(i=0;i<q;i++)
    {
        int x=str[i]-'0';
        int y=str1[i]-'0';
        if(x<y)
        {
            cout<<str<<endl;
            return 0;
        }
        else if(x>y)
        {
            cout<<str1<<endl;
            return 0;
        }
    }
    if(a==b)
    {
        cout<<str<<endl;
    }
    else
    {
        if(str.size()==q)
        {
            cout<<str<<endl;
        }
        else
        {
            cout<<str1<<endl;
        }
    }

    return 0;
}


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

plan = []

Feasible = True

for i in range(N):
  t,x,y = map(int,input().split())
  plan.append([t,x,y])

t0,x0,y0 = 0,0,0

for t1,x1,y1 in plan:
  dx = x1-x0
  dy = y1-y0
  dt = t1-t0
  dist = abs(dx)+abs(dy)
  d = dt - dist
  
  if dt < dist:
    Feasible = False
  elif (dist+dt)%2 != 0:
    Feasible = False
  t0,x0,y0 = t1,x1,y1
print("Yes" if Feasible else "No")

Measured memory_bytes: 25600
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int nInt = sc.nextInt();

    String nString = String.valueOf(nInt);
    
    String first = nString.substring(0,1);
    if (first.equals("1")) {
        first = "9";
    } else {
        first = "1";
    }
    
    String second = nString.substring(1,2);
     if (second.equals("1")) {
        second = "9";
    } else {
        second = "1";
    }
    
    String third = nString.substring(2,3);
     if (third.equals("1")) {
        third = "9";
    } else {
        third = "1";
    }
    
    System.out.println(first + second + third);
  }
}

Measured memory_bytes: 21460
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
class Point{
public:
	long double x;
	long double y;
	const Point operator*(const long double &a) {
		Point ans;
		ans.x = x * a;
		ans.y = y * a;
		return ans;
	}
	const Point operator=(const Point &a){
		x = a.x;
		y = a.y;
		return *this;
	}
	const Point operator+(const Point &a) const{
		Point ans;
		ans.x = a.x + x;
		ans.y = a.y + y;
		return ans;
	}
	const Point operator+=(const Point &a){
		x += a.x;
		y += a.y;
		return *this;
	}
	const Point operator-(const Point &a) const{
		Point ans;
		ans.x = x - a.x;
		ans.y = y - a.y;
		return ans;
	}
	const Point operator-=(const Point &a) {
		x -= a.x;
		y -= a.y;
		return *this;
	}
	static long double inner(const Point &a, const Point &b) {
		return a.x * b.x + a.y * b.y;
	}
	static long double cross(const Point &a, const Point &b) {
		return a.x * b.y - a.y * b.x;
	}
	static Point norms(const Point &a) {
		long double hoge = abs(a);
		Point ans;
		ans.x = a.x / hoge;
		ans.y = a.y / hoge;
		return ans;
	}
	static long double abs(const Point &a) {
		return sqrtl(a.x * a.x + a.y * a.y);
	}
};
int main(){
	int n;
	cin >> n;
	vector<Point> input(n + 1);
	REP(i, n) {
		cin >> input[i].x >> input[i].y;
	}
	input[n] = input[0];
	long double ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += Point::cross(input[i], input[i + 1]);
	}
	ans = abs(ans);
	ans /= 2.0;
	cout << fixed << setprecision(1);
	cout << ans << endl;
	return 0;
}


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

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

    int n;
    cin >> n;

    int two = 0, four = 0, other = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(!(a % 4)) four++;
        else if(!(a % 2)) two++;
        else other++;
    }

    if(!two)
        cout << (four + 1 >= other ? "Yes" : "No") << endl;
    else cout << (four >= other ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

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

  long long x; 
  cin >> x;
  long long r = (sqrt(1+8*x)-1)/2;
  for (; r * (r+1) < 2*x; ++r);
  cout << r << endl;


  return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  ll N;
  cin >> N;
  N--;

  cout << (N*(N+1))/(2) << endl;

}


Measured memory_bytes: 256
mod = 10**9+7

f = [1]
for i in range(1, 2001):
    f.append(f[-1]*i%mod)

S = int(input())
ans = 0
for n in range(1, S//3+1):
    r = S-n*3
    ans += f[r+n-1] * pow(f[n-1], mod-2, mod) * pow(f[r], mod-2, mod) % mod # comb(r+n-1, r)                                                                                        
    ans %= mod
print(ans)


Measured memory_bytes: 9208
// AOJ ITP1_11_B Dice II
// 2018.4.29 bal4u

#include <stdio.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];

int main()
{
	int i, j;
	int a[7], b[7], dice[7];

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	for (j = 0; j < 24; j++) {
		for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
		for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
		for (i = 1; ; i++) {
			if (i > 6) { puts("Yes"); return 0; }
			if (a[i] != b[i]) break;
		}
	}
	puts("No");
	return 0;
}



Measured memory_bytes: 2100
//三角形の２辺 a, b とその間の角 C から、その三角形の面積 S、周の長さ L, a を底辺としたときの高さ h を求めるプログラムを作成して下さい。
#include <iostream>
#include <stdio.h>
#include <math.h>
#define sq(x) ((x) * (x))

using namespace std;

int main()
{
    int a, b, C;
    cin >> a >> b >> C;
    
    const double ab = a * b;
    const double theta = M_PI * C / 180;
    const double S = 0.5 * ab * sin(theta);
    const double c = sqrt( sq(a) + sq(b) - 2 * ab * cos(theta));
    const double l = a + b + c;
    const double h = S / a * 2.0; 
    
    printf("%f\n", S);
    printf("%f\n", l);
    printf("%f\n", h);
    
    return 0;
}


Measured memory_bytes: 3464
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B,C=MAP()

if A*C<=B:
    print(C)
else:
    print(B//A)


Measured memory_bytes: 6024
n = int(input())
v = list(map(int, input().split()))
d1 = {}
d2 = {}

for i in range(0, n, 2):
    if v[i] in d1.keys():
        d1[v[i]] += 1
    else:
        d1[v[i]] = 1
for i in range(1, n, 2):
    if v[i] in d2.keys():
        d2[v[i]] += 1
    else:
        d2[v[i]] = 1


def keys_values(d):
    fk, fv, sk, sv = 0, 0, 0, 0
    for k in d:
        if d[k] > fv:
            sk, sv = fk, fv
            fk, fv = k, d[k]
        elif d[k] > sv:
            sk, sv = k, d[k]
    return fk, fv, sk, sv


ak, av, bk, bv = keys_values(d1)
ck, cv, dk, dv = keys_values(d2)
if ak != ck:
    print(n-av-cv)
else:
    print(min((n-av-dv), n-bv-cv))


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

int main() {
  string s;
  cin>>s;
  int i,f,b,n=s.size();
  for(i=0;i<n;i++){
    if(s[i]=='A'){
      f=i;
      break;
    }
  }
  for(i=0;i<n;i++){
    if(s[n-1-i]=='Z'){
      b=n-1-i;
      break;
    }
    
  }
  cout<<b-f+1;

}

Measured memory_bytes: 640
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int n, m; 
vi tmp;
bool C( const vi & states, const vvi & mtx ){
  tmp = states;
  //tmp.assign(n, -1);
  //forall(i,0,n) if(states[i]) tmp[i] = states[i]1;
  forall(i,0,n){
    if( states[i]== 0 ) continue;
    forall(j,0,n){
      if( mtx[i][j] == -1 ) continue;
      if( tmp[j] == -1 ) tmp[j] = mtx[i][j];
      else if( tmp[j] != mtx[i][j] ) return false;
    }
  }
  return true;
}

int main( int argc, char * argv[] ){
  cin >> n; 
  tmp.resize(n);
  vvi mtx(n);
  forall(i,0,n){
    cin >> m;
    mtx[i].resize(n, -1);
    forall(j,0,m){
      int a,b; cin >> a >> b;
      mtx[i][a-1] = b; // b=1 honest, b=0 unkind
    }
  }
  for(auto & v : mtx){
    print_(v);
  }
    
  vector<int> states(n,0);
  for(int ans = n; ans > 0; --ans){
    states.assign(n, 0);
    for(int j = n-1; j > n - ans - 1; --j ){
      states[j] = 1;
    }
    do{
      if( C( states, mtx ) ){
        cout << ans << endl;
        return 0;
      }
    }while(next_permutation(all(states)));
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b){if (a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b){if (a < b) a = b;}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

//i番目までで表がj枚出る確率
//0で初期化
double dp[3010][3010] = {0};

int main()
{
	int N;
	cin >> N;
	vector<double> p(N);
	rep(i, N) cin >> p[i];

	//rep(i, N) cout << p[i];

	//初期条件
	dp[0][0] = 1.0 - p[0];
	dp[0][1] = p[0];
 
	//1からN-1まで更新
	rep(i, N-1) {
		//表の枚数は0からN
		for (int j = 0; j <= N; j++) {
			if(j > 0)
				dp[i + 1][j] = dp[i][j - 1] * p[i + 1] + dp[i][j] * (1.0 - p[i + 1]);
			else
				dp[i + 1][j] = dp[i][j] * (1.0 - p[i + 1]);
		}
	}

	//答え
	double ans = 0.0;
	for (int j = 0; j <= N; j++) {
		//表の枚数が裏より上なら足す
		if (j > N - j)  ans += dp[N - 1][j];
	}
	printf("%.10lf\n", ans);
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
 int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c=c-b;
    if(c<=0)break;
    a=a-d;
    if(a<=0)break;
  }
  if(c<=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, m, q;
int a[N], b[N];

int cost(int x, int p, int q)
{
	return abs(x-p) + abs(p-q);
}

int32_t main()
{
	IOS;
	cin>>n>>m>>q;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=m;i++)
		cin>>b[i];
	while(q--)
	{
		int ans=1e18;
		int x;
		cin>>x;
		int idx1=lower_bound(a+1, a+n+1, x) - a;
		int idx2=lower_bound(b+1, b+m+1, x) - b;
		for(int i=max(1LL, idx1-2);i<=min(n, idx1+2);i++)
		{
			for(int j=max(1LL, idx2-2);j<=min(m, idx2+2);j++)
			{
				ans=min(ans, cost(x, a[i], b[j]));
				ans=min(ans, cost(x, b[j], a[i]));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=(0);i<(n);++i)
#define fill(a,b) memset(a,b,sizeof a);

const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
	//freopen("test.txt","r",stdin);
	LL a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	LL ans = INF;
	ans = min(ans,b*c*((a+1)/2 - a/2));
	ans = min(ans,a*c*((b+1)/2 - b/2));
	ans = min(ans,a*b*((c+1)/2 - c/2));
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
ans = A[0]
if N % 2 == 0 and N>2:
    for i in range(1,N//2):
        ans += A[i]*2
elif N % 2 == 1 and N>3:
    ans += A[N//2]
    for i in range(1,N//2):
        ans += A[i]*2
elif N == 3:
    ans += A[1]
print(ans)

Measured memory_bytes: 94000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
bool isPrime(int x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    for(int i=3; i*i<=x; i+=2){
        if(x % i == 0) return false; 
    }
    return true;
}
int main(){
    int n,p;
    while(cin >> n >> p){
        if(n == -1 && p == -1) break;
        vector<int> vec;
        for(int i=n+1; i<=n+1000; i++){
            if(isPrime(i)){
                for(int j=i; j<=n+1000; j++) if(isPrime(j)) vec.push_back(i+j);
            }
        }
        sort(vec.begin(),vec.end());
        cout << vec[p-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3264
#include <stdio.h>
 
const int N = 105;
 
int main(void) 
{
    int n, a[N]={0};
    
    scanf("%d",&n);

     for(int i = 0 ; i < n ; i++)
     {
     	scanf("%d", &a[i]);
	 }
	 for(int i = n-1 ; i>=0 ; i-- )
	 {
	 	if(i)
	 	{
	 	  printf("%d ",a[i]);	
		 }
		 else
		 {
		 	printf("%d\n",a[i]);
		 }
	 }
 
}


Measured memory_bytes: 2756
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>

const long long INF = 10000000000000000;

using namespace std;

int main(){
	string S;
	cin>>S;
	while(S.size()>0){
		if(S.substr(S.size()-5,5)=="erase" ){
			S.erase(S.size()-5,5);
		}else if(S.substr(S.size()-5,5)=="dream"){
			S.erase(S.size()-5,5);
		}else if(S.substr(S.size()-6,6)=="eraser"){
			S.erase(S.size()-6,6);
		}else if(S.substr(S.size()-7,7)=="dreamer"){
			S.erase(S.size()-7,7);
		}else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;	
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

#define all(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)

using namespace std;
typedef long long ll;

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  if(S[K-1] == 'A')S[K-1] = 'a';
  if(S[K-1] == 'B')S[K-1] = 'b';
  if(S[K-1] == 'C')S[K-1] = 'c';
  cout<<S;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if n%2==1:
    x=""
    for i in range(m):
        x+=f"{i+1} {n-i} "
    print(x)
else:
    x=""
    for i in range(m):
        x+=(f"{i+1} {n-i} " if i<m/2 else f"{i+1} {n-i-1}\n")
    print(x)

Measured memory_bytes: 11140
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 100291

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 252 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 988
n,l=map(int,input().split())
a=list(map(int,input().split()))
f=True
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    print("\n".join([str(j) for j in range(1,i+1)]+[str(j) for j in range(n-1,i+1,-1)]+[str(i+1)]))
    f=False
    break
if f:
  print("Impossible")


Measured memory_bytes: 94752