akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>

#define ll long long

using namespace std;

void solve() {
    ll n;
    cin >> n;
    ll res = 0;

    for(ll i = 1; i <= n; i++) {
        ll j = n / i;
        res += i * (j * (j + 1)) / 2;
    }
    cout << res << endl;
}

int main() {
    
    // int T;
    // cin >> T;
    // while(T--) {
        // solve();
    // }
    solve();
    
    return 0;
};


Measured memory_bytes: 3588
<?php

$input = trim(fgets(STDIN));
$x =1;

while($input!== '0'){
	if(1<= $input &&  $input<= 10000 ){
 echo ("Case ".$x.":"." ");	
 echo  ($input). PHP_EOL;
$input = trim(fgets(STDIN));
$x++;
 }
}

exit;
?>	

Measured memory_bytes: 15196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n,maxw;cin>>n>>maxw;
    vector<int>pr(n),we(n);
    rep(i,n)cin>>pr[i]>>we[i];
    vector<vector<int>>dp(n+1,(vector<int>(maxw+1,-1)));
    dp.at(0).at(0)=0;
    rep(i,n){
        rep(j,maxw+1){
            if(dp.at(i).at(j)!=-1){
                dp.at(i+1).at(j)=max(dp.at(i+1).at(j),dp.at(i).at(j));
                if(j+we.at(i)<=maxw)dp.at(i+1).at(j+we.at(i))=max(dp.at(i).at(j)+pr.at(i),dp.at(i).at(j+we.at(i)));
            }
        }
    }
    int ans=0;
    rep(i,maxw+1){
        ans=max(ans,dp.at(n).at(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6860
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

const int PENALTY_TIME = 1200;
struct Team{
	Team(int quesNum) : acceptCnt(0), penalty(0) {
		wrongCnt.resize(quesNum, 0);
	}
	int id;
	int acceptCnt;
	int penalty;
	vector<int> wrongCnt;
};

bool TeamLess(const Team& t1, const Team& t2) {
	if (t1.acceptCnt != t2.acceptCnt) {
		return t1.acceptCnt < t2.acceptCnt;
	}
	if (t1.penalty != t2.penalty) {
		return t1.penalty > t2.penalty;
	}
	return t1.id > t2.id;
}


int main(void) {
	int teamNum, quesNum, recordNum;
	while (cin >> teamNum >> quesNum >> recordNum, teamNum) {
		vector<Team> teams(teamNum, quesNum);
		for (int i = 0; i < teamNum; i++) {
			teams[i].id = i + 1;
		}

		int tID, qID, time;
		string mes;
		for (int i = 0; i < recordNum; i++) {
			cin >> tID >> qID >> time >> mes;
			tID--; qID--;
			if (mes == "CORRECT") {
				teams[tID].acceptCnt++;
				teams[tID].penalty += teams[tID].wrongCnt[qID] * PENALTY_TIME + time;
			}else {
				teams[tID].wrongCnt[qID]++;
			}
		}

		sort(teams.rbegin(), teams.rend(), TeamLess);

		for (int i = 0; i < teams.size(); i++) {
			printf("%d %d %d\n",
				teams[i].id, teams[i].acceptCnt, teams[i].penalty);
		}
	}

	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t lint;
int main(){
    lint a, b;
    cin >> a >> b;
    lint m = 3000;
    lint e = min(b , a + 2019);
    for (lint i = a ; i <= e - 1 ; i ++)
        for(lint j = i + 1 ; j <= e ; j ++)
            m = min(m, i * j % 2019);
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int H, W;
	cin >> H >> W;

	vector<string> grid(H);
	rep(i, H) cin >> grid[i];

	vector<int> column_mark(W);
	vector<int> row_mark(H);

	rep(i, H) {
		if (grid[i].find("#") != string::npos) {
			row_mark[i] = 1;
		}
	}

	rep(i, W) {
		rep(j, H) {
			if (grid[j][i] == '#') {
				column_mark[i] = 1;
				break;
			}
		}
	}

	rep(i, H) {
		rep(j, W) {
			if (row_mark[i] and column_mark[j]) {
				cout << grid[i][j];
			}
		}
		if (row_mark[i]) {
			cout << endl;
		}
	}
}


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

int main(){
  int n;
  cin >>n;
  ll sum = 0;
  for(int i = 1; i<=n; i++){
    if(i%3!=0 && i%5!=0) sum+=i;
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l;
      l--;
      s[i].push_back(l);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  ll ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool flg = true;
    for (int j = 0; j < m; ++j) {
      int con = 0;
      for (auto x : s[j])
        if (i & (1 << x)) con++;
      if (con % 2 != p[j]) flg = false;
    }
    if (flg) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	int x, t;
	cin >> x >> t;
	if(x-t > 0) cout << x-t << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
*P, = map(int, input().split())

ans = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
if P[n-1] == n:
    ans += 1
print(ans)

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int x;
    cin >> x;
    vector<bool> f(x+1, false);
    f[1]=true;
    for(int i=2; i*i<=x; i++){
        int t = i;
        while(t*i<=x){ f[t*i] = true; t*=i;}
    }

    for(int i=x; i>0; i--)
        if(f[i]){cout << i << endl; break;}
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	int a[n], b[n], c[n];
  	for (int i = 0; i < n; i++) cin >> a[i];
  	for (int i = 0; i < n; i++) cin >> b[i];
  	for (int i = 0; i < n; i++) c[i] = i + 1;
  	int aa = 0;
  	int bb = 0;
  	int cnt = 0;
  	do {
      	cnt++;
    	bool aw = 1, bw = 1;
      	for (int i = 0; i < n; i++) {
        	aw &= a[i] == c[i];
          	bw &= b[i] == c[i];
        }
      	if (aw) aa = cnt;
      	if (bw) bb = cnt;
    } while (next_permutation(c, c + n));
  	cout << abs(aa - bb) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

typedef long long ll;

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

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll asc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll dsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

ll n, k, a[200001], max = 0;

bool check(ll d) {
    ll count = 0;
    for (int i=0; i < n; i++) {
        count += (a[i]+d-1) / d-1;
    }
    return (count <= k)?1:0;
}

ll  binary(void) {
    ll r, l;
    r = 0, l = max;
    while (l - r > 1) {
        ll mid = (r + l) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    return l;
}

int main() {
    scanf("%lld%lld", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        max = (max > a[i]) ? max : a[i];
    }
    ll ans = binary();
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k, ans;
    cin >> a >> b >> k;
    c = min(a, b);
    for (int i = c; i > 0; --i) {
      if (a % i == 0 && b % i == 0) {
        k--;
      }
      if (k == 0) {
        ans = i;
        break;
      }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int N, M;
vector<vector<int>> G(200010);
bool visited[200010];

void dfs(int v, int t)
{
    if (visited[v] || t >= 3)
        return;

    visited[v] = true;

    for (int i = 0; i < (int)G[v].size(); ++i)
    {
        dfs(G[v][i], t + 1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    cin >> N >> M;

    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < N; ++i)
        visited[i] = false;

    dfs(0, 0);

    if (visited[N - 1])
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12144
//https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a
//C - Product and GCD
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

template< typename T >
std::pair<std::vector<T>, std::vector<T>> prime_factor_decomp(T n) {
    std::vector<T> p, e;
    T m = n;
    for (T i = 2; i * i <= n; i++) {
        if (m % i != 0) continue;
        T c = 0;
        while (m % i == 0) c++, m /= i;
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return std::make_pair(p, e);
}

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-4.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,P; cin>>N>>P;
    auto r=prime_factor_decomp(P);
    ll ans=1;
    REP(i,r.first.size()){
        ll num=r.second.at(i) / N;
        REP(j,num){
            ans*=r.first.at(i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(N); cin >> A;

        auto f = [&] (ll b) {
            b -= 1e9;
            ll sum = 0;
            rep(i, N) sum += abs(A[i] - (b + i + 1));
            return sum;
        };

        ll l = 0, r = 2 * (1e9) + 1;
        while(l + 10 < r) {
            ll m1 = (2 * l + r) / 3;
            ll m2 = (l + r * 2) / 3;
            // cerr << l << " " << r << " " << m1 << " " << m2 << endl;;
            ll v1 = f(m1), v2 = f(m2);
            if(v1 > v2) {
                l = m1;
            } else {
                r = m2;
            }
        }
        ll a = INFL;
        repeat(i, l, r + 1) set_min(a, f(i));
        cout << a << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n,a[1000001],g[20],i,j,k,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  int m=0,x=1;
  for(i=0; x<=n; i++) {
    g[i]=x;
    x=x*3+1;
    m++;
  }
  for(k=m-1; k>=0; k--) {
    for(i=g[k]; i<n; i++) {
      int v=a[i];
      j=i-g[k];
      while(j>=0 && a[j]>v) {
	a[j+g[k]]=a[j];
	j=j-g[k];
	cnt++;
      }
      a[j+g[k]]=v;
    }
  }
  printf("%d\n",m);
  for(i=m-1; i>=0; i--) {
    printf("%d",g[i]);
    if(i) printf(" ");
  }
  printf("\n%d\n",cnt);
  for(i=0; i<n; i++) printf("%d\n",a[i]);
  return 0;
}



Measured memory_bytes: 5656
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int a;
   int b;
   float c;
 
   cin >> a >> b >> c;
  
   
   
   
   int d = c+0.5;
  
   int e = (d/a)*b;
  
   //cout << d/a << endl; 
  
   cout << e << endl;
   
  return 0;
}

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

class Solver
{
    string s;
    int n;

    public Solver Scan()
    {
        n = int.Parse(Console.ReadLine());
        s = Console.ReadLine();

        return this;
    }

    public void Solve()
    {
        var sb = new System.Text.StringBuilder();
        foreach(var x in s) {
            sb.Append(CalcChar(x));
        }
        Console.WriteLine(sb.ToString());
    }

    char CalcChar(char c)
    {
        return c + n <= 'Z' ? (char)(c + n) : (char)(c + n - ('Z' - 'A' + 1));
    }
}

class Program
{
    static void Main(string[] args)
    {
        new Solver().Scan().Solve();
    }
}

Measured memory_bytes: 11096
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100100];
    rep(i,0,n) cin >> A[i];

    bool flag = true;
    rep(i,0,n){
        if(A[i] % 2 != 0){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "second" << endl;
    }else{
        cout << "first" << endl;
    }
    return 0;
 }


Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    int ans = 0, f_b = 0, b_a = 0, both_ab = 0;
    for (int i = 0; i < n; ++i) {
        for (size_t j = 0; j < s[i].size() - 1; ++j) {
            if (s[i][j] == 'A'&&s[i][j + 1] == 'B')ans++;
        }
        if (s[i][0] == 'B'&&s[i][s[i].size() - 1] != 'A') f_b++;
        else if (s[i][0] != 'B'&&s[i][s[i].size() - 1] == 'A') b_a++;
        else if (s[i][0] == 'B'&&s[i][s[i].size() - 1] == 'A') both_ab++;
    }
    if (both_ab == 0) {
        ans += min(f_b, b_a);
    }else if (b_a == 0 && f_b == 0 && both_ab > 0) {
        cout << ans+both_ab-1 << endl;
        return 0;
    }
    else {
        ans += both_ab + min(f_b, b_a);
    }
   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int f)
{
	int cnt = 0;
	for(int i=e[w].size()-1;i>=0;i--)
		if (e[w][i] != f)
			if (dfs(e[w][i], w))
			{
				cnt++;
				if (cnt >= 2)
				{
					cout << "First" << endl;
					exit(0);
				}
			}
	return cnt ^ 1;
}
int main()
{
	n = read();
	for (int i = 1; i < n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	if (dfs(1, 0))cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 5888
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        line = Console.ReadLine().Trim().Split(' ');
        var asum = Array.ConvertAll(line, int.Parse).Sum();
        var ans = asum / (n + 1);
        if (asum % (n + 1) > 0) ans += 1;
        Console.WriteLine(ans);
    }
}




Measured memory_bytes: 18268
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n-1):
  if a[i+1] - a[i] > ans:
    ans = a[i+1] - a[i]

if a[0] + k - a[n-1] > ans:
  ans = a[0] + k - a[n-1]
  
print(k - ans)

Measured memory_bytes: 26444
s=input()
t=input()

S=[]
for i in range(len(s)):
    S.append(str(s[i]))
S.sort()
s=''.join(S)

T=[]
for i in range(len(t)):
    T.append(str(t[i]))
T.sort(reverse=True)
t=''.join(T)

if s==t:
    print('No')
else:
    print(['Yes','No'][sorted([s,t]).index(s)])

Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s,t;
	cin>>s>>t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[110][3]={{0}}; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[110][6]={{0}};

int main() {
    long long N,a,b; cin >> N >> a >> b;
    int counter,counter1;
    if((b-a)%2==0){
    cout<<(b-a)/2<<endl;}
    else if(N-b>=a){
    cout<<a+(b-a-1)/2<<endl;}
    else {
    cout<<N-b+(b-a+1)/2<<endl;}
}
    


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

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

    long long X;
    cin >> X;
    int pos = 0;
    int i;
    for (i = 0; pos < X; i++)
        pos += i;

    cout << --i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 vector<int> p(3);
  for(int i=0;i<3;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  cout<<p.at(2)-p.at(0)<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n,d;
    cin >> n >> d;

    int x[n][d];

    rep(i,n){
        rep(j,d){
            cin >> x[i][j];
        }
    }

    int ans = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            long double tmp = 0;
            for(int k=0;k<d;k++){
                tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            tmp = sqrt(tmp);
            if(tmp == (int)tmp){
                ans++;
            }
        }
    }

    cout << ans/2 << endl;
}



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

int n;
int ans;
vector<vector<pair<int, bool>>> v;
vector<bool> test;

void dfs(){
    if(test.size()==n){
        bool pos = true;
        int count = 0;
        for(int i=0;i<n;i++){
            if(test[i]){
                count++;
                for(auto testi:v[i]){
                    if(test[testi.first]!=testi.second){
                        pos = false;
                        return;
                    }
                }
            }
        }
        ans = max(ans, count);
        return;
    }
    test.push_back(true);
    dfs();
    test.pop_back();
    test.push_back(false);
    dfs();
    test.pop_back();
    return;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        v.push_back({});
        int A;
        cin>>A;
        for(int j=0;j<A;j++){
            int x;
            bool b;
            cin>>x>>b;
            x--;
            v[i].push_back(make_pair(x, b));
        }
    }
    dfs();
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define LL long long

LL N, L;
LL p[100010];
LL d[100010];
signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    cin >> N >> L;
    vector<pair<int, int>> v(N);
    /** 前処理 **/
    /**
      すべての矢印を位置の昇順で整列し、i番目までの矢印をすべて左に詰めたときのスコアを動的計画法で求めておく。右へ詰める方向も同様に求めておく。
      **/
    for(int i=0; i<N; i++){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    for(int i=0; i<N; i++){
        p[i] = v[i].first;
        d[i] = v[i].second;
    }

    LL ans = 0;
    LL tmp = 0;
    for(int i=0; i<N; i++){
        tmp += (p[i]-(i+1)) * (d[i] == 0 ? 1 : -1);
    }
    ans = tmp;
    for(int i=0; i<N; i++){
        tmp += ((L-i)-(N-i)) * (d[N-i-1] == 1 ? 1 : -1);
        ans = max(ans, tmp);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5012
import java.util.ArrayList;
import java.util.Scanner;

class Dice{
	int[] dice = new int[7];
	int[] dice2 = new int[7];
	
	void diceroll(char[] roll)
	{
		for(int i = 0;i < roll.length;i++)
		{
			int temp =0;
			if(roll[i] == 'N'){
				temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = temp;
			}else if(roll[i] == 'E'){
				temp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = temp;
			}else if(roll[i] == 'S'){
				temp = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = temp;
			}else if(roll[i] == 'W'){
				temp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'R'){
				temp = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}else if(roll[i] == 'L'){
				temp = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}
		}
	}
	
	int Getdice(int num)
	{
		return dice[num];
	}
}

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int dicenum = scan.nextInt();
		Dice dice = new Dice();
		ArrayList<int[]> dicelist = new ArrayList<int[]>();
		
		for(int i = 0;i < dicenum;i++)
		{
			int[] tmp = new int[7];
			for(int j = 1;j < 7;j++)
			{
				tmp[j] = scan.nextInt();
			}
			dicelist.add(tmp);
		}
		boolean ansflg = false;
		
		for(int d2 = 0;d2 < dicenum;d2++)
		{
			for(int d1 = 0;d1 < dicenum;d1++)
			{
				dice.dice = dicelist.get(d1);
				dice.dice2 = dicelist.get(d2);
				if(d1 != d2)
				{
					int count;
					String str = "";
					for(int m = 0;m < 4;m++){
						for(int j = 0;j < 4;j++){
							for(int k = 0;k < 4;k++){
								count = 0;
								for(int l = 1;l < dice.dice.length;l++)
								{
									if(dice.dice[l] == dice.dice2[l])
									{
										count++;
									}
									if(count == 6)
									{
										ansflg = true;
									}
								}
								str = "R";
								dice.diceroll(str.toCharArray());
							}
							str = "S";
							dice.diceroll(str.toCharArray());
						}
						str = "E";
						dice.diceroll(str.toCharArray());
					}
				}
			}
		}
		
		if(ansflg == true)
		{
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 42776
n,a,b=map(int,input().split())
p=1000000007
def pmod(N,K,p):
  s=1
  for i in range(K):
    s=(s*(N-i))%p
  return (s)

def bin(N):
    lists=[]
    t=0
    while N>0:
        lists.append(N%2)
        N=N//2
        t=t+1
    lists.append(t)
    return (lists)

def digb(N):
    t=0
    while N>0:
        N=N//2
        t=t+1
    return (t)

def mod(a,N,p):
    listm=[]
    for i in range(digb(N)):#2**(2**i)%pの余を記録
        listm.append(a*bin(N)[i])
        a=(a**2)%p
    s=1
    for i in range(digb(N)):
        if listm[i]!=0:
            s=(s*listm[i])%p
    return(s)

print ((mod(2,n,p)-pmod(n,a,p)*mod(pmod(a,a,p),p-2,p)-pmod(n,b,p)*mod(pmod(b,b,p),p-2,p)-1)%p)

Measured memory_bytes: 3064
A,B,C = map(int,input().split())
A,B,C = A-min(A,B,C),B-min(A,B,C),C-min(A,B,C)

X = max(A,B,C)

ans = (3*X)-(A+B+C)
if ans%2 == 1:
  ans += 3

print(ans//2)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

 void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!= NIL){
    y = x;
    if(z->key< x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}








void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
   if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}


Measured memory_bytes: 25160
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
    cout<<"Left"<<endl;
  }else if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
  

}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
    var ans = 0
    repeat(n){i->
        repeat(n){j->
            ans = Math.max(ans, Math.abs(t[i] - t[j]))
        }
    }
    println(ans)
}

Measured memory_bytes: 31144
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

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

int main() {
    int x,y;
    cin >> x >> y;
    cout << x + y - gcd(x,y) + 1 << endl;

}

Measured memory_bytes: 3088
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <set>

#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int main() {
   string s;
    cin >> s;
   int ans = 0;
    char now = s[0];
    for(int i = 1;i<s.size();i++){
     if (s[i]==now){
     }
        else{
         now = s[i];
         ans++;
     }
   }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll n, x, a[110];
    cin >> n >> x;
    REP(i, n)
    cin >> a[i];

    sort(a, a + n);

    ll ans = 0;
    REP(i, n)
    {
        if (i == n - 1)
        {
            if (a[i] == x)
                ans++;
        }
        else if (a[i] <= x)
            ans++;

        x -= a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math

def ri(): return int(input())
def rli(): return list(map(int, input().split()))

r, n = rli()
while(r != 0):
    shade = [0 for i in range(41)]
    shade[40] = 1145148101919
    t = [1145148101919 for i in range(41)]
    for i in range(n):
        xl, xr, h = rli()
        for j in range(xl+20, xr+20):
            shade[j] = max(shade[j], h)
    shade[20-r-1] = 1145148101919
    shade[20+r] = 1145148101919

    for i in range(20-r, 20+r+1):
        x = 20-i
        t[i] = min(shade[i-1], shade[i]) - math.sqrt(r**2 - x**2) + r

    print(min(t))
    r, n = rli()

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main()
{
    string s;
    // string s1="Sunny",s2="Cloudy",s3="Rainy";

    cin>>s;
    if(s == "Sunny")
    {
        cout<<"Cloudy";
    }
    else if(s == "Cloudy")
    {
        cout<<"Rainy";
    }
    else if(s == "Rainy")
    {
        cout<<"Sunny";
    }
    cout <<endl;
}

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

const int MOD=1e9+7;

int n,m1,m2,m3,ans;

int main(){
	scanf("%d",&n);
	m1=m2=m3=1;
	for(int i=1;i<=n;i++){
		m1=8ll*m1%MOD;
		m2=9ll*m2%MOD;
		m3=10ll*m3%MOD;
	}
	ans=((1ll*m3+m1-m2-m2)%MOD+MOD)%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<complex>
using namespace std;


int n, a[100000];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    double m = 1000000000;
    sort(a, a+n);
    int x = a[n-1];
    int y = 0;
    for(int i = 0; i < n-1; i++){
        if(abs((double)x/2 - a[i]) < m){
            y = i;
            m = abs((double)x/2 - a[i]);
        }
    }
    printf("%d %d\n", x, a[y]);
}

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

#define pb push_back
using ll = long long;
const ll mod = 1e9L + 7;

const int N = 303;

ll dp[N][N][N];

vector <pair <int, int>> lim[N];

int main() {
	ios :: sync_with_stdio(0);
	int n, m; cin >> n >> m;
	for(int i = 1; i <= m; i ++) {
		int l, r, x; cin >> l >> r >> x;
		lim[r].pb({l, x});
	}
	dp[0][0][0] = 1;
	for(int i = 0; i <= n; i ++)
		for(int j = 0; j <= i; j ++)
			for(int k = j; k <= i; k ++) {
				dp[i][j][k] %= mod;
				bool f = 1;
				for(auto p : lim[i]) {
					int l = p.first, x = p.second;
					x --;
					if(j >= l) x --;
					if(k >= l) x --;
					if(x != 0) f = 0;
				}
				if(!f) dp[i][j][k] = 0;
				dp[i + 1][j][i] += dp[i][j][k];
				dp[i + 1][k][i] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}

	ll ans = 0;
	for(int i = 0; i <= n; i ++)
		for(int j = 0; j <= n; j ++) {
			//cout << i << ' ' << j << ' ' << dp[n][i][j] << '\n';
			ans += dp[n][i][j];
			ans %= mod;
		}
	cout << ans << '\n';
}

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

int main() {
	int n; cin >> n;
	map<string, int> M;
	while(n--) {
		string S; cin >> S;
		M[S]++;
	}
	vector<pair<int, string>> V;
	for(auto p : M) 
		V.push_back({-p.second, p.first});
	sort(V.begin(), V.end());
	for(int i = 0; i < V.size() && V[i].first == V[0].first; i++)
		cout << V[i].second << "\n";
}


Measured memory_bytes: 29552
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 705;

int n, m;
bool lnk[N][N];
int cnt[2];
int col[N];
bool f;

void dfs(int u, int c) {
    col[u] = c;
    ++cnt[c];
    for(int v = 1; v <= n; v++) {
        if(lnk[u][v]) {
            if(col[v] == -1) dfs(v, 1 - c);
            else if(col[v] == c) {
                f = false;
                return;
            }
        }
    }
}

pii num[N];
bool dp[N][N];

void run() {
    memset(col, -1, sizeof(col));
    memset(dp, 0, sizeof(dp));
    f = true;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++) {
            if(i != j) lnk[i][j] = 1;
        }
    for(int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        lnk[u][v] = lnk[v][u] = 0;
    }
    int tot = 0;
    for(int i = 1; i <= n; i++) {
        if(col[i] == -1) {
            cnt[0] = cnt[1] = 0;
            dfs(i, 0);
            num[++tot] = MP(cnt[0], cnt[1]);
        }
    }
    if(f == false) {
        cout << -1 << '\n';
        return;
    }
    dp[0][0] = 1;
    for(int i = 1; i <= tot; i++) {
        for(int j = 0; j <= n; j++) {
            if(dp[i - 1][j]) {
                dp[i][j + num[i].fi] = 1;
                dp[i][j + num[i].se] = 1;
            }
        }
    }
    int ans = 1e9;
    for(int i = 0; i <= n; i++) {
        if(dp[tot][i]) {
            ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n >> m) run();
    return 0;
}


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

int main(){

  string s;
  bool f=false;

  cin>>s;

  for(int i=0;i<s.length();i++){
    for(int j=i+1;j<s.length();j++){
      if(s[i]==s[j]){
        f=true;
        break;
      }
    }
    if(f) break;
  }

  if(f) cout<<"no"<<endl;
  else cout<<"yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel a(N); rep(i,N) cin >> a[i];

    ll cnt = 0;
    rep(i,N) {
        while(a[i] % 2 == 0) {
            cnt++;
            a[i] /= 2;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define INFTY -1

void merge( int [], int left, int mid, int right );
void MergeSort( int [], int left, int right );
int n, cnt = 0;

int main(){
    int i, A[500000];

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

    //sort
    MergeSort(A, 0, n);

    //display
    for (i = 0; i<n; i++){
	printf("%d", A[i]);
	if (i < n-1) printf(" ");
    }
    printf("\n%d\n", cnt);

    return 0;
}

void merge( int A[], int left, int mid, int right ){
    int *L, *R;
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k;
    // allocate the memory for merge
    L = malloc(sizeof(int) * (n1+1)); //left side
    R = malloc(sizeof(int) * (n2+1)); //right side

    // substitute the value of A-array for each divided array 
    for (i = 0; i<n1; i++)
	L[i] = A[left + i];
    for (i = 0; i<n2; i++)
	R[i] = A[mid + i];
    //as sentinels
    L[n1] = INFTY;
    R[n2] = INFTY;
    //sort
    i = 0;
    j = 0;
    for (k = left; k<right; k++){
	if (R[j] == INFTY){
	    A[k] = L[i];
	    i++;
	}
	else if (L[i] == INFTY){
	    A[k] = R[j];
	    j++;
	}
	else if (L[i] <= R[j]){
	    A[k] = L[i];
	    i++;
	}
	else if (L[i] > R[j]){ 
	    A[k] = R[j];
	    j++;
	}
	cnt++;
    }
    free(L);
    free(R);
    return ;
}

void MergeSort( int A[], int left, int right ){
    int mid;
    if (left+1 < right){
	mid = (left + right)/2;
	MergeSort(A, left, mid);
	MergeSort(A, mid, right);
	merge(A, left, mid, right);
    }
    return ;
}



Measured memory_bytes: 5420
I=lambda:list(map(int,input().split()))
n,m=I()
A=[]
for _ in range(n):
  a,b=I()
  A+=[[a,b]]
A.sort()
s=0
for i,j in A:
  s+=i*min(m,j)
  m-=j
  if m<=0:
    break
print(s)

Measured memory_bytes: 20464
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

min_ab = min(a) + min(b)
ans = min_ab
for i in range(M):
  x, y, c = map(int, input().split())
  ab = a[x - 1] + b[y - 1] - c
  ans = min(ans, ab)
  
print(ans)

Measured memory_bytes: 18736