akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
//#define _DEBUG

int N;
pii ps[110];

void _main() {
    cin >> N;
    REP(i, N) cin >> ps[i];
    sort(ps, ps + N, [&](pii p, pii q) {
        return atan2(p.second, p.first) < atan2(q.second, q.first);
    });
    double ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            double x = 0, y = 0;
            for (int k = 0; k <= j; k++) {
                x += ps[(i + k) % N].first;
                y += ps[(i + k) % N].second;
            }
            CHMAX(ans, sqrt(x*x + y*y));
        }
    }
    cout << ans << endl;
}

signed main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    _main();
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s[] = new int[1000];
        double sum=0.0, avg,alpha;
        
        while(n!=0){
            sum = 0.0;
            for(int i=0; i<n; i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            avg = sum/n;
            sum = 0.0;
            for(int i=0; i<n; i++){
                sum += (s[i] - avg)*(s[i] - avg);
            }
            alpha = Math.sqrt(sum/n);
            System.out.println(alpha);
            n = sc.nextInt();
        }
    }
}

Measured memory_bytes: 31580
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000
#define BEAM 10

using namespace std;

class state {
    public:
        int day;
        int previous_score;
        vector<int> previous;
        vector<int> types;

        state() {}

        state(const state& a) : day(a.day), previous_score(a.previous_score), previous(a.previous), types(a.types) {}
};

int _scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        int day,
        int type,
        const vector<int> &previous) {
    int score = s[day][type];

    REP(i, 26) {
        score -= c[i] * (day + 1 - previous[i]);
    }

    return score;
}

int scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        state &this_state) {
    this_state.previous[this_state.types.back()] = this_state.day + 1;
    return this_state.previous_score + _scoring(c, s, this_state.day, this_state.types.back(), this_state.previous);
}

using queue_type = pair<state, int>;
struct CustomCompare
{
    bool operator()(const queue_type &a, const queue_type &b) {
        return a.second < b.second;
    }
};

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

    vector<int> c(26);
    REP(i, 26)
        cin >> c[i];

    vector<vector<int>> s(D, vector<int>(26, 0));
    REP(i, D)
        REP(j, 26)
        cin >> s[i][j];

    vector<state> initial;
    REP(i, 26) {
        state this_state;
        this_state.day = 0;
        this_state.types.push_back(i);
        this_state.previous_score = 0;
        this_state.previous = vector<int>(26, 0);
        initial.push_back(this_state);
    }

    priority_queue<queue_type, vector<queue_type>, CustomCompare> q1, q2;
    REP(i, D) {
        if (i == 0) {
            // use initial
            for (auto i : initial) {
                q2.push(make_pair(i, scoring(c, s, i)));
            }
        } else {
            // use queue
            for (int ii = 0; ii < BEAM && !q1.empty(); ++ii) {
                auto i = q1.top();

                REP(j, 26) {
                    state new_state = i.first;
                    new_state.day++;
                    new_state.types.push_back(j);

                    q2.push(make_pair(new_state, scoring(c, s, new_state)));
                }

                q1.pop();
            }
        }
        swap(q1, q2);

        q2 = decltype(q2)();
    }

    auto res = q1.top().first;

    for (auto t : res.types)
        cout << t + 1 << endl;

    return 0;
}



