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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef unsigned long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    lli ans = 0;
    REPE(i,1,40) {
        lli x = 1;
        REP(j,0,i) {
            x *= 5;
        }
        if (n / x != 0) {
            //cout2(i,n/(x*2));
            ans += n/(x*2);
        }
        else
            break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int 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 int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<int> p(N);
  cin >> p;
  int sum = 0;
  REP(i,N) {
    sum += (p[i]-1 != i);
  }
  if (sum <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int mop(int x, int y)
{
    int res = 1;
    while (y > 0)
        res *= x, --y;

    return res;
}
using namespace std;
void solve(void)
{
    int x;
    cin >> x;
    int ans = 0;
    for (int i = 2; i <= 10; ++i)
        rep(j, 1000) if (mop(j, i) <= x) ans = max(ans, mop(j, i));
    cout << ans << endl;
}
int main(void)
{
    solve();
}

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

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

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

  LL ans;
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  ans = min(A, B) + min(C, D);

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main(){
    vector<long> city(6);
    vector<long> trans(5);
    cin>>city.at(0);
    for(int i=0;i<5;i++){
        cin>>trans.at(i);
    }
    long res;
    sort(trans.begin(),trans.end());
    if(trans.at(0)>city.at(0))res=5;
    else if(city.at(0)%trans.at(0))res=5+city.at(0)/trans.at(0);
    else res=4+city.at(0)/trans.at(0);

    cout<<res<<endl;
}

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

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  for (int i = 0; i < n - k; i++) {
    int l = a[i];
    int r = a[i + k];
    if (l < r)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 4044
n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)

def card_game(x)
    alice = []
    bob = []
    (0...x.size).map do |i|
        i.even? ? alice << x.sort.reverse[i] : bob << x.sort.reverse[i]
    end
    alice.inject(:+) - bob.inject(:+)
end

print card_game(x)

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORT_ALL(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<std::string> vs;
struct aaa{
    aaa(){
        std::cin.tie(0); std::ios::sync_with_stdio(0); std::cout<<std::fixed<<std::setprecision(20);
    };
}aaaaaaa;

class UnionFind {
private:
    vll _par;
    vll _rank;
public:
    UnionFind(const ll n);
    ll root(const ll n);
    bool unite(ll x, ll y);
    bool same(const ll x, const ll y);
};

UnionFind::UnionFind(const ll n) : _par(n), _rank(n, 1LL) {
    REP(i,n) _par[i] = i;
}

ll UnionFind::root(const ll x) {
    if(_par[x] == x) return x;
    else return _par[x] = root(_par[x]);
}

bool UnionFind::unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(_rank[x] < _rank[y]) _par[x] = y;
    else {
        _par[y] = x;
        if(_rank[x] == _rank[y]) _rank[x]++;
    }
    return true;
}

bool UnionFind::same(const ll x, const ll y) {
    return root(x) == root(y);
}

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind ufr(n), ufl(n);
    REP(i, k) {
        int p, q;
        cin >> p >> q;
        ufr.unite(p - 1, q - 1);
    }
    vi a(n,1);
    REP(i, l) {
        int r, s;
        cin >> r >> s;
        ufl.unite(r - 1, s - 1);
    }

    map<pair<int, int>, int> ans;
    vector<pair<int, int>> p(n);
    REP(i, n) {
        p[i].first = ufr.root(i);
        p[i].second = ufl.root(i);
        ans[p[i]]++;
    }
    REP(i, n) {
        if(i != n - 1) cout << ans[p[i]] << " ";
        else cout << ans[p[i]] << "\n";
    }

    return 0;
}


Measured memory_bytes: 20352
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami();
		int a = saori.saori_hayami();
		if(h % a == 0){
			System.out.println(h/a);
		} else {
			System.out.println(h/a + 1);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20820
import sys

import numpy as np

N = int(sys.stdin.buffer.readline())
S = np.frombuffer(sys.stdin.buffer.read(),dtype='S1').reshape(N,-1)[:,:N]

# 2倍しておく
S = np.concatenate([S,S])

answer = 0
for x in range(N):
    T = S[x:x+N]
    if (T == T.T).all():
        answer += N

print(answer)

Measured memory_bytes: 14812
using System;

namespace AOJ
{
    class DigitNumber
    {
        public static void Main(string[] args)
        {
            for (int i = 0; i < 200; i++)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var tmp = input.Split(' ');

                int test = int.Parse(tmp[0]) + int.Parse(tmp[1]);
                Console.WriteLine(test.ToString().Length);
            }
        }
    }
}

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


int main(int argc, const char * argv[]) {
    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);

    // implement
    int a, b;
    cin >> a >> b;
    if(a < 10 && b<10){
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    string Sa,Sb,Sc;
    cin >> Sa >> Sb >> Sc;
    char player = 'a';
    int itr1 = 0,itr2 = 0,itr3 = 0;
    while(true) {
        if(player == 'a') {
            if(itr1 == Sa.size()) {
                cout << "A";
                return 0;
            }
            player = Sa[itr1];
            itr1++;
        }else if(player == 'b') {
            if(itr2 == Sb.size()) {
                cout << "B";
                return 0;
            }
            player = Sb[itr2];
            itr2++;
        }else if(player == 'c') {
            if(itr3 == Sc.size()) {
                cout << "C";
                return 0;
            }
            player = Sc[itr3];
            itr3++;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, T;
  cin >> n >> T;
  int c;
  int t;
  int ans = 10000;
  REP(i, n){
    cin >> c >> t;
    if(t <= T){
      ans = min(c, ans);
    }
  }
  if(ans == 10000){puts("TLE");}
  else{
    cout << ans << endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){

    int n;
    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n - 1; i++){
        int num;
        cin >> num;
        v[num - 1] ++;
    }

    for(int i = 0; i < n; i++){
        cout << v[i] << endl;
    }




    return 0;
} 

Measured memory_bytes: 4056
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		Console.WriteLine(Kruskal(h[0] - 1, es).Sum(e => e[2]));
	}

	static int[][] Kruskal(int n, int[][] es)
	{
		var uf = new UF(n);
		var minEdges = new List<int[]>();

		foreach (var e in es.OrderBy(e => e[2]))
		{
			if (uf.AreUnited(e[0], e[1])) continue;
			uf.Unite(e[0], e[1]);
			minEdges.Add(e);
		}
		return minEdges.ToArray();
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n + 1).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
}



Measured memory_bytes: 33724
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
int_list = []
for _ in range(N):
    A, B = map(int, input().split())
    int_list.append([A, B])

K_bin = bin(K)[2:]
max_len = len(K_bin)
for i in range(N):
    int_list[i] = (bin(int_list[i][0])[2:].zfill(max_len), int_list[i][1])

or_list = [K_bin]
for i in range(max_len):
    if K_bin[i] == '1':
        or_list.append(K_bin[:i] + '0' + '1' * (max_len - i - 1))

ans = 0
for k in or_list:
    ans_k = 0
    for A, B in int_list:
        if len(A) > max_len:
            continue
        ok = 1
        for j, a in enumerate(A):
            if a == '1' and k[j] == '0':
                ok = 0
                break
        if ok:
            ans_k += B
    ans = max(ans, ans_k)

print(ans)


Measured memory_bytes: 81372
A,B = map(int, input().split())

def g(n):
    if n%4 == 1:
        return 1
    elif n%4 == 2:
        return 1^n
    elif n%4 == 3:
        return 0
    else:
        return n
    
print(g(A-1)^g(B))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cout << "x";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
#define ll long long

int n, m, a, b, c, d, e[5555]={};

int main(){
    for(int j=1; j<5555; j++)e[j] = 1001001001;
    scanf("%d%d", &n, &m);
    for(int i=0; i<m; i++){
        scanf("%d%d", &a, &b);
        d = 0;
        for(int j=0; j<b; j++){
            scanf("%d", &c);
            d |= (1<<(c-1));
        }
        for(int j=0; j<(1<<n); j++){
            e[j|d] = min(e[j|d], e[j] + a);
        }
    }
    if(e[(1<<n)-1] == 1001001001)e[(1<<n)-1] = -1;
    printf("%d\n", e[(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int n, k, x, y;

	std::cin >> n >> k >> x >> y;

	long long ans = 0;

	ans += std::min(k, n) * x;
	n -= k;
	if(n > 0)
		ans += n * y;

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

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
W = N.times.map{gets.to_i}

def check(p)
  i = 0

  K.times do
    s = 0
    while s + W[i] <= p
      s += W[i]
      i += 1
      return N if i == N
    end
  end
  return i
end

def solve()
  left = 0
  right = 100000 * 10000

  while right - left > 1
    mid = (left + right) / 2
    v = check(mid)
    if v >= N
      right = mid
    else
      left = mid
    end
  end
  return right
end
puts solve()


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int N;
  cin >> N;
  vector<int>s(N);
  int sum = 0;
  REP(i, N){
    cin >> s.at(i);
    sum += s.at(i);
  }

int mi = MOD;
if(sum % 10 != 0) {
  print(sum);
  return 0;
}else{ 
  REP(i, N){
  if(s.at(i) % 10 != 0) mi = min (s.at(i), mi); 
  }
}

if(mi == MOD) {
  print(0);
  return 0;
}else{
  sum -= mi;
  print(sum);
  return 0;
}

}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [[0 for i in range(W)] for j in range(H)]
for j in range(H):
  c = input()
  for i in range(W):
    if c[i] == "#":
      C[j][i] = 1
ans = 0
P = [0 for k in range(H + W)]

while 1:
  S = 0
  for j in range(H):
    for i in range(W):
      if P[j] == 0 and P[H + i] == 0:
        S += C[j][i]
  if S == K:
    ans += 1
  if sum(P) == H + W:
    break
  a = 1
  for k in range(H+W):
    b = (P[k] + a) // 2
    P[k] = (P[k] + a) % 2
    a = b
print(ans)

Measured memory_bytes: 68424
#include <iostream>
#include <math.h>
#include<string>
using namespace std;

int main()

{
    int n,x,k,m=10000000,s=0;
    cin>>n>>k;
   for(int i =0;i<n;i++)
       {
           cin>>x;
            if(min(x,m)==x){
            s=1;
            m=x;
           }
           else{if(m==x)s++;}
   }
   n=n-s+1;
   cout<<ceil((n-k)*1.0/(k-1))+1;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
check=[0,0,0,0,0,0,0,0]
rate=list(map(int,input().split()))
red=0
for n in range(N):
  if 1<=rate[n]<400:
    check[0]=1
  elif 400<=rate[n]<800:
    check[1]=1
  elif 800<=rate[n]<1200:
    check[2]=1
  elif 1200<=rate[n]<1600:
    check[3]=1
  elif 1600<=rate[n]<2000:
    check[4]=1
  elif 2000<=rate[n]<2400:
    check[5]=1
  elif 2400<=rate[n]<2800:
    check[6]=1
  elif 2800<=rate[n]<3200:
    check[7]=1
  else:
    red+=1
if sum(check)==0:
  M=red
  m=1
else:
  M=sum(check)+red
  m=sum(check)
print(m,M)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    char s[77];
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#define N 100

int fibonacci(int *F,int n){
  
  int i;
  
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }
  return F[n];
}

int main(void){

  int F[N]={};
  int i,j,n,x=0;

  scanf("%d",&n);
  x = fibonacci(F,n);
  printf("%d\n",x);
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << "+" << endl;
    }else if(a*b==15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n;
    cin>>n;

 	ll ans=0;
 	for(int i=1;i<n; i++) 
        ans+=(n-1)/i;
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int SumNumber(int n) {

    return (1 + n) * n / 2;

}

int numbers[200000 + 30];

int main() {

    int n;
    int k;
    
    int max_sum = 0;
    int max_index = 0;

    int now_sum = 0;

    scanf("%d %d", &n, &k);


    max_index = k - 1;

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

        numbers[i] = num;

        if(i < k) {
            max_sum += num;
            now_sum += num;
        } 
        else {
            now_sum += num;
            now_sum -= numbers[i - k];


            if(now_sum > max_sum) {
                max_sum = now_sum;
                max_index = i;


            }

        }

    }


    double answer = 0;

    for(int i = max_index; i > max_index - k; i--) {
        answer += (double)SumNumber(numbers[i]) / (double)numbers[i];
    }

    printf("%f\n", answer);

}

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

int main () {
  int N, L;
  cin >> N >> L;
  vector<string> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for (int j = 0; j < N - 1; j++) {
    int k = N;
    for (int k = 0; k < N - 1 - j; k++ ) {
      if (data.at(k)  < data.at(k + 1)) {
        string cp = data.at(k);
        data.at(k) = data.at(k + 1);
        data.at(k + 1) = cp;
      }
    }
  }
  for (int l = N - 1; l > -1; l--) {
    cout << data.at(l);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;
  int ans = 1, zero = 0;
  for (int i = 0; i < n; i++)
  {
    int foo;
    cin >> foo;
    if (foo == 0)
      zero++;

    if (zero == 0 && ans <= (1000000000000000000ll) / foo)
      ans = ans * foo;
    else
      ans = 0;
  }

  if (zero > 0)
    cout << 0;
  else
  {
    if (ans <= 0)
      cout << "-1";
    else
      cout << ans;
  }

  return 0;
}

Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

public class Main {
	static final FastIn in = new FastIn();
	static final PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] $) {
//		new Solver().solveD();
		new Solver().solveE();
		out.close();
	}
	
	private static class Solver {
		public void solveD() {
			int N = in.nextInt(), M = in.nextInt();
			List<Integer>[] adj = new List[N];
			for (int i = 0; i < N; ++i) adj[i] = new ArrayList<Integer>();
			for (int i = 0; i < M; ++i) {
				int a = in.nextInt() - 1, b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			ArrayList<Integer> individuals = new ArrayList<>();
			boolean[] visited = new boolean[N];
			for (int i = 0; i < N; ++i) {
				if (visited[i]) continue;
				ArrayList<Integer> component = new ArrayList<>();
				Stack<Integer> stack = new Stack<>();
				stack.add(i);
				while (!stack.empty()) {
					int top = stack.pop();
					if (visited[top]) continue;
					visited[top] = true;
					component.add(top);
					for (int child : adj[top]) {
						if (visited[child]) continue;
						stack.push(child);
					}
				}
				individuals.add(component.size());
			}
			int ans = individuals.stream().mapToInt(a -> a).max().orElse(0);
			out.println(ans);			
		}
	
		public void solveE() {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; ++i) {
				a[i] = in.nextInt();
			}
			int g = a[0];
			for (int x : a) {
				g = gcd(g, x);
			}
			if (g > 1) {
				out.println("not coprime");
				return;
			}
			HashSet<Integer> seen = new HashSet<>();
			for (int x : a) {
				HashSet<Integer> saw = new HashSet<>();
				while (x%2 == 0) {
					x /= 2;
					seen.add(2);
				}
				int d = 3;
				while (d * d <= x) {
					while (x % d == 0) {
						saw.add(d);
						x /= d;
					}
					d += 2;
				}
				if (x > 1)
					saw.add(x);
				for (int p : saw)
					if (seen.contains(p)) {
						out.println("setwise coprime");
						return;
					}
				seen.addAll(saw);
			}
			
			out.println("pairwise coprime");
			
		}
		
		int gcd(int a, int b) {
			while (b != 0) {
				int temp = a % b;
				a = b;
				b = temp;
			}
			return a;
		}
	}
	
	private static class FastIn {
		private BufferedReader br;
		private StringTokenizer st;
		public FastIn() {
			st = null;
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
		}
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 71472
def gcd(a,b):
    c = 0
    while b != 0:
        a,b = b,a % b
        c += 1
    return [a,c]
    
while 1:
    x,y = map(int,input().split())
    if x == 0:
        break
    
    x,y = max(x,y),min(x,y)
    print(*(gcd(x,y)))


Measured memory_bytes: 5604
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, Z, W; std::cin >> N >> Z >> W;
    std::vector<int> a(N);
    for(int i(0); i < N; ++i) std::cin >> a[i];
    int ans(std::abs(a[N-1] - W));
    if(N > 1) chmax(ans, std::abs(a[N-1] - a[N-2]));
    std::cout << ans << std::endl;
    return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

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

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

    int ans = 1;
    REP(i, k){
        if(s[i] != '1') {
            ans = s[i] - '0';
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

void min_self(int &a, int b) {
    a = min(a, b);
}

int main() {
    int n = nxt();
    int k = nxt();
    VI a(n);
    generate(all(a), nxt);
    VI memo(n, INF);
    memo[0] = 0;
    REP(i, n) {
        for (int j = i + 1; j <= min(i + k, n - 1); j++)
            min_self(memo[j], memo[i] + abs(a[j] - a[i]));
        // if (i + 2 < n) min_self(memo[i + 2], memo[i] + abs(a[i + 2] - a[i]));
    }
    printf("%d\n", memo[n - 1]);
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>

int n;
char str[200005];
int cnt[30];
long long sol;

int main(){
    scanf("%s", str);
    n=strlen(str);
    sol=(long long)n*(n-1)/2+1;
    for(int i=0;str[i];++i){
        cnt[str[i]-'a']++;
    }
    for(int i=0;i<26;++i){
        sol-=(long long)cnt[i]*(cnt[i]-1)/2;
    }
    printf("%lld", sol);
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
 
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      String s[]=line.split(" ",0);
      int n=Integer.parseInt(s[0]);
      int k=Integer.parseInt(s[1]);
      int a=n+k;
      int su=n-k;
      int m=n*k;
      int ans=a;
      if(ans<su)
        ans=su;
      if(ans<m)
        ans=m;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, M;
int D[1010], C[1010];

int dp[1010][1010];

int rec(int i, int j)
{
    if (j == N) return 0;
    if (i == M) return inf;

    int& res = dp[i][j];

    if (~res) return res;

    res = min(rec(i + 1, j), rec(i + 1, j + 1) + C[i] * D[j]);

    return res;
}

signed main()
{
    cin >> N >> M;

    rep(i, N) cin >> D[i];
    rep(i, M) cin >> C[i];

    memset(dp, -1, sizeof(dp));

    cout << rec(0, 0) << endl;
}

Measured memory_bytes: 7056
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define test int t;cin>>t; while(t--)
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
vi b_v;void bin(unsigned int n) { if (n > 1) bin(n>>1); b_v.pb(n & 1); }
int isPowerof2(int x) { return (x && !(x & x-1)); }

int32_t main(){
    boost;osit;
    int n;
    cin>>n;
    int a[n],dp[n];set0(dp);
    rep(i,0,n)cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    rep(i,2,n){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    //pa(dp);cout<<endl;
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define int long long
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 3005
#define mod 1000000007


int dp[N][N];
int a[N];

int solveDp(int index_1, int index_2) {
       if (index_1 > index_2)  return 0;
       if (dp[index_1][index_2] != -1)       return dp[index_1][index_2];

       dp[index_1][index_2] = max(a[index_1] - solveDp(index_1 + 1, index_2), a[index_2] - solveDp(index_1, index_2 - 1));
       return dp[index_1][index_2];
}

void solve() {
       pencho
       int n; cin >> n;
       for (int i = 0; i < n; i++) cin >> a[i];
       memset(dp, -1, sizeof(dp));
       for (int i = 0; i < n; i++) dp[i][i] = a[i];
       cout << solveDp(0, n - 1);
}


signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

Measured memory_bytes: 74308
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    D = int(input().strip())
    C = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    S = np.empty((D, 26), dtype=np.int32)
    for i in range(D):
        s = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
        S[i, :] = s[:]
    return D, C, S


@njit
def satisfaction(d, C, S, t, last):
    v = 0
    v += S[d, t]
    v += C[t] * ((d+1) - last[t])
    for i in range(26):
        v -= C[i] * ((d+1) - last[i])
    return v


@njit
def solve(D, C, S):
    last = np.zeros(26, dtype=np.int32)
    cumsat = 0
    for i in range(D):
        maxt = 0
        maxsat = -999999999
        for t in range(26):
            sat = satisfaction(i, C, S, t, last)
            if maxsat < sat:
                maxt = t
                maxsat = sat
        last[maxt] = i+1
        cumsat += sat
        print(maxt + 1)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 112000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n ,k;
    cin >> n >> k;
    vector <int> v(n);
    for(int i =0;i<n;i++)cin >> v[i];
    vector <bool> dp(k+1);
    for(int stones = 0;stones<=k;stones++){
        for(int i =0;i<n;i++){
            if(stones>=v[i] && !dp[stones-v[i]]){
                dp[stones] = true;
            }
        }
    }
    puts(dp[k]?"First" : "Second");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define endl '\n'

using namespace std;

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

	long long n, k;

	cin >> n >> k;

	cout << min(n % k, k - (n % k)) << endl;

	return 0;
}

Measured memory_bytes: 256
int main(){
    
    char num[1000];
    char ans[1000];
    char fun[20];
    int i,j,q;
    int a,b;
    char t;

    scanf("%s",num);
    scanf("%d",&q);
    
    for(i=0;i<q;i++){
      scanf("%s",fun);
        if(strcmp(fun,"print")==0){
            scanf("%d %d",&a,&b);
            for (j=a; j<b+1; j++) {
                printf("%c",num[j]);
            }
            printf("\n");
            
        }else if(strcmp(fun,"replace")==0){
            scanf("%d %d %s",&a,&b,ans);
            for (j=0; j<b-a+1; j++) {
                num[a+j]=ans[j];
            }
        }else if(strcmp(fun, "reverse")==0){
            scanf("%d %d",&a,&b);
            while(a<b){
                t=num[a];
                num[a]=num[b];
                num[b]=t;
                a++;
                b--;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
  double a,b,x,h,t,pi,res;
  pi=acos(-1.0);
  cin >> a >> b >> x;
  h=a*a*b*0.5;
  if(x>h){
    t=2*(a*a*b-x)/(a*a);
    res=atan2(t,a)*180/pi;
  }else{
    t=2*x/(a*b);
    res=atan2(b,t)*180/pi;
  }
  cout << setprecision(10) << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long k,a,b;
int main()
{
	cin>>k>>a>>b;
	if(b<=a||k<=a)
	{
		cout<<1+k;
	}
	else
	{
		long long ex=(k-a+1)/2;
		long long bout=k-2*ex;
		cout<<max(1+k,1+bout+ex*(b-a));
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = len(s);
  int ans = 1000;
  rep(i,0,n-2) {
    ans = min(ans,abs(stoi(s.substr(i,3)) - 753));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[100100];
int q;
ll b[100100], c[100100];

void solve() {
    map<ll, ll> m;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        m[a[i]]++;
        sum += a[i];
    }

    for (int i = 0; i < q; i++) {
        if (m[b[i]] > 0){
            sum += (c[i] - b[i]) * m[b[i]];
            m[c[i]] += m[b[i]];
            m[b[i]] = 0;
        }
        cout << sum << endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    for (int i = 0; i < q; i++) cin >> b[i] >> c[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 11700
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll a[N];
    ll count[100002];
    rep(i, 100002){
        count[i] = 0;
    }
    rep(i, N){
        cin >> a[i];
        count[a[i]]++;
    }
    sort(a, a + N);

    ll counter;
    ll countMax = 0;
    ll check;
    rep(i, N){
        check = a[i];
        counter = 0;
        counter += count[check];
        if(check > 0){
            counter += count[check - 1];
        }
        counter += count[check + 1];//cout << "i: " << i << ", counter: " << counter << endl;
        if(counter > countMax){
            countMax = counter;
        }
    }

    cout << countMax << endl;
    
    return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define oo 36005
using namespace std;
int n, m, mat[16][16], ans;
int dp[oo][16], lim, val[oo];
int main ()
{
    scanf("%d%d", &n, &m);
    lim = (1 << n) - 1;
    for(int i = 1, x, y, z; i <= m; ++ i)
    {
        scanf("%d%d%d", &x, &y, &z);
        mat[x][y] = mat[y][x] = z; ans += z;
    }
    memset(dp, -63, sizeof dp);
    dp[1][1] = 0;
    for(int S = 1; S <= lim; ++ S)
    for(int i = 1; i <= n; ++ i)
    if(!((1 << i - 1) & S))
    {
        int tmp = 0;
        for(int j = 1; j <= n; ++ j)
        if((1 << j - 1) & S) tmp += mat[i][j];
        val[S | (1 << i - 1)] = val[S] + tmp;
    }
    for(int S = 1; S <= lim; ++ S)
    {
        for(int u = 1; u <= n; ++ u)
        if((1 << u - 1) & S)
        for(int v = 1; v <= n; ++ v)
        if(!((1 << v - 1) & S) && mat[u][v])
        dp[S | (1 << v - 1)][v] = max(dp[S | (1 << v - 1)][v], dp[S][u] + mat[u][v]);
        for(int B = S ^ lim; B; B = B - 1 & (S ^ lim))
        for(int x = 1; x <= n; ++ x)
        if((1 << x - 1) & S) dp[S | B][x] = max(dp[S | B][x], dp[S][x] + val[B | (1 << x - 1)]);
    }
    printf("%d", ans - dp[lim][n]); return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct Info{
    int num;
    int count;
};

int main(){
    int n, m;
    while(cin >> n >> m, n||m){
        Info v[105];
        rep(i,105){
            v[i].num = i + 1;
            v[i].count = 0;
        }
        rep(i,n){
            rep(j,m){
                bool inp;
                cin >> inp;
                if(inp)
                    v[j].count++;
            }
        }
        rep(i,m){
            rep(j,m - 1){
                if(v[j].count < v[j + 1].count){
                    Info c = v[j]; v[j] = v[j + 1]; v[j + 1] = c;
                }
            }
        }
        rep(i,m){
            if(i) cout << ' ';
            cout << v[i].num;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1160