akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int minute=H2*60+M2-H1*60-M1;
  if(minute>=K){
    cout<<minute-K<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}

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

template<typename T, T M>
struct modint {
  T n;
  constexpr modint(const T n = 0) : n((n % M + M) % M) {}
  constexpr modint pow(T r) const {
    modint ans(1), a(n);
    while(r) { if (r & 1) ans *= a; a *= a; r >>= 1; }
    return ans;
  }
  
  constexpr modint& operator+= (const modint r) {
    n += r.n; if (n >= M) n -= M; return *this;
  }
  constexpr modint& operator-= (const modint r) {
    n -= r.n; if (n < 0) n += M; return *this;
  }
  constexpr modint& operator*= (const modint r) {
    n = n * r.n % M; return *this;
  }
  constexpr modint operator+ (const modint r) const { return modint(n) += r; }
  constexpr modint operator- (const modint r) const { return modint(n) -= r; }
  constexpr modint operator* (const modint r) const { return modint(n) *= r; }
  
  /* Divisions only work for prime modules */
  constexpr modint& operator/= (const modint r) { return (*this) *= r.pow(M-2); }
  constexpr modint operator/ (const modint r) const { return modint(n) /= r; }
};

template<typename T>
struct modfact {
  vector<T> fact, invfact;
  
  constexpr modfact(int n): fact(n + 1), invfact(n + 1) {
    fact[0] = T(1);
    for(int i = 1; i <= n; i++)
      fact[i] = fact[i - 1] * T(i);
    invfact[n] = T(1) / fact[n];
    for(int i = n - 1; i >= 0; --i)
      invfact[i] = invfact[i + 1] * T(i + 1);
  }
  
  constexpr T p(int n, int k) const {
    // permutations: n! / k!
    if (k < 0 || k > n) return T(0);
    return fact[n] * invfact[k];
  }
  
  constexpr T c(int n, int k) const {
    // combinations(binomial coefficient): n! / (k! * (n - k)!)
    if (k < 0 || k > n) return T(0);
    return p(n, k) * invfact[n - k];
  }
};

typedef modint<long, 1000003L> mint;

int main() {
  int q, x, d, n;
  cin >> q;
  modfact<mint> mf(1000002);
  
  const auto solve = [&](const int& x, const int& n) {
    if (x == 0 || x + n > 1000003) return mint(0);
    return mf.p(x + n - 1, x - 1);
  };
 
  while(q--) {
    cin >> x >> d >> n;
    
    cout << (d ? solve((mint(x) / mint(d)).n, n) * mint(d).pow(n) :
                 mint(x).pow(n)).n << endl;
  }
}

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int N = 1e6+2;
int prime[N], spf[N], a[N];
bool co=true;

void smallest_prime_factor(){
	spf[1] = 1; 
    for (int i=2; i<N; i++) 
        spf[i] = i; 

    for (int i=4; i<N; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<N; i++){ 
        if (spf[i] == i){ 
            for (int j=i*i; j<N; j+=i) 
                if (spf[j]==j) spf[j] = i; 
        } 
    } 
}

vector<int> ff(N,0);
void prime_factorize_using_seive(int x){
    while(x!=1){
			int SPF=spf[x];
			while(x%SPF==0){
				x/=SPF;
			}
			ff[SPF]++;
			if(ff[SPF]>1)co=false;
	}
}

void solve(){
	int n; cin >> n;
	For(i,n)cin >> a[i];
	smallest_prime_factor();
	For(i,n){
		prime_factorize_using_seive(a[i]);
	}

	if(co){
		cout << "pairwise coprime\n";
	}
	else{
		vector<int> g(n);
		g[0]=a[0];
		FOR(i,1,n){
			g[i]=gcd(g[i-1],a[i]);
		}
		if(g[n-1]==1){
			cout << "setwise coprime\n";
		}
		else{
			cout << "not coprime\n";
		}
	}
}

int32_t main(){ 
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	for(int tt=1;tt<=t;tt++){
		solve();
	}
}


