akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)






int main()
{
	int n;
	cin >> n;
	int i;
	int d[100];

	rep(i, 0, n) scanf("%d", &d[i]);

	int j;
	int Ans = 0;

	for (j = 0; j < n - 1; j++) {
		for (i = j + 1; i < n;i++) {
			Ans += (d[j] * d[i]);
			
		}
	}


	cout << Ans << endl;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

void DEAD(){
    cout << "No" << endl;
    exit(0);
}
int cnt[3];
ii cmd[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,3) cin >> cnt[i];
    REP (i,n) {
        string s;
        cin >> s;
        cmd[i].X = s[0]-'A';
        cmd[i].Y = s[1]-'A';
    }
    REP (i,n) {
        if (cnt[cmd[i].X] > cnt[cmd[i].Y]) swap(cmd[i].X,cmd[i].Y);
        else if (cnt[cmd[i].X] == cnt[cmd[i].Y]) {
            if (i != n-1 && (cmd[i].Y == cmd[i+1].X || cmd[i].Y == cmd[i+1].Y)) swap(cmd[i].X,cmd[i].Y);
        }
        if (!cnt[cmd[i].Y]) DEAD();
        cnt[cmd[i].X]++, cnt[cmd[i].Y]--;
    }
    cout << "Yes" << endl;
    REP (i,n) {
        cout << char('A' + cmd[i].X) << endl;
    }
}


Measured memory_bytes: 4360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

