akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

string S;
set<char> ori;

int main() {
    cin >> S;
    int N = S.length();
    REP(i, N) { ori.insert(S[i]); }
    bool we = false, ns = false;
    if((ori.find('W') != ori.end()) == (ori.find('E') != ori.end())) {
        we = true;
    }
    if((ori.find('S') != ori.end()) == (ori.find('N') != ori.end())) {
        ns = true;
    }
    if(ns && we) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
}


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

const long long INF = 1LL << 60;

template <class T> bool chmin(T& a, T b)
{
  if (a > b) {
    a = b; return true;
  } else return false;
}

template <class T> bool chmax(T& a, T b)
{
  if (a < b) {
    a = b; return true;
  } else return false;
}


int main()
{
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin >> l.at(i);
  
  long long ans = INF;
  
  for (int i = 0; i < pow(4, N); i++)
  {
    long long at = 0, bt = 0, ct = 0;
    long long al = 0, bl = 0, cl = 0;
    
    for (int j = 0; j < N; j++)
    {
      int p = pow(4, j);
      int Z = (i / p) % 4;
      if (Z == 1) {at++; al += l.at(j);}
      else if (Z == 2) {bt++; bl += l.at(j);}
      else if (Z == 3) {ct++; cl += l.at(j);}
    }
    
    if (at > 0 && bt > 0 && ct > 0)
    {
      long long MP = (at + bt + ct - 3) * 10 
                    + abs(A - al) + abs(B - bl) + abs(C - cl);
      chmin(ans, MP);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int mo[4]={0,1,0,-1};

int main(){
    int n,a,b,c,cal[100],ans=0,sum=0;
    
    scanf("%d%d%d%d",&n,&a,&b,&c);
    
    for(int i=0;i<n;i++)
        scanf("%d",&cal[i]);
    
    sort(cal,cal+n);
    
    ans=c/a;
    
    for(int i=1;i<=n;i++){
        sum+=cal[n-i];
        if(ans<=(c+sum)/(a+(i)*b))
            ans=(c+sum)/(a+(i)*b);
        else
            break;
    }
    
    printf("%d\n",ans);
    
    
    return 0;
}

Measured memory_bytes: 1204
num = input()
num_list = []
num_list = num.split()

if int(num_list[0]) == int(num_list[1]):
    print('a','b',sep=' == ')
elif int(num_list[0]) > int(num_list[1]):
    print('a','b',sep=' > ')
else:
    print('a','b',sep=' < ')

Measured memory_bytes: 7668
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()) {
        if (s.substr(i, s.size()) + s.substr(0,i) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin >> N;
    for (int h = 1; h <= 3500; h++) {
        for (int n = 1; n <= 3500; n++) {
            ll x = N * h * n;
            ll y = 4 * h * n - N * (n + h);
            if (y > 0 && x % y == 0) {
                ll w = x / y;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(min(p+q, q+r), r+p) << endl;;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
int main(){
  int k;
  cin>>k;
  int l[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<l[k-1];
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<stack>

using namespace std;

int main(void){
  stack<int> st;
  char mozsu[10]={0};
  int hen=0;
  int aa=0;
  int bb=0;
  while(scanf("%s",mozsu)!=EOF){
    switch(mozsu[0]){
    case '+':
      aa=st.top();
      st.pop();
      bb=st.top();
      st.pop();
      aa=aa+bb;
      st.push(aa);
	break;
    case '-':
      aa=st.top();
      st.pop();
      bb=st.top();
      st.pop();
      aa=bb-aa;
      st.push(aa);
	break;
    case '*':
      aa=st.top();
      st.pop();
      bb=st.top();
      st.pop();
      aa=aa*bb;
      st.push(aa);
	break;
    default:
      hen=atoi(mozsu);
      st.push(hen);
      break;
    }
  }
  aa=st.top();
  printf("%d\n",aa);
  return 0;
}

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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn=0,ans,res,pos,flag;

string s;


ll a[200007],b[200007];
int main()
{

   io;

cin>>n>>m>>res;

f(i,n)cin>>a[i];//sum+=a[i];
f(j,m)cin>>b[j];//sum+=b[j];
i=0;j=0;
while(i<n&&a[i]+sum<=res)
{sum+=a[i];
    i++;
}
for(;i>=0;i--)
{
    while(j<m&&sum+b[j]<=res)
    {
        sum+=b[j];
        j++;
    }
    ans=max(ans,(i+j));
    sum-=a[i-1];
}
cout<<ans;
return 0;
}





Measured memory_bytes: 6720
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int n;
    string s;
    cin >> s;
    int c1 = 0, c2 = 0;
    n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0')
                c1++;
        }
        else
        {
            if(s[i] == '1')
            c1++;
        }
        
        if(i%2 == 0)
        {
            if (s[i] == '1')
                c2++;
        }
        else
        {
            if(s[i] == '0')
            c2++;
        }
        
    }
    cout << min(c1, c2);
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    static int GCM(int a,int b){
        var c = a % b;
        while(a % b != 0){
            c = a % b;
            a = b;
            b = c;
        }
        return b;
    }
    static int LCM(int a,int b){
        return a * b / GCM(a,b);
    }
    public static void Main(){
       var N = int.Parse(Console.ReadLine());
       var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
       long ans = a.Sum(x => x - 1);
       Console.WriteLine(ans);
       
    }
}


Measured memory_bytes: 13396
/// IN THE NAME OF METAL
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
const ll MAXN = 1e5 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll fen[MAXN], X[MAXN], Y[MAXN], n, m;
vector<pll> compress; vector<ll> vec;

void update(ll pos, ll val) {
    for (pos += 5; pos < MAXN; pos += pos & -pos) 
        fen[pos] = (fen[pos] + val) % MOD;
}

ll get(ll pos) {
    ll res = 0;
    for (pos += 5; pos; pos -= pos & -pos) {
        res = (res + fen[pos]) % MOD;
    }
    return res;
}

int main() {
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", &X[i]);
    }
    for (ll i = 1; i <= m; i++) {
        scanf("%lld", &Y[i]);
    }
    for (ll i = 1; i <= n; i++) {
        if (X[i] < Y[1] || X[i] > Y[m]) continue;
        ll ptr = lower_bound(Y + 1, Y + m + 1, X[i]) - Y;
        vec.push_back(X[i] - Y[ptr - 1]);
        compress.push_back({Y[ptr] - X[i], Y[ptr - 1] - X[i]});
    }
    sort(all(vec));
    sort(all(compress));
    vec.resize(unique(all(vec)) - vec.begin());
    compress.resize(unique(all(compress)) - compress.begin());
    update(0, 1);
    for (ll i = 0; i < sz(compress); i++) {
        pll &t = compress[i];
        update(lower_bound(all(vec), -t.S) - vec.begin() + 1, get(lower_bound(all(vec), -t.S) - vec.begin()));
    }
    printf("%lld\n", get(MAXN - 10));
    return 0;
}



Measured memory_bytes: 7688
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    s = S()
    if 'A' in s and 'B' in s:
        print('Yes')
    else:
        print('No')
    return


# Solve
if __name__ == "__main__":
    solve()


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  ll a,b;
  cin >> a >> b;

  cout << a / __gcd(a,b) * b << endl;

}

Measured memory_bytes: 256
/* Official House */
#include <stdio.h>

int main()
{
    int n, b, f, r, v, i, j, k, l;
    int A[3][10], B[3][10], C[3][10], D[3][10];
    for(i=0; i<3; i++){
        for(j=0; j<10; j++){
            A[i][j] = 0;
            B[i][j] = 0;
            C[i][j] = 0;
            D[i][j] = 0;
        }
    }
    // Input
    scanf("%d", &n);
    for(l=0; l<n; l++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        if(b == 1){
            A[f-1][r-1] += v;
            if(A[f-1][r-1] < 0){ A[f-1][r-1]=0; }
            if(A[f-1][r-1] > 9){ A[f-1][r-1]=9; }
        }
        if(b == 2){
            B[f-1][r-1] += v;
            if(B[f-1][r-1] < 0){ B[f-1][r-1]=0; }
            if(B[f-1][r-1] > 9){ B[f-1][r-1]=9; }
        }
        if(b == 3){
            C[f-1][r-1] += v;
            if(C[f-1][r-1] < 0){ C[f-1][r-1]=0; }
            if(C[f-1][r-1] > 9){ C[f-1][r-1]=9; }
        }
        if(b == 4){
            D[f-1][r-1] += v;
            if(D[f-1][r-1] < 0){ D[f-1][r-1]=0; }
            if(D[f-1][r-1] > 9){ D[f-1][r-1]=9; }
        }
    }
    // Output
    for(k=0; k<4; k++){
        for(i=0; i<3; i++){
            for(j=0; j<10; j++){
                if(k==0){
                        printf(" %d", A[i][j]);
                }
                else if(k==1){
                        printf(" %d", B[i][j]);
                }
                else if(k==2){
                        printf(" %d", C[i][j]);
                }
                else if(k==3){
                        printf(" %d", D[i][j]);
                }
            }
            printf("\n");
        }
        if(k!=3){
        printf("####################\n");
        }
    }
}


Measured memory_bytes: 2044
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  println(abc142c(n, a))
}

private fun abc142c(n: Int, a: List<Int>): String {
  val ansList = mutableListOf<Int>()

  val map = mutableMapOf<Int, Int>()
  for (i in 0 until n) {
    map.put(a.get(i), i)
  }

  for (i in map.keys.sorted()) {
    ansList.add(map.get(i)!!)
  }

  return ansList.map { it + 1 }.joinToString(" ")
}


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

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

    for(int i = 0;i<=25;i++){
        for(int j = 0;j<=15;j++){
            if(N == i*4 + j * 7){
                cout <<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  for(int i=1;i<n;i++){
    int m=n/i;
    if(n%i==0)m--;
    ans+=m;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3584
// C.cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
const int MX_N = 1e5 + 200;
ll n, ai[MX_N], bi[MX_N], ci[MX_N], dp[MX_N][3];
int main()
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld%lld", &ai[i], &bi[i], &ci[i]);
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = max(dp[i - 1][1] + ai[i], dp[i - 1][2] + ai[i]);
        dp[i][1] = max(dp[i - 1][0] + bi[i], dp[i - 1][2] + bi[i]);
        dp[i][2] = max(dp[i - 1][1] + ci[i], dp[i - 1][0] + ci[i]);
    }
    printf("%lld", max(dp[n][0], max(dp[n][1], dp[n][2])));
    return 0;
}

Measured memory_bytes: 4992
from collections import defaultdict

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(map(str, input().rstrip()))

cir = defaultdict(list)
for i in range(k):
    cir[i] = t[i::k]


def solve(sq):
    # 初手
    x = sq[0]
    if x == "r":
        prev, score = "r", p
    elif x == "s":
        prev, score = "s", r
    else:
        prev, score = "p", s
    cnt = 1

    # 前回と違う手なら問答無用で勝てる、前回と同じ手なら奇数回目に勝てる
    for x in sq[1:]:
        if prev != x:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            prev = x
            cnt = 1
        elif cnt % 2 == 1:
            cnt += 1
        else:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            cnt += 1
    return score


ans = []
for i in range(k):
    ans.append(solve(cir[i]))

print(sum(ans))

Measured memory_bytes: 24272
H,N = map(int,input().split())
X = []
for _ in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
dp = [10000000000000 for i in range(H+1)] 
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        a = X[j][0]
        b = X[j][1]
        dp[i] = min(dp[i],dp[max(0,i-a)] + b)
#print(dp)
print(dp[H])

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

using namespace std;

struct card{
	int num;
	char mark;
	int order;
};

int partition(vector<int> &A,vector<char> &B,vector<int> &C,int p,int r){ 
		int x = A[r];
		int i = p - 1;

		for (int j = p; j < r; j++){
				if (A[j] <= x){ 
						i++;
						int itmp = A[i];
						A[i] = A[j];
						A[j] = itmp;
						char ctmp = B[i];
						B[i] = B[j];
						B[j] = ctmp;
						int iitmp = C[i];
						C[i] = C[j];
						C[j] = iitmp;
				}   
		}   

		int itmp = A[i+1];
		A[i+1] = A[r];
		A[r] = itmp;
		char ctmp = B[i+1];
		B[i+1] = B[r];
		B[r] = ctmp;
		int iitmp = C[i+1];
		C[i+1] = C[r];
		C[r] = iitmp;

		return i+1;
}

void quicksort(vector<int> &A,vector<char> &B,vector<int> &C,int p,int r){
	if (p < r){
		int q = partition(A,B,C,p,r);
		quicksort(A,B,C,p,q-1);
		quicksort(A,B,C,q+1,r);
	}
}

bool check(vector<int> &A,vector<int> &C,int n){
	for (int i = 1; i < n; i++){
		if (A[i-1] == A[i] and C[i-1] > C[i]) return false;
	}
	return true;
}

int main(){
		int n; cin >> n;
		vector<int> A(n);
		vector<char> B(n);
		vector<int> C(n);

		for (int i = 0; i < n; i++){
			cin >> 	B[i] >> A[i];
			C[i] = i;
		}

		quicksort(A,B,C,0,n-1);
		if(check(A,C,n)){
			cout << "Stable" << endl;
		}else{
			cout << "Not stable" << endl;
		}

		for (int i = 0; i < n; i++){
				cout << B[i] << " " << A[i] << endl;
		}
		return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    ll Max=-INF,Min=INF;
    ll wMax,wMin;
    for(ll i=0;i<N;++i){
        if(chmax(Max,a[i]))wMax=i;
        if(chmin(Min,a[i]))wMin=i;
    }
    if(Min>=0){
        prt(N-1)
        for(ll i=0;i<N-1;++i)cout<<i+1<<" "<<i+2<<endl;
    }
    else if(Max<=0){
        prt(N-1)
        for(ll i=N-2;i>=0;--i)cout<<i+2<<" "<<i+1<<endl;
    }
    else if(Min+Max>=0){
        prt(2*N-2)
        for(ll i=0;i<N;++i)if(i!=wMax)cout<<wMax+1<<" "<<i+1<<endl;
        for(ll i=0;i<N-1;++i)cout<<i+1<<" "<<i+2<<endl;
    }
    else{
        prt(2*N-2)
        for(ll i=0;i<N;++i)if(i!=wMin)cout<<wMin+1<<" "<<i+1<<endl;
        for(ll i=N-2;i>=0;--i)cout<<i+2<<" "<<i+1<<endl;
        cout<<endl;
    }
    
    return 0;
}


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

int main() {
  string a, b;
  int c = 0;
  cin >> a >> b;
  for (int i = 0;i < 3;i++) {
    if (a.at(i) == b.at(i))
      c++;
  }
  cout << c << endl;
}


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

int main(){
    int s;
    cin >> s ;
    int a=0;
    int b=s;
    for(int i=0;i<10;i++){
         a +=s%10;
         s /=10;
    } 
    if(b%a==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A_ = list(map(int, input().split()))
A = []
mod = 10 ** 9 + 7
for i, a_ in enumerate(A_[::-1]):
    if i == 0:
        A.append(a_ % mod)
    else:
        a = (a_ + A[-1]) % mod
        A.append(a)
A = A[::-1]
A = A[1:]
ans = 0
for i, a in enumerate(A_[:-1]):
    ans += A[i] * a % mod
    ans %= mod

print(ans)

Measured memory_bytes: 108244
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int seatL;
    string tmp;
    cout << 0 << endl;
    cin >> tmp;
    if (tmp == "Vacant")    return 0;
    else if (tmp == "Male") seatL = 0;
    else seatL = 1;

    int l = 0, r = n;
    while(l+1 < n){
        int mid = (l+r)/2;
        cout << mid << endl;
        cin >> tmp;
        int valtmp;
        if (tmp == "Vacant")    return 0;
        else if (tmp == "Male") valtmp = 0;
        else valtmp = 1;

        if ((l - seatL + 2) % 2 == (mid - valtmp + 2) % 2){
            seatL = valtmp;
            l = mid;
        }
        else r = mid;
    }
    cout << l << endl;
}


Measured memory_bytes: 852
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;


struct Point {
	int x, y;
	struct Vector operator-(const Point& other) const;
	double distance(const Point& other) const;
};
struct Vector {
	int dx, dy;
	int cross(const Vector& other) const;
	int dot(const Vector& other) const;
	double length() const;
};

int main() {
	while (true) {
		int n; cin >> n; if (n == 0) break;
		vector<Point> points(n);
		for (auto& point : points) cin >> point.x >> point.y;
		Point current{ 0, 0 }, prev{ 0, -1 };
		double result = 0;
		for (auto i = 0; i < n; ++i) {
			const auto base_vector = current - prev;
			sort(points.begin(), points.end(), [&](const Point& a, const Point& b) {return (a - current).cross(base_vector) >= 0 && (b - current).cross(base_vector) >= 0 ? 
				((b - current).cross(a - current) == 0 ? abs((b - current).dx) < abs((a - current).dx) : (b - current).cross(a - current) < (a - current).cross(b - current)): 
				(a - current).cross(base_vector) < (b - current).cross(base_vector); });
			result += current.distance(points.back());
			prev = current;
			current = points.back();
			points.pop_back();
		}
		int t10 = round(result * 10);
		cout << t10 / 10 << '.' << t10 % 10 << '\n';
	}
}

Vector Point::operator-(const Point& other) const
{
	return Vector{ x - other.x, y - other.y };
}

double Point::distance(const Point& other) const
{
	return (*this - other).length();
}

int Vector::cross(const Vector& other) const
{
	return dx * other.dy - dy * other.dx;
}

int Vector::dot(const Vector& other) const
{
	return dx * other.dx + dy * other.dy;
}

double Vector::length() const
{
	return sqrt(dx * dx + dy * dy);
}



Measured memory_bytes: 3200
n,m = map(int,input().split())
MOD = 10**9 + 7
dp = [0 for i in range(n+1)]
t = [True for _ in range(n+1)]
for i in range(m):
    a = int(input())
    t[a] = False

dp[0] = 1
for now in range(n):
    for next in range(now+1,min(n+1,now+3)):
        if t[next]:
            dp[next] += dp[now]
            dp[next] %= MOD

print(dp[n])

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

using namespace std;

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

  if(s == "Sunny") cout << "Cloudy" << endl;
  if(s == "Cloudy") cout << "Rainy" << endl;
  if(s == "Rainy") cout << "Sunny" << endl;


}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
lenH = len(H)
if lenH <= 1:
  print('Yes')
  exit()
for i in range(lenH-1):
  h_2 = H[lenH-i-1]
  h_1 = H[lenH-i-2]
  if h_2 < h_1:
    if h_1 - h_2 > 1:
      print('No')
      exit()
    else:
      H[lenH-i-2] -= 1
print('Yes')

Measured memory_bytes: 14396
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    int n;
    vector<int> a;
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;++i) cin>>a[i];
    
    ll dp[n][n]; //min cost to merge l to r
    
    for(int len = 1; len <= n; ++len){
        for(int i=0;i<=n-len;++i){
            if(len == 1) dp[i][i] = 0;
            else{
                int l = i;
                int r = i+len-1;
                dp[l][r] = 1e18;
                ll sum = 0;
                for(int i=l;i<=r;++i) sum += a[i];
                for(int p = l; p < r; ++p)
                    dp[l][r] = min(dp[l][r], dp[l][p] + dp[p+1][r] + sum);
            }
        }
    }

    cout<<dp[0][n-1];
    return 0;
}


Measured memory_bytes: 4868
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M, A[101010];

void printvec(ivec& a)
{
	if (a.size() > 0) {
		printf("%d", a[0]);
		for (int i = 1; i < a.size(); ++i) printf(" %d", a[i]);
	}
	puts("");
}

void rezero(ivec &v)
{
	for (;;) {
		for (int i = 0; i < v.size(); ++i) {
			if (v[i] == 0) {
				v.erase(v.begin() + i);
				goto nex;
			}
		}
		break;
	nex: continue;
	}
}
int main()
{
	scanf("%d%d", &N, &M);
	vector<int> even, odd;
	for (int i = 0; i < M; ++i) {
		scanf("%d", A + i);
		if (A[i] % 2 == 0) even.push_back(A[i]);
		else odd.push_back(A[i]);
	}

	if (odd.size() >= 3) {
		puts("Impossible");
		return 0;
	}

	vector<int> as, bs;

	if (M == 1 && A[0] == 1) {
		as.push_back(1);
		bs.push_back(1);
	} else if (odd.size() == 2) {
		as.push_back(odd[0]);
		for (int a : even) as.push_back(a);
		as.push_back(odd[1]);

		bs.push_back(odd[0] + 1);
		for (int a : even) bs.push_back(a);
		bs.push_back(odd[1] - 1);
	} else if (odd.size() == 1) {
		as.push_back(odd[0]);
		for (int a : even) as.push_back(a);

		if (even.size() > 0) {
			bs.push_back(odd[0] + 1);
			for (int i = 0; i < even.size() - 1; ++i) bs.push_back(even[i]);
			bs.push_back(even[even.size() - 1] - 1);
		} else {
			bs.push_back(odd[0] - 1);
			bs.push_back(1);
		}
	} else {
		for (int a : even) as.push_back(a);

		if (even.size() == 1) {
			bs.push_back(N - 1);
			bs.push_back(1);
		} else {
			bs.push_back(even[0] - 1);
			for (int i = 1; i < even.size(); ++i) bs.push_back(even[i]);
			bs.push_back(1);
		}
	}
	rezero(bs);
	printvec(as);
	printf("%d\n", bs.size());
	printvec(bs);
	return 0;
}


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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<int, int>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

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

    int r, d, x;
    while (cin >> r >> d >> x) {
        forn(i, 10) {
            x = r * x - d;
            cout << x << endl;
        }
    }
}


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

int main()
{
  string w;
  cin >> w;
  
  map<char, int> mp;
  for(char c : w)
    mp[c]++;
  
  bool b = true;
  map<char, int>::iterator it2;
  for(it2 = mp.begin(); it2 != mp.end(); it2++)
  {
    if((it2->second % 2) != 0)
    {
      b = false;
      break;
    }
  }
  
  if(b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
def convert_chars_to_num(chars)
  nums = []
  chars.split('').each do |char|
    nums << convert_char_to_num(char)
  end
  num2 = []
  nums.each_with_index { |_, i| num2[i] = (nums[i] - nums[0] + 26)%26 }
  return num2
end

def convert_char_to_num(char)
  ('a'..'z').to_a.each_with_index do |al, i|
    return i if char == al
  end
end

def get_dif_num(char1, char2)
  num1 = convert_char_to_num(char1)
  num2 = convert_char_to_num(char2)
  num1 - num2
end

def is_match_sequence?(str1, str2)
  dif1 = convert_chars_to_num(str1)
  dif2 = convert_chars_to_num(str2)
  dif1 == dif2
end

def decode_char(char, n)
  cn = convert_char_to_num(char)
  raise 'invalid cn' if cn.nil?
  ('a'..'z').to_a[cn + n]
end

def decode_chars(str, n)
  str.split(//).each_with_index do |char, i|
    next if char !~ /[a-z]/
    str[i] = decode_char(char, n)
  end
  return str
end

while gets do
  sentence = $_.chomp

  n = nil
  sentence.split(/\s/).each do |str|
    if str.length == 3 and is_match_sequence?('the', str)
      n = get_dif_num('e', str.split('')[2])
      break
    elsif str.length == 4 and is_match_sequence?('this', str)
      n = get_dif_num('i', str.split('')[2])
      break
    elsif str.length == 4 and is_match_sequence?('that', str)
      n = get_dif_num('a', str.split('')[2])
      break
    end
  end
  raise "no n str:#{sentence}" if n.nil?
  puts decode_chars(sentence, n)
end

Measured memory_bytes: 6132
a, b, c, d = list(map(int, list(input())))
if a + b + c + d == 7:
    print("{0}+{1}+{2}+{3}=7".format(a, b, c, d))
elif a + b + c - d == 7:
    print("{0}+{1}+{2}-{3}=7".format(a, b, c, d))
elif a + b - c + d == 7:
    print("{0}+{1}-{2}+{3}=7".format(a, b, c, d))
elif a - b + c + d == 7:
    print("{0}-{1}+{2}+{3}=7".format(a, b, c, d))
elif a - b - c + d == 7:
    print("{0}-{1}-{2}+{3}=7".format(a, b, c, d))
elif a - b + c - d == 7:
    print("{0}-{1}+{2}-{3}=7".format(a, b, c, d))
elif a + b - c - d == 7:
    print("{0}+{1}-{2}-{3}=7".format(a, b, c, d))
elif a - b - c - d == 7:
    print("{0}-{1}-{2}-{3}=7".format(a, b, c, d))


Measured memory_bytes: 3064
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    while(cin>>n)
    {
        n=((n+1)*n)/2;
        cout<<n<<en;
    }
}




Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N; cin >> N;
	vector<long long>A(N);
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long ans = 0;
	for (long i = 1; i < N; i++) {
		if (A.at(i - 1) < A.at(i))ans++;
	}
	cout << ans << endl;
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0; i < n; i++) {
        int refi=i+1;
        int d=2;
        while(refi>1){
            if(refi%d==0){
                refi/=d;
                mp[d]++;
            }
            else d++;
        }
        mp[refi]++;
    }
    ll ans=1;
    for(auto itr = mp.begin(); itr!=mp.end() ; itr++) {
        int t=itr->second;
//        cout << itr->first << " " << t << "\n";
        if(itr->first!=1) ans=ans*(t+1)%MOD;
    }
    cout << ans << "\n";

    return 0;
}

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


int main() {
  int date;
  cin >> date;
  int h1 = date / 100;
  int h2 = date % 100;

  bool y = false;
  bool m = false;

  if (1 <= h2 && h2 <= 12) {
    y = true;
  }

  if (1 <= h1 && h1 <= 12) {
    m = true;
  }

  if (y && m) { 
    printf("AMBIGUOUS\n");
  } else if (y) {
    printf("YYMM\n");
  } else if (m) {
    printf("MMYY\n");
  } else {
    printf("NA\n");
  }

  return 0;
}

Measured memory_bytes: 256
require 'pp'
require 'set'

n, m = gets.chomp!.split(' ').map(&:to_i)
prefs = {}
cities = {}
m.times do |i|
    p, y = gets.chomp!.split(' ').map(&:to_i)
    prefs[p] ||= SortedSet.new
    prefs[p] << y
    cities[y] = i
end

ans = {}
prefs.each do |pref, cs|
    cs.each_with_index do |c, rank|
        ans[cities[c]] ||= {}
        ans[cities[c]] = {
            pref: pref,
            rank: rank + 1,
        }
    end
end

m.times do |i|
    puts sprintf("%06d%06d", ans[i][:pref], ans[i][:rank])
end


Measured memory_bytes: 108540
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
#define pb push_back
#define pii pair<int,int>
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
int r,c,k;
bool valid(int i, int j) {
  return (i<r&&j<c);
}
map<pii,int> mp;
int dp[3000][3000][4];
int rec(int i, int j, int prevrow) {
      if(!valid(i,j)) return 0;
      if(~dp[i][j][prevrow]) return dp[i][j][prevrow];
      if(!mp.count({i,j})) {
        return dp[i][j][prevrow]=max(rec(i,j+1,prevrow),rec(i+1,j,0));
      }
      else {
        if(prevrow>=3) {
          return dp[i][j][prevrow]=max(rec(i,j+1,prevrow),rec(i+1,j,0));
        }
        else return dp[i][j][prevrow]=max(mp[{i,j}]+max(rec(i,j+1,prevrow+1),rec(i+1,j,0)),max(rec(i,j+1,prevrow),rec(i+1,j,0)));
      }
}
void solve() {
  cin>>r>>c>>k;
  fora(i,k) {
    int u,v,wt;
    cin>>u>>v>>wt;
    u--; v--;
    mp[{u,v}]=wt;
  }
  memset(dp,-1,sizeof(dp));
  cout<<rec(0,0,0);
}
int32_t main()
{
    fastio
    solve();
    

    return 0;


}

Measured memory_bytes: 298240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,1,n + 1){
    ans += (n - 1) / i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long max = a * c;

		if(a * d > max) {
			max = a * d;
		}

		if(b * c > max) {
			max = b * c;
		}

		if(b * d > max) {
			max = b * d;
		}

		System.out.println(max);
	}

}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