Measured memory_bytes: 34500
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int  N;
  cin >> N;
  
  for(int i = 0 ; i < N ; i++){
    
    string color;
    cin >> color;
    
    if(i == N-1){
      if(color != "Y"){
        cout << "Three" << endl; 
      }else{
        cout << "Four" << endl;
      }
    }
    
    if (color == "Y"){
      cout << "Four" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz5 100005

ll BIT[sz5*5];

void update(ll idx, ll n, ll val){
	while(idx<=n){
		BIT[idx]+=val;
		idx+=(idx&(-idx));
	}
}

ll query(ll idx){
	ll ans=0;
	while(idx){
		ans+=BIT[idx];
		idx-=(idx&(-idx));
	}
	return ans;
}

int main() {
	FAST

	ll n,q,la,lb,num;
	cin>>n>>q;
	for(la=1;la<=n;la++){
		cin>>num;
		update(la, n, num);
	}

	while(q--){
		ll ch, a, b;
		cin>>ch>>a>>b;

		if(ch==0)
			update(a+1, n, b);
		else
			cout<<query(b)-query(a)<<endl;
	}

	return 0;
}

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

using namespace std;

int n, m;

int main()
{
	cin >> n >> m;
	if(m%n == 0)
	{
		cout << m/n << endl;
		return 0;
	}
	for(int i = m/n; i; --i)
	{
		if(m%i) continue;
		cout << i << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BNarrowRectanglesEasy {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int w, a, b;
	    in >> w >> a >> b;
	    int upper = min(b+w, a+w);
	    int lower = max(a, b);
	    out << max(lower - upper, 0) << endl;
	}
};


int main() {
	BNarrowRectanglesEasy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x1fffffffffffffff;
template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& i : a) cin >> i;
    const ll cnt = 1 + (n & 1);
    vector<vector<ll>> dp(n + 2, vector<ll>(cnt + 1, -INF));
    dp[0][0] = 0;
    for(ll i = 0; i <= n; i++) for(ll j = 0; j <= cnt; j++){
        if(j < cnt) chmax(dp[i + 1][j + 1], dp[i][j]);
        if(i < n) chmax(dp[i + 2][j], dp[i][j] + a[i]); // 1個選んだら1個選ばないのもセット
    }
    cout << dp[n + 1][cnt] << endl; // なので floor(n / 2) * 2 + cnt == n + 1 に答えが入る
}

Measured memory_bytes: 15632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define rep(i, n) for ((i)=0;(i)<(n);(i)++)

int tmp1, tmp2, tmp3;

typedef struct {
    int top;
    int S;
    int E;
    int W;
    int N;
    int bottom;
} Dice3;

void roll_S(Dice3 *a) {
    tmp1 = a->S;
    a->S = a->top;
    tmp2 = a->bottom;
    a->bottom = tmp1;
    tmp3 = a->N;
    a->N = tmp2;
    a->top = tmp3;
}

void roll_E(Dice3 *b) {
    tmp1 = b->E;
    b->E = b->top;
    tmp2 = b->bottom;
    b->bottom = tmp1;
    tmp3 = b->W;
    b->W = tmp2;
    b->top = tmp3;
}

void roll_N(Dice3 *c) {
    tmp1 = c->N;
    c->N = c->top;
    tmp2 = c->bottom;
    c->bottom = tmp1;
    tmp3 = c->S;
    c->S = tmp2;
    c->top = tmp3;
}

void roll_W(Dice3 *d) {
    tmp1 = d->W;
    d->W = d->top;
    tmp2 = d->bottom;
    d->bottom = tmp1;
    tmp3 = d->E;
    d->E = tmp2;
    d->top = tmp3;
}

int main(void) {
    int i, n;
    scanf("%d", &n);
    Dice3 dice[n];

    char commands[4] = {'S','E','N','W'};
    char command;

    rep(i, n) {
        scanf("%d %d %d %d %d %d",&dice[i].top,&dice[i].S,&dice[i].E,&dice[i].W,&dice[i].N,&dice[i].bottom);
    }
    
    srand((unsigned)time(NULL));

    for (int p = 0; p < n - 1; p++) {
        for (int q = p + 1; q < n; q++) {
            rep(i, 100) {
                command = commands[rand()%4];
                if (command == 'S') roll_S(&dice[p]);
                else if (command == 'E') roll_E(&dice[p]);
                else if (command == 'N') roll_N(&dice[p]);
                else if (command == 'W') roll_W(&dice[p]);
                
                if (dice[p].top == dice[q].top && dice[p].S == dice[q].S && dice[p].N == dice[q].N && dice[p].W == dice[q].W && dice[p].E == dice[q].E && dice[p].bottom == dice[q].bottom) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");

    return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int calc(int x) {
  string s = to_string(x);
  int ans = 0;
  for (int i = 1; i < s.length(); i++) {
    int a = stoi(s.substr(0, i));
    int b = stoi(s.substr(i));
    ans = max(ans, a*b);
  }
  return ans;
}

signed main() {
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int N; cin >> N;
    int ans = 0;
    while (N >= 10) {
      N = calc(N);

      ans++;
      if (ans > 100100) break;
    }
    if (N < 10) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
}



Measured memory_bytes: 3292
#include<stdio.h>>

int main(){

    int A, B, C;

    scanf("%d %d", &A, &B);

    C = A + B;

    if(C >= 0 && C <= 23){
        printf("%d", C);
    }
    else if(C >= 0 && C >= 23){
        C = C - 24;
        printf("%d", C);
    }

    return 0;
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    string s;cin >> s;

    int ans = 0;
    int n = (int)s.length();
    REP(i,n){
        int j = n - 1 -i;
        if(s[i] != s[j])ans++;
    }
    cout << ans/2 << endl;


    return 0;
}

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

int main() {
	int n;
	long long h, w;
	long long a, b;
	int count = 0;
	cin >> n >> h >> w;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a >= h && b >= w) {
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
s=input()
t=input()

S=[]
T=[]
for a in s:
    S.append(a)
for a in t:
    T.append(a)
S.sort()
T.sort(reverse=True)


s2=0
t2=0
ans="No"
for i in range(min(len(S),len(T))):
    s2=s2*256+ord(S[i])
    t2=t2*256+ord(T[i])
if s2<t2 :
    ans="Yes"
elif s2==t2 :
    if len(s)<len(t) :
        ans="Yes"
print(ans)

Measured memory_bytes: 9092
A,B,K = list(map(int,input().split()))

def process(a,b,k):
    if k%2==0:
        if a%2==1:
            a -= 1
        b += a//2
        a //= 2
    else:
        if b%2==1:
            b -= 1
        a += b//2
        b //= 2
    return a,b

for k in range(K):
    A,B = process(A,B,k)

print(A,B)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    int ans;
    if(B == 1) ans = 0;
    else if(B <= A) ans = 1;
    else ans = (B-A+A-2)/(A-1)+1;
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int a_max = 0, a_min = inf;
  rep(i,n){
    a_max = max(a_max, a[i]);
    a_min = min(a_min, a[i]);
  }

  cout << a_max-a_min << endl;
}


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

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

  if (64 <= n) {
    cout << 64 << endl;
  } else if (32 <= n) {
    cout << 32 << endl;
  } else if (16 <= n) {
    cout << 16 << endl;
  } else if (8 <= n) {
    cout << 8 << endl;
  } else if (4 <= n) {
    cout << 4 << endl;
  } else if (2 <= n) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    n_head_pos = dict() #一番最初にnが出てくるindex
    rem_head_num = [-1] * N #i番目から処理を始めた時に残る数列の先頭の数字
    for i in reversed(range(N)):
        if A[i] not in n_head_pos:
            rem_head_num[i] = A[i]
        else:
            if n_head_pos[A[i]] == N-1: rem_head_num[i] = -1
            else: rem_head_num[i] = rem_head_num[n_head_pos[A[i]] + 1]
        n_head_pos[A[i]] = i
    #print(n_head_pos)
    #print(rem_head_num)

    start_cycle = [] #先頭の数字の周期
    start = -1
    used = set()
    while start not in used:
        used |= {start}
        start_cycle.append(start)
        if start == -1: next = rem_head_num[0]
        elif n_head_pos[start] < N - 1: next = rem_head_num[n_head_pos[start] + 1]
        else: next = -1
        start = next

    #print(start_cycle)

    len_cycle = len(start_cycle)
    last = (K - 1) % len_cycle 
    #print(last)
    if start_cycle[last] == -1: start_index = 0
    elif n_head_pos[start_cycle[last]] < N - 1: start_index =n_head_pos[start_cycle[last]] + 1
    else: start_index == -1
    #print(start_index)
    if start_index >= 0:
        out = []
        using = dict()
        l = 0
        for i in range(start_index, N):
            if A[i] in using:
                aindex = using[A[i]]
                l = aindex
                for a in out[aindex:]:
                    using.pop(a)
                out = out[:aindex]
            else:
                out.append(A[i])
                using[A[i]] = l
                l += 1
                #print(out, using, l)
        print(" ".join(map(str, out)))
    else: print(" ")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 82928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,d,w,h,i,j,k,l,m,n,z;
	double	ans = 0;
	cin >> a >> b >> h >> m;
	
	double x = m*6;
	double y = h*30+(double)m/2;
	
	double rad = abs(x-y);
	if (rad>180.0) rad = 360.0 - rad;
	
	//cout << cos(0) << endl;
	//cout << cos(180.0/180.0*M_PI) << endl;

	ans = sqrt( a*a + b*b - 2*a*b*cos(rad/180.0*M_PI) );
	printf("%.10f\n",ans);
	return 0;
}


Measured memory_bytes: 4200
ARGF.each_line do |line|
    a, q, b = line.split
    break if q == "?"
    case q
    when "+"
      z = a.to_i + b.to_i
    when "-"
      z = a.to_i - b.to_i
    when "*"
      z = a.to_i * b.to_i
    when "/"
      z = a.to_i / b.to_i
    end
    puts z
end

Measured memory_bytes: 6092
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))

a.sort()
a = a[::-1]
ans = 0
cnt = 0
flag = 0
for _ in range(n-1):
  ans += a[cnt]
  flag = 1-flag
  cnt += flag

print(ans)

Measured memory_bytes: 50192
from functools import reduce


def main():
    n, k = tuple(map(int, input().split()))
    s = input().strip()
    start = 0
    count_zero = {}

    for i, c in enumerate(s):
        if c == "0":
            if i == start:
                count_zero[start] = 0

            count_zero[start] += 1
        elif c == "1":
            start = i + 1

    if len(count_zero) <= k:
        print(n)
        return

    count_zero[-1] = 1
    count_zero[n] = 1

    count_zero_list = sorted(count_zero.items(), key=lambda pair: pair[0])

    print(reduce(lambda ans, i:
        max(ans, count_zero_list[i + k + 1][0] - (count_zero_list[i][0] + count_zero_list[i][1])),
        range(0, len(count_zero) - k - 1), 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12232
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
vector<vector<int>>g;
int ans=INF;
int h,w;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
vector<vector<bool>>used;
signed main(){
    cin>>h>>w;
    vector<vector<int>>g(h,vector<int>(w,1));
    vector<vector<bool>>used(h,vector<bool>(w,true));
    int sub=0;
    rep(i,h)rep(j,w){
        char f;cin>>f;
        if(f=='#'){
            g[i][j]=INF;
            sub++;
        }
    }
    int cnt=INF;
    int flag=0;
    vvi d(h,vi(w,INF));
    d[0][0]=0;
    priority_queue<piii,vector<piii>,greater<piii>>que;
    que.push(mp(0,mp(0,0)));
    while(!que.empty()){
        piii temp=que.top();que.pop();
        pii now=temp.second;
        int cost=temp.first;
        used[now.first][now.second]=false;
        if(now==mp(h-1,w-1))break;
        if(d[now.first][now.second]<cost)continue;
        rep(i,4){
            pii next=mp(now.first+dy[i],now.second+dx[i]);
            if((0<=next.first&&next.first<h)&&(0<=next.second&&next.second<w)){
                if(g[next.first][next.second]==INF)continue;
                if(used[next.first][next.second]==false)continue;
                if(d[next.first][next.second]<=d[now.first][now.second]+1)continue;
                d[next.first][next.second]=d[now.first][now.second]+1;
                que.push(mp(d[next.first][next.second],next));
            }
        }
    }
    cnt=d[h-1][w-1];
    if(cnt==INF)cout<<-1<<endl;
    else cout<<h*w-cnt-1-sub<<endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public void keisan(int n,int a) {
    boolean k = false;
    
    for (int i = 0; i < 100; i ++) {
      for ( int j = 0; j <= a; j++) {
        int r = j + i *500;
        if (n == r) {
          k = true;
          break;
        }
      }
    }
    if (k) System.out.println("Yes");
    else System.out.println("No");
  }

  public static void main (String args[]) {
    Scanner scan = new Scanner(System.in);

    String N = scan.next();
    String A = scan.next();

    int n = Integer.parseInt(N);
    int a = Integer.parseInt(A);

    Main main = new Main();
    
    main.keisan(n,a);
  }
}


Measured memory_bytes: 21204
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        int cnt=0;

        for(int i = 0;i<len/2;i++){
            if(s.charAt(i)!=s.charAt(len-i-1)){
                cnt++;
            }
        }
        System.out.println(cnt);
      
    }
}


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

int main() {
  int n, k;
  long long res=0;
  cin >> n >> k;
  vector<long long> h(n);
  for(int i=0;i<n;++i) cin >> h[i];
  sort(h.begin(),h.end());
  for(int i=0;i<n-k;++i) res+=h[i];
  cout << res << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n) cin >> a[i + 1];
    vector<int> b(n + 1);
    for (int i = n; i >= 1; --i)
    {
        int sum = 0;
        for (int j = i + i; j <= n; j += i)
        {
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }
    vector<int> ans;
    for (int i = 1; i <= n; ++i)
    {
        if (b[i])
            ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size())
    {
        printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	x=arr[0];//max
	y=arr[0];//min
	z=1000;
	for (i=0;i<n;i++)
	{
		if (arr[i]>y)
		{
			z=(z/y)*arr[i]+z%y;
			y=arr[i];
		}
		else if (arr[i]<y)
		{
			y=arr[i];
		}
	}
	cout<<z<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;

  // 後ろから文字列を走査
  reverse(all(S));
  rep(i, 0, 4) reverse(all(divide[i]));

  for (int i=0; i<S.size();) {
    bool can = false;  // 4個の文字列のいずれかで divide できるか
    rep(j, 0, 4) {
      string d = divide[j];
      if (d == S.substr(i, d.size())) {
        can = true;
        i += d.size();
      }
    }
    if (!can) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int N;
	cin >> N;
	vector<int> T(N);
	for(int i = 0; i < N; i++){
		cin >> T[i];
	}
	int sum = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++ ){
			sum += T[i] * T[j];
		}
	}
	cout << sum << endl;
}

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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const ll mxn = 2e6+10;
ll fact[mxn];
ll in_fact[mxn];
ll c(ll n,ll r) {
	ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	return ans;
}
int main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        ll k;
        ll ans = 0;
        string s;
        cin>>k>>s;
        ll n = s.size();
		fact[0] = 1;
		for(ll i = 1; i < mxn; i++) {
			fact[i] = (i*fact[i-1])%mod;
		}
		in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
		for(ll i = mxn-2; i >= 0; i--) {
			in_fact[i] = (in_fact[i+1] * (i+1))%mod;
		}
		for(ll i = n; i <= n+k; i++) {
			ll tmp = (bigmod(26,n+k-i) * bigmod(25,i-n)) % mod;
			tmp = (tmp * c(i-1,n-1))%mod;
			ans = (ans+tmp)%mod;
		}
		cout<<ans<<endl;
        
        
    }



return 0;
}


Measured memory_bytes: 35592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] height = new int[10];
		
		for (int i = 0; i < 10; i++){
			String s = br.readLine();
			height[i] = Integer.parseInt(s);
		}
		
		Arrays.sort(height);
		
		System.out.println(height[height.length-1]);
		System.out.println(height[height.length-2]);
		System.out.println(height[height.length-3]);
	}
}

