akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

using namespace std;

void solution()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2] && s[0] == 'R'){
        cout << "3\n";
    }
    else if(s[0] == s[1] && s[0] == 'R' || s[1] == s[2] && s[1] == 'R'){
        cout << "2\n";
    }
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
        cout << "1\n";
    }
    else {
        cout << "0\n";
    }
}

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)
#define COUT(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================
// Template End =========================

constexpr int MOD=1e9+7;
locale LOCATE=locale::classic();

int main(void){
  int n; cin>>n;
  vec<pair<double,double>> p(n);
  rep(i,n){
    double x,y; cin>>x>>y;
    p[i]=pair<double,double>(x,y);
  }
  vec<int> idx(n);
  iota(all(idx),0);
  double ans; int num=0;
  do{
    //cout<<idx<<endl;
    double tmp=0.0;
    double xlen,ylen;
    rep(i,n-1){
      xlen=(p[idx[i]].first-p[idx[i+1]].first);
      ylen=(p[idx[i]].second-p[idx[i+1]].second);
      tmp+=sqrt(xlen*xlen+ylen*ylen);
    }
    //cout<<tmp<<endl;
    ans+=tmp; ++num;
  }while(next_permutation(all(idx)));
  cout<<fixed<<setprecision(10)<<ans/num<<endl;
}











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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
  int n, m; cin >> n >> m;
  vll a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  auto c = convolution(a,b);
  for(auto x : c) cout << x << " ";
  cout << endl;
  return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

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

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

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

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

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

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

constexpr int MOD = 1000000007;

