akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define dist(a,b) max((a)-(b),(b)-(a))
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



int main(){
  int h,w; cin >>h >>w;
  int a,b; cin >>a >>b;
  int s=0;
  rep(i,h){
    if(i==b) s^=1;
    rep(j,w){
      if(j==a) s^=1;
      printf("%d",s);
    }
    printf("\n");
    s^=1;
  }
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mod (int)(1e9+7)
int dp[63][2][2][2];
main(){
  int l,r;
  cin>>l>>r;
  dp[62][0][0][0]=1;
  for(int i=61;i>=0;--i){
    int li=l>>i&1, ri=r>>i&1;
    for(int j=0;j<2;++j)for(int k=0;k<2;++k)for(int p=0;p<2;++p){
      int m=dp[i+1][j][k][p];
      for(int x=0;x<2;++x)for(int y=0;y<2;++y){
        int j_=j,k_=k,p_=p;
        if(x&&!y)continue;
        //MSB
        if(!p&&x!=y)continue;
        if(x&&y)p_=1;
        //whether l<x
        if(!j&&!x&&li)continue;
        if(x&&!li)j_=1;
        //whether y<r
        if(!k&&y&&!ri)continue;
        if(!y&&ri)k_=1;
        dp[i][j_][k_][p_]=(dp[i][j_][k_][p_]%mod+m%mod)%mod;
      }
    }
  }
  int res=0;
  for(int j=0;j<2;++j)for(int k=0;k<2;++k)for(int p=0;p<2;++p)res=(res%mod+dp[0][j][k][p]%mod)%mod;
  cout<<res%mod;
}
// y-x = y^x
//     = y+x - 2(y&x)
// 2x = 2(y&x)
//  x = y&x

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=5e3+7;
unsigned long long dp[maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	vi a(n+1);
	ll tot=0;
	for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		tot+=a[i];
	}
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=k;j>=a[i];j--)
			dp[j]+=dp[j-a[i]];
	}
	//for(int i=1;i<=k;i++) dbg(i,dp[i]);
	if(tot<k)
		cout<<n<<'\n';
	else{
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=a[i];j<=k;j++)
			{
				dp[j]-=dp[j-a[i]];
	//			dbg(i,j,dp[j]);
			}
			bool ok=1;
			for(int j=k;j>=0;j--)
			{
				if(j!=k&&j+a[i]>=k&&dp[j])
					ok=0;
				if(j>=a[i])
					dp[j]+=dp[j-a[i]];
			}
			ans+=ok;
		}
		cout<<ans<<'\n';
	}

}


Measured memory_bytes: 256
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int l,r,d; cin >> l >> r >> d;

	int cnt =0;
	for(int i=l;i<=r;i++) cnt += (i%d==0 ? 1 : 0);
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int H, W,i,j;

	while (1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0){
			break;
		}
			for (i = 0; i < H; i++){
				for (j = 0; j < W; j++){
					putchar('#');
				}
				putchar('\n');
			}
			putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 1000
import java.util.*;
import java.lang.Math;
class Main{
    void run(){
	Scanner sc=new Scanner(System.in);
	int q=sc.nextInt();
	for(int attend=0;attend<q;attend++){
	    int[][] map=new int[5+1][5+1];
	    for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
		    map[i][j]=sc.nextInt();
		}
	    }    
	    