Measured memory_bytes: 16928
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-9;

typedef pair<xy_t, bool> dat;

namespace std{
	bool operator < (const xy_t &a, const xy_t &b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

string chs[] = {
	".,!? ", 
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};

int main(){
	int n;
	string s;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s;
		int pos = 0;
		int sz = s.size();
		while(pos < sz){
			while(pos < sz && s[pos] == '0') pos++;
			if(pos == sz) break;
			char ch = s[pos];
			int cnt = 0;
			while(pos < sz && s[pos] == ch) cnt++, pos++;
			cout << chs[ch-'1'][(cnt-1)%chs[ch-'1'].size()];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int gcd(int x, int y){
    if(y == 0) return x;
    else return gcd(y, x % y);
}

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

    sort(a.begin(), a.end());

    int MAX = a[n-1];

    vector<int> v;
    for(int i=1; i*i<=MAX; i++){
        if(MAX % i == 0){
            v.eb(i);
            v.eb(MAX/i);
        }
    }

    int ans = 1;
    for(int i=0; i<v.size(); i++){
        int cnt = 0;
        for(int j=0; j<n; j++){
            if(a[j] % v[i] == 0) cnt++;
        }

        if(n - 1 <= cnt){
            chmax(ans, v[i]);
        }
    }

    int GCD = gcd(a[0], a[1]);
    for(int i=2; i<n-1; i++){
        GCD = gcd(GCD, a[i]);
    }

    cout << max(ans, GCD) << endl;
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

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

    sort(ALL(p));

    int ans = 0;
    REP(i, K) ans += p[i];

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

Measured memory_bytes: 3628
import math
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
num=factorization(n)
if len(num)==1:
    if num[0][1]==1:
        ans=num[0][0]
    else:
        ans=num[0][0]*(-(num[0][1]//-2))
    print(len(str(ans)))
else:
    num2=int(math.sqrt(n))
    if num[-1][0]>=num2:
        ans=num[-1][0]
    else:
        for i in range(num2):
            if n%(num2-i)==0:
                ans=n//(num2-i)
                break
    print(len(str(ans)))


Measured memory_bytes: 9508
// Partition
#include <stdio.h>
#include <stdlib.h>

int partition(int *, int, int);

int main() {
  int i, n;
  int p, r, q;
  int *a;

  // input
  scanf("%d", &n);
  a = (int *)malloc(n * sizeof(int));
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  // partition
  p = 0;
  r = n - 1;
  q = partition(a, p, r);
  for(i = 0; i < n; i++) {
    if(i == q) printf("[");
    printf("%d", a[i]);
    if(i == q) printf("]");
    if(i == n - 1) printf("\n");
    else printf(" ");
  }
  return 0;
}

int partition(int *a, int p, int r) {
  int x, tmp;
  int i, j;

  x = a[r];
  i = p - 1;
  for(j = p; j < r; j++) {
    if(a[j] <= x) {
      i = i + 1;
      // exchange a[i] and a[j]
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  // exchange a[i + 1] and a[r]
  tmp = a[i + 1];
  a[i + 1] = a[r];
  a[r] = tmp;

  return i+1;
}



Measured memory_bytes: 2108
import sys
input = sys.stdin.readline
N = int(input())
S = input()
Q = int(input())

ide_ele = 0

def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(N):
        seg[i+num-1]=1<<(ord(init_val[i])-ord('a'))
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    x = 1<<(ord(x)-ord('a'))
    if x == seg[k]: return
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg=[ide_ele]*2*num

init(S)

for _ in range(Q):
    t, a, b = input().split()
    if t == '1':
        a = int(a)
        update(a-1, b)
    else:
        a, b = int(a)-1, int(b)
        print(bin(query(a,b)).count('1'))


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

int a[100010];

int main(){
	int n; scanf("%d", &n);
	int cnt1 = 0, cnt0 = 0, sum = 0;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if (a[i] >= 0) cnt1++;
		else cnt0++;
		sum += abs(a[i]);
	}
	if (cnt0 && cnt1){
		printf("%d\n", sum);
		int last, pos = -1;
		for (int i = 0; i < n; i++){
			if (a[i] < 0){
				last = a[i];
				pos = i;
				break;
			}
		}
		if (cnt0 > 1){
			int cnt = 0;
			for (int i = 0; i < n; i++){
				if (a[i] >= 0){
					cnt++;
					if (cnt == cnt1) printf("%d %d\n", a[i], last), last = a[i] - last;
					else printf("%d %d\n", last, a[i]), last -= a[i];
				}
			}
			for (int i = 0; i < n; i++){
				if (a[i] < 0 && i != pos){
					printf("%d %d\n", last, a[i]), last -= a[i];
				}
			}
		} else {
			int cnt = 1;
			for (int i = 0; i < n; i++){
				if (a[i] > 0){
					cnt++;
					if (cnt == n) printf("%d %d\n", a[i], last);
					else printf("%d %d\n", last, a[i]), last -= a[i];
				}
			}
		}
	} else if (cnt1){
		int minj = 0x3f3f3f3f, pos = -1;
		for (int i = 0; i < n; i++){
			if (minj > a[i]){
				minj = a[i], pos = i;
			}
		}
		printf("%d\n", sum - 2 * minj);
		int last = minj, cnt = 1;
		for (int i = 0; i < n; i++){
			if (i == pos) continue;
			cnt++;
			if (cnt == n) printf("%d %d\n", a[i], last);
			else printf("%d %d\n", last, a[i]), last -= a[i];
		}
	} else {
		int maxj = -0x3f3f3f3f, pos = -1;
		for (int i = 0; i < n; i++){
			if (maxj < a[i]){
				maxj = a[i], pos = i;
			}
		}
		printf("%d\n", sum + 2 * maxj);
		int last = maxj;
		for (int i = 0; i < n; i++){
			if (i == pos) continue;
			printf("%d %d\n", last, a[i]);
			last -= a[i];
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> a(n);
  rep (i, n) {
    cin >> k[i];
    a[i].resize(k[i]);
    rep (j, k[i]) cin >> a[i][j];
  }
  vector<int> like(m + 1);
  allrep (x, a) {
    allrep (y, x) {
      ++like[y];
    }
  }
  cout << count(all(like), n) << endl;
  return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int x[n];
  for(int i=0;i<n;i++)cin>>x[i];
  
  int l,r,d,mm;
  int m=2000000001;
  
  for(int i=0;i<n-k+1;i++){
    l=max(x[i],-x[i]);
    r=max(x[i+k-1],-x[i+k-1]);
    d=max(x[i]-x[i+k-1],x[i+k-1]-x[i]);
    mm=min(l+d,r+d);
    m=min(mm,m);
    }
  cout<<m<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=15,M=55;
int num[N],a[M],b[M],c[M],d[M],ans,n,m,q;


int calc(){
	int res=0;
	for(int i=1;i<=q;i++) if(num[b[i]]-num[a[i]]==c[i]) res+=d[i];
	return res;
}

void dfs(int x){
	if(x==n+1){
		ans=max(ans,calc());
		return ;
	}
	for(int i=num[x-1];i<=m;i++){
		num[x]=i;
		dfs(x+1);
	}
}

signed main(){
	read(n);read(m);read(q);
	for(int i=1;i<=q;i++){
		read(a[i]);
		read(b[i]);
		read(c[i]);
		read(d[i]);
	}
	num[0]=1;
	dfs(1);
	write(ans);
}

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

typedef long long int ll;
double PI = 3.14159265358979;

int main(){
 ll N,K;
 cin >> N >> K;
 vector<pair<ll,ll>> L(N);
 for(ll i = 0;i < N;i++){
     ll a , b;
     cin >> a >> b;
     L[i].first = a,
     L[i].second = b;
 }
 sort(L.begin(),L.end());
 ll ans = 0;
 ll sum = 0;
 for(ll i = 0;i < K;i++){
     sum += L[i].second;
     if(sum >= K){
         cout << L[i].first << endl;
         return 0 ;
     }
 }
}




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

int main(){
    int h, w;
    cin >> h >> w;
    vvi a(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vvi ans;
    vi dx{1, 0};
    vi dy{0, 1};
    bool flag;
    rep(i, h){
        rep(j, w){
            if(a[i][j] % 2 == 1){
                flag = true;
                rep(k, 2){
                    int ny, nx;
                    ny = i + dy[k];
                    nx = j + dx[k];
                    if(0 <= ny && ny < h && 0 <= nx && nx < w){
                        if(a[ny][nx] % 2 == 1){
                            a[ny][nx] += 1;
                            a[i][j] -= 1;
                            ans.emplace_back(vi {i+1, j+1, ny+1, nx+1});
                            flag = false;
                            break;
                        }
                    }
                }
                if(flag){
                    if(j + 1 < w){
                        a[i][j+1] += 1;
                        a[i][j] -= 1;
                        ans.emplace_back(vi {i+1, j+1, i+1, j+2});
                    }
                    else if(i + 1 < h){
                        a[i+1][j] += 1;
                        a[i][j] -= 1;
                        ans.emplace_back(vi {i+1, j+1, i+2, j+1});
                    }
                }
            }
        }
    }
    
    int n;
    n = ans.size();
    cout << n << endl;
    rep(i, n){
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }
}


Measured memory_bytes: 9904
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=new Scanner(System.in);

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

	void run(){
		for(; sc.hasNext();){
			println(String.format("3C%02d", (sc.nextInt()-1)%39+1));
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

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

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

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

b = 0
by = 0
flg = 0
for i,j in enumerate(a):
	if abs(j) > abs(b):
		b = j
		by = i+1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(1,n):
		a[i] += a[i-1]
		ans.append([i,i+1])
else:
	x = max(a)
	if x > 0:
		for i in range(n-1,-1,-1):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(n-2,-1,-1):
		a[i] += a[i+1]
		ans.append([i+2,i+1])
print (len(ans))
for i in ans:
	print (*i)


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

using namespace std;

int main() {
	constexpr int INF = 1e9;
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> grid(H);
	int Sx = 0, Sy = 0;
	for (int i = 0; i < H; ++i) {
		cin >> grid[i];
		for (int j = 0; j < W; ++j) {
			if (grid[i][j] == 'S') {
				Sx = j, Sy = i;
			}
		}
	}

	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	auto in = [&](int x, int y) -> bool {
		return x >= 0 && x < W && y >= 0 && y < H;
	};

	vector<vector<int>> distS(H, vector<int>(W, INF));
	distS[Sy][Sx] = 0;
	{
		deque<pair<int, int>> que;
		que.emplace_back( Sy, Sx );
		while (!que.empty()) {
			auto p = que.front(); que.pop_front();
			int x = p.second, y = p.first;
			for (int k = 0; k < 4; ++k) {
				int nx = x + dx[k];
				int ny = y + dy[k];
				if (!in(nx, ny) || grid[ny][nx] == '#' || distS[ny][nx] <= distS[y][x] + 1) {
					continue;
				}
				distS[ny][nx] = distS[y][x] + 1;
				que.emplace_back( ny, nx );
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (distS[i][j] > K) { continue; }
			int cost = min({ i, j, H - 1 - i, W - 1 - j });
			ans = min(ans, (cost + K - 1) / K + 1);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	string s;
	cin >> s;
	cout << ((s[2]==s[3]&&s[4]==s[5])?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    int n;
    long long int sum =0;
    int mod = 1000000007;
    cin>>n;
    vector<int> a(n);
    long int add = 0;

    for(int i=0; i<n; i++){
        cin>>a[i];
        add += a[i];
        add %= mod;
    }
    for(int i=0; i<n; i++){
        add -= a[i];
        if(add<0) add += mod;
        sum += add*a[i];
        sum%=mod;
    }

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

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int v[2] ;
    cin >> v[0] >> v[1] ;

    for ( int i=1 ; i < 4 ; i ++ )
    {
        bool ok = false ;
        for ( auto j : v )
        {
            if ( j == i )
            {
                ok = true ;
                break ;
            }
        }

        if ( !ok )
        {
            cout << i ;
            line ;
            return ;
        }

    }
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

using namespace std;

int main(){

    long long n,t,i,j,k,total=0;

    cin >> n >> t;

    for(i=0;i<=n;i++){
        for(j=0;j<=(n-i);j++){
            for(k=0;k<=(n-i-j);k++){
               total=(i*10000)+(j*5000)+(k*1000);
               if(total==t && i+j+k==n){
                   cout << i << ' ' << j << ' ' << k << endl;
                   return 0;
               }
            }
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

int n;
string a,b;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> a >> b;
    for(int i=0; i<n; i++) cout << a[i] << b[i];

    return 0;
}


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

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if ((a1 + a2 + a3) >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
#　動的計画法で求める
s = int(input())
mod = 10 ** 9 + 7
A = [0, 0, 0, 1, 1, 1, 2, 3]
for i in range(8, 2000 + 1):
    ans = (sum(A[:i - 3 + 1]) + 1) % mod #Aの先頭からi-3+1までを取得
    A.append(ans)#配列に結果を加える
print(A[s])

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5  +10;
typedef pair<int, int> pii;
long long res, sum, pref, goodsum;
int n, ar[MAXn], m;
vector<pii> vec;
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		sum += ar[i];
	}
	for (int i = 0; i < m; i++) {
		pii hp;
		cin >> hp.second >> hp.first;
		vec.push_back(hp);
	}
	sort(vec.begin(), vec.end());
	sort(ar, ar + n);
	res = sum;
	for (int i = 0; i < n; i++) {
		if (vec.empty())
			break;
		pref += vec.back().first;
		vec.back().second--;
		if (vec.back().second == 0)
			vec.pop_back();
		goodsum += ar[i];
		res = max(res, sum - goodsum + pref);
	}
	cout << res;
}


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

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for(int i=0; i<25; i++){
        for(int j=0; j<25; j++){
            if(4*i+7*j==N){
                flag =true;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define mod 1000000007
using namespace std;
#define ll long long int
int main()
{
	ll a,b,c,d;
  	cin>>a>>b>>c>>d;
  	cout << max(max(a * c, a * d), max(b * c, b * d))<<endl;
  	}
 

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
const int limit = 55;
bool graph[limit][limit];
bool visited[limit];

void dfs(int now ,int n){
   visited[now] = true;
   rep(i,n){
      if(visited[i] == true)continue;
      if(graph[now][i] == true){
         dfs(i,n);
      }
   }
}

int main(){
   int n ,m;
   cin >> n >> m;
   vector<int> a(m),b(m);
   rep(i,m){
      cin >> a[i] >> b[i];
      graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
   }
   int ans = 0;

   rep(i,m){
      graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = false;
      rep(j,n)visited[j] = false;

      dfs(0,n);
      bool bridge = false;
      rep(j,n)if(visited[j] == false)bridge = true;
      if(bridge)ans++;
      graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256