Measured memory_bytes: 5072
import java.util.Scanner;

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

            main.solveA(sc);
            // main.solveB(sc);
            // main.solveC(sc);

        }
    }

    private void solveC(Scanner sc) {

    }

    void solveB(Scanner sc) {
    }

    void solveA(Scanner sc) {
        String s = sc.next();
        if (s.indexOf("N") >= 0 && s.indexOf("S") < 0) {
            System.out.println("No");
            return;
        }
        if (s.indexOf("S") >= 0 && s.indexOf("N") < 0) {
            System.out.println("No");
            return;
        }
        if (s.indexOf("W") >= 0 && s.indexOf("E") < 0) {
            System.out.println("No");
            return;
        }
        if (s.indexOf("E") >= 0 && s.indexOf("W") < 0) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 9932
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define dep(i,a,b) for(register int i=(a);i>=(b);i--)
using namespace std;
const int maxn=100010;
int n,m,k;
int a[15];
bool ok(int x)
{
    while(x)
    {
        if(a[x%10]) return 1;
        x/=10;
    }
    return 0;
}
int main()
{
    int T,cas=1;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        memset(a,0,sizeof(a));
        while(k--)
        {
            int x;
            scanf("%d",&x);
            a[x]=1;
        }
        while(ok(n)) n++;
        printf("%d\n",n);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = cin.nextInt();
        }

        Set<Integer> s = new HashSet<>();
        for (int i = 0; i < N; i++) {
            s.add(d[i]);
        }

        System.out.println(s.size());
    }
}


Measured memory_bytes: 22996
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#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;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
struct ps
{
	ll a , b , c , d;
};
ll n , m , q ;
ll brr[100000];
ps arr[10000];
ll mx;
void dfs(ll sz=0, ll idx=1){
	if(sz==n){
		ll ans=0;
		for(ll j=0;j<q;j++){
			if(brr[arr[j].b]-brr[arr[j].a]==arr[j].c){
				ans+=arr[j].d;
			}
		}
		mx=max(mx,ans);
		return ;
	}
	for(ll i=idx;i<=m ; i++){
		brr[sz]=i;
		dfs(sz+1 , i);
	}
}
int main(){
	//mahakal(),fast;
	cin>> n >> m >> q ;
	for(ll i=0;i<q;i++){
		cin>>arr[i].a>>arr[i].b>>arr[i].c>>arr[i].d;
		arr[i].a--,arr[i].b--;
	}
	dfs();
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1)
		a=a+15;
	if(b==1)
		b=b+15;
	if(a==b)
	printf("Draw\n");
	else if(a>b)
		printf("Alice\n");
	else
		printf("Bob\n");
	return 0;
}

Measured memory_bytes: 1636
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	n := len(s)

	ans := 0
	for i := 0; i < n-1; i++ {
		if s[i] != s[i+1] {
			ans++
		}
	}
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 896
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
check = {}
for i in set(a):
    check[i] = 0
for i in a:
    check[i] += 1
    
count = 0
for i in check.items():
    if i[1] % 2 != 0:
        count += 1
print(count)

Measured memory_bytes: 23312
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var S = ReadLine();
            var ans = S.Select(c => (c + N <= 'Z') ? (char)(c + N) : (char)((c + N) % 'Z' + 'A'-1));
            WriteLine(string.Join("", ans));
        }
    }
}


Measured memory_bytes: 19228
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct N {
  int p, l, r;
} Node;

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  c = T[u].l;
  for( i = 0 ; ; i++ ){
    if( c == NIL ) break;
    if(i) printf(", ");
    printf("%d", c);
    c = T[c].r;
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if( T[u].r != NIL ) rec(T[u].r, p);
  if( T[u].l != NIL ) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d", &v, &d);
    for( j = 0 ; j < d ; j++ ){
      scanf("%d", &c);
      if( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    if( T[i].p == NIL ) r = i;
  }

  rec(r, 0);

  for( i = 0 ; i < n ; i++ ) print(i);

  return 0;
}



Measured memory_bytes: 6376
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

ll read() {
	ll X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=50+10;

int n; ll a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	ll ans=0;
	while (1) {
		int p=max_element(a+1,a+n+1)-a;
		if (a[p]<n) break;
		ll c=(a[p]-n)/n+1; ans+=c;
		a[p]-=c*n;
		for (int i=1;i<=n;++i)
			if (i!=p) a[i]+=c;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n), left(n), right(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) {
        left[i] = (i == 0 ? v[i] : (v[i] ^ left[i - 1]));
        right[n - i - 1] = (i == 0 ? v[n - i - 1] : (v[n - i - 1] ^ right[n - i]));
    }
    for (int i = 0; i < n; i++) {
        if (i == 0)
            cout << right[i + 1] << ' ';
        else if (i == n - 1)
            cout << left[n - 2] << ' ';
        else
            cout << (left[i - 1] ^ right[i + 1]) << ' ';
    }

    return 0;
}


Measured memory_bytes: 7852
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] x = {a,b,c};
        Arrays.sort(x);
        for(int i = 0; i < 2; i++){
            System.out.printf("%d ",x[i]);
        }