char s[5];

int main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=3;i++)
	cin>>s[i];
	if(s[2]=='R')
	cout<<"ABC";
	else cout<<"ARC";
	return 0;
}




Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner stdin = new Scanner(System.in);

        int A = stdin.nextInt();
        int B = stdin.nextInt();
        
        if(A-(B*2)>=0) {
        	System.out.println(A-(B*2));
        }
        else {
        	System.out.println("0");
        }
	}
}


Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(250000)

def main():
    a,b,c = map(int, input().split())

    if a == b + c :
        print("Yes")
    elif b == a + c:
        print("Yes")
    elif c == a + b:
        print("Yes")
    else:
        print("No")
main()



#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))


Measured memory_bytes: 9160
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;

void main()
{
	long a, b, c, k;
	readln.chomp.split.tie(a, b, c, k);
	BigInt A, B, C;
	A = BigInt(a);
	B = BigInt(b);
	BigInt ans;
	if (k % 2) {
		ans = -A + B;
	} else {
		ans = A - B;
	}
	BigInt limit = BigInt(1_000_000_000_000_000_000L);
	if (ans < -limit || limit < ans) {
		writeln = "Unfair";
	} else {
		ans.writeln;
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 256
N = int(input())
a = [input() for i in range(N)]

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0

for num in range(N):
  if a[num] == 'AC':
    AC_num += 1
  elif a[num] == 'WA':
    WA_num += 1
  elif a[num] == 'TLE':
    TLE_num += 1
  else:
    RE_num += 1

print('AC x ',AC_num)
print('WA x ',WA_num)
print('TLE x ',TLE_num)
print('RE x ',RE_num)

Measured memory_bytes: 16200
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;


int main(void){
    int n;
    cin>>n;
    vector<pair<pair<int, int>, int> > v(n);
    rep(i, n){
        int x, y, h;
        cin>>x>>y>>h;
        pair<int, int> pos=pair<int, int>(x, y);
        v[i]=pair<pair<int, int>, int> (pos, h);
    }
    int kirokux=0;
    int kirokuy=0;
    int kirokuh=0;
    int zeroflag=0;
    rep(i, n){
        if(v[i].second!=0) {
            kirokux=v[i].first.first;
            kirokuy=v[i].first.second;
            kirokuh=v[i].second;
            zeroflag++;
        }
    }
    if(zeroflag==1) {
        cout<<kirokux<<" "<<kirokuy<<" "<<kirokuh<<endl;
        return 0;
    }
    rep(i, 101)rep(j, 101){
        int x, y, h;
        int setflag=0;
        int H=-1;
        int flag=0;
        for(int k=0;k<n;k++){
            x=v[k].first.first;
            y=v[k].first.second;
            h=v[k].second;
            //cout<<h<<endl;
            if(setflag==1){
                if(h==0) continue;
                if(h+abs(x-i)+abs(y-j)!=H) {
                    flag=1;
                    break;
                }
            }
            else{
                if(h==0) continue;
                H=h+abs(x-i)+abs(y-j);
                setflag=1;
            }
        }
        if(flag!=1 && H!=-1){
            cout<<i<<" "<<j<<" "<<H<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256