akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;

int main()
{
	string s;
	ll ans=0;
	cin >> s;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] == '0') {
			if (s[i+1] == '0') {
				s[i + 1] = '1';
				ans++;
			}
		}
		else if (s[i] == '1') {
			if (s[i + 1] == '1') {
				s[i + 1] = '0';
				ans++;
			}
		}
		
	}
	
	cout << ans << endl;
	return 0;
}


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

int main() {
	int a, b;
	int check = 0;
	cin >> a >> b;
	string s;
	cin >> s;

	for (int i = 0; i < a + b + 1; ++i) {
		if (s[a] != '-') {
			break;
		}
		if ((((int)(unsigned char)s[i]) - 48 >= 0) && ((((int)(unsigned char)s[i]) - 48) / 10 == 0)) {
			check++;
		}
		else if (s[i] == '-') {
			if (i == a) {
				check++;
			}
		}
		else {
			break;
		}
	}
	if (check == (a + b + 1)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

  char C;
  cin >> C;
  out((char)(C + 1));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node
{
    ll w,v;
}a[4],b[4];

bool cmp(node a,node b)
{
    return a.w<b.w;
}
ll dp[25000010]={0};
int main()
{
    ll n;
    ll gA,sA,bA,gB,sB,bB;
    scanf("%lld",&n);
    scanf("%lld%lld%lld",&gA,&sA,&bA);
    scanf("%lld%lld%lld",&gB,&sB,&bB);

    a[1]={gA,gB};
    a[2]={sA,sB};
    a[3]={bA,bB};

    b[1]={gB,gA};
    b[2]={sB,sA};
    b[3]={bB,bA};
    sort(a+1,a+4,cmp);
    sort(b+1,b+4,cmp);

        for(ll j=1;j<=n;j++)dp[j]=j;
    for(ll i=1;i<=3;i++)
        for(ll j=1;j<=n;j++)
        {
            if(j-a[i].w>=0)
            dp[j]=max(dp[j-a[i].w]+a[i].v,dp[j]);
        }

    n=dp[n];

        for(ll j=1;j<=n;j++)dp[j]=j;
       for(ll i=1;i<=3;i++)
        for(ll j=1;j<=n;j++)
        {
            if(j-b[i].w>=0)
            dp[j]=max(dp[j-b[i].w]+b[i].v,dp[j]);
        }

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


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

int main() {
  string N;
  cin>>N;
  if (N[0]==N[1]&&N[1]==N[2]) {
    cout<<"Yes"<<endl;
  }
  else if (N[1]==N[2]&&N[2]==N[3]) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
}





Measured memory_bytes: 256
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int in1,in2;
		while(true) {
			in1 = Integer.parseInt(s.next());
			in2 = Integer.parseInt(s.next());
			if((in1|in2)==0)
				return;
			if(in1<=in2)
				System.out.printf("%d %d\n",in1,in2);
			else
				System.out.printf("%d %d\n",in2,in1);
		}
	}
}

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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int mx = 1000000;
int t[mx] ;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x ;
	cin >> x ;
	if(x >= 30){
		cout << "Yes" ;
		return 0;
	}
	cout << "No" ;
	
	return 0 ;
}


Measured memory_bytes: 3564
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int a[100005];
int ex[100005];
LL p2[100005];

const int MAX = 100005;
LL fac[MAX], finv[MAX], inv[MAX];

void init() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