System.out.printf("%d\n",x[2]);
        sc.close();
    }
}


Measured memory_bytes: 26452
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

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


void solve(){

   
    
    string s;
    cin>>s;

    int64_t ans = 0;

    for(int i=0; i<s.size(); i++) {
        ans = ans + s[i] - '0';
        ans = ans % 9;
    }

    if(ans % 9 == 0) {
        yes;
    } else {
        no;
    }


    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3740
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log,floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
l= LIST()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if(l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k] and l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]):
                ans+=1
                # print(i,j,k)

print(ans)

Measured memory_bytes: 75532
// https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  rep1(a, 3500) rep1(b, 3500) {
    ll divisor = 4 * a * b - N * b - N * a;
    if (divisor == 0) continue;

    if (N * a * b % divisor == 0) {
      ll c = N * a * b / divisor;

      if (c <= 0) continue;
      print_ints({a, b, c});
      return;
    }
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  int cnt = 0;
  int b = a[0];
  int state = 0;
  rep(i, N) {
    if (b < a[i]) {
      if (state < 0) {
        cnt++;
        state = 0;
      } else {
        state = 1;
      }
    } else if (b > a[i]) {
      if (state > 0) {
        cnt++;
        state = 0;
      } else {
        state = -1;
      }
    }
    b = a[i];
  }
  cout << cnt + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;