void solve() {
    int n;
    string s[2];
    cin >> n >> s[0] >> s[1];
    LL ans = 1 * (s[0][0] == s[1][0] ? 3 : 6);
    int index = (s[0][0] == s[1][0] ? 1 : 2);
    bool same = s[0][0] == s[1][0];
    while (index < n) {
        if (s[0][index] == s[1][index]) {
            if (same) ans = (ans * 2) % MOD;
            ++index;
            same = true;
        } else {
            if (same) ans = (ans * 2) % MOD;
            else ans = (ans * 3) % MOD;
            index += 2;
            same = false;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
/*
    coder:xxjAc
    time:2017/10/28 
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
int main(){
	int n;
	int sum=0;
	int x,mn=107;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&x);
		sum+=x;
		if (x%10!=0){
			mn=min(mn,x);
		}
	}
	if (sum%10!=0){
		printf("%d\n",sum);
		return 0;
	}
	if (mn==107){
		printf("0\n");
	}
	else{
		printf("%d\n",sum-mn);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

int n, a[300000];

int main()
{
//    ifstream cin ("house.in");
//    ofstream cout ("house.out");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(25);
    cout.setf(ios_base::fixed);
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int t;
        cin >> t;
        a[t]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>




#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define sz(x) (int)x.size()
#define pii pair < int, int >
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const ll MAXN = 1e18;
const ll SIZE = 5e5 + 10;  //are u sure?
const ll mod = 1e9+7;
ll A[SIZE], B[SIZE];

void solve(){
	string s; cin >> s;
	for(int i = 0; i < sz(s); i++){
		if(s[i] == '<'){
			A[i + 1] = A[i] + 1;
		}
	}
	for(int i = sz(s) - 1; i >= 0; i--){
		if(s[i] == '>'){
			B[i] = B[i + 1] + 1;
		}
	}
	ll sum = 0;
	for(int i = 0; i <= sz(s); i++){
		sum += max(A[i], B[i]);
	}
	cout << sum << endl;

}

int main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}

Measured memory_bytes: 8732
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

void solve()
{
  int n;
  string s;
  ll r = 0, g = 0, b = 0;
  cin >> n >> s;
  rep(i,n){
    if(s[i]=='R')
      ++r;
    else if(s[i]=='G')
      ++g;
    else if(s[i]=='B')
      ++b;
  }
  ll ans = r * g * b;
  REP(i, 1, n)
  {
    rep(j,n){
      if(j+2*i>=n)
        continue;
      if((s[j]!=s[j+i])&&(s[j]!=s[j+2*i])&&(s[j+i]!=s[j+2*i]))
        --ans;
    }
  }
  cout << ans;
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool isPrime(long a) {
	if (a < 2) return false;
	long i;
	for (i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int Prime[1000000] = {};
	for (int i = 0; i < 1000000; i++) {
		if (isPrime(i)) {
			Prime[i] = 1;
		}
	}
	for (int i = 1; i < 1000000; i++) {
		Prime[i] += Prime[i - 1];
	}
	int n;
	while (cin >> n) {
		cout << Prime[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 10880
i,n,a,b,c;
int main(){
	scanf("%d",&n);
	for(;n>0;n--){
		scanf("%d %d %d",&a,&b,&c);
		a*=a;b*=b;c*=c;printf("%s\n",a==b+c||b==a+c||c==a+b?"YES":"NO");
	}
	return 0;
}

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

if abs(A-B) % 2 == 0:
    print(abs(A-B) // 2)
else:
    ans = 0
    if N-A < B-1:
        ans += N - B + 1
        A += ((N - B) + 1)
        if A == N:
            print(ans)
        else:
            print(ans + ((N - A) // 2))
    else:
        ans += A - 1 + 1
        B -= (A - 1 + 1)
        if B == 1:
            print(ans)
        else:
            print(ans + ((B - 1) // 2))
            

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int A, B;
  std::cin >> A >> B;
  for (int i: range(0, 1000001)) {
    if (int(i * 0.08) == A && int(i * 0.10) == B) {
      std::cout << i << '\n';
      return 0;
    }
  }
  std::cout << "-1\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a[7]={1,3,5,7,8,10,12};
	int b[4]={4,6,9,11};
	int c[1]={2};
	int x,y,i,f2,f1;
	cin>>x>>y;
	f1=f2=0;
	for(i=0;i<7;i++) {
		if(a[i]==x) f1=1;
		if(a[i]==y) f2=1;
	}
	if(f1==1&&f2==1) {
		cout<<"Yes"<<endl;
		return 0;
	}
	f1=f2=0;
	for(i=0;i<4;i++) {
		if(b[i]==x) f1=1;
		if(b[i]==y) f2=1;
	}
	if((f1==1&&f2==1)) {
		cout<<"Yes"<<endl;
		return 0;
	}
	if(x==2&&y==2) {
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}
	

Measured memory_bytes: 256
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 ans = 0;

		if ( a <= b ) {
			ans = a;
		} else {
			ans = a-1;
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b, x;
    cin >> a >> b >> x;
    if (a > 0)
        cout << b / x - (a - 1) / x << endl;
    else
    {
        cout << b / x + 1 << endl;
    }
}

Measured memory_bytes: 256
import itertools

N = int(input())
v = []
for i in range(N):
    x,y = map(int, input().split())
    v.append((x,y))

res = 0
L = list(itertools.permutations(v))
for l in L:
    for i in range(1,len(l)):
        res += (abs(l[i][0]-l[i-1][0])**2 + abs(l[i][1]-l[i-1][1])**2)**.5
print(res/len(L))

Measured memory_bytes: 8180
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H, W;
        int i, j;
        while (true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (j = 0; j < H; j++) {
                for (i = 0; i < W; i++) {
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}



Measured memory_bytes: 64348
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	scanf("%s",S+1);int c[26]={0},n=strlen(S+1);
	for(int i=1;i<=n;++i)++c[S[i]-'a'];
	ll ans=1ll*n*(n-1)/2+1;
	for(int i=0;i<26;++i)ans-=1ll*c[i]*(c[i]-1)/2;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
# 1 "c.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "c.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "c.cpp" 2

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long x, n;
    cin >> x >> n;
    vb cnt(1e2+2);
    for(long long i=0; i<n; ++i){
        long long p;
        cin >> p;
        cnt[p] = true;
    }
    long long ans = -1;
    for(long long i=x; i<=101 and ans==-1; ++i){
        if(!cnt[i])
            ans = i;
    }
    for(long long j=x; j>=0 and abs(x-j) <= abs(x-ans); --j){
        if(!cnt[j])
            ans = j;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

   ll n;
   cin >> n;
   ll ans = 0;
   for (ll i = 2; i * i <= n; i++) {
      ll temp = 0;
      while (n % i == 0) {
         n /= i;
         temp++;
      }
      if (temp)
         ans += (-1 + sqrt(1 + 8 * temp)) / 2;
   }
   if (n > 1)
      ans++;

   cout << ans << '\n';

   return 0;
}

Measured memory_bytes: 3696
// Last Change: 04/12/2020 21:08:05.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

ll gcd(ll a, ll b, ll c) {
  return gcd(gcd(a, b), c);
}

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

  ll res = 0;
  for (ll i = 1; i <= K; ++i) {
    for (ll j = 1; j <= K; ++j) {
      for (ll k = 1; k <= K; ++k) {
        res += gcd(i, j, k);
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3192
for _ in range(int(input())):
    y,m,d = map(int,input().split())
    vy,vm,vd = y-1,m-1,d-1
    r = vy//3*590 + vy%3*195
    r += vd
    if (vy+1)%3==0: r += vm*20
    else: r += vm//2*39 + vm%2*20
    print(196470-r)

Measured memory_bytes: 7604
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int N;
    cin >> N;

    vector<int>A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[(N - 1)] - A[0] << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int main(){
   int n;
   cin>>n;
   ll ans =0;
   ans+=(1000*(n/500));
   n%=500;
   ans+=(5*(n/5));
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[1002][1002],c[10],d[10],n,w,h,x,y,z;
  int sm=0;
  char s;
  bool b[1002][1002];
  queue<pair<pair<int,int>,int> > q;
  memset(a,-1,sizeof(a));
  cin>>h>>w>>n;
  for(i=1;i<h+1;i++){
    for(j=1;j<w+1;j++){
      cin>>s;
      if(s!='X'){
	a[j][i]=0;
	if(0){
	}else if(s=='.'){
	}else if(s=='S'){
	  c[0]=j;
	  d[0]=i;
	}else{
	  c[s-'0']=j;
	  d[s-'0']=i;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    memset(b,0,sizeof(b));
    while(q.empty()==0)
      q.pop();
    q.push(make_pair(make_pair(c[i],d[i]),0));
    for(;;){
      x=q.front().first.first;
      y=q.front().first.second;
      z=q.front().second;
      q.pop();
      if(a[x][y]!=-1&&b[x][y]==0){
	if(x==c[i+1]&&y==d[i+1])
	  break;
	b[x][y]=1;
	q.push(make_pair(make_pair(x-1,y),z+1));
	q.push(make_pair(make_pair(x,y-1),z+1));
	q.push(make_pair(make_pair(x+1,y),z+1));
	q.push(make_pair(make_pair(x,y+1),z+1));
      }
    }
    sm+=z;
  }
  cout<<sm<<endl;
  return 0;
}

Measured memory_bytes: 5776
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  int cp = 0;

  for (int i = 0, c = 0, size = s.size(); i < size; i ++)
    if (strchr("ACTG", s[i])) {
      cp = std::max(++ c, cp);
    }
    else {
      c = 0;
    }

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


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5, LOG = 20;

bool BAN[N];

int main() {
 
	sync;

	int n, k; cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		BAN[d] = true;
	}
	for (int i = n; i < N; i++) {
		bool flag = true;
		int tmp = i;
		while (tmp) {
			int d = tmp % 10;
			if (BAN[d]) flag = false;
			tmp /= 10;
		}
		if (flag) die(i);
	}

	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:
const ll inf = 1LL << 60;
ll a[10010];

signed main(void) {
	int n;
	cin >> n;

	rep(i, n) cin >> a[i];

	ll ans = -inf;

	int l = 0, r = 0;

	rep(i, n) if (chmax(ans, a[i])) l = i, r = i;

	rep(i, n) {
		ll cur = a[i];
		for (int j = i + 2; j < n; j += 2) {
			if (chmax(ans, cur + a[j])) {
				l = i, r = j;
			}
			cur += max(a[j], 0LL);
		}
	}

	cout << ans << endl;

	vector<int> seq;

	int len = n;

	rep(loop, n - r - 1) {
		seq.push_back(len);
		len--;
	}

	//cerr << l << " " << r << endl;

	rep(loop, l) {
		seq.push_back(1);
		len--;
	}

	vector<ll> tmp;
	for (int i = l; i <= r; ++i) tmp.push_back(a[i]);

	for (int i = len - 3; i >= 2; i -= 2) {
		if (tmp[i] < 0) {
			seq.push_back(i + 1);
			len -= 2;
		}
	}


	while (len > 1) {
		seq.push_back(2);
		len -= 2;
	}

	cout << seq.size() << endl;
	for (auto &elem : seq) cout << elem << endl;

	return 0;
}

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

//#define LOCAL

int main()
{
#ifdef LOCAL
    freopen("inputb.txt", "r", stdin);
#endif
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) cout << k;
    else if (k <= a + b) cout << a;
    else cout <<  a - (k - a - b);
    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const int MAX = 2e5 + 10;

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for_each(begin(a), prev(end(a)), [](auto &e) {
    cin >> e;
  });

  vector<int> tmp(MAX);
  vector<int> dp(MAX);
  dp[0] = 1;
  tmp[a[0]] = 1;
  for (int i = 0; i < N; i++) {
    if (a[i] == a[i + 1]) {
      continue;
    }

    dp[i + 1] = tmp[a[i]];
    (tmp[a[i + 1]] += dp[i + 1]) %= MOD;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int a,b,x;
	scanf("%i%i%i",&a,&b,&x);
	if(a>x)	printf("NO");
	else
	{
		if(a+b>=x)	printf("YES");
		else printf("NO");
	}
	return 0;
}


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

using namespace std;

int n,k,l;

class graph{
public:
	int n, comp=0;
	vector<vector<int>> g, cl;
	vector<int> c, vis;
	
	graph(int n):n(n){
		g.resize(n);
		c.resize(n);
		vis.resize(n,0);
	}
	
	void addedge(int u, int v){
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	void dfs(int u){
		vis[u]=1;
		c[u]=comp;
		cl[comp].push_back(u);
		for(auto v:g[u]){
			if(!vis[v]){
				dfs(v);
			}
		}
	}
	
	void solve(){
		for(int i=0;i<n;i++){
			if(!vis[i]){
				cl.emplace_back();
				dfs(i);
				comp++;
			}
		}
	}
	
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> k >> l;
	graph gk(n),gl(n);
	
	for(int i=0,u,v;i<k;i++){
		cin >> u >> v;
		u--,v--;
		gk.addedge(u,v);
	}
	for(int i=0,u,v;i<l;i++){
		cin >> u >> v;
		u--,v--;
		gl.addedge(u,v);
	}
	
	gk.solve();
	gl.solve();
	
	vector<int> ans(n,0);
	
	for(int i=0;i<gk.comp;i++){
		map<int,int> mp;
		for(auto u:gk.cl[i]){
			mp[gl.c[u]]++;
		}
		
		for(auto u:gk.cl[i]){
			ans[u]=mp[gl.c[u]];
		}
	}
	
	for(auto v:ans){
		cout << v << " ";
	}
	cout << endl;
	
	return 0;
}

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

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

  vector<int> a(N); // N個のボタンデータ
  for (int i = 0; i < N; i++) {
    int z;
    cin >> z;
    z--;
    a.at(i) = z;
  }
  //cout << a.at(0) << endl;
  //cout << a.at(1) << endl;
  //cout << a.at(2) << endl;

  int now = 0, c = 0;
  
  for (;;)
  {
    if (now == 1)
    {
      cout << c << endl;
      return 0;
    }
    if (c > N)
    {
      cout << -1 << endl;
      return 0;
    }
    now = a.at(now);
    c++;
  }
  
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>

using namespace std;
const int INFTY = (1 << 21);

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

    vector<vector<int> > map(H+2, vector<int>(W+2,'#'));
    vector<vector<int> > s(H*W, vector<int>(H*W, 0));
    vector<int> d(H*W, INFTY);
    char tmp;
    int white_count = 0;

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> tmp;
            map[i][j] = tmp;
            if(tmp == '.') white_count++;
        }
    }

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            int I = i-1, J = j-1;
            int index  = I*W + J;
            int index_nbh[4];
            index_nbh[0] = (I-1)*W + J; // up
            index_nbh[1] = (I+1)*W + J; // down
            index_nbh[2] = I*W + J-1;   // left
            index_nbh[3] = I*W + J+1;   // right

            if(map[i-1][j] == '.') s[index][index_nbh[0]] = 1;
            if(map[i+1][j] == '.') s[index][index_nbh[1]] = 1;
            if(map[i][j-1] == '.') s[index][index_nbh[2]] = 1;
            if(map[i][j+1] == '.') s[index][index_nbh[3]] = 1;
        }
    }


    queue<int> q;
    q.push(0);
    d[0] = 1;
    int u;
    while( !q.empty()){
        u = q.front(); q.pop();
        for(int v=1;v<(H+1)*(W+1);v++){
            if(s[u][v] == 0) continue;
            if(d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    cout << (d[W*H-1] != INFTY ? white_count-d[W*H-1] : (-1) ) << endl;

    return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
using namespace std;


double dp[3000][30001];
double p[3000];

int main(){
    
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    dp[0][0] = 1.0 - p[0];
    dp[0][1] = p[0];
    for(int i = 0; i < N + 1; i++){
        if(i == 0){
            dp[0][0] = 1 - p[0];
            continue;
        } 
        if(i == 1){
            dp[0][1] = p[0];
            continue;
        }
        dp[0][i] = 0;
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j < N + 1; j++){
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
        }
    }

    double ans = 0.0;
    for(int i = N / 2 + 1; i < N + 1; i++){
        ans += dp[N - 1][i];
    }
    printf("%.10f\n", ans);
    

    
    return 0;

}

Measured memory_bytes: 700928
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll sum=0,n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll x=n/i;
		sum+=(x)*(x+1)/2*i;
	}
	cout<<sum;
}


Measured memory_bytes: 3584
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF=1e9+7;
const int maxn=1e5+5;

int n;
ll ans=1;
int ch[33];
char s[maxn];

int main(){
	scanf("%d",&n);
	scanf("%s",s);
	FOR(i,0,n) ++ch[s[i]-'a'];
	FOR(i,0,26) ans=ans*(ch[i]+1)%INF;
	printf("%d\n",ans-1);
	return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    string S;
    cin >> S;

    if (C < D) {
        bool b = true;
        rep(i, A, D) {
            if (S[i] == '#' && S[i + 1] == '#') {
                b = false;
            }
        }
        write(b ? "Yes" : "No");
    }
    else {
        bool b = false;
        rep(i, B, D + 1) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                b = true;
            }
        }
        write(b ? "Yes" : "No");
    }
}

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

int CHECK(map<int,int> N,map<int,int> B,int D,int G,bitset<10> to){
  int sum=0,count=0;
  queue<int> el; 
  for(int i=0;i<D;i++){
    int n=D-i;
    if(to.test(i)){
      sum+=(n*N.at(n)*100)+B.at(n);
      count+=N.at(n);    
    }
    else
      el.push(n);
  }
  if(sum>=G)
    return count;
  else
    for(int i=0;i<N.at(el.front());i++){
      sum+=el.front()*100;
      count++;
      if(sum>=G)
        break;
    }
  if(sum>=G)
    return count;
  else
    return 1000;
}
  

int main(){
  int D,G;
  cin>>D>>G;
  vector<int> num(D),bo(D),su(D);
  map<int,int> N,B;
  for(int i=0;i<D;i++){
    cin>>num.at(i)>>bo.at(i);
    N[i+1]=num.at(i);
    B[i+1]=bo.at(i);
  }
  int ans=1000;
  for(int i=0;i<(1<<D);i++){
    bitset<10> to(i);
    int re=CHECK(N,B,D,G,to);
    if(ans>re)
      ans=re;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  if(a>b)swap(a,b);
  if(a==1&&b==2)cout <<"3\n";
  else if(a==1)cout <<"2\n";
  else cout <<"1\n";
}

Measured memory_bytes: 3544
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1e6 + 5, maxn = 1e5 + 5;
int n, a[N], b[N];
struct node {
    int cnt, v;
} s[N], t[N];

inline bool cmp(const node &p, const node &q) {
    return p.cnt > q.cnt;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), s[a[i]].v = t[a[i]].v = a[i];
    for (int i = 1; i <= n; i += 2) s[a[i]].cnt++;
    for (int i = 2; i <= n; i += 2) t[a[i]].cnt++;
    sort(s + 1, s + 1 + maxn, cmp);
    sort(t + 1, t + 1 + maxn, cmp);
    if (s[1].v == t[1].v) printf("%d\n", std::min(n - s[2].cnt - t[1].cnt, n - s[1].cnt - t[2].cnt));
    else printf("%d\n", n - s[1].cnt - t[1].cnt);
    return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    while((x > 0) || (y > 0)){
        if(x < y){ cout << x << " " << y << endl; }
        else{ cout << y << " " << x << endl; }
        cin >> x >> y;
    };
    return 0;
}


Measured memory_bytes: 3104
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

n,m,d=get_f
if d.zero?
  puts (m-1)/n
else
  puts 2*(n-d)*(m-1)/(n*n)
end

Measured memory_bytes: 14272
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, P, judge=0, i, d;

    cin >> N >> P;

    for(i=2; i<=1000000; i++){
        if(P % (i*i) == 0){
            judge = 1;
        }
    }

    if(N==1 || P==1){
        cout << P << endl;
    }
    else if(judge==0){
        cout << 1 << endl;
    }
    else{
        judge = 0;
        for(i=1000000; i>=2; i--){
            d = pow(i,N);
            if(P % d == 0){
                judge = 1;
                break;
            }
        }
        if(judge==1){
            cout << i << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"

int32_t main()
{
	fast;
	int a, b, c;
	cin>>a>>b>>c;
	cout<<max(0LL, c-(a-b))<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int player[20];
int ba;
int N;
int main()
{
	while(1)
	{
		memset(player,0,sizeof(player));
		ba=0;
		scanf("%d",&N);
		if(N==0)break;
		string fuda;
		cin >> fuda;
		for(int i=0;i<100;i++)
		{
			player[i%N]++;
			if(fuda[i]=='S')
			{
				ba+=player[i%N];
				player[i%N]=0;
			}
			else if(fuda[i]=='L')
			{
				player[i%N]+=ba;
				ba=0;
			}
		}
		sort(player,player+N);
		for(int i=0;i<N;i++)printf("%d ",player[i]);
		printf("%d\n",ba);
	}
	return 0;
}

Measured memory_bytes: 1252
N = int(input())
ans = [0]*N

for x in range(1,100,1):
    for y in range(1,100,1):
        for z in range(1,100,1):
            if x**2+y**2+z**2+x*y+y*z+x*z <=N:
                ans[x**2+y**2+z**2+x*y+y*z+x*z-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 68780
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<pii> ab(N);
    REP(i, N){
        cin >> ab[i].fi >> ab[i].se;
    }
    SORT(ab);

    priority_queue<int> q;
    int it = 0;
    ll ans = 0;
    for (int i = 1; i <= M; i++) {
        while(1){
            if(it < N && ab[it].fi <= i){
                q.push(ab[it].se);
                it++;
            }else{
                break;
            }
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    pr(ans);
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <map>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

const ll MAX = 100000;

int main(){
    int n;
    while(cin >> n){
        ll a[MAX],ans=0,v[MAX];
        for(int i=0;i<n;i++) scanf("%lld",&a[i]);
        fill(v,v+n,0);
        for(int i=0;i<n;i++){
            ll in = v[a[i]-1] + a[i];
            ans = max(ans,in);
            int pos = lower_bound(v+a[i]-1,v+n,in) - v;
            fill(v+a[i]-1,v+pos,in);
        }
        printf("%lld\n",(ll)n*(n+1)/2 - ans);
    }
}

Measured memory_bytes: 2792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {Main instance = new Main();sc = instance.new Scanner();instance.solve();}
    private class Scanner {String[] s = new String[0];String regex = " ";int i = 0;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));public String next() {try {if (i < s.length) { return s[i++];}String st = br.readLine();while ("".equals(st)) { st = br.readLine(); }s = st.split(regex, 0);i = 0;return s[i++];} catch (IOException e) { return null; }}public int nextInt(){return Integer.parseInt(next());}}        
    private static Scanner sc;

    private void solve() {
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        int[] a = new int[3];
        int[] b = new int[3];
        int ret = 1;
        for (int i = 0; i <= 100; i++) {
            a[0] = i;
            for (int j = 0; j < 3; j++) {
                b[j] = c[0][j]-a[0];
            }
            for (int j = 0; j < 3; j++) {
                a[j] = c[j][1] - b[1];
            }
            ret = 1;
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    ret *= a[j] + b[k] == c[j][k] ? 1 : 0;
                }
            }
            if (ret == 1){break;}
        }
        if (ret == 1){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	max := a + b
	if a-b > max {
		max = a - b
	}
	if a*b > max {
		max = a * b
	}

	fmt.Println(max)
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;

const int MAXN = 100005;

int N;
ll a[MAXN];
vector <int> E[MAXN];
vector <int> nodes[MAXN];
int dad[MAXN];

void load() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%lld", a + i);
  for (int i = 1; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
    
  }
}

void dfs(int x, int p, int d) {
  nodes[d].push_back(x);
  dad[x] = p;
  for (int i = 0; i < E[x].size(); i++)
    if (E[x][i] != p)
      dfs(E[x][i], x, d + 1);
}

bool work(int depth) {
  vector <int> curr = nodes[depth];
  while (!curr.empty()) {
    int node = curr.back();
    int parent = dad[node];
    vector <ll> tmp;
    for (; !curr.empty() && dad[curr.back()] == parent; curr.pop_back()) 
      tmp.push_back(a[curr.back()]);
    ll sum = 0;
    for (int i = 0; i < tmp.size(); i++)
      sum += tmp[i];
    if (tmp.size() > 1)  {
      if (sum < a[parent] || sum > 2 * a[parent])
        return false;
      ll val = sum - a[parent];
      ll mx = *max_element(tmp.begin(), tmp.end());
      if (val > min(sum / 2, sum - mx))
        return false;
      a[parent] *= 2;
      a[parent] -= sum;
    }
    else if (a[node] != a[parent])
      return false;
  }
  
  return true;
}

bool solve() {
  if (N == 2)
    return a[1] == a[2];
  
  int root = 0;
  for (int i = 1; i <= N; i++)
    if (E[i].size() > 1) {
      root = i;
      break;
    }
  
  dfs(root, 0, 0);
  
  for (int i = N - 1; i >= 0; i--)
    if (!work(i))
      return false;
  
  return true;
}

int main() {
  load();
  puts(solve() ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 15872