// 1-indexed
template<typename T>
class BIT {
public:
    explicit BIT(int n) : N(calcN_(n)), mVal(calcN_(n)+1, 0) {}
    void add(int idx, T val){
        for(int x=idx;x<=N;x+=x&-x) mVal[x] += val;
    }
    T sum(int idx){
        T res = 0;
        for(int x=idx;x>0;x-=x&-x) res += mVal[x];
        return res;
    }
    void clean(){
        fill(mVal.begin(), mVal.end(), 0);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    const int N;
    vector<T> mVal; 
};

int main(){
    int N;
    while(cin >> N){
        vector<vector<int>> lines(N, vector<int>(3));
        for(auto& v : lines) cin >> v[0] >> v[1] >> v[2];
        double res[2];
        for(int i=0;i<2;i++){
            sort(lines.begin(), lines.end(), [](const vector<int>& a, const vector<int>& b){ return (double)a[0]/a[1] < (double)b[0]/b[1]; });
            double L = -1e10, R = 1e10;
            vector<int> v(N);
            auto val = [](const vector<int>& l, double x){ return ((double)l[2] - x * l[0])/l[1]; };
            for(int i=0;i<N;i++) v[i] = i;
            BIT<int> bit(N);
            long long thr = (N*(N-1LL)/2+1)/2;
            for(int _=0;_<200;_++){
                bit.clean();
                double mid = 0.5*(L+R);
                sort(v.begin(), v.end(), [&](int a, int b){ return val(lines[a], mid) < val(lines[b], mid); });
                long long cnt = 0;
                for(int i=N-1;i>=0;i--){
                    cnt += bit.sum(v[i]+1);
                    bit.add(v[i]+1, 1);
                }
                if(cnt < thr) L = mid;
                else R = mid;
            }
            res[i] = 0.5*(L+R);
            for(auto& v : lines) swap(v[0], v[1]);
        }
        printf("%.10lf %.10lf\n", res[0], res[1]);
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string s; cin >> s;
  multiset<char> ms{s.begin(), s.end()};

  int a = ms.count('a');
  int b = ms.count('b');
  int c = ms.count('c');
  set<int> st = {a, b, c};
  auto ans = st.size() == 1 || (st.size() == 2 && (std::abs(*st.begin() - *(std::next(st.begin()))) == 1));
  cout << (ans ? "YES" : "NO") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 5072
import java.util.*;

public final class Main {


    static int N;

    static int[] array;

    public static void main(String[] args) {


        Scanner s = new Scanner(System.in);

        array = new int['z' - ('a' -1)];

        N = s.nextInt();

        String first[] = s.next().split("");

        for (int j = 0; j < first.length; j++) {

            char k  = first[j].charAt(0);

            array[k - 'a']++;

        }
        for (int i = 1; i < N; i++) {

            int[] now = new int[array.length];

            String line[] =  s.next().split("");

            for (int j = 0; j < line.length; j++) {

                char k  = line[j].charAt(0);

                if (array[k-'a'] > 0) {

                    array[k-'a']--;

                    now[k-'a']++;
                }
            }

            array = now;
        }

        for (int i = 0; i < array.length; i++) {

            char k = (char) (i+ 'a');

            for (int j = 0; j < array[i]; j++) {

                System.out.print(k);
            }
        }
    }




}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define umap unordered_map
#define uset unordered_set
#define frw(i, a, b) for(int i = a; i < b; i++)
#define bck(i, a, b) for(int i = a; i > b; i--)
#define fi first
#define se second
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpll vector<pll>
#define vpii vector<pii>

const int N = 1e5 + 5;

string a, b;
vector<vi> dp;

int rec(int n1, int n2){
	if(n1 == 0 or n2 == 0)	return dp[n1][n2] = 0;
	int &aux = dp[n1][n2];
	if(aux != -1)	return aux;
	aux = 0;
	if(a[n1 - 1] == b[n2 - 1])	return aux = 1 + rec(n1 - 1, n2 - 1);
	return aux = max(rec(n1 - 1, n2), rec(n1, n2 - 1));
}

int main(){
	ios::sync_with_stdio(0);
	cin >> a >> b;
	dp.assign(sz(a) + 1, vi (sz(b) + 1, -1));
	rec(sz(a), sz(b));
	string ans;
	int n1 = sz(a), n2 = sz(b);
	while(n1 and n2){
		if(a[n1 - 1] == b[n2 - 1])	ans += a[n1 - 1], n1--, n2--;	else
		if(dp[n1 - 1][n2] > dp[n1][n2 - 1])	n1--;
		else	n2--;
	}
	reverse(all(ans));
	cout << ans;
}

Measured memory_bytes: 36096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll r, d, x;
  cin >> r >> d >> x;
  rep(i, 10) { 
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();


    if (A == B && B == C ) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } 
    

  }

}


Measured memory_bytes: 22228
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys
import io
import re
import math
import itertools
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
#start = time.clock()
l=map(int,raw_input().split())
n=int(raw_input())
ans=chk=0


def rolling(word,dice):
    if word=='S':
        dice[0],dice[1],dice[5],dice[4]=dice[4],dice[0],dice[1],dice[5]
    elif word=='N':
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    elif word=='W':
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    else:
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    return dice

def face(x,y,dice):
    if (x==dice[5] and y==dice[4])or(x==dice[4] and y==dice[0])or(x==dice[0] and y==dice[1])or(x==dice[1] and y==dice[5]):
        return dice[2]
    elif (x==dice[0] and y==dice[2])or(x==dice[2] and y==dice[5])or(x==dice[5] and y==dice[3])or(x==dice[3] and y==dice[0]):
        return dice[4]
    elif (y==dice[5] and x==dice[4])or(y==dice[4] and x==dice[0])or(y==dice[0] and x==dice[1])or(y==dice[1] and x==dice[5]):
        return dice[3]
    elif (y==dice[0] and x==dice[2])or(y==dice[2] and x==dice[5])or(y==dice[5] and x==dice[3])or(y==dice[3] and x==dice[0]):
        return dice[1]
    elif (x==dice[2] and y==dice[1])or(x==dice[1] and y==dice[3])or(x==dice[3] and y==dice[4])or(x==dice[4] and y==dice[2]):
        return dice[5]
    else:
        return dice[0]
        

for i in range(n):
    a,b=map(int,raw_input().split())
    print face(a,b,l)

Measured memory_bytes: 4844
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int H, W, A, B;
        cin >> H >> W >> A >> B;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if ((i < B) ^ (j < A)) {
                    cout << 0;
                } else {
                    cout << 1;
                }
            }
            cout << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