int main(){
    int N;
    cin >> N;
    vector<vector<int>> a(N,vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }
    vector<LL> dp(1<<N);
    dp[0]=1;
    for (int i = 0; i < N; i++) {
        for (int k = 0; k < (1<<N); k++) {
            if(__builtin_popcount(k)!=i) continue;
            for (int j = 0; j < N; j++) {
                if(k&(1<<j)||!a[i][j]) continue;
                int nx=k|(1<<j);
                dp[nx]=(dp[nx]+dp[k])%mod;
            }
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}




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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d){
		P("Left");
	}else if(a+b < c+d){
		P("Right");
	}else{
		P("Balanced");
	}
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

bool grid[1007][1007];
long long int dp[1007][1007];
const long long int MOD=1000000007;
int main()
{
    int H,W;
    scanf("%d %d\n",&H,&W);
    for(int h=1; h<=H; h++)
    {
        for(int w=1; w<=W; w++)
        {
            char c;
            scanf("%c",&c);
            grid[h][w]=(c=='#');
        }
        scanf("\n");
    }

    dp[0][1]=1;
    for(int h=1; h<=H; h++)
    {
        for(int w=1; w<=W; w++)
        {
            if(grid[h][w]) continue;
            dp[h][w]=dp[h-1][w]+dp[h][w-1];
            dp[h][w]%=MOD;
        }
    }

    printf("%lld\n",dp[H][W]);
    return 0;
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    public static void Main(string[] args)
    {
        var ant = new int[5];
        for (int i = 0; i < 5; i++)
            ant[i] = Input.NextInt();

        int minr = int.MaxValue;
        int mini = -1;
        for (int i = 0; i < 5; i++)
        {
            var n = ant[i];
            var r = n % 10;
            if (r == 0)
                r = 10;
            if (minr > r)
            {
                mini = i;
                minr = r;
            }
        }

        int sum = 0;
        for (int i = 0; i < 5; i++)
        {
            if (i == mini)
            {
                sum += ant[mini];
            }
            else
            {
                var n = ant[i];
                var r = n % 10;
                sum += (n / 10) * 10;
                if (r != 0)
                    sum += 10;
            }
        }

            Console.WriteLine(sum);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13268
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int nA, nB, nC;
	cin >> nA >> nB >> nC;
	int nCount = 0;
	for (size_t i = nA; i <= nB; i++)
	{
		if (nC%i == 0)
		{
			++nCount;
		}
	}
	printf("%d\n", nCount);

	//system("pause");
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e14;

struct Edge {
	Edge(ll from, ll to, ll get_coin): from(from), to(to), get_coin(get_coin) {}
	ll from, to, get_coin;
};

int main() {
	ll N, M, P;
	cin >> N >> M >> P;
	vector<Edge> edges;
	for(int i=0;i<M;i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		c -= P;
		edges.emplace_back(a, b, c);
	}

	vector<ll> coin(N, -INF);
	coin[0] = 0;

	for (int i=0;i<N;i++) {
		for (int j=0;j<M;j++) {
			Edge e = edges[j];

			if (coin[e.from] != -INF and coin[e.to] < coin[e.from] + e.get_coin) {
				coin[e.to] = coin[e.from] + e.get_coin;
			}
		}
	}

	vector<bool> is_negative(N, false);
	for (int i=0;i<N;i++) {
		for (int j=0;j<M;j++) {
			Edge e = edges[j];

			if (coin[e.from] != -INF and coin[e.to] < coin[e.from] + e.get_coin) {
				coin[e.to] = coin[e.from] + e.get_coin;
				is_negative[e.to] = true;
			}
			if(is_negative[e.from]) is_negative[e.to] = true;
		}
	}

	if(is_negative[N-1]) {
		cout << -1 << endl;
	} else {
		cout << max(coin[N-1], 0LL) << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    while(true){
        if(N%111==0) break;
        N++;
    }
    cout << N << endl;



}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 100

int main(void)
{
	int n, a, lngth, count;
	int i;
	int num[SIZE];

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;

		for (i = 0; i < n; i++)
			num[i] = 0;

		for (i = 0; i < n; i++)
			scanf("%d", &num[i]);

		count = 0;
		while (1) {
			lngth = 1;
			for (i = 0; i < n - 1; i++) {
				if (num[i] > num[i + 1]) {
					a = num[i]; num[i] = num[i + 1]; num[i + 1] = a;
					count++;

				}
			}
			for (i = n - 1; i >= 1; i--) {
				if (num[i - 1] > num[i])
					break;
				lngth = i;
			}
			if (lngth == 1)	break;
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	REP(i, H) {
		cin >> S[i];
	}
	vector<VI> sumh(H);
	int sumw[2010][2010] = { 0 };
	REP(i, H) {
		REP(j, W) {
			if (j == 0) {
				if (S[i][j] == '#')sumh[i].push_back(0);
				else sumh[i].push_back(1);
			}
			else {
				if(S[i][j]=='#')sumh[i].push_back(0);
				else sumh[i].push_back(sumh[i][j-1]+1);
			}
		}
	}
	REP(i, H) {
		REP(j, W-1) {
			if (S[i][j] == '.')sumh[i][j] = max(sumh[i][j], sumh[i][j + 1]);
		}
	}
	REP(i, H) {
		for(int j=W-2;j>=0;j--){
			if (S[i][j] == '.')sumh[i][j] = max(sumh[i][j], sumh[i][j+1]);
		}
	}


	REP(i,W) {
		REP(j, H) {
			if (j == 0) {
				if (S[j][i] == '#')continue;
				else sumw[j][i] = 1;;
			}
			else {
				if (S[j][i] == '#')continue;
				else sumw[j][i] = sumw[j - 1][i] + 1;
			}
		}
	}
	





	REP(j, W) {
		REP(i, H-1) {
			if (S[i][j] == '.')sumw[i][j] = max(sumw[i][j], sumw[i + 1][j]);
		}
	}
	REP(j, W) {
		for (int i = H - 2; i >= 0; i--) {
			if (S[i][j] == '.')sumw[i][j] = max(sumw[i][j], sumw[i+1][j]);
		}
	}

	




	int ans = 0;
	REP(i, H) {
		REP(j, W) {
			//cout << sumw[i][j];
			ans = max(ans, sumw[i][j] + sumh[i][j] - 1);
		}
		//cout << endl;
	}

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



Measured memory_bytes: 68224
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places == 0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k+1,
	print

Measured memory_bytes: 4252
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL INF=1e9;


int main(){
    vector<int> A(3);
    REP(i,3)cin>>A[i];
    SORT(A);
    int cnt=0;
    int flag=0;
    if((A[2]-A[0])%2){
        flag++;
    }
    cnt+=(A[2]-A[0])/2;
    if((A[2]-A[1])%2){
        flag++;
    }
    cnt+=(A[2]-A[1])/2;
    if(flag==1){
        cnt+=2;
    }else if(flag==2){
        cnt+=1;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys

def main():
	# ２つの整数を入力
	N, Y = map(int, input().split(' '))

	# すべての枚数を列挙する。
	N_max_1k = Y // 1000
	N_1k = -1
	N_5k = -1
	N_10k = -1

	if N == N_max_1k:
		# 最大枚数と一致する
		N_1k = N_max_1k
		N_5k = 0
		N_10k = 0
	elif N < N_max_1k:
		# 最大枚数以下である
		# 千円札を最小の五千円札と一万円札とで区別する
		N_diff = N_max_1k - N
		# 五千円札が最小のときの両替枚数（端数）
		N_5k_values = (
			0,
			7,
			5,
			3,
			1,
			8,
			6,
			4,
			2,
		)
		N_5k = N_5k_values[N_diff % 9]
		N_1k = N_max_1k - N_5k * 5
		if N_1k < 0:
			# 最小枚数を下回る。
			N_1k = -1
			N_5k = -1
		else:
			# 千円札と一万円札の枚数を計算する
			# 下記の方程式を解く
			#    N_1k + N_10k = N - N_5k
			#    N_1k + N_10k * 10 = Y // 1000 - N_5k * 5
			N_10k = (N_diff - N_5k * 4) // 9
			if N_10k < 0:
				N_1k = -1
				N_5k = -1
				N_10k = -1
			else:
				N_1k = N - N_5k - N_10k
				if N_1k < 0:
					N_1k = -1
					N_5k = -1
					N_10k = -1

	print('%d %d %d' % (N_10k, N_5k, N_1k))


if __name__ == '__main__':
	main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long double PI=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline long long read() {
	long long x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    long long a=read(),b=read();
    unsigned long long c=(unsigned long long)b*pow(b-1,a-1);
    cout<<c<<"\n";
    return 0;
}

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

int main(){ 
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  bool approved = true;
  
  rep(i,N) {
    if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) approved = false;
  }
  
  if (approved) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};
bool dp[MAX_N]={};

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

    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct {
  int  id;
  char s[11];
  int  p;
} st_res;

int main(void) {
  int N;
  scanf("%d", &N);

  st_res res[100];
  for(int i = 0; i < N; i++){
    scanf("%s %d", res[i].s, &res[i].p);
    res[i].id = i+1;
  }

  for(int i = 1; i < N; i++) {
    for(int j = 1; j < N; j++) {
      int cmp = strcmp(res[j-1].s, res[j].s);
      if(cmp > 0) {
	st_res tmp;
	memcpy(&tmp, &res[j-1], sizeof(st_res));
	memcpy(&res[j-1], &res[j], sizeof(st_res));
	memcpy(&res[j], &tmp, sizeof(st_res));
      } else if(cmp == 0) {
	if(res[j-1].p < res[j].p) {
	  st_res tmp;
	  memcpy(&tmp, &res[j-1], sizeof(st_res));
	  memcpy(&res[j-1], &res[j], sizeof(st_res));
	  memcpy(&res[j], &tmp, sizeof(st_res));
	}
      }
    }
  }

  for(int i = 0; i < N; i++) {
    //printf("res[%d]: s=%s p=%d\n", i, res[i].s, res[i].p);
  }

  for(int i = 0; i < N; i++) {
    printf("%d\n", res[i].id);
  }


  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define debug(x)  cout<<#x<<" " <<x<<endl;
#define dbg(x,y)  cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define si(x) x.size()

const int e = 100005;
const ll INF = 1e18+5;
template<typename T>void show2(T& dp)
{
    for( auto row:dp)
    {
        for(auto col:row)
            cout<<col<<" ";
        cout<<endl;
    }
}
template<typename T>void show1(T &a)
{
    for(auto x:a)
        cout<<x<<" ";
    cout<<endl;
}
void solve()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}
int main() {
	// your code goes here
	io;
	int t ;
	//cin>>t;
	//while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

int main()
{
	int n;
	char s[4001];
	scanf("%d%s", &n, s);
	std::vector<int> r;
	std::vector<int> g;
	std::vector<int> b;
	for (int i = 0; i < n; ++i)
	{
		switch (s[i])
		{
			case 'R':
				r.emplace_back(i);
				break;
			case 'G':
				g.emplace_back(i);
				break;
			case 'B':
				b.emplace_back(i);
				break;
			default:
				throw;
		}
	}

	long long ans = 0;
	for (int i = 0; i < n - 2; ++i)
	{
		for (int j = i + 1; j < n - 1; ++j)
		{
			std::vector<int>* ptr = nullptr;
			switch (s[i])
			{
				case 'R':
					if (s[j] == 'G') ptr = &b;
					else if (s[j] == 'B') ptr = &g;
					break;
				case 'G':
					if (s[j] == 'R') ptr = &b;
					else if (s[j] == 'B') ptr = &r;
					break;
				case 'B':
					if (s[j] == 'R') ptr = &g;
					else if (s[j] == 'G') ptr = &r;
					break;
			}
			if (ptr == nullptr)
			{
				continue;
			}
			ans += (long long)(ptr->end() - std::lower_bound(ptr->begin(), ptr->end(), j + 1));
			if (std::binary_search(ptr->begin(), ptr->end(), j + (j - i)))
			{
				ans -= 1;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a,b;
int main()
{
	SPEED;
	cin>>n>>a>>b;
	ll ans=n;
	for(int i=1;i<=n;i++)
	{
		ll x;
		cin>>x;
		ans-=(x<b&&x>=a);
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef pair<char, int> P;

bool equals(P b[], P c[], int n) {
  for (int i = 0; i < n; i++) {
    if (b[i].first != c[i].first) return false;
    if (b[i].second != c[i].second) return false;
  }
  return true;
}

void merge(P a[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  
  P l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++) {
    l[i] = a[left + i];
  }
  l[n1].second = INF;
  for (int i = 0; i < n2; i++) {
    r[i] = a[mid + i];
  }
  r[n2].second = INF;

  int p = 0, q = 0;
  for (int i = left; i < right; i++) {
    if (l[p].second <= r[q].second) {
      a[i] = l[p++];
    } else {
      a[i] = r[q++];
    }
  }
}

void mergeSort(P a[], int left, int right) {
  if (left + 1 == right) return;
  int mid = (left + right) / 2;
  mergeSort(a, left, mid);
  mergeSort(a, mid, right);
  merge(a, left, mid, right);
}

int partition(P a[], int p, int r) {
  int x = a[r].second;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (a[j].second <= x) {
      i++;
      P temp = a[i];
      a[i] = a[j];
      a[j] = temp;
    }
  }

  P temp = a[i + 1];
  a[i + 1] = a[r];
  a[r] = temp;
  return i + 1;
}

void quicksort(P a[], int p, int r) {
  if (p >= r) return;
  int q = partition(a, p, r);
  quicksort(a, p, q - 1);
  quicksort(a, q + 1, r);
}

int main() {
  int n;
  cin >> n;
  P a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }

  P b[n], c[n];
  for (int i = 0; i < n; i++) {
    b[i] = a[i];
    c[i] = a[i];
  }

  quicksort(b, 0, n - 1);
  mergeSort(c, 0, n);

  if (equals(b, c, n)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  for (int i = 0; i < n; i++) {
    cout << b[i].first << ' ' << b[i].second << endl;
  }

  return 0;
}

Measured memory_bytes: 6184
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
L = A[0]
for i in range(1,N):
    g = math.gcd(L,A[i])
    L = L*A[i]//g
ans = 0
L %= MOD
for i in range(N):
    ans += (L*pow(A[i],MOD-2,MOD))
    ans %= MOD
print(ans)

Measured memory_bytes: 79076
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

ll gcd(ll a, ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a, b)*b;}

int main(){
	ll n,a;
	cin>>n>>a;
	ll b;
	rep(i,n-1) cin>>b,a=lcm(a,b);
	cout<<a<<endl;
}

Measured memory_bytes: 1156
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int x;
	cin>>x;
	for (int i = 1; i*i <= x; ++i)
	{
		if(!(x%i)){
			int d=i;
			for (int A = -300; A <= 300; ++A)
			{
				int B=A-d;
				if((A*A*A*A*A-B*B*B*B*B)==x){
					cout<<A<<" "<<B<<"\n";
					return 0;
				}
			}
			d=x/i;
			for (int A = -300; A <= 300; ++A)
			{
				int B=A-d;
				if((A*A*A*A*A-B*B*B*B*B)==x){
					cout<<A<<" "<<B<<"\n";
					return 0;
				}
			}
		}
	}
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
using namespace std;
int k;
int main()
{
   
    cin>>k;
    long long res=0;
    FOR(i,1,k){
        if (((i%3)==0) || ((i%5)==0)) continue; else res+=i;
    }
    cout<<res;

}


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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long

using namespace std ;

const int MAXN = 888 , MOD = 1e9 + 7 ; 

char ma[MAXN][MAXN] ; 

int d[MAXN][MAXN] ; 

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

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
 	int n , k ,  m ; 
	cin >> n >> m >> k  ; 
	int ans = 1e18 , x , y ; 
	for(int i = 0 ; i < n ; i ++ ) for(int j = 0 ; j < m ; j ++ ) 
	{
		cin >> ma[i][j] ;
		if(ma[i][j]=='S') x = i , y = j ; 
	}
	queue<pair<int,int>> q ; 
	q.push({x,y}) ;
	memset(d,63,sizeof d) ; 
	d[x][y] = 0 ; 
	while(q.size())
	{
		int x = q.front().F , y = q.front().S ; 
		q.pop() ; 
		if(d[x][y]>k) break ;
		int i = x , j = y ;
		ans = min(ans,(i+k-1)/k) ; 
		ans = min(ans,(j+k-1)/k) ; 
		ans = min(ans,(n-i-1+k-1)/k) ; 
		ans = min(ans,(m-j-1+k-1)/k) ; 	
		for(int i = 0 ; i < 4;  i ++ ) 
		{
			int X = x + dx[i] , Y = y + dy[i] ; 
			if(X<0||X>=n||Y<0||Y>=m||d[X][Y]<=d[x][y]+1||ma[X][Y]=='#') continue ; 
			d[X][Y] = d[x][y] + 1 ; 
			q.push({X,Y}) ; 
		}
	}
	cout << ans + 1<< endl ; 

}

Measured memory_bytes: 7168
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    REP(i,0,s.size()-1) if (s[i] == s[i+1]) {
        cout << i + 1 << " " << i + 2 << endl;
        return;
    }
    REP(i,0,s.size()-2) if (s[i] == s[i+2]) {
        cout << i + 1 << " " << i + 3 << endl;
        return;
    }
    cout << "-1 -1" << endl;
}

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

Measured memory_bytes: 512