LL  ncr(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL mod_pow(LL a, LL p) {
	LL ret = 1;
	LL tmp = a;
	while (p) {
		if (p & 1)ret = (ret * tmp) % MOD;
		p >>= 1;
		tmp = (tmp * tmp) % MOD;
	}
	return ret;
}

int main() {
	int n, d;
	scanf("%d", &n);
	REP(i, n + 1)scanf("%d", &a[i]);
	init();
	REP(i, n + 1) {
		if (ex[a[i]]) {
			d = a[i];
			break;
		}
		ex[a[i]] = 1;
	}
	int lr[2];
	int cnt = 0;
	REP(i, n + 1)if (a[i] == d)lr[cnt++] = i;
	int p, q, r;
	p = lr[0];
	q = lr[1] - lr[0] - 1;
	r = n - lr[1];
	printf("%d\n", n);
	FOR(k, 2, n + 2) {
		printf("%lld\n", (ncr(n - 1, k) + ncr(n - 1, k-2) + ncr(n - 1, k-1) * 2 - ncr(p + r, k-1) + MOD) % MOD);
	}
	return 0;
}

Measured memory_bytes: 4352
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	vector<vector<int>> ans(H, vector<int>(W));
	int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
	int dy[8] = { 0,1,0,-1,1,-1,1,-1 };
	for (int j = 0; j < H; j++) {
		for (int i = 0; i < W; i++) {
			if (S[j][i] == '#') {
				ans[j][i] = -1;
				continue;
			}
			for (int d = 0; d < 8; d++) {
				int x = dx[d] + i;
				int y = dy[d] + j;
				if (x >= 0 && y >= 0 && x < W && y < H) {
					if (S[y][x] == '#') {
						if (S[j][i] == '.')
							ans[j][i]++;
					}
				}
			}
		}
	}
	for (int j = 0; j < H; j++) {
		for (int i = 0; i < W; i++) {
			if (ans[j][i] == -1)
				cout << '#';
			else
				cout << ans[j][i];
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int X, Y;
  cin >> X >> Y;
  int ans = 0;
  if (X <= 3) ans += (4 - X) * 100000;
  if (Y <= 3) ans += (4 - Y) * 100000;
  if (X == 1 && Y == 1) ans += 400000;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunused-result"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e6 + 34;
const ll INF = (ll)1e18 + 41;
//const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;
bool D = false;

ll num[N];
ll numP[N];

ll go(ll n, ll x) {
	if (n == 0) return 1;
	if (x == 1) return 0;
	if (x - 1 <= num[n - 1]) return go(n - 1, x - 1);
	if (x - 2 == num[n - 1]) return 1 + numP[n - 1];
	return 1 + numP[n - 1] + go(n - 1, x - 2 - num[n - 1]);
}

void solve() {
	num[0] = 1;
	numP[0] = 1;
	for (int i = 1; i < 60; i++) {
		num[i] = 2 * num[i - 1] + 3;
		numP[i] = 2 * numP[i - 1] + 1;
	}

	ll n, x;
	cin >> n >> x;
	cout << go(n, x) << "\n";
}

int main() {
#ifdef LOCAL
	freopen("a.in", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tst = 1;
	//scanf("%d", &tst);
	//cin >> tst;
#ifdef MADE_BY_SERT
	D = true;	
	tst = 3;
	while (tst--) {
		solve();
	}
#else
	while (tst--) solve();
#endif
}


Measured memory_bytes: 2304
# 22:22
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if b[i] > a[i]+a[i+1]:
        ans += a[i]+a[i+1]
        a[i+1] = 0
    else:
        ans += b[i]
        if a[i] - b[i] < 0:
            a[i+1] = a[i] + a[i+1] - b[i]
print(ans)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

ll cnt[100003]={0};
vector< vector<ll> > arr(100003);

void func(ll i){
  if(arr[i].size()==0) return;
  ll j;
  cnt[i]=1;
  for(j=0;j<arr[i].size();j++){
    if(cnt[arr[i][j]]==0) func(arr[i][j]);
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n,m,i,j,count=0;
  cin>>n>>m;
  ll a,b;
  
  for(i=0;i<m;i++){
    cin>>a>>b;
    arr[a].pb(b); arr[b].pb(a);
  }
  
  for(i=1;i<=n;i++){
    if(cnt[i]) continue; 
    count++;
    func(i);
  }
  //for(i=1;i<=n;i++) cout<<cnt[i]<<" ";
  cout<<count-1<<"\n"; 
}
    

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

using namespace std;

#define ll long long int
#define vi vector<int>
#define prec fixed<<precision(10)
#define mod 1000000007
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)

int main(){
	int n,m;
	cin >> n >> m;
	vi v(n);
	ll sum =0;
	for(int i=0;i<n;i++){cin >> v[i];sum+=v[i];}
	sort(v.begin(),v.end(),greater<int> ());
  
for (int i = 0; i < m; ++i)
{
	if(v[i]<((float)sum/(4*m)))
		{cout << "No";return 0;}
}
 cout << "Yes";
}


Measured memory_bytes: 256
from itertools import chain
from functools import reduce

N = int(input())
atgc = "ATGC"
labels = []
for c1 in atgc:
    for c2 in atgc:
        for c3 in atgc:
            labels.append(c1+c2+c3)

labels[0], labels[11] = labels[11], labels[0]
labels[1], labels[14] = labels[14], labels[1]
labels[2], labels[35] = labels[35], labels[2]

lb2i = {lb:i for i, lb in enumerate(labels)}
mat = [[0]*64 for i in range(64)]

def swap(s, i, j):
    s = list(s)
    s[i], s[j] = s[j], s[i]
    return "".join(s)

for i, lb1 in enumerate(labels):
    tmp = [(lb1+c) for c in atgc]
    tmp = [s for s in tmp if not any(["AGC" in swap(s, i, i+1) for i in range(3)])]
    for lb2 in tmp:
        mat[i][lb2i[lb2[1:]]] += 1

prev = [1]*64
curr = [0]*64

mod = 1000000007

for _ in range(N-3):
    prev[0:3] = [0,0,0]
    for j in range(64):
        curr[j] = 0
    for lbi1 in range(64):
        for lbi2 in range(64):
            curr[lbi2] += mat[lbi1][lbi2]*prev[lbi1]
            curr[lbi2] %= mod
    curr, prev = prev, curr

prev[0:3] = [0,0,0]
print(reduce(lambda acc, x: (acc+x)%mod, prev, 0))


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

int main() {
    long long int n;
    cin >> n;
    string s = "";
    while (n) {
        n--;
        long long int toAlpha = n % 26;
        n /= 26;
        s += 'a' + toAlpha;
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n,m,t,a;
  cin >> n >> m >> t;
  vector<int> used(1000000,0);
  rep(i,n){
    cin >> a;
    used[a] = 1;
    rep(i,m){
      used[a+i+1]= 1;
      used[a-i-1]= 1;
    }
  }
  int cnt = 0;
  rep(i,t){
    if(used[i] != used[i+1]) cnt++;
  }
  cnt /= 2;
  rep(i,t){
    if(used[i]==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}




Measured memory_bytes: 6788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
    char c;ll x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
    while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
ll n,res,flag,a[55],b[55],f[55][55],d[55][55];
ll pows(ll a,ll b){
    ll base=1;
    while(b){
        if(b&1) base*=a;
        a*=a;b/=2;
    }
    return base;
}
ll check(ll x){
    for(ll i=0;i<=50;i++)
     for(ll j=0;j<=50;j++) d[i][j]=f[i][j];
    for(ll i=1;i<=x;i++)
     for(ll j=0;j<=50;j++) d[j][j%i]=1;
    for(ll k=0;k<=50;k++) 
     for(ll i=0;i<=50;i++)
      for(ll j=0;j<=50;j++)
       if(d[i][k]&&d[k][j]) d[i][j]=1;
    for(ll i=1;i<=n;i++) if(!d[a[i]][b[i]]) return 0;
    return 1;
}
void go(ll x){
    res+=pows(2,x);
    for(ll i=0;i<=50;i++) f[i][i%x]=1;
    for(ll i=x;i>=1;i--){
        if(check(i-1)) continue;
        if(i!=x) go(i);break;
    }
}
int main()
{
    n=read();
    for(ll i=1;i<=n;i++) a[i]=read();
    for(ll i=1;i<=n;i++) b[i]=read();
    for(ll i=0;i<=50;i++)
     for(ll j=0;j<=i;j++) if(i==j) f[i][j]=1;else f[i][j]=0;
    for(ll i=51;i>=1;i--){
        if(check(i-1)) continue;
        if(i==51) flag=1;else go(i);break;
    }
    if(!flag) printf("%lld",res);
    else puts("-1");
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(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--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	int N,number[100001]={},result=0;
	cin>>N;
	REP(i,N) cin>>number[i];

	REP(i,N){
		if(i==N-1){
			if(number[i]==i+1){
				swap(number[i],number[i-1]);
				result++;
			}
		}
		else if(number[i]==i+1){
			swap(number[i],number[i+1]);
			result++;
		}
	}
	
	printf("%d\n",result);

	return 0;
}



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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}
int n;
char s[110];
int l=0,r=0;

int main(){
  scanf("%d",&n);
  scanf("%s",s);
  REP(i,n){
    char a = s[i];
    if(a == '('){
      l++;
    }else{
      if(l>0){
        l--;
      }else{
        r++;
      }
    }
  }
  //printf("%d %d",l ,r);
  REP(i,r){
    printf("(");
  }
  printf("%s",s);
  REP(i,l){
    printf(")");
  }
  printf("\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

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

using namespace std;
using lint = long long;

int main(void)
{
	lint N;
	cin >> N;
	lint rt_N = (lint)sqrt(N);
	for (int i = rt_N; i >= 0; i--){
		if (N % i == 0){
			cout << i + N / i - 2 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1e5+10;
int n,m,k;
int p[maxn];
int sz[maxn];//标记所有朋友的个数 
int blo[maxn];//标记是直接朋友和敌人 
int find(int x)
{
	return p[x]==x?x:p[x]=find(p[x]);
}
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		p[i]=i;//初始化并查集 
		sz[i]=1; 
	}
	int a,b; 
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		blo[a]++;
		blo[b]++;
		int pa=find(a);
		int pb=find(b);
		if(pa!=pb)
		{
			p[pa]=pb;
			sz[pb]+=sz[pa];
		}
	 } 
	 for(int i=1;i<=k;i++)
	 {
	 	scanf("%d%d",&a,&b);
	 	if(find(a)==find(b))
	 	{
		 	blo[a]++;
			blo[b]++;
		}
	 }
	 for(int i=1;i<=n;i++)
	 {
	 	printf("%d ",sz[find(i)]-1-blo[i]);
	 }
	return 0;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

N, D = map(int, input().split())

X = [[int(x) for x in input().split()] for i in range(N)]

ans = 0


def isSquared(n):
    return n == math.floor(math.sqrt(n)) ** 2


for i in range(N):
    for j in range(N):
        if i < j:
            ssum = 0
            for k in range(D):
                ssum += (X[i][k] - X[j][k]) ** 2
            ans += isSquared(ssum)


print(ans)

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

bool can(){
	ll n; cin >> n;
	vector<ll> a(n),d(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	ll k=n*(n+1)/2;
	if(sum%k){
		return 0;
	}
	k=sum/k;
	for(int i=0;i<n;i++){
		d[i]=a[(i+1)%n]-a[i]-k;
	}
	for(int i=0;i<n;i++){
		if(d[i]%n!=0||d[i]>0)return 0;
	}
	return 1;
}
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	if(can()){
		cout << "YES" << endl; 
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1792
#!/usr/bin/python3

import os
import sys


def main():
    N, K = read_ints()
    T = [read_int() for _ in range(N)]
    print(solve(N, K, T))


def solve(N, K, T):
    diffs = [T[i + 1] - T[i] for i in range(N - 1)]
    diffs.sort()
    t = N
    for i in range(N - K):
        t += diffs[i] - 1
    return t


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 13808
a,b,m = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
x = [0]*m
y = [0]*m
c = [0]*m
for i in range(m):
    x[i],y[i],c[i] = map(int,input().split())

ans = 10**6
for i in range(m):
    p = x[i]-1
    q = y[i]-1
    ans = min(ans, A[p]+B[q]-c[i])

ans = min(ans, min(A)+min(B))
print(ans)

Measured memory_bytes: 23284
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,k;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    vector<char> v(n);
    vector<ll> su(n);

    rep(i,n){
        cin>>v[i];
        if(v[i]=='r'){
            su[i]=p;
        }else if(v[i]=='s'){
            su[i]=r;
        }else{
            su[i]=s;
        }
    }

    ll ans = 0;
    for(int j=0;j<n;j++){
        if(j>=k){
            if(v[j]==v[j-k]){
               v[j] = 't';
            }else{
                ans+=su[j];
            }
        }else{
            ans+=su[j];
        }
    }
    cout<<ans<<endl;





    
return 0;
}


Measured memory_bytes: 1152
import           Control.Monad
import           Data.Array.Unboxed
import           Data.List.Split
import           Data.List

main :: IO ()
main = do
  n  <- readLn
  ta <- replicateM n $ map read . words <$> getLine

  let s = solve (1, 1) ta

  print $ uncurry (+) s

solve :: (Int, Int) -> [[Int]] -> (Int, Int)
solve vt [] = vt
solve (avt, bvt) (rt : rts) | newA >= avt = solve ((b `div` brt) * art, b) rts
                            | otherwise   = solve (a, (a `div` art) * brt) rts
 where
  art  = head rt
  brt  = last rt
  a    = getMinVt avt art
  b    = getMinVt bvt brt
  newA = (b `div` brt) * art
  getMinVt :: Int -> Int -> Int
  getMinVt vt rt | vt `mod` rt == 0 = vt
                 | otherwise        = vt + (rt - (vt `mod` rt))


Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> w(N+1);//w[0]は使わない
  for(int i=0;i<N;i++)w[v[i]]=i;
  set<int> s;
  s.insert(-1);
  s.insert(N);
  int ans=0;
  for(int i=1;i<=N;i++){
    int l=*--s.lower_bound(w[i]);
    int r=*s.lower_bound(w[i]);
    ans+=i*(w[i]-l)*(r-w[i]);
    s.insert(w[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std ;

int main()
{
    string s;
    int m=0,c=0;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
            m=max(m,c);
        }
        else
        {
            m=max(m,c);
            c=0;
        }
        
    }
    cout<<m;
}

Measured memory_bytes: 3568
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
A = LI()

result = 0
for a in A:
    while a % 2 == 0:
        a /= 2
        result += 1

print(result)


Measured memory_bytes: 6744
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		List<Integer> scores = new ArrayList<>(N);
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			scores.add(Integer.parseInt(tokens[i]));
		}
		Collections.sort(scores);
		int little = scores.get(scores.size() / 2 - 1);
		int large = scores.get(scores.size() / 2);
		int result = large - little;
		System.out.println(result);

		in.close();
	}

}


Measured memory_bytes: 44320
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  int n;
  while(cin >> n, n){
    int score_a = 0, score_b = 0;
    int a, b;
    for(int i = 0; i < n; i++){
      cin >> a >> b;
      if(a == b){
        score_a += a;
        score_b += b;
      }else if(a > b){
        score_a += a + b;
      }else{
        score_b += a + b;
      }
    }
    cout << score_a << " " << score_b << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0079
{
    public class Program

    {
        public static void Main(string[] args)
        {
            List<Tuple<double, double>> points = new List<Tuple<double, double>>();
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;

                double[] items = Array.ConvertAll(line.Trim().Split(','), e => double.Parse(e));
                points.Add(new Tuple<double, double>(items[0], items[1]));
            }

            double sum = 0;
            for (int i = 0 ; i < points.Count() - 2 ; i++)
            {
                double edge1 = Math.Sqrt(Math.Pow(points[i + 1].Item1 - points[0].Item1, 2) + (Math.Pow(points[i + 1].Item2 - points[0].Item2, 2)));
                double edge2 = Math.Sqrt(Math.Pow(points[i + 2].Item1 - points[0].Item1, 2) + (Math.Pow(points[i + 2].Item2 - points[0].Item2, 2)));
                double edge3 = Math.Sqrt(Math.Pow(points[i + 2].Item1 - points[i + 1].Item1, 2) + (Math.Pow(points[i + 2].Item2 - points[i + 1].Item2, 2)));

                double z = (edge1 + edge2 + edge3) / 2;
                sum += Math.Sqrt(z * (z - edge1) * (z - edge2) * (z - edge3));
            }
            Console.WriteLine(sum);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16112
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

A,B,C,D=map(int,input().split())

list1=[]

list1.append(A*C)
list1.append(A*D)
list1.append(B*C)
list1.append(B*D)

list1.sort()


print(list1[3])
    


Measured memory_bytes: 9892
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

const long long MAX_V = 1010101;

struct edge {
  long long to, cost;
};

using Pll = pair<long long, long long>;

long long V;
vector<edge> Graph[MAX_V];
long long dist[MAX_V];

void dijkstra(long long s) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;

  // 0-indexedと1-indexedの両方に対応
  fill(dist, dist + V + 1, INF);

  dist[s] = 0;
  que.push(Pll(0, s));

  while (!que.empty()) {
    auto elem = que.top();
    que.pop();

    auto cv = elem.second;

    if (elem.first > dist[cv]) {
      continue;
    }

    for (auto e : Graph[cv]) {
      if (dist[e.to] > dist[cv] + e.cost) {
        dist[e.to] = dist[cv] + e.cost;
        que.push(Pll(dist[e.to], e.to));
      }
    }
  }
}

ll N;
ll Q, K;

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

  rep(i, 1, N) {
    ll a, b, c;
    cin >> a >> b >> c;
    Graph[a].push_back(edge{b, c});
    Graph[b].push_back(edge{a, c});
  }

  cin >> Q >> K;
  dijkstra(K);
  vector<ll> ans;
  rep(i, 0, Q) {
    ll x, y;
    cin >> x >> y;
    ans.push_back(dist[x] + dist[y]);
  }

  for (auto e : ans) {
    cout << e << "\n";
  }
}


Measured memory_bytes: 35344
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

using P = pair<int, int>;

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

inline bool is_inside(const int& h, const int& w, const int& u, const int& v) {
  return !(u < 0 || h <= u || v < 0 || w <= v);
}

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[0][0] = 0;

  queue<P> q;
  q.push({0, 0});

  while (!q.empty()) {
    P u = q.front(); q.pop();
    rep(i, 4) {
      int nh = u.first + dx[i];
      int nw = u.second + dy[i];
      if (!is_inside(h, w, nh, nw)) continue;
      if (s[nh][nw] == '#') continue;
      if (dist[nh][nw] != -1) continue;
      dist[nh][nw] = dist[u.first][u.second] + 1;
      q.push({nh, nw});
    }
  }

  if (dist[h-1][w-1] == -1) {
    cout << -1 << endl;
    return 0;
  }

  int num_white = 0;
  rep(i, h) rep(j, w) if (s[i][j] == '.') num_white++;

  int ans = num_white - (dist[h-1][w-1] + 1);

  cout << ans << endl;

  return 0;
}


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

int main() {
  int b,c;
  int a; 
  cin >> a;
  cin >> b;
  vector<int> vec(a);
  for (int i = 0; i < a; i++) {
  cin >> vec.at(i);
	}
  int sum = 0;
  int ret = 0;
  	if(sum <= b){
      	ret++;
    }
  	for(int i=0;i < a;i++){
      	sum+=vec.at(i);
  		if(sum <= b){
          ret++;
        }
    }	
  cout << ret<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        fr(i,0,n) cin>>a[i];
        ll ans=1000;
        fr(i,1,n)
        {
            if(a[i]>a[i-1])
            {
                ll num=ans/a[i-1];
                ll prof=num*(a[i]-a[i-1]);
                //cout<<num<<" "<<prof<<endl;
                ans+=prof;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1){
		c -= b;
		if (c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	ll n;
	cin >> n;
	int len = log2(n);
	ll ans = 1;
	for(int i = 1; i <= len+1; i++){
		ans *= 2;
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans[200];
	int d=0;
	for(int i=0;i<c;i++){
		if(a+i<=b){
			cout<<a+i<<endl;
			ans[i]=a+i;
			d++;
		}
	}
	bool flag=true;
	for(int i=c-1;i>=0;i--){
		if(b-i>=a){
			flag=true;
			for(int j=0;j<d;j++){
				if(ans[j]==b-i){
					flag=false;
					break;
				}
			}
			if(flag==true){
				cout<<b-i<<endl;
			}
		}
	}
} 

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(b<0)puts(((b-a+1)&1)?"Negative":"Positive");
	else if(a>0)puts("Positive");
	else puts("Zero");
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  ll N;
  cin >> N;
  for(int i = 1;i <= 3500;i++){
    for(int j = 1;j <= 3500;j++){
      ll k = N*i*j;
      ll l = 4*i*j-N*i-N*j;
      if(l <= 0)continue;
      if(k%l == 0){
        printf("%d %d %d\n",i,j,k/l);
        return 0;
      }
    }
  }

  
  




  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> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp 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)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    vl part;
	for (int i=1; i<=sqrt(N); i++) { 
        if (N%i == 0) {
            if (N/i == i) part.pb(i);
            else { part.pb(i); part.pb(N/i); }
        } 
    }
    vl ans;
	rep(i,part.size()) {
        if(part[i] == 1) continue;
		ll now = N;
		while(now%part[i]==0) now /= part[i];
		if(now % part[i] == 1) ans.pb(part[i]);
	}
	N = N-1;
    for (int i=1; i<=sqrt(N); i++) { 
        if (N%i == 0) {
            if (N/i == i) ans.pb(i);
            else { ans.pb(i); ans.pb(N/i); }
        } 
    }
    uniq(ans);
    cout << ans.size() -1 << endl;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  ll n, a = 2, b = 1, c = 0;
  cin >> n;
  if (n == 0) {
    b = 0;
  } else if (n == 1) {
    b = 1;
  } else {
    rep(i, n - 1) {
      c = b;
      b += a;
      a = c;
    }
  }
  cout << b << endl;
}


Measured memory_bytes: 256
S = list(input())
ans = []
count = 0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='T' or S[i]== 'C' or S[i]== 'G':
        count += 1
        if i == len(S)-1 :
            ans.append(count)
    else:
        ans.append(count)
        count = 0
print(max(ans))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	cout << K * (int)pow(K - 1, N - 1) << endl;
	
	return 0;
}

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

using namespace std;

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

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

int tot;
int even;
int n;

int a[110000];

bool can_ri(int ri, int le) {
	return ri+1 < n && a[ri+1] > le;
}

bool can_le(int ri, int le) {
	return a[ri] > le+1;
}

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

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	sort(a,a+n);
	reverse(a,a+n);

	int ri = 0;
	int le = 0;
	while (ri+1 < n && a[ri+1] > (ri+1)) {
		ri++; le++;
	}

	int ri_win = 0;
	int le_win = 0;

	if (can_ri(ri,le)) {
		int ori = ri;
		while (can_ri(ri,le)) ri++;
		ri_win = ((ri+le)%2 != 0);
		ri = ori;
	}
	if (can_le(ri,le)) {
		while (can_le(ri,le)) le++;
		le_win = ((ri+le)%2 != 0);
	}

	if (le_win||ri_win) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 640
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	al.sort()
	r=0
	for i, vi in enumerate(al):
		for j, vj in enumerate(al[i:],i):
			if vi == vj:
				continue
			for vk in al[j:]:
				if vi == vk:
					pass
				elif vj == vk:
					pass
				elif vi + vj <= vk:
					pass
				else:
					r+=1
	return r
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 67404
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let mut s = Vec::new();
    let mut sum = 0;
    let n: usize = read();
    for _ in 0..n {
        let t: usize = read();
        s.push(t);
        sum += t;
    }

    s.sort();

    if sum % 10 != 0 {
        println!("{}", sum);
    } else {
        for &num in &s {
            if num % 10 != 0 {
                sum -= num;
                break;
            }
        }

        if sum % 10 == 0 {
            println!("0");
        } else {
            println!("{}", sum);
        }
    }
}


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

int main() {
  long long N,M;
  cin >> N >> M;

	vector<long long> H(N);
	vector<long long> A(M);
	vector<long long> B(M);
	for(int i=0;i<N;i++){
		cin >> H.at(i);
	}

	vector<long long> cnt_i(N,0);

	for(int i=0;i<M;i++){
		cin >> A.at(i) >> B.at(i);

		if( H.at(A.at(i)-1) < H.at(B.at(i)-1) ){
			cnt_i.at(A.at(i)-1) ++;
		}else if(H.at(A.at(i)-1) > H.at(B.at(i)-1)){
			cnt_i.at(B.at(i)-1) ++;
		}else{
			cnt_i.at(A.at(i)-1) ++;
			cnt_i.at(B.at(i)-1) ++;
		}
	}

	long long cnt_ans = 0;

	for(int i=0;i<N;i++){
		if(cnt_i.at(i)==0){
			cnt_ans ++;
		}
	}

	cout  << cnt_ans << "\n";
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
int n, d[1000];
int ans;
int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> d[i];
	}
	for(int i = 1; i < n; i++) {
		for(int j = i + 1; j <= n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

namespace AOJ0011
{
    class Program
    {
        static void Main()
        {
            var items = Enumerable.Range(1, int.Parse(Console.ReadLine() ?? "")).ToList();
            var swapCount = int.Parse(Console.ReadLine() ?? "");

            for (var i = 0; i < swapCount; i++)
            {
                var values = (Console.ReadLine() ?? "").Split(',').Select(int.Parse).ToArray();
                items.Swap(values[0] - 1, values[1] - 1);
            }

            foreach (var item in items)
            {
                Console.WriteLine(item);
            }
        }
    }

    public static class EnumerableExtentions
    {
        public static void Swap<T>(this List<T> array, int index1, int index2)
        {
            var temp = array[index1];
            array[index1] = array[index2];
            array[index2] = temp;
        }
    }
}

Measured memory_bytes: 5932