using namespace std;
int main(){
        string search,old;
        int n,counter=0;
        cin >> n >> search;
        for(int i=0 ; i<n ; i++ ){
                cin >> old;
                int points[100],points_counter=0,point=-1;
                while(true){
                        point=old.find(search[0],point+1);
                        if(point==-1)
                                break;
                        else{
                                points[points_counter]=point;
                                points_counter++;
                        }
                }
                int interval=1;
                for( int interval=1 ; interval<old.size() ; interval++ ){
                for( int j=0 ; j<points_counter ; j++ ){
                        string tmp="";
                        for( int l=points[j] ; l<old.size() ; l+=interval){
                                tmp+=old[l];
                                if(tmp.size()==search.size())
                                        break;
                        }
                        if(tmp==search){
                                counter++;
                                interval = j =1000000;
                                break;
                        }
                }
                }
        }
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 5050, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string s, t;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, x;
	cin >> n >> x;
	n = 2*n-1;
	if(x == 1 || x == n) return cout << "No", 0;
	set<int> a;
	cout << "Yes\n";
	for(int i = 1; i <= n; i++) if(abs(x-i) > 1) a.insert(i);
	for(int i = 0; i < n; i++) {
		if(abs((n/2)-i) < 2) cout << x + ((n/2)-i) << "\n";
		else {
			cout << *a.begin() << '\n';
			a.erase(a.begin());
		}
	}
	
}


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

using namespace std;

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

  int N; cin>>N;
  vector<int> L(N); for (auto& l : L) cin>>l;

  sort(L.begin(), L.end());
  long ans = 0;
  for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
    int a = L[i], b=L[j];
    int d = b - a, u = b + a;
    int sum = lower_bound(L.begin(), L.end(), u) - (L.begin()+j) - 1;
    ans += max(sum, 0);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    int x,y;
    cin >> x >> y;
    bool ans = (x*2)<=y && y<=(x*4) && y%2==0;
    print(ans?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3632
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<string> cur;
    vector<string> nxt;
    cur.push_back("a");

    for (int i = 1; i < n; ++i) {
        nxt.clear();
        for (auto& s : cur) {
            char mx = 'a';
            for (auto c : s) {
                mx = max(mx, c);
            }

            for (char ch = 'a'; ch <= mx + 1; ++ch) {
                string t = s;
                t += ch;
                nxt.push_back(t);
            }
        }
        swap(cur, nxt);
    }

    for (auto s : cur) {
        cout << s << '\n';
    }

    return 0;
}

Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> whi(n + 1, 0);
  vector<int> bla(n + 1, 0);
  rep(i, n) {
    if (s[i] == '.')
      whi[i + 1] += whi[i] + 1;
    else
      whi[i + 1] += whi[i];
    if (s[i] == '#')
      bla[i + 1] += bla[i] + 1;
    else
      bla[i + 1] += bla[i];
  }
  ll res = INF;
  for (int left = 0; left <= n; left++) {
    ll now = 0;
    now += bla[left] - bla[0];
    now += whi[n] - whi[left];
    res = min(res, now);
  }
  cout << res << endl;
}

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

bool pal(int x){
    int a,b,c,d,e;
    a = x%10; x /= 10;
    b = x%10; x /= 10;
    c = x%10; x /= 10;
    d = x%10; x /= 10;
    e = x%10; x /= 10;
    if(a != e)
        return false;
    else if(b != d)
        return false;
    else
        return true;
}

