akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
    double s = t-h*0.006;
    return s;
}

int main() {
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> X(n);
    vector<int> Y(m);
    rep(i,n) {
        cin >> X[i];
    }
    rep(i,m) {
        cin >> Y[i];
    }
    for(int z=x+1; z<=y; ++z) {
        bool bx = true, by = true;
        rep(i,n) {
            if (X[i] >= z) {
                bx = false;
            }
        }
        rep(i,m) {
            if (Y[i] < z) {
                by = false;
            }
        }
        if (bx == true && by == true) {
            cout << "No War" << "\n";
            return 0;
        }
    }

        cout << "War" << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a == b) System.out.println("Yes");
    if(a != b) System.out.println("No");    
  }
}

Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    char a[110000],b;
    int n,ans=1;
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i==0){
            b=a[0];
        }
        else if(a[i]!=b){
            ans++;
            b=a[i];
        }
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 384
my($n) = split(" ", <>);
my(@a) = split(" ", <>);
my($c) = 1;
my(%h);
while ($a = shift(@a)) {
    $h{"$c"} = $a;
    $c++;
}
print join(" ", sort {$h{"$a"} <=> $h{"$b"}} keys(%h));

Measured memory_bytes: 27028
def judge_prime(n):
    if n == 1:
        return False
    else:
        cnt = 2
        while cnt ** 2 <= n:
            if n % cnt == 0:
                return  False
            else:
                cnt += 1
        return  True

cnt_prime = 0

N = int(input())
for i in range(N):
    judge_num = int(input())
    if judge_prime(judge_num):
        cnt_prime += 1
        
print(cnt_prime)


Measured memory_bytes: 5612
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder.XXX.A
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var datas = cr();
            var a = datas[0];
            var b = datas[1];
            var r = a * b;
            P(r % 2 == 0 ? "Even" : "Odd");
        }

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

//sum(i=0 to n-1) floor((a*i+b)/m)
long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll t;cin>>t;
  while(t--){
    ll n,m,a,b;cin>>n>>m>>a>>b;
    cout<<floor_sum(n,m,a,b)<<endl;
  }
  return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    if(H%2==1) swap(H,W);
    vector<int> cnt(26,0);
    for(int i=0; i<H*W; i++){
        char c;  cin >> c;
        cnt[c-'a']++;
    }
    if(H%2==0 && W%2==0){
        for(int i=0; i<26; i++){
            if(cnt[i]%4!=0){
                cout << "No" << endl;
                return 0;
            }
        }
    }else if(H%2==1 && W%2==1){
        int nOdd = 0;
        int div2 = 0;
        for(int i=0; i<26; i++){
            if(cnt[i]%2!=0){
                nOdd++;
            }else if(cnt[i]%4!=0){
                div2++;
            }
        }
        if(nOdd != 1 || div2 > H/2 + W/2){
            cout << "No" << endl;
            return 0; 
        }
    }else{
        int div2 = 0;
        for(int i=0; i<26; i++){
            if(cnt[i]%2!=0){
                cout << "No" << endl;
                return 0;
            }else if(cnt[i]%4!=0){
                div2++;
            }
            if(div2 > H/2){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


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

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

    std::sort(s.begin(), s.end());
    const auto ret = (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) ? "Yes" : "No";    

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Cryptography;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();

			if (s == "0") {
				Console.WriteLine("1");
			} else {
				Console.WriteLine("0");
			}

		}
	}
}