	    int ans=0;
	    for(int i=0;i<5;i++){for(int j=0;j<5;j++){
		    int maxX=5;
		    for(int y=i;y<5;y++){
			for(int x=j;x<maxX;x++){
			    if(map[y][x]==0){
				maxX=x;
				break;
			    }
			    else{
				ans=Math.max(ans,(y-i+1)*(x-j+1));
			    }
			}
		    }
		}
	    }
	    System.out.println(ans);
	}
	
    }
    public static void main(String[] args){
	new Main().run();
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int dp[1005][1005];

main()
{ int m,n;char a[1005][1005];
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	for(int j=1;j<=n;j++)
    cin>>a[i][j];
    dp[1][1]=1;
    
    for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
    {   if(i==1 and j==1)
    dp[i][j]=1;
    	else if(a[i][j]=='.')
    	dp[i][j]= (dp[i-1][j]+dp[i][j-1])%mod;
    	
	}
	cout<<dp[m][n];
}


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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;
int N, D, ans = 0;
double x, y;
inline bool d(double x, double y) { return (D >= hypot(x, y)); }
void solve() {
  cin >> N >> D;
  rep(i, 0, N) {
    cin >> x >> y;
    if (d(x, y)) ans++;
  }
  cout << ans << endl;
}

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

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

using namespace std;

string shuffle(string s, int h)
{
	string bottom, top;
	bottom = s.substr(0, h);
	top = s.substr(h);
	return top + bottom;
}

int main()
{
	string s;
	string res[11];
	int m, h;
	int count = 0;
	while (cin >> s, s != "-")
	{
		cin >> m;
		for (int i = 0; i < m; i++)
		{
			cin >> h;
			s = shuffle(s, h);
		}
		res[count++] = s;
	}
	for (int i = 0; i < count; i++)
	{
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 3156
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], h[N];
long long seg[4 * N];
long long dp[N];

long long query(int l, int r, int start, int end, int pos) {
	
	if (start >= l && end <= r) {  // [start [l , r] end]
		return seg[pos];
	}

    if (r < start || l > end)
		return INT_MIN;
	int mid = (start + end) >> 1;
	long long Left = query(l, r, start, mid, 2 * pos);
	long long right = query(l, r, mid + 1, end, 2 * pos + 1);
	return max(Left, right);
}
void update(int updateIndex, long long value, int start, int end, int pos) {
	if (start == end) {
		seg[pos] = value;
		return;
	}
	int mid = (start + end) >> 1;
	if (mid >= updateIndex) {
		update(updateIndex, value, start, mid, 2 * pos);
	}
	else {
		update(updateIndex, value, mid + 1, end, 2 * pos + 1);
	}
    seg[pos] = max(seg[2 * pos], seg[2 * pos + 1]);
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = 0; i < n; i++) {
		long long leftmax = query(0, h[i], 0, n, 1);
        //cout << leftmax << " \n";
        dp[i] = leftmax + a[i];
		update(h[i], dp[i], 0, n, 1);
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++) {
cin >>vec.at(i);
  }
  int sum=0;
  for(int i=0; i<N; i++) {
   for(int j=0; j<N;j++) {
     sum +=(vec.at(i))*(vec.at(j));
   }
  }
  
  int hosei=0;
  for (int i=0; i<N; i++) {
    hosei +=(vec.at(i))*(vec.at(i));
  }
  
  
  
  
  
  
  
  cout << (sum-hosei)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <set>
#include <map>
#include <random>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

int h, w;
char b[12][12];

bool vertcheck() {
    map<vector<char>, int> m;
    REP(i,w) {
        vector<char> v;
        REP(j,h) {
            v.push_back(b[j][i]);
        }
        sort(v.begin(), v.end());
        m[v]++;
    }
    int odd = 0;
    vector<char> o;
    for (auto p: m) {
        if (p.second % 2 == 1) {
            odd++;
            o = p.first;
        }
    }
    if (w % 2 == 1 && odd == 1) {
        return true;
    }
    if (odd == 0) return true;
    return false;
}

bool horizcheck() {
    map<vector<char>, int> m;
    REP(i,h) {
        vector<char> v;
        REP(j,w) {
            v.push_back(b[i][j]);
        }
        sort(v.begin(), v.end());
        m[v]++;
    }
    int odd = 0;
    for (auto p: m) {
        if (p.second % 2 == 1) {
            odd++;
        }
    }
    if (h % 2 == 1 && odd == 1) {
        return true;
    }
    if (odd == 0) return true;
    return false;
}


int main() {
    cin >> h >> w;
    random_device rd;
    REP(i,h) {
        string s;
        cin >> s;
        REP(j,s.size()) {
            b[i][j] = s[j];
        }
    }
    if (5 < h && h < 9 && 7 <= w) {
        cout << "NO" << endl;
        return 0;
    }
    if (vertcheck() && horizcheck()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
from collections import Counter
def main():
  N = int(input())
  A = [int(_) for _ in input().split()]
  MOD = 10 ** 9 + 7
  B = Counter(A)
  
  if N%2 == 0:
    for i in range(N):
      if (i%2 == 0 and B[i] == 0) or (i%2 == 1 and B[i] == 2):
        pass
      else:
        print(0)
        break
    else:
      print(pow(2, N//2, MOD))
  else:
    for i in range(N):
      if (i == 0 and B[i] == 1) or (i%2 == 0 and B[i] == 2) or (i%2 == 1 and B[i] == 0):
        pass
      else:
        print(0)
        break
    else:
      print(pow(2, N//2, MOD))
      
  return

if __name__ == '__main__':
  main()
    

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

int main()
{
    int64_t N;
    cin >> N;
    int64_t A[N];
    map<int64_t, int64_t> Amap, Bmap;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t B;
        cin >> B;
        A[i] = B;
        Amap[B]++;
    }

    int64_t sumtmp = 0;
    for (auto x : Amap)
    {
        int64_t tmp = x.second;
        sumtmp += tmp * (tmp - 1) / 2;
    }

    for (int64_t i = 0; i < N; i++)
    {
        int64_t K = A[i];
        //      Amap[K]--;
        int64_t tmp = Amap[K];
        int64_t sum = sumtmp - tmp * (tmp - 1) / 2 + (tmp - 1) * (tmp - 2) / 2;
        cout << sum << endl;
        //      Amap[K]++;
    }
}

Measured memory_bytes: 11008
#include<iostream>
using namespace std;
int main()
{
   
	long long int x; cin>> x;
	for (long long int i = -200; i <= 200; i++) {
		for (long long int  j = -200; j <= 200; j++) {
			if (i*i*i*i*i - j*j*j*j*j == x) {
				cout<< i <<" "<< j <<endl;
				return 0;
			} 
		}
	}
	return 0;
} 

Measured memory_bytes: 3532
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int a, b; cin >> a >> b;
	cout << 2 * b - a << endl;
}

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

string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int ans[] = {7, 6, 5, 4, 3, 2, 1};

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string t;
    cin >> t;
    for (int i = 0; i < 7; i++)
        if (t == s[i])
            cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

void record(int v, vector<vector<int>>& A, vector<vector<bool>>& Map)
{
    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            if (v == A[i][j]) Map[i][j] = true;
        }
    }
}

int main()
{
    vector<vector<bool> > Map(3, vector<bool>(3, false));
    vector<vector<int> > A(3, vector<int>(3, 0));

    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            cin >> A[i][j];
            Map[i][j] = false;
        }
    }
    size_t N; cin >> N;
    for (size_t i=0; i<N; i++) {
        int b; cin >> b;
        record(b, A, Map);
    }

    for (size_t i=0; i<3; i++) {
        if (Map[i][0] && Map[i][1] && Map[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (size_t j=0; j<3; j++) {
        if (Map[0][j] && Map[1][j] && Map[2][j]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (Map[0][0] && Map[1][1] && Map[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if (Map[0][2] && Map[1][1] && Map[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#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>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}


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

int su[100005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int aa;
        scanf("%d",&aa);
        aa++;
        su[aa-1]++; su[aa]++; su[aa+1]++;
    }
    int ans = 0;
    for(int i=0;i<=100003;i++){
        if(ans < su[i]) ans = su[i];
    }
    printf("%d\n", ans);
}


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

long long INF = 1e18;

int main(){
    int n;
    cin >> n;
    int imp;
   
    for (int i = 0; i < n;i++){
        cin >> imp;
        if(imp % 2 == 0){
            if(imp % 3 != 0 && imp%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a[200001],ok,b[200001];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        ok=1;
        for(int j=0;j<n;j++){
            b[max(j-a[j],0LL)]++;
            b[min(j+a[j]+1,n)]--;
        }
        for(int j=0;j<n;j++){
            b[j+1]+=b[j];
            //cout<<b[j+1]<<endl;
        }
        for(int j=0;j<n;j++){
            a[j]=b[j];
            b[j]=0;
            if(a[j]<n)ok=0;
        }
        if(ok==1){
            for(int j=0;j<n;j++){
                cout<<n<<" ";
            }
            cout<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int d = Integer.parseInt(tmpArray[0]);
			int w = Integer.parseInt(tmpArray[1]);
			int h = Integer.parseInt(tmpArray[2]);
			
			if(d == 0 && w == 0 & h == 0){
				break;
			}
			
			int n = Integer.parseInt(br.readLine());
			
			int a;
			int b;
			
			if(d >= w && d >= h){
				a = w;
				b = h;
			}
			else if(w >= d && w >= h){
				a = d;
				b = h;
			}
			else{
				a = w;
				b = d;
			}
			
			for(int i = 0; i < n; i++){
				int r = Integer.parseInt(br.readLine());
				
				if(r*2 > Math.sqrt(a*a + b*b)){
					System.out.println("OK");
				}
				else {
					System.out.println("NA");
				}
			}

		}
	}

}

Measured memory_bytes: 24092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    vector<int> A(N);
    int cnt1 = 0, cnt2 = 0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]%2==0){
            cnt1++;
            if(A[i]%3==0||A[i]%5==0){
                cnt2++;
            }
        }
    }
    if(cnt1==cnt2){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }
    
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int cnt = 0;
        repd(j, 1, i + 1) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }

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

Measured memory_bytes: 256
row, column = gets.chomp.split.map(&:to_i)
table = row.times.map{ gets.chomp.split.map(&:to_i) }

table.each do |line| 
  line << line.sum
  puts line.join(' ')
end

puts (column+1).times.map { |x|
  row.times.reduce(0) { |t, y|
    t + table[y][x]
  }
}.join(' ')



Measured memory_bytes: 7084
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll a[101] = {};
int main() {
	ll n, x; cin >> n >> x;
	rep(i, 0, n)cin >> a[i];

	sort(a, a + n);
	ll cnt = 0;
	rep(i, 0, n) {
		x -= a[i];
		if (x < 0) {
			cout << cnt << endl;
			return 0;
		}
		cnt++;
	}
	if (x > 0) {
		cout << n - 1 << endl;
	}
	else {
		cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
flg = [False] * N
for _ in range(K):
    d = int(input())
    A = [int(a) for a in input().split()]
    for a in A:
        flg[a-1] = True
cnt = 0
for f in flg:
    if not f:
        cnt += 1
print(cnt)


Measured memory_bytes: 9180
// https://www.hamayanhamayan.com/entry/2019/01/11/004701
// https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2

import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] h = new int[N];
    long[] a = new long[N];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextLong();
    }
    Seg seg = new Seg(N, h, a);
    List<int[]> sortedByH =
        IntStream.range(0, N)
            .mapToObj(i -> new int[] {i, h[i]})
            .sorted(Comparator.comparingInt(i -> i[1]))
            .collect(Collectors.toList());
    for (int[] ih : sortedByH) {
      int i = ih[0];
//      seg.update(i, seg.max(0, i, 0, 0, N) + a[i]);
      seg.update(i, seg.max1(i) + a[i]);
    }
    System.out.println(seg.data[0]);
  }

  // Max seg tree.
  static class Seg {
    int offset;
    long[] data;

    Seg(int size, int[] heights, long[] values) {
      int n = 1;
      while (n < size) n <<= 1;
      data = new long[(n << 1) - 1];
      offset = n - 1;
    }

    void update(int idx, long val) {
      int i = offset + idx;
      while (i >= 0 && data[i] < val) {
        data[i] = val;
        i = (i - 1) / 2;
      }
    }

    // Find max in range [l,r), seg in [segl, segr)
    long max(int l, int r, int seg, int segl, int segr) {
      if (segr <= l || r <= segl) return 0;

      if (l <= segl && segr <= r) return data[seg];
      else {
        int m = (segl + segr) / 2;
        return Math.max(max(l, r, seg * 2 + 1, segl, m), max(l, r, seg * 2 + 2, m, segr));
      }
    }
    // Find max in range[0,i)
    long max1(int idx) {
      int i = offset + idx;
      long max = data[i];
      while (i > 0) {
        // 自身が右枝の場合のみ、左枝と比較
        if (i % 2 == 0) {
          max = Math.max(data[i - 1], max);
        }
        i = (i - 1) / 2;
      }
      return max;
    }
  }
}


Measured memory_bytes: 125784
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll M = 998244353;

ll n, m, k;
ll fac[400005];
ll fiv[400005];
ll ans;

ll pow(ll p, ll q)
{
    if(q < 0) return 0;
    if(q == 0) return 1;
    ll t = pow(p, q / 2);
    if(q % 2 == 0) return t * t % M;
    else return t * t % M * p % M;
}

ll C(ll p, ll q)
{
    if(p < q) return 0;
    return fac[p] * fiv[p - q] % M * fiv[q] % M;
}

int main()
{
    scanf("%lld%lld%lld", &n, &m, &k);
    n--;
    fac[0] = 1;
    for(ll i = 1; i <= 2 * n; i++) fac[i] = fac[i - 1] * i % M;
    fiv[2 * n] = pow(fac[2 * n], M - 2);
    for(ll i = 2 * n - 1; i >= 0; i--) fiv[i] = fiv[i + 1] * (i + 1) % M;
    for(ll i = 0; i <= k; i++)
    {
        ans += C(n, i) * m % M * pow(m - 1, n - i) % M;
        ans %= M;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 10004
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N, K = sc.nextInt
  val A = Array.fill(N)(sc.nextInt)

  for (i <- K + 1 to N) {
    val z = if (A(i - 1) > A(i - K - 1)) "Yes" else "No"
    println(z)
  }
}


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

int main(){
    int n;
    cin >> n;
    string s;
    int card;
    int num[4][13]={0};
    for(int i=0; i<n; i++){
        cin >> s >> card;
        if(s=="S"){
            num[0][card-1]++;
        }
        else if(s=="H"){
            num[1][card-1]++;
        }
        else if(s=="C"){
            num[2][card-1]++;
        }
        else if(s=="D"){
            num[3][card-1]++;
        }
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            if(num[i][j]==0){
                switch(i){
                    case 0:
                        cout << "S" << " " << j+1 << endl;
                        break;
                    case 1:
                        cout << "H" << " " << j+1 << endl;
                        break;
                    case 2:
                        cout << "C" << " " << j+1 << endl;
                        break;
                    default:
                        cout << "D" << " " << j+1 << endl;
                        break;
                }
            }
        }
    }
}



Measured memory_bytes: 3144
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
ans = 1
for i in range(1, n + 1):
    ans *= i
    ans %= mod
print(ans)

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

int main(){
  int tmp;
  ll N,M,K; //Aの冊数　Bの冊数　読める時間
  ll sum=0;
  int ans = 0;
  cin >> N >> M >> K;
  
  vector<ll> A(N+1);
  vector<ll> B(M+1);
  
  for(int i = 1; i <= N; i++){
    cin >> tmp;
    A.at(i) = A.at(i-1) + tmp;
  }
  for(int i = 1; i <= M; i++){
    cin >> tmp;
    B.at(i) = B.at(i-1) + tmp;
  }
  
  tmp = M;
  for(int i = 0; i < N + 1 ; i++){
    if(A.at(i) > K)
      break;
    for(int j = tmp ; j >= 0 ; j--){
      if(B.at(j) <= K - A.at(i)){
        tmp = j;
        ans = max(ans,i+j);
        break;
      }
    }
  }
  
  cout << ans << endl;
  
}

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

int main(){
    string a,b;
    cin >> a >> b;
    if(a.length() == b.length()){
        if(a<b){
            cout << "LESS" << endl;
        }else if(a>b){
            cout << "GREATER" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }else if(a.length() < b.length()){
        cout << "LESS" << endl;
    }else{
        cout << "GREATER" << endl;
    }
    return 0;
}


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

ll mod = 1e9 + 7;
const ld error = 1e-8;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = bt(16)+1;
///===========================================  template  =======================================================

int main(){
    FASTIO;
    int n;
    cin>>n;
    map<string, int> mp;
    for(int i = 0; i<n; i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx = 0;
    for(auto &p: mp){
        mx = max(mx, p.second);
    }

    for(auto &p: mp){
        if(p.second == mx){
            cout<<p.first<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main(void){
    int N,D,X,ans=0;
    cin >> N >> D >> X;
    int n;
    for(int i=0;i<N;i++){
        cin >> n;
        ans += (D-1)/n;
    }
    cout << ans+X+N << endl;
	return 0;
}

Measured memory_bytes: 3620
from itertools import *

N = input()
P = tuple(map(int, raw_input().split()))
Q = tuple(map(int, raw_input().split()))

c = 0
for p in permutations(range(1, N+1)):
  if p==P:
    a = c
  if p==Q:
    b = c
  c += 1
print abs(a-b)


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 1005
ld a,b,x;
void solve(){
	cin>>a>>b>>x;
	ld A=a*a*b;
	x=x/a/a;
	if(x<=b/2)bug(atan(b*b/2/a/x)*180/PI);
	bug(atan(2*(b-x)/a)*180/PI);
}
void prep(){
	
}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
//#include <limits>
//#include <type_traits>
//#include <boost/integer/common_factor_rt.hpp>
using namespace std;

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


int main(){

  long N,K,a,b,s,ans;
  int i,j,k,d;
  bool can;
  can=true;
  //using T = int32_t;
  ans=0;
  cin>>K;

  for(i=1;i<K+1;i++){
    for(j=1;j<K+1;j++){
      for(k=1;k<K+1;k++){
	d=gcd(i,j);
        ans+=gcd(d,k);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    map<char,string> m{};
    string a,b,c; cin >> a >> b >> c;
    m['a'] = a; m['b'] = b; m['c'] = c;
    char now='a';
    char ans;
    while(true){
        string s = m[now];
        if(s.size()==0) {ans=toupper(now); break;}
        char c = s[0];
        s.erase(s.begin());
        m[now] = s;
        now = c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
n=len(s)
a=b=0
M=10**9+7
for i in range(n):
  if'0'<s[i]:
    a=(a+pow(2,b,M)*pow(3,n-i-1,M))%M
    b+=1
print((a+pow(2,b,M))%M)

Measured memory_bytes: 3188
import heapq

n, m = map(int, input().split())

cands = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        cands[a - 1].append(-b)

heapq.heapify(cands[0])
total = 0
for i in range(m):
    if len(cands[0]) > 0:
        total -= heapq.heappop(cands[0])
    if i < m - 1:
        for c in cands[i + 1]:
            heapq.heappush(cands[0], c)

print(total)


Measured memory_bytes: 71968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;
const int inf=0x3f3f3f;
ll dp[2][N];

int main(){
    string s;
    cin>>s;
    dp[0][0]=0;
    dp[1][0]=inf;
    reverse(s.begin(),s.end());
    for(int i=0;i<s.size();i++){
        dp[0][i+1]=min(dp[0][i],dp[1][i])+s[i]-'0';
        dp[1][i+1]=min(dp[0][i]+1+10-s[i]+'0',dp[1][i]+10-s[i]+'0'-1);
    }
    //cout<<dp[1][1]<<endl;
    cout<<min(dp[0][s.size()],dp[1][s.size()])<<endl;
    return 0;
}
/*
87
13
4
*/


Measured memory_bytes: 17028
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

const int N = 100000 + 5;
int n;
int a[N];

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; ++ i) {
        scanf("%d", a + i);
    }
    int ans = 0;
    for(int i = 1, j; i <= n; i = j + 1) {
        for(j = i; j == a[j] && j <= n; ++ j);
        ans += (j - i + 1) / 2;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int a, b, s1, s2, s3;
	cin >> a >> b;
	s1=2*a-1;
	s2=2*b-1;
	s3=a+b;
	if (s1>=s2 && s1>=s3)
		cout << s1 << endl;
	else if (s2>=s1 && s2>=s3)
		cout << s2 << endl;
	else if (s3>=s1 && s3>=s2)
		cout << s3 << endl;
	return 0;
}

Measured memory_bytes: 256
//                   ********** YATIN KWATRA **********

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node


using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

/*
    
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible 
*/





void solve()
{ 
        int n,m;
        ll t;
        cin >> n >> m >> t;
        
        vii v1(n),v2(m);
        
        fo(i,0,n-1) cin >> v1[i];
        fo(i,0,m-1) cin >> v2[i];

        ll sum = 0;
        int best = 0;

        int i = -1;

        while(i<n)
        {
           i++;
           if((t-sum)>=v1[i]) sum += v1[i];
           else break;
        }

        i--;

        int j = -1;

        while(j<m)
        {
        //  cout << " sum : " << sum << " i: " << i << " j: " << j << endl;
          while(j<m)
          {
            j++;
            if((t-sum)>=v2[j]) sum += v2[j];
            else break;
          }
          j--;

       //   cout << i << ' ' << j << endl;

           best = max(best,(i+j+2));

           if(i>=0)
           {
                i--;
                sum -= v1[i+1];
           } 
           else break;
        }

        cout << best << endl;

       
}
int main() {
    
    FIO
   // INPUT();
    
    int t;
    t = 1;
//    cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	int s;
		string k,a;
	cin >> s>>k;
	a = k;
	
	if (s<3200) {
		a="red";
	
	}
	
	
	cout << a<< endl;
}

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

int main() {
  string S;
  cin >> S;
  int ans = 0, temp = 0;
  for (unsigned int i = 0; i < S.length(); i++) {
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      temp++;
    } else {
      ans = max(ans, temp);
      temp = 0;
    }
  }
  ans = max(ans, temp);
      temp = 0;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'G') cout << 'C' << endl;
    if(b == 'C') cout << 'G' << endl;
}

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

#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 SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll a, b, c;

    cin >> a >> b >> c;

    if ((a==b && b==c && c==a) || (a!=b && b!=c && c!=a)){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

using namespace std;
#define mod 1000000007
int main()
{
    long long n,k;
    cin >> n >> k;
    long long f[n+1][k+1];
    long long a[n];
    for(long long i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(long long i=0;i<=n;i++)
    {
        for(long long j=0;j<=k;j++)
        {
            f[i][j]=0;
        }
        f[i][0]=1;
    }
    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;j<=k;j++)
        {
            f[i][j]=f[i-1][j]+f[i][j-1];
            f[i][j]%=mod;
            if(j-a[i]-1>=0)
            {
                f[i][j]=(f[i][j]-f[i-1][j-a[i]-1]+mod)%mod;
            }
        }
    }
    cout << f[n][k];
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a[100000];
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    deque<int> que;
    rep(i,n){if(i==0&&a[i]>=0||a[i]<0)ans-=a[i];
        else ans+=a[i];
        que.push_back(a[i]);
    }
    if(a[n-1]<0)ans+=a[n-1]*2;
    cout<<ans<<endl;
    rep(i,n-1){
        if(que.front()>0){
            int x=que.front();que.pop_front();
            int y=que.front();que.pop_front();
            cout<<x<<" "<<y<<endl;
            que.push_front(x-y);
        }
        else{
            if(que[que.size()-2]<=0){
                int x=que.front(),y=que.back();
                que.pop_front();que.pop_back();
                cout<<y<<" "<<x<<endl;
                que.push_back(y-x);
            }
            else{
                int x=que.front(),y=que.back();
                que.pop_front();que.pop_back();
                cout<<x<<" "<<y<<endl;
                que.push_front(x-y);
            }
        }
    }
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include<math.h>
#include <stdlib.h>
#include <queue>
#include <string.h>
using namespace std;
#define Minf -1e9
#define scan(n) scanf("%lld",&n)
typedef long long ll;
const int maxn = 2*1e5+10;
const ll INF = 1e9+100;
const int mod = 998244353;

char a[maxn];
int main()
{
	scanf("%s", &a);
	int te = 0;
	int len = strlen(a);
	for (int i = 0; i < len; i++) {
		te += a[i] - '0';
		te %= 9;
	}
	if (te % 9 == 0) {
		cout << "Yes\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,  ll>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	int n; cin >> n;
    for(int i = 0; i < 26; ++i){
    	for(int j = 0; j < 16; ++j){
    	    if(4*i + 7*j == n){
    	         cout << "Yes" << endl;
                 return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unordered_set>

using namespace std;

int main(){
  int M;
  cin>>M;
  for(int m=0;m<M;++m){
    string s;
    cin>>s;
    int n=s.size();
    unordered_set<string> list;
    for(int i=1;i<n;++i){
      string s1=s.substr(0,i),s2=s.substr(i,n);
      for(int t=0;t<4;++t){
        if(t==2){
          reverse(s1.begin(),s1.end());
        }
        if(t%2==1){
          reverse(s2.begin(),s2.end());
        }
        string res=s1+s2;
        list.insert(res);
        res=s2+s1;
        list.insert(res);
      }
    }
    cout<<list.size()<<endl;
  }
  return 0;
}



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

bool isOk(const vector<long long>& v, const vector<long long>& food, long long k, long long lim)
{
  for (long long i = 0; i < (long long)v.size(); i++) {
    if (v.at(i) * food.at(i) <= lim) {
      continue;
    }
    long long target = lim / food.at(i);
    long long diff = v.at(i) - target;
    k -= diff;
    if (k < 0) {
      return false;
    }
  }
  return true;
}

int main()
{
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  vector<long long> food(n);
  for (long long i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (long long i = 0; i < n; i++) {
    cin >> food.at(i);
  }
  sort(v.begin(), v.end());
  sort(food.rbegin(), food.rend());
  long long maxi = 0;
  for (long long i = 0; i < n; i++) {
    maxi = max(maxi, v.at(i) * food.at(i));
  }
  long long ok = maxi;
  long long ng = -1;
  while (abs(ok - ng) > 1) {
    auto mid = (ok + ng) / 2;
    if (isOk(v, food, k, mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << '\n';
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

vector<int> z_algorithm(const string& s) {
  vector<int> prefix(s.size());
  prefix[0] = s.size();
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) ++j;
    prefix[i] = j;
    if (j == 0) { ++i; continue; }
    int k = 1;
    while (i + k < s.size() && k + prefix[k] < j) { prefix[i + k] = prefix[k]; ++k; }
    i += k; j -= k;
  }
  return prefix;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  rep(i, N) {
    string s = S.substr(i);
    vector<int> prefix = z_algorithm(s);
    rep(j, s.size())
      chmax(ans, min(prefix[j], j));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<ll>;

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int c = 0;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < 3; i++) c+= s[i] == t[i];
  cout << c <<"\n";
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n;
    ll tmp1=0, tmp2=0;
    cin >> n;
    vector <ll> x(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        tmp2 += x[i];
    }
    ll diff = inf;
    for (int i = 0; i < n; i++) {
        diff = min(diff, abs(tmp2-tmp1));
        tmp1 += x[i];
        tmp2 -= x[i];
    }
    cout << diff << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
  int N,t;
  long long sum=0;
  vector<long long> A,B;
  int neg_count=0;
  multiset<long long,greater<long long>> pos;
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> t;
    A.push_back(t);
  }
  for(int i=0;i<N;i++){
    cin >> t;
    if(t>A[i]){
      neg_count++;
      sum+=t-A[i];
    }else if(t<A[i]){
      pos.insert(A[i]-t);
    }
  }
  int pos_count=0;
  for(auto itr=pos.begin();itr!=pos.end();itr++){
    if(sum<=0) break;
    sum-=*itr;
    pos_count++;
  }
  if(sum<=0){
    cout << pos_count+neg_count << endl;
  }else{
    cout << -1 << endl;
  }
   
}
  

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

using namespace std;

int main() {

    int K;
    cin >> K;

    string S;
    cin >> S;

    int length = S.length();

    if (length <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes";
            return 0;
        }
        a -= d;
        if(a<=0){
            cout<<"No";
            return 0;
        }
    }
}

Measured memory_bytes: 3652