int main(){
    int A,B; cin>>A>>B;
    int count = 0;
    for(int i=A; i <= B; i++){
        if(pal(i))
            count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int N;
  cin >> N;
  vpr L, R;
  vector<string> vec(N);
  rep(i, N) {
    string s;
    cin >> s;
    vec[i] = s;
    int sz = s.size();
    int maxl = 0, maxr = 0, l = 0, r = 0;
    rep(j, sz) {
      if(s[j] == ')') l++;
      else l--;
      chmax(maxl, l);
      if(s[sz-j-1] == '(') r++;
      else r--;
      chmax(maxr, r);
    }
    if(maxl <= maxr) L.push_back(make_pair(maxl, i));
    else R.push_back(make_pair(maxr, i));
  }
  sort(ALL(L), less<pair<ll, ll>>());
  sort(ALL(R), greater<pair<ll, ll>>());
  copy(ALL(R), back_inserter(L));
  int cnt = 0;
  for(auto& l : L) {
    int sz = vec[l.second].size();
    rep(j, sz) {
      if(vec[l.second][j] == '(') cnt++;
      else cnt--;
      if(cnt < 0) {
        cout << "No\n";
        return;
      }
    }
  }
  if(cnt == 0) cout << "Yes\n";
  else cout << "No\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 58716
//
// ABC171D
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.IO.Pipes;

namespace AtCoder
{
    class ABC171D
    {
        static void Main(string[] args)
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }
        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var An = Console.ReadLine().Split(' ').Select(_inputStr => long.Parse(_inputStr)).ToArray();
            var Q = int.Parse(Console.ReadLine());

            //それぞれの要素が現れる数をカウント
            var countList = new long[100001];//1つ多めにして[0]を使わないでおくと、indexのずれをなくせる
            foreach(var a in An)
            {
                countList[a]++;
            }

            //前の総和から、入れ替えた場合の総和を求める
            var ans = An.Sum();
            for(int i = 0; i < Q; ++i) {
                var BC = Console.ReadLine().Split(' ').Select(_inputStr => long.Parse(_inputStr)).ToArray();
                long B = BC[0];
                long C = BC[1];
                //入れ替え前に値がBだった要素の数
                long BCountInPrev = countList[B];
                //総和を前回からの差分で計算
                ans += (C - B) * BCountInPrev;

                //要素の個数を更新
                //Bが全部Cになったので
                countList[C] += BCountInPrev;
                countList[B] = 0;//Bだったものはなくなった

                Console.WriteLine(ans);
            }
        }
    }
}



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


int n;
string s;

#define MAX 100002
char buf[MAX];

int ans[MAX];


int main(){
	cin >> n;
	scanf("%s", buf);
	s = buf;
	for (ans[0] = 0; ans[0] <= 1; ans[0]++){
		for (ans[1] = 0; ans[1] <= 1; ans[1]++){
			for (int i = 1; i+1 < n; i++){
				int pr = ans[(n - 1 + i) % n];
				if (ans[i] == 1){
					int go = pr;
					if (s[i] == 'x'){
						go ^= 1;
					}
					ans[i + 1] = go;
				}
				else{
					int go = pr;
					if (s[i] == 'o'){
						go ^= 1;
					}
					ans[i + 1] = go;
				}
			}
			bool ok = false;
			for (int i = 0; i < n; i++){
				int pr = ans[(n - 1 + i) % n];
				int go = ans[(i + 1) % n];
				int k = (pr == go);
				if (ans[i] == 0){
					k ^= 1;
				}
				if (k == 1 && s[i] == 'x'){
					ok = true;
				}
				if (k == 0 && s[i] == 'o'){
					ok = true;
				}
			}
			if (ok == false){
				for (int i = 0; i < n; i++){
					if (ans[i] == 1){
						printf("S");
					}
					else{
						printf("W");
					}
				}
				puts("");
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int k; cin>>k;
    if(k%2==0){
        cout << -1;
        return 0;
    }
    int x = 0;
    for(int i = 1;i<=1000000;++i){
        x = ((x*10) + 7)%k;
        if(x == 0){
            cout << i;
            return 0;
        }
    }
    cout << -1;
   
    
    return 0;
}
    

// Химаншу


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b){
    if(a == 0){
      return b;
    }
    if (b ==0){
      return a;
    }
    if(a==b){
      return a;
    }
    if(a>b){
      return gcd(a-b, b);
    }else{
      return gcd(b-a, a);
    }
}
 
int main(){
    LL a, b;
    LL ans = 0;
    cin >> a >> b;
 
    const LL C = gcd(a, b);
    LL c = C;
 
    for(int i = 2;i < sqrt(C);i++){
        if(c % i == 0){
            ans++;
            while(c % i == 0){
              c /= i;
            }
        }
    }
    if(c != 1)ans++;
    cout << ans + 1;
}

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

char a[m][15];

int getChar(char ch){
  if(ch=='A')return 1;
  if(ch=='C')return 2;
  if(ch=='G')return 3;
  if(ch=='T')return 4;
}
ll getKey(char str[]){
  ll sum=0,p=1;
  rep(i,strlen(str)){
    sum+=p*getChar(str[i]);
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%m;
}
int h2(int key){
  return 1+(key%(m-1)); //1足さなかったらゼロになって移動させられないかもしれない
}

int find(char str[]){
  ll key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%m;
    if(strcmp(a[h],str)==0)return 1;
    else if(strlen(a[h])==0)return 0;
  }
  return 0;
}
int insert(char str[]){
  ll key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+h2(key)*i)%m;
    if(strcmp(a[h],str)==0)return 1;
    else if(strlen(a[h])==0){
      strcpy(a[h],str);
      return 0;
    }
  }
  return 0;
}