Measured memory_bytes: 25876
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long mod = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c) {
		if (a % 2 == 0) {
			cout << -1 << endl;
			return 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	else {
		int cnt = 0;
		while (true) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
				cout << cnt << endl;
				return 0;
			}
			int ta = a;
			int tb = b;
			int tc = c;
			a = (ta + tb) / 2;
			b = (tb + tc) / 2;
			c = (tc + ta) / 2;
			cnt++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]


mod = 998244353
inf = 1e10

#solve
def solve():
    n, s = LI()
    a = LI()
    dp1 = [0] * (3000 + 1)
    dp2 = [0] * (3000 + 1)
    ans = 0

    for i in range(n):
        for j in range(s+1):
            dp2[j] = dp1[j]
        
        for j in range(a[i], s + 1):
            dp2[j] += dp1[j - a[i]]
            dp2[j] %= mod
        dp2[a[i]] += i + 1 
        ans += dp2[s]
        ans %= mod
        dp1 = dp2[::1]
        # print(dp2)
    print(ans)
            
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 42604
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:table/trie.cpp>
namespace table {
    template <class ValueType> class Trie {
    public:
        typedef std::string::const_iterator StringIterator;
        static const int SIZE = 256;
        ValueType value;
        Trie *next[SIZE];
        Trie() { clear(); }
        void clear() { std::fill( next, next+SIZE, (Trie*)NULL ); }
        Trie& find( const std::string& s ) {
            Trie* res = this;
            for ( StringIterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
                const int& c = *it_i;
                if ( ! res->next[c] ) res->next[c] = new Trie;
                res = res->next[c];
            }
            return *res;
        }
        int count( const std::string& s ) {
            Trie* res = this;
            for ( StringIterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
                const int& c = *it_i;
                if ( ! res->next[c] ) return 0;
                res = res->next[c];
            }
            return 1;
        }
        ValueType& operator []( const std::string& s ) { return find(s).value; }
    };
}

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    class Solution: public ISolution {
    public:
        table::Trie<int> T;
        int n;
        void init() {
            T.clear();
        }
        bool input() {
            if ( ! ( cin >> n && n ) )
                return false;
            for ( int i = 0; i < n; ++ i ) {
                string item;
                int value;
                cin >> item >> value;
                T[item] = value;
            }
            return true;
        }
        void solve() {
            int m;
            cin >> m;
            for ( int i = 0; i < m; ++ i ) {
                string item;
                cin >> item;

                int k;
                cin >> k;

                int sum = 0;
                for ( int j = 0; j < k; ++ j ) {
                    string item;
                    cin >> item;
                    sum += T[item];
                }
                T[item] = min( T[item], sum );
            }
            string q;
            cin >> q;
            cout << T[q] << endl;
        }
        int run() {
            while ( init(), input() ) {
                solve();
                output();
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 6260
from sys import stdin

a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
num = 0

while True:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        print(count)
        exit()
    elif a==b==c:
        print(-1)
        exit()
    else:
        a,b,c = b//2+c//2,c//2+a//2,a//2+b//2
        count += 1
    num += 1

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long A[100000];
long B[100000];
pair<long,int> C[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		A[i] = rel();
		B[i] = rel();
		C[i] = {A[i]+B[i],i};
	}
	sort(C,C+N);
	bool fs = true;
	long ans = 0;
	for(int i=N-1;i>=0;i--){
		if(fs){
			ans += A[C[i].second];
		}
		else{
			ans -= B[C[i].second];
		}
		fs = !fs;
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)


int n,r;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> r;

	if(n < 10)
		r = r + (100 * (10-n));
	cout << r << endl;	
}

Measured memory_bytes: 256
function MainB(input){
    const arr = input.split('\n');
    const N = Number(arr[0]);
    const Ln = arr[1].split(' ').map(Number);
    let answer = 0;
    for(let a=0; a<Ln.length; a++){
        for(let b=a+1; b<Ln.length; b++){
            for(let c=b+1; c<Ln.length; c++){
                if(Ln[a]===Ln[b] || Ln[b]===Ln[c] || Ln[c]===Ln[a]) continue;
                if(Ln[a] + Ln[b] > Ln[c]
                   && Ln[b] + Ln[c] > Ln[a]
                   && Ln[c] + Ln[a] > Ln[b]){
                       answer++;
                   }
            }
        }
    }
    console.log(answer);
}
MainB(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 32444
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int n, a, M = 0, m = INT_MAX, ans = 0;

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

		M = max(M, a);
		m = min(m, a);
	}

	ans = M - m;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using ll=long long int;

int main() {
	ll x;
	std::cin>>x;
	ll ans=x/11*2;
	x%=11;
	if(x!=0){
		++ans;
		if(x>6)
			++ans;
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for _ in range(h)]

dis = [[10**10] * w for _ in range(h)]
dis[0][0] = 0

q = [(0,0)]

while q:
    h1,w1 = q.pop(-1)
    if h1 > 0:
        if s[h1-1][w1] == '.':
            if dis[h1][w1] + 1 < dis[h1-1][w1]:
                dis[h1-1][w1] = dis[h1][w1] + 1
                q.append((h1-1,w1))
    if w1 > 0:
        if s[h1][w1-1] == '.':
            if dis[h1][w1] + 1 < dis[h1][w1-1]:
                dis[h1][w1-1] = dis[h1][w1] + 1
                q.append((h1,w1-1))
    if h1 < h - 1:
        if s[h1+1][w1] == '.':
            if dis[h1][w1] + 1 < dis[h1+1][w1]:
                dis[h1+1][w1] = dis[h1][w1] + 1
                q.append((h1+1,w1))
    if w1 < w - 1:
        if s[h1][w1+1] == '.':
            if dis[h1][w1] + 1 < dis[h1][w1+1]:
                dis[h1][w1+1] = dis[h1][w1] + 1
                q.append((h1,w1+1))

if dis[-1][-1] == 10 ** 10:
    print(-1)
    exit()

count = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            count += 1

print(count - dis[-1][-1] - 1)


Measured memory_bytes: 3188
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let n: usize = read();
    let a: Vec<i32> = readnc();

    let mut min_idx = 0;
    let mut max_idx = 0;
    for i in 1..n {
        if a[i] < a[min_idx] {
            min_idx = i;
        }
        if a[i] > a[max_idx] {
            max_idx = i;
        }
    }

    let mut ops = vec![];
    if a[min_idx].abs() > a[max_idx].abs() {
        for i in 0..n {
            if i != min_idx {
                ops.push(vec![min_idx, i]);
            }
        }
        for i in 1..n {
            ops.push(vec![n-i, n-i-1]);
        }
    } else {
        for i in 0..n {
            if i != max_idx {
                ops.push(vec![max_idx, i]);
            }
        }
        for i in 1..n {
            ops.push(vec![i-1, i]);
        }
    }

    println!("{}", ops.len());
    for o in ops {
        println!("{} {}", o[0]+1, o[1]+1);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
long long s;
int a[300010],n;
int main()
{
    scanf("%d",&n);
    for(int i=3*n;i;--i)scanf("%d",&a[i]);
    std::sort(a+1,a+3*n+1);
    for(int i=n;i;--i)s+=a[3*n-2*i+1];
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + a[i] - 1;
        }
        System.out.print(sum);
    }
}

Measured memory_bytes: 27284
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	string s, t;
	int c = 0;
	cin >> s >> t;
	for (int i = 0; i <= s.size(); i++){
		if (s[i] != t[i]) {
			c++;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 3832
n = int(input())

import math

# input->3以上の奇数のみ
def first_div(n):
    for i in range(3, math.ceil(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return i
    return n

def next_div(start, stop):
    for i in range(start, math.ceil(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return i
    return n   

if n == 1:
    print(0)
    exit()


ans = 0
currentBase = 2
while n > 1:
    if n % currentBase == 0:
        currentDiv = currentBase
        while True:
            ans += 1
            n = n//currentDiv
            currentDiv = currentDiv * currentBase
            if n%currentDiv != 0 or n <= 1:
                while n%currentBase == 0:
                    n = n//currentBase
                break
    if currentBase == 2:
        currentBase = 3
    else:
        currentBase = next_div(currentBase+2, n)


print(ans)


Measured memory_bytes: 9216
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



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

int main() {
    while (cin >> n >> h) {
        if (n == 0) break;
        vector<pint> xy, xz, yz;
        for (int i = 0; i < h; ++i) {
            cin >> c >> a >> b; --a; --b;
            if (c == "xy") xy.PB(pint(a,b));
            if (c == "xz") xz.PB(pint(a,b));
            if (c == "yz") yz.PB(pint(a,b));
        }
        int res = h*n;
        for (int i = 0; i < xy.size(); ++i) for (int j = 0; j < xz.size(); ++j) 
            if (xy[i].first == xz[j].first) --res;
        for (int i = 0; i < xy.size(); ++i) for (int j = 0; j < yz.size(); ++j) 
            if (xy[i].second == yz[j].first) --res;
        for (int i = 0; i < xz.size(); ++i) for (int j = 0; j < yz.size(); ++j) 
            if (xz[i].second == yz[j].second) --res;
        for (int i = 0; i < xy.size(); ++i) for (int j = 0; j < xz.size(); ++j) for (int k = 0; k < yz.size(); ++k)
            if (xy[i].first == xz[j].first && xy[i].second == yz[k].first && xz[j].second == yz[k].second) ++res;
        cout << n*n*n-res << endl;
    }
    return 0;
}


Measured memory_bytes: 1220
/*
Author : N_o_o_B
Created : April 12 2020 17:54:01 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vl a(n);
    fori(i,n) cin >> a[i];
    if(n%2 == 0){
        vl dp(n+3);
        ford(i,n){
            dp[i] = a[i] + dp[i+2];
            if(i%2==0) dp[i] = max(dp[i],dp[i+1]);
        }
        cout << dp[0] << endl;
        return 0;
    }
    else{
        vvl dp(n+3,vl(2));
        vector<vii> nxt(n,vii(2));
        ford(i,n){
            dp[i][0] = a[i] + dp[i+2][0];
            if(i&1) dp[i][0] = max(dp[i][0],dp[i+1][0]);
            if(i&1) continue;
            if(i == n-1){
                dp[i][1] = 0;
            }
            else{
                dp[i][1] = max({dp[i+1][0],dp[i+2][0],dp[i+2][1]+a[i]});
            }
        }
        cout << dp[0][1] << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

vector<ll> to[100005];

int main() {
    ll n, m;
    cin(n);
    cin(m);

    rep2(i, m) {
        ll a, b;
        cin(a); cin(b);
        --a; --b;

        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<ll> dist(n, LLONG_MAX);
    vector<ll> pre(n, -1);

    dist[0] = 0;
    q.push(0);

    while(!q.empty()) {
        int v = q.front(); q.pop();
        for (ll i: to[v]) {
            if (dist[i] != LLONG_MAX) continue;
            dist[i] = dist[v] + 1;
            pre[i] = v;
            q.push(i);
        }
    }

    print("Yes");
    rep2(i, n) {
        if (i == 0) continue;
        ll ans = pre[i];
        ++ans;
        print(ans);
    }
    return 0;
}

Measured memory_bytes: 13412
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	int N;
  	cin >> N;
  	int A[N],B[N],C[N];
  	for(int i = 0; i < N ; i++)cin >> A[i];
	for(int i = 0; i < N ; i++)cin >> B[i];
  	for(int i = 0; i < N ; i++)cin >> C[i];
  	sort(A,A+N);
  	sort(B,B+N);
  	sort(C,C+N);
  	ll cont = 0;
  	ll l,u;
  	for(int i = 0; i < N ; i++){
		//cout <<"Lower"<< lower_bound(A,A+N,B[i])-A<<endl;
      	//cout <<"Upper"<< N-(upper_bound(C,C+N,B[i])-C)<<endl;
      	l=lower_bound(A,A+N,B[i])-A;
        u=N-(upper_bound(C,C+N,B[i])-C);
      	cont +=l*u;
    }
  	cout << cont << endl;


}

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

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A, B;
    scanf("%d%d",&A, &B);
    if(A>=1&&A<=9&&B>=1&&B<=9)
    {
        printf("%d",A*B);
    }
    else
    {
        printf("-1");
    }
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=[]
for i in range(n):
  b,c=map(str,input().split())
  d=[str(i+1),b,int(c)*(-1)]
  a.append(d)
  
a.sort(key=lambda x:x[1])
r={}
ans=[]
q=[]

for f in a:
  e=f[1]
  t=[f[0],f[2]]
  if e not in r:
    q.sort(key=lambda x:x[1])
    ans.append(q)
    q=[]
    q.append(t)
    r[e]=0
    
  else:
    q.append(t)


q.sort(key=lambda x:x[1])
ans.append(q)

for y in ans:
  for w in y:
    print(w[0])
    

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

int main(){
    string T;
    cin >> T;
    rep(i,T.size()){
        if(T[i]=='?'){
                T[i]='D';
        }
    }
    cout<<T<<endl;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
int main(){
    int n,m;cin>>n>>m;
    vector<pair<ll,ll>> p(n,makep(0,0));

    rep(i,n){
        
        cin>>p[i].first>>p[i].second;
    }
    sort(all(p));
    ll ans=0;
    int sum=0;

    rep(i,n){
        if(sum+p[i].second>=m){
            ans+=p[i].first*(m-sum);
            break;
        }else{
            ans+=p[i].first*p[i].second;
            sum+=p[i].second;
        }
    }
    cout<<ans <<endl;


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[200005];
main()
{
      int n,k,sum = 0;
      cin>>n>>k;
      for(int i = 0 ;i <n; i++){
        cin>>a[i];
      }
      sort(a,a+n);
      for(int i = 0 ; i<n-k; i++){
        sum+=a[i];
      }
      cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 1792
X ,N= map(int,input().split())
p=[]
if N!=0:
    p = list(map(int, input().split()))
    p = set(p)
for i in range(101):
    if  not((X-i)in p):
        d = -i
        break
    if not ((X+i)in p):
        d = i
        break
    

print(X+d)



Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 10;

deque<pii> qac, qde;

int p[N];
int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }

    int len = 1;
    int cnt2 = 0;
    for (int i = 1; i < n; i++)
    {
        if (p[i] > p[i - 1])
            len++;
        else
            len = 1;
        if (len == k)
            cnt2++;
    }

    for (int i = 0; i < k; i++)
    {
        while (!qac.empty() && qac.back().first > p[i])
            qac.pop_back();
        qac.push_back({p[i], i});

        while (!qde.empty() && qde.back().first < p[i])
            qde.pop_back();
        qde.push_back({p[i], i});
    }
    int cnt = 0;
    for (int i = k; i < n; i++)
    {
        // cout << qac.front().first << " ";
        // cout << qde.front().first << endl;
        bool f1 = qac.front().first == p[i - k];
        if (qac.front().second <= i - k)
            qac.pop_front();
        if (qde.front().second <= i - k)
            qde.pop_front();

        while (!qac.empty() && qac.back().first > p[i])
            qac.pop_back();
        qac.push_back({p[i], i});
        while (!qde.empty() && qde.back().first < p[i])
            qde.pop_back();
        qde.push_back({p[i], i});
        bool f2 = qde.front().first == p[i];
        if (f1 && f2)
        {
            // cout << "same" << endl;
            cnt++;
        }
    }
    cout << n - k + 1 - cnt - max(0, cnt2 - 1);
}

Measured memory_bytes: 2688
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 109;
int n, s, sum, best = maxn;

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%d", &s);
		sum += s;
		if (s % 10) best = min(best, s);
	}
	if (sum % 10) printf("%d\n", sum);
	else if (best != maxn) printf("%d\n", sum - best);
	else puts("0");
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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;
};

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i, 0, N) {
    cin >> A[i];
  }

  rep(i, 0, N) {
    cin >> B[i];
  }

  rep(i, 0, N-1) {
    cin >> C[i];
  }

  int ans = 0;
  rep(i, 0, N-1) {
    int food_id = A[i];
    int next_food_id = A[i+1];
    ans += B[food_id-1];
    if (next_food_id - food_id == 1) {
      ans += C[food_id - 1];
    }
  }

  ans += B[A[N-1]-1];

  cout << ans << endl;

  return 0;
};



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll s = 0;
    V<ll> a(n);
    read(a);
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += s * a[i] % MOD;
        res %= MOD;
        s += a[i];
        s %= MOD;
    }
    cout << res << newl;
}

Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n;

int main(){
	cin >> n;
	
	if(n % 2){
		printf("%.10f\n", (double)(n/2+1)/(double)n);
	}
	else{
		cout << "0.500000000" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000;

long long xx[1 + N], vv[1 + N], pp[1 + N], qq[1 + N];

int main() {
	int n; cin >> n;
	long long c; cin >> c;
	for (int i = 1; i <= n; i++) {
		long long x, v; cin >> x >> v;
		xx[i] = x;
		pp[i] = qq[i] = vv[i] = v;
	}
	for (int i = 1; i <= n; i++)
		pp[i] += pp[i - 1];
	for (int i = n - 1; i; i--)
		qq[i] += qq[i + 1];
	long long ans = 0, z = 0;
	for (int i = 1; i <= n; i++) {
		long long p2 = pp[i] - xx[i] - xx[i];
		long long q = qq[i] - (c - xx[i]);
		ans = max(ans, z + q);
		z = max(z, p2);
	}
	z = 0;
	for (int i = n; i; i--) {
		long long p = pp[i] - xx[i];
		long long q2 = qq[i] - (c - xx[i]) - (c - xx[i]);
		ans = max(ans, z + p);
		z = max(z, q2);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6732
/*
	C - Bugged
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; cin >> x;
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<lint> v(n); REP(i,n) cin >> v[i];
#define double(x) double x; cin >> x[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define string(x) string x; cin >> x;

int main()
{
	int(N);
	vint(s, N);

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

	int all = 0;
	REP(i, N)
	{
		all += s[i];
	}

	REP(i, N)
	{
		if (all % 10)
		{
			break;
		}
		else
		{
			if (s[i] % 10)
				all -= s[i];
		}
	}

	if (all % 10)
		cout << all << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
list_x= list(map(int, input().split()))

minx = min(list_x)
maxx = max(list_x)
sums_list = []

for i in range(minx, maxx+1):
    sums = 0
    for j in list_x:
        sums += (j - i)**2
    sums_list.append(sums)

print(min(sums_list))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

long long n, a[200010], ta[200010], ans = 1;

signed main() {
	cin >> n;
	cin >> a[0];
	ta[a[0]] = 1;
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		if (a[i - 1] != a[i]) {
			int mu = ta[a[i]];
			int rin = ans;
			ta[a[i]] += rin;
			ta[a[i]] %= mod;
			ans += mu;
			ans %= mod;
		}
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 3328
def main():
    n,k = map(int,input().split())
    r,s,p = map(int,input().split())
    T = list(input()) #後で適宜書き換えるのでlist型
    score = {"r": p, "s":r, "p":s} #辞書型で, 手に対応する得点を予めinput
    ans = sum([score[T[i]] for i in range(k)]) #初めのk回は勝利
    for i in range(k,n):
        if T[i]==T[i-k]:
            T[i]="." #i回目の手を適切に選べば, i+k回目は勝てる.
            continue
        ans += score[T[i]]
    print(ans)
main()

Measured memory_bytes: 4652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cassert>

typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::max;
using std::min;
using std::abs;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M,K;
     ll A,B,C;
     ll P[11];
     ll ans;
     char S[100];
int main() {
    cin>>A>>B;
    ans=2019;
    for(ll i=A;i<=A+2019;i++){
        if(i>B)break;
        for(ll j=i+1;j<=A+2019;j++){
            if(j>B)break;
            ans=min(ans,i*j%2019);
        }

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


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

int main() {
	int offset = 'a' - 'A'; //32
	char c;
	while (1) {
		(void)scanf("%c", &c);
		if ('a' <= c && c <= 'z') c -= offset;
		else if('A' <= c && c <= 'Z') c += offset;
		printf("%c", c);
		if (c == '\n') break;
	}
	return 0;
}


Measured memory_bytes: 2604