int main(){
  int n;
  cin>>n;
  rep(i,m){a[i][0]='\0';}
  rep(i,n){
    char s[10],b[14];
    scanf("%s %s",s,b);
    if(s[0]=='i')insert(b);
    else if(s[0]=='f'){
      if(find(b))printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 18484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;
int K;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s >> K;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a') continue;
    int cost = ('z' - s[i]) + 1;
    if (K < cost) continue;
    s[i] = 'a';
    K -= cost;
  }  
  s.back() = ((s.back() - 'a') + K) % 26 + 'a';
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll d[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(y, h) {
        rep(x, w) {
            if (s[y][x] != '#') continue;
            int cnt = 0;
            rep(i, 4) {
                ll nx = x + d[i][0];
                ll ny = y + d[i][1];
                if ((nx < 0) || (nx >= w) || (ny < 0) || (ny >= h)) continue;
                if (s[ny][nx] == '#') cnt++;
            }
            if (cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
l = list(map(int, input()))
l_zero = [0]*len(l)
l_one = [0]*len(l)
    
for i in range(len(l)):
    if i%2 == 0 or i == 0:
        pass
    else:
        l_zero[i] = 1
    
for i in range(len(l)):
    if i%2 == 0 or i == 0:
        l_one[i] = 1
    else:
        pass
    
# print(l_zero)
# print(l_one)

cnt_zero = 0
for n in range(len(l)):
    if l[n] == l_zero[n]:
        cnt_zero += 1
    else:
        pass
    
cnt_one = 0
for n in range(len(l)):
    if l[n] == l_one[n]:
        cnt_one += 1
    else:
        pass

rlt = 0
if cnt_zero < cnt_one:
    rlt = cnt_zero
elif cnt_one < cnt_zero:
    rlt = cnt_one
else:
    rlt = cnt_zero

print(rlt)

Measured memory_bytes: 5536
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)


int a[101][101];
int main() {

	int H, W, N; cin >> H >> W >> N;

	vector<int> cnt(N);

	for (int i = 0; i < N; i++) {
		cin >> cnt[i];
	}

	int x = 0;
	int y = 0;

	//色の種類のループ
	for (int i = 0; i < N; i++) {

		//指定された数だけ塗る。
		for (int j = 0; j < cnt[i]; j++) {
			a[y][x] = i + 1;

			//偶数行は右にいく。端にぶつかったら下へ
			if (y%2==0) {
				if (x == W-1)y++;
				else x++;
			}
			else {

				if (x == 0)y++;
				else x--;
			}

		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << a[i][j];

			if (j != W - 1) {
				cout << " ";
			}
			
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)
for i in range(M):
    print(sum(T)-T[P[i]-1]+X[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  int H,A;
  cin>>H>>A;
  //出力
  int ans=0;
  while(H>0){
    H-=A;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<int, int>> p(a);
    int in;
    rep(i, a) {
        cin >> in;
        p[i] = make_pair(in, 0);
    }
    vector<pair<int, int>> q(b);
    rep(i, b) {
        cin >> in;
        q[i] = make_pair(in, 1);
    }
    vector<pair<int, int>> r(c);
    rep(i, c) {
        cin >> in;
        r[i] = make_pair(in, 2);
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    vector<pair<int, int>> vec;
    vector<pair<int, int>> v;
    merge(p.begin(), p.end(), q.begin(), q.end(), back_inserter(v));
    merge(v.begin(), v.end(), r.begin(), r.end(), back_inserter(vec));
    reverse(vec.begin(), vec.end());
    int xcn = 0;
    int ycn = 0;
    int mcn = 0;
    int i = 0;
    ll sum = 0;
    while (true) {
        if (mcn + ycn + xcn == x + y)
            break;
        else if (vec[i].second == 0 && xcn < x) {
            sum += vec[i].first;
            xcn++;
        }
        else if (vec[i].second == 1 && ycn < y) {
            sum += vec[i].first;
            ycn++;
        }
        else if (vec[i].second == 2 && mcn + ycn + xcn < x + y) {
            sum += vec[i].first;
            mcn++;
        }
        i++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 10352
A, B, C, X, Y = map(int, input().split())
if A+B < 2*C:
    print(A*X+B*Y)
else:
    low = min(X,Y)
    high = max(X,Y)
    if C*(high-low)*2<=A*(X-low)+B*(Y-low):
        print(C*high*2)
    else:
        print(C*low*2+A*(X-low)+B*(Y-low))

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

int main() {
	int M, K;
	scanf("%d %d", &M, &K);
	
	if(K >= pow(2, M)) {
		printf("-1");
	} else if(M == 0) {
		printf("0 0");
	} else if(M == 1) {
		if(K == 1) printf("-1");
		else printf("0 0 1 1");
	} else {
		for(int i = 0; i < pow(2, M); i++) if(i != K) printf("%d ", i);
		printf("%d ", K);
		for(int i = pow(2, M)-1; i >= 0; i--) if(i != K) printf("%d ", i);
		printf("%d", K);
	}
	
	return 0;
}

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

using namespace std;

#define int long long

#define  mod 1000000007
#define  N   10005
#define  inf 1e18

int a[N];
vector < int > primes;

void foo()
{
        for(int i=2;i<N;i++)
        {
                if(!a[i])
                {
                        primes.push_back(i);
                        for(int j=2*i; j<N; j+=i)
                                a[j] = 1;
                }
        }
}

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

        int n;
        cin>>n;

        vector < int > a(n);

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

        foo();

        map < int , int > pp;

        for(int i=1;i<=100000;i++)
        {
                pp[i*i]=i;
        }


        map < __int128_t , __int128_t > me;
        int flag = 0;
        int ans = 0;

        vector < pair < __int128_t , __int128_t > > arr;

        for(int i=0;i<n;i++)
        {
                int cur = a[i];
                __int128_t opp = 1;
                __int128_t red = 1;
                for(int j=0;j<primes.size();j++)
                {
                        __int128_t curp = primes[j];
                        int count = 0;
                
                        while(cur%curp==0)
                        {
                                cur/=curp;
                                count++;
                        }
                        count%=3;
                        if(count==1)
                        {
                                opp*=curp*curp;
                                red*=curp;
                        }
                        else if(count==2)
                        {
                                opp*=curp;
                                red*=curp*curp;
                        }
                }
                red*=cur;
                
                
                if(pp.find(cur)!=pp.end())
                {
                        opp*= pp[cur];
                }
                else if(cur <= 100000)
                {
                        opp*= cur*cur;
                }
                else
                {
                        ans++;
                        continue;
                }
                
                me[red]++;
                arr.push_back({red, opp});
                
        }

        sort(arr.begin(), arr.end());
        arr.erase( unique( arr.begin(), arr.end() ), arr.end() );


        for(int i=0; i<arr.size();i++)
        {
                if(arr[i].first==1)
                        ans++;
                else
                        ans+= max(me[arr[i].first], me[arr[i].second]);
                me[arr[i].first] =0;
                me[arr[i].second] =0;
        }       
        cout<<ans<<endl;

        return 0;
}



Measured memory_bytes: 23404
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;


int n,A[1000000];


int binarySearch(int key){
	int left =0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==A[mid]) return 1;
		if(key>A[mid]) left= mid+1;
		else if(key<A[mid]) right = mid;
	}
	return 0;
}


int main() {
	cin>>n;
	Rep(i,n) cin>>A[i];
	int q;
	cin>>q;
	int sum=0;
	Rep(i,q){
		int key;
		cin>>key;
		sum += binarySearch(key);
	}
	cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 3480
#include<cstdio>
#define N 2005
using namespace std;
const int P=998244353,__=4000;
inline int In(){
	char c=getchar(); int x=0,ft=1;
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ft=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return x*ft;
}
int K,n,ans[N],fac[N*2],inv[N*2];
inline int power(int x,int k){
	int s=1,t=x;
	for(;k;k>>=1,t=1ll*t*t%P) if(k&1) s=1ll*s*t%P;
	return s;
}
inline int C(int m,int n){
	return 1ll*fac[m]*inv[n]%P*inv[m-n]%P;
}
int main(){
	K=In(); n=In();
	fac[0]=1; for(int i=1;i<=__;++i) fac[i]=1ll*fac[i-1]*(i)%P;
	inv[__]=power(fac[__],P-2); for(int i=__-1;~i;--i) inv[i]=1ll*inv[i+1]*(i+1)%P;
	for(int i=2,t;i<=K+1;++i){
		t=i/2;
		for(int j=0,d=1;2*j<=n&&j<=t;++j,d=P-d)
		(ans[i]+=1ll*d*C(t,j)%P*C(n-2*j+K-1,K-1)%P)%=P;
		printf("%d\n",ans[i]);
	}
	for(int i=K;i>=2;--i) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   ll n;
           cin>>n;
           ll A=1,B=1,C=1;
           if(n%2==0){
            A=B=n;
             C=n/2;
           }
           else{
             //a,b固定
             /*
             4abc=n(ab+bc+ca)
             (4ab-nb-na)c=nab
             c=nab/(4ab-na-nb);
             */
             for(int a=1;a<=3500;a++){
               for(int b=a;b<=3500;b++){
              // if(a==3&&b==2)cout<<(n*a*b)%(4*a*b-n*a-n*b)<<endl;
                if((4*a*b-n*a-n*b)>0&&(n*a*b)%(4*a*b-n*a-n*b)==0){
                 C= (n*a*b)/(4*a*b-n*a-n*b);
                  A=a;
                  B=b;
                  cout<<A<<" "<<B<<" "<<C<<endl;
                  return 0;
                }
               }
             }
           }
           cout<<A<<" "<<B<<" "<<C<<endl;
           
}



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

int main()
{
    int n, T;
    cin >> n >> T;
    int ans = 1e9;
    rep(i, n)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T)
            ans = min(ans, c);
    }
    if (ans != 1e9)
        cout << ans << endl;
    else
        cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
int main() {
	ll N, K;
	cin >> N >> K;
	printf("%lld\n", K * power(K - 1, N - 1));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
   public static void main(String[] argv){
      int A, B, C, D;
      
      Scanner stdIn = new Scanner(System.in);
      A = stdIn.nextInt();
      B = stdIn.nextInt();
      C = stdIn.nextInt();
      D = stdIn.nextInt();
      
      if(B<=C){
         System.out.print(0);
      }else if(A<C&&C<B&&B<D){
         System.out.print(B-C);
      }else if(A<=C&&D<=B){
         System.out.print(D-C);
      }else if(D<=A){
         System.out.print(0);
      }else if(C<A&&A<D&&D<B){
         System.out.print(D-A);
      }else if(C<=A&&B<=D){
         System.out.print(B-A);
      }
   }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,(int)v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define Endl cout << endl
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);

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

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	string s;
	ll cnt=0;
	cin >> s;
	rep(i,SIZE(s)/2){
		if(s[i]!=s[SIZE(s)-1-i]) cnt++;
	}
	cout << cnt << endl;
    return 0;
}


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

using namespace std;

void Main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    }
    else if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3524
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    string s;
    cin >> s;
    int temp = -1e8;
    REP(i, s.size() - 2){
        string t = s.substr(i, 3);
        int tmp = stoi(t);
        if(abs(753 - temp) > abs(753 - tmp)){
            temp = tmp;
        }
    }
    cout << abs(753 - temp) << endl;
}


Measured memory_bytes: 256