akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N,K;
	cin >> N >> K;
	VLL P(N);
	for (LL n = 0; n < N; n++)cin >> P[n];
	sort(P.begin(), P.end(), [](LL a, LL b) {
		return a < b; });
	LL ans = 0;
	for (LL k = 0; k < K; k++) {
		ans += P[k];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3132
import sys
from collections import defaultdict as dd
from itertools import permutations as permi
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
res = 0
for p in permi([x for x in range(1, N + 1)], N):
  if p[0] != 1: continue
  go = list(p[: : -1])
  s = [go.pop()]
  while len(s):
    x = s.pop()
    if len(go) == 0: break
    for y in e[x]:
      if y == go[-1]:
        s.append(go.pop())
        break
  res += len(go) == 0

print(res)

Measured memory_bytes: 41968
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 

int32_t main(){
  fast; 

  int l ; cin>>l; 
  double long val= (double ) l/3; 
  val=(val*val*val); 
  cout<<setprecision(7)<<val<<endl; 
   
  return 0; 
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
const double EPS = 1e-12;

double cross(const xy_t &a, const xy_t &b){
  return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
  return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
  double t = dot(l.second - l.first, p - l.first) / norm(l.second - l.first);
  return l.first + t * (l.second - l.first);
}

bool intersectSP(const line &l, const xy_t &p){
  return abs(p - l.first) + abs(p - l.second) < abs(l.first - l.second) + EPS;
}

double distanceSP(const line &l, const xy_t &p){
  xy_t r = projection(l, p);
  if(intersectSP(l, r)) return abs(r - p);
  else return min(abs(l.first - p), abs(l.second - p));
}

int ccw(xy_t a, xy_t b, xy_t c){
  b -= a, c -= a;
  if(cross(b, c) > 0) return 1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
 
xy_t p[3];
line l[3];
xy_t c;
double r;


int main(){
  int x, y;
  int c1, c2;
  while(cin >> x>> y && (x || y)){
    p[0] = xy_t(x, y);
    for(int i = 1; i < 3; i++) {
      cin >> x >> y;
      p[i] = xy_t(x, y);
    }
    cin >> x >> y;
    cin >> r;
    c = xy_t(x, y);
    
    rep(i, 3) l[i] = line(p[i], p[(i+1)%3]);
    c1 = 0, c2 = 0;
    int cnt = 0;

    rep(i, 3){
      int d = ccw(p[i], p[(i+1)%3], c);
      if(d > 0) c1++;
      if(d < 0) c2++;
    }
    bool circle_in[3];
    rep(i, 3){
      if(distanceSP(l[i], c) < r + EPS) cnt++;
      if(distanceSP(l[i], c) > r - EPS){
	circle_in[i] = true;
      }else{
	circle_in[i] = false;
      }
    }
    
    bool t_in[3];
    rep(i, 3){
      if(abs(c - p[i]) < r + EPS){
	t_in[i] = true;
	cnt++;
      }else{
	t_in[i] = false;
      }
    }
    if(circle_in[0] && circle_in[1] && circle_in[2] && max(c1, c2) == 3){
      cout << 'a' << endl;
    }else if(t_in[0] && t_in[1] && t_in[2]) {
      cout << 'b' << endl;
    }else if(cnt > 0){
      cout << 'c' << endl;
    }else{
      cout << 'd' << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
sa = [0]
for a in A:
    sa.append((sa[-1] + a) % K)
d = {0: 1}
ans = 0
for i in range(1, N+1):
    if i >= K:
        d[sa[i-K]] -= 1
    v = d.get(sa[i], 0)
    ans += v
    d[sa[i]] = v + 1
print(ans)

Measured memory_bytes: 117248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum=0;
    if(k>=a){
        sum=a;
        if(k-a>=b){
            if(k-a-b<=c){
                sum+=(-1)*(k-a-b);
                cout<<sum<<endl;
                return 0;
            }
        }else{
            sum=a;
            cout<<sum<<endl;
            return 0;
        }
    }else{
        sum=k;
        cout<<sum<<endl;
        return 0;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<30)
using namespace std;
typedef pair<int,int>pii;
int n,K;
vector<int>a;
int tot;
// int a[5010];
int f[5010];
bool check(int k){
	int t=a[k];
	a.erase(a.begin()+k);
	int m=n-1;
	memset(f,0,sizeof(f));
	f[0]=1;
	for(int i=1;i<=m;i++){
		for(int j=K;j>=a[i];j--){
			f[j]=max(f[j],f[j-a[i]]);
		}
	}
	a.insert(a.begin()+k,t);
	bool flg=0;
	for(int i=max(K-t,0);i<K;i++){
		if(f[i]){
			flg=1;
			break;
		}
	}
	return flg==0;
	// for(int i=1;i<=K;i++)cout<<f[i]<<' ';
	// puts("");
}
int main(){
	// freopen("my sol.in","r",stdin);
	// freopen("my sol.out","w",stdout);
	cin>>n>>K;
	a.resize(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a.begin()+1,a.end());
	int ll=0,rr=n;
	while(rr-ll>1){
		// cout<<ll<<' '<<rr<<endl;
		int mid=(ll+rr)>>1;
		if(check(mid))ll=mid;
		else rr=mid-1;
	}
	// cout<<ll<<' '<<rr<<endl;
	if(check(rr))cout<<rr<<endl;
	else cout<<ll<<endl;
	return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7) YES;
    else if(a==5&&b==7&&c==5) YES;
    else if(a==7&&b==5&&c==5) YES;
    else NO;
    return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int DEBUG = 0;

const int N = 100010;
bool done[N];

bool match(int n, int m, const VI &target, const VI &op, int tol) {
  assert (0 <= tol && tol < m);
  VI inv_t(m);
  REP(i, 0, m) {
    inv_t[target[i]] = i;
  }
  VI prog(m + 1);
  VI pass(m + 1);
  prog[0] = n;
  REP(i, 0, op.size()) {
    int idx = inv_t[op[i]];
    if (0 <= idx && idx < m) {} else {
      exit(1);
    }
    if (prog[idx] == 0 && !pass[idx]) {
      return false;
    }
    if (prog[idx] == 0) {
      continue;
    }
    prog[idx]--;
    prog[idx + 1]++;
    pass[idx] = 1;
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      cout << "prog[" << i << "]=" << prog[i] << endl;
    }
  }
  REP(i, 0, tol) {
    if (prog[i] > 0) {
      return 0;
    }
  }
  return 1;
}

int main(void){
  int n, m, q;
  cin >> n >> m >> q;
  VI a(q);
  REP(i, 0, q) {
    cin >> a[i];
    a[i]--;
  }
  reverse(a.begin(), a.end());
  vector<bool> used(m);
  int cur = 0;
  VI target(m);
  REP(i, 0, q) {
    if (used[a[i]]) {
      continue;
    }
    used[a[i]] = 1;
    target[cur] = a[i];
    cur++;
  }
  REP(i, 0, m) {
    if (!used[i]) {
      target[cur++] = i;
    }
  }
  assert (cur == m);
  int oldcur = m - 1;
  while (oldcur > 0) {
    if (target[oldcur - 1] < target[oldcur]) {
      oldcur--;
    } else {
      break;
    }
  }
  if (DEBUG) {
    cerr << "target:";
    REP(i, 0, m) {
      cerr << " " << target[i];
    }
    cerr << endl << "tol = " << oldcur << endl;
  }
  cout << (match(n, m, target, a, oldcur) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 3e3 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 998244353;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
ll dp[N][N];
int a[N];
int n, s;
ll bp(ll a, ll n){
    a %= MOD; 
    ll ans = 1;
    while(n) {
        if(n & 1)
            ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return ans;
}
void solve(){
    cin >> n >> s;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    dp[0][0] = bp(2, n);

    ll inv2 = bp(2, MOD - 2);
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= s; ++j)
            dp[i][j] = dp[i - 1][j];
        for(int j = s; j >= a[i]; --j) {
            dp[i][j] += (dp[i - 1][j - a[i]] * inv2);
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][s];
}
 
int main(){
    speed();
    int t = 1;

    // cin >> t;
    while(t--)solve();
}

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

typedef long long lint;

const int MAXN = 100010;

lint A[MAXN];
lint bas[60];

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

	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];

	lint B = 0;
	for(int i = 0; i < N; i++) B ^= A[i];
	for(int i = 0; i < N; i++) A[i] ^= A[i] & B;
	for(int i = 0; i < N; i++) for(int j = 59; j >= 0; j--) if(A[i] & (1ll << j)) {
		if(bas[j]) A[i] ^= bas[j];
		else {
			bas[j] = A[i];
			break;
		}
	}

	lint C = 0;
	for(int i = 59; i >= 0; i--) if(!(C & (1ll << i)) && bas[i]) 
		C ^= bas[i];

	cout << B + 2 * C;
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 500005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int cn = 0;
    while (a > 0 && c > 0) {
        if (cn & 1)
            a -= d;
        else
            c -= b;
        cn++;
    }
    if (a <= 0) {
        printf("No");
    } else {
        printf("Yes");
    }
    return 0;
}

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

#define MAX_N 100000

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int RL = 0;
  int LR = 0;
  int RR_LL = 0;
  rep(i, N - 1) {
    if (S[i] == 'R' && S[i + 1] == 'L') RL++;
    if (S[i] == 'L' && S[i + 1] == 'R') LR++;
    if (S[i] == S[i + 1]) RR_LL++;
  }
  // cout << "N=" << N << " LLRR=" << RR_LL << " RL=" << RL << " LR=" << LR <<
  // endl;
  int Ans = min(N - 1, RR_LL + 2 * K);
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    char ch;
    int x[123] = {0};

    while (cin >> ch){
        if('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z'){
            if(ch <= 96)    ch = ch + 32;
            x[ch-0]++;
        }
    }
    for(int i = 97 ; i <= 122 ; i++){
        printf("%c : %d\n", i ,x[i]);
    }
    return 0;
}



Measured memory_bytes: 3156
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    rep(i,N) cout << S[i];
    cout <<  endl;



    return 0;
}

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

using namespace std;

int main(){
  ll X,ans=0,n;
  cin>>X;
  for(int i=1;;i++){
    ans+=i;
    if(X<=ans){
      n=i;
      break;
    }
  }
  cout<<n<<endl;
}


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

int main(){
	string s,t; cin >> s >> t;
	int cnt=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i])cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;
const int INF = 1e9 + 10 ;
int main(){
    int n , m ;
    cin >> n >> m ;
    vector<vector<int> > c(10, vector<int>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j] ;
            if ( c[i][j] == 0 ) c[i][j] = INF ;
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                if ( c[j][i] + c[i][k] < c[j][k] ){
                    c[j][k] = c[j][i] + c[i][k] ;
                }
            }
        }
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            int x ;
            cin >> x ;
            if ( x == -1 || x == 1) continue ;
            ans += c[x][1] ;
        }
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{

}
int main()
{
    long long a, b, c; cin >> a >> b >> c;
    long long aa = a;
    a = abs(a);
    if(a < c)
    {
        long long d = a-c;
        long long tt = d+c;
        if(b%2 == 1)
        {
            cout << abs(d) << endl;
            return 0;
        }
        else
        {
            cout << tt << endl;
            return 0;
        }
    }
    if(a == c)
    {
        if(b%2 == 0)
        {
            cout << a << endl;
            return 0;
        }
        else
        {
            cout << 0 << endl;
            return 0;
        }
    }
    long long dd = a/c;
    if(b <= dd)
    {
        cout << a-(b*c) << endl;
    }
    else
    {
        long long re = b-dd;
        a = a-(dd*c);
        long long aaa = a+c;
        long long bbb = abs(a-c);
        //cout << re << " " << a << " " << aaa << " " << bbb << endl;
        long long mm = min(aaa, bbb);
        if(re%2 == 1)
        {
            cout << mm << endl;
        }
        else
        {
            cout << a << endl;
        }
    }
    return 0;
}


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

int main(){

	int N;
	cin >> N;

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

	int count = 0;
	bool  flag = 1;
	while (flag){
		flag = 0;
		for (int i = N-1; i > 0; i--){
			if (A[i] < A[i - 1]){ 
				int t = A[i];  A[i] = A[i - 1]; A[i - 1] = t;
				flag = 1;
				count++;
			}
		}
	}

	for (int i = 0; i < N; i++){
		printf("%d%c", A[i], i == N - 1 ? '\n' : ' ');
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3140
n = int(input())
s = input()

answer = 0
for index in range(1,len(s)-1):
  x = list(set(s[:index]))
  y = list(set(s[index:]))
  count = 0
  if len(x) > len(y):
    for check in x:
      if check in y:
        count += 1
  else:
    for check in y:
      if check in x:
        count += 1
  if count > answer:
    answer = count
  
print(answer)

Measured memory_bytes: 9096
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N,a,b,c;
    cin>>N;
    a=N/100;
    b=(N-100*a)/10;
    c=N-100*a-10*b;
    if (a==7||b==7||c==7) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3676
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> xo(60);
    rep(i, n) {
        rep(j, 60) {
            xo[j] += 1 & (a[i] >> j);
        }
    }

    mint ans;
    rep(i, 60) {
        ans += mint(xo[i])*mint(n-xo[i])*mint(2).pow(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
# coding: utf-8
# @????????? #?????? *?????????
import sys
sys.setrecursionlimit(10000000)

def dfs(x, y, fru):
    # ???????????¨?????????.???????????????
    field[x][y] = '.'
    # 4??????????????????
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)
    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)

def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] != '.':
                dfs(i,j,field[i][j])
                count+=1
            # elif field[i][j] == '#':
            #     dfs(i,j,'#')
            #     count+=1
            # elif field[i][j] == '*':
            #     dfs(i,j,'*')
            #     count+=1
    print(count)

f = 0
while(f == 0):
    H, W = map(int, input().split())
    if H != 0 and W != 0:
        field = [] # ????¨??????¨?????????
        for i in range(H):
            field.append(list(input()))
        solv(H,W)
    else:
        f = 1

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= x; i++) {
    if (2 * i + 4 * (x - i) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int main() {
  int x, y;
  cin >> y >> x;
  x+=2;
  y+=2;
  for(int i=0; i < y; i++){
  	for(int j=0; j < x; j++){
      if ((i == 0) || (i == (y - 1))) {
       	 cout << '#';
      } 
      else if ((j == 0) || (j == (x - 1))) {
       	 cout << '#';
      }
      else {
        char c;
        cin >> c;
        cout << c;
      }
  	}
    cout << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a = new int[n];
		int A=0;
		int B=0;
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			b[i] = a[n - i - 1];
		}
		for(int i = 0; i < n; i++) {
			if(i % 2 == 0) {
				A += b[i];
			} else {
				B += b[i];
			}
		}
		System.out.println(A - B);

	}

}


Measured memory_bytes: 21844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);		
		int x = sc.nextInt();
		int y = sc.nextInt();

		int sum = 0;
		
		if(x == 3) {
			sum += 100000;
		} else if (x == 2) {
			sum += 200000;
		} else if(x == 1) {
			sum += 300000;
		}
		
		if(y == 3) {
			sum += 100000;
		} else if (y == 2) {
			sum += 200000;
		} else if(y == 1) {
			sum += 300000;
		}
		
		if(x == 1 & y == 1) {
			sum += 400000;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main() 
{
  fastio;
  
  
  map<string,int> mp;
  mp["SUN"]=7;
  mp["MON"]=6;
  mp["TUE"]=5;
  mp["WED"]=4;
  mp["THU"]=3;
  mp["FRI"]=2;
  mp["SAT"]=1;
  string s;
  cin>>s;
  cout<<mp[s]; 
 
}

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz);

  for (int i = 0; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 0; n < ( 1 << cnrvvoExpr.size() ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() ; i++)
      if (n & ( 1 << i ))
      {
        vnHonest[i] = 1;               // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i] = 0;               // UnKind

    bool bReslt = true;

    for (int nMan = 0; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int inf = 1001001001;
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1);
	h[0] = 0;
	rep(i, n) cin >> h[i + 1];

	vector<int> dp(n + 2*k,inf);

	//1-indexed

	dp[1] = 0;
	
	rep(i, n + 1) {
		if (i == 0) continue;
		for (int j = 1; j <= k; ++j) {
			if (i + j >= n + 1) continue;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	dunk(dp[n]);

	return 0;
}

Measured memory_bytes: 1024
$s=<>;$t=<>;chomp($s);chomp($t);
@S=sort{$a cmp $b}(split//,$s);
@T=sort{$b cmp $a}(split//,$t);
for(0..$#S){
    $j = $S[$_] cmp $T[$_];
    next if $j==0;
    if($j>0){
        print "No";
    }else{
        print "Yes";
    }
    exit;
}
print+($#S<$#T)?Yes:No

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << std::min(a*n , b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 2001

char resultTable[SIZE];
int n,q,elems[20];

void calc(int sum,int index){
	if(index == n){
		if(sum >= 1 && sum <= 2000){
			resultTable[sum] = 'y';
		}
	}else{
		calc(sum+elems[index],index+1);
		calc(sum,index+1);
	}
}

int main(){

	for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';

	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
	calc(0,0);

	scanf("%d",&q);

	int tmp;
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		if(resultTable[tmp] == 'y'){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
}



Measured memory_bytes: 2628
#include <iostream>
using namespace std;
int main()
{
    int sum;
    int P, Q, R;
    cin >> P >> Q >> R;

    int min[] = {P, Q, R};

    for (int i=0; i < 2; i++)
    {
        if (min[i] > min[i + 1])
            swap(min[i], min[i + 1]);
    }
    // 出力
    cout << min[0] + min[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define P 1000000007
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
ll gcd(ll a, ll b){
  if(a==0) return b;
  if(b==0) return a;
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  map<vll, ll> mp;
  ll zero = 0;
  for(int i=0;i<n;i++){
    ll a, b; scanf("%lld %lld", &a, &b);
    if(a==0&&b==0) {
      zero++;
      continue;
    }
    ll g = gcd(abs(a), abs(b));
    a /= g, b /= g;

    vll A{a, b};
    vll B{-b, a};
    vll C{-a, -b};
    vll D{b, -a};
    if(mp.find(A) == mp.end()) mp.emplace(A, 0);
    if(mp.find(B) == mp.end()) mp.emplace(B, 0);
    if(mp.find(C) == mp.end()) mp.emplace(C, 0);
    if(mp.find(D) == mp.end()) mp.emplace(D, 0);
    auto itr = mp.find(A);
    (*itr).second++;
  }

  ll ans = 1;
  for(auto now:mp){
    vll tmp = now.first;
    if(tmp[0]<=0||tmp[1]<0) continue;
    ll a = mp.at(tmp);
    ll b = mp.at(vll{-tmp[1], tmp[0]});
    ll c = mp.at(vll{-tmp[0], -tmp[1]});
    ll d = mp.at(vll{tmp[1], -tmp[0]});
    ll f = (mpow(2, a+c, P) - 1 + P)%P;
    ll g = (mpow(2, b+d, P) - 1 + P)%P;
    ll x = (1+f+g)%P;
    ans = (ans*x)%P;
  }
  std::cout << ((ans-1+P)%P + zero)%P << '\n';
  return 0;
}


Measured memory_bytes: 90724
#include <stdio.h>
int main(void)
{
	int a, b;
	scanf("%d",&a);
	scanf("%d",&b);

	if (a > b)
	   printf("a > b\n",a,b);
	else if (a < b)
	   printf("a < b\n",a,b);
	else if (a == b)
	   printf("a == b\n",a,b);



	return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        double x1, x2, y1, y2;
        str = scan.nextLine();
        String[] num = str.split(" ", 0);
        x1 = Double.valueOf(num[0]);
        y1 = Double.valueOf(num[1]);
        x2 = Double.valueOf(num[2]);
        y2 = Double.valueOf(num[3]);
        System.out.println(Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2)));


        scan.close();

    }

}



Measured memory_bytes: 26280
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;
const int mod=1000000007;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int n,m;
int v[N],cnt=0;
int dp[32][N];

int fac[N],ifac[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
}
inline int C(int n,int m) {
    if (n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main() { init(1e5);
    n=read(),m=read();
    if (m==1) { puts("1"); return 0; }
    for (re int i=1;i*i<=m;++i) {
        if (m%i==0) {
            v[++cnt]=i;
            if (i*i!=m) v[++cnt]=m/i;
        }
    }
    sort(v+1,v+cnt+1); dp[0][1]=1;
    for (re int i=1;i<=min(n,31);++i)
        for (re int j=1;j<=cnt;++j)
            for (re int k=1;k<=j&&v[k]*2<=v[j];++k)
                if (v[j]%v[k]==0)
                    dp[i][j]=(dp[i][j]+dp[i-1][k])%mod;
    int ans=0;
    for (re int i=1;i<=min(n,31);++i)
        ans=(ans+1ll*C(n,i)*dp[i][cnt])%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 11264
using System;

					
public class Program
{
	static int[,] DP;
	static int[] p;
	
	public static void Main()
	{		
		int n = int.Parse(Console.ReadLine());
		DP = new int[n+1,n+1];
		p = new int[n + 1];
		
		string[] buf = Console.ReadLine().Split(" ".ToCharArray());
		p[0] = int.Parse(buf[0]);
		p[1] = int.Parse(buf[1]);
		for(int i = 1; i < n; i++) {
			buf = Console.ReadLine().Split(" ".ToCharArray());
			p[i+1] = int.Parse(buf[1]);
		}
		
		for(int i = 0; i < n; i++) {
			DP[i,i] = 0;
			if(i >= 1) {
				DP[i, i +1] = p[i-1]*p[i]*p[i+1];
			}
		}
		
		for(int j = 0; j<= n-3; j++) {
			for(int i = 3+j; i <= n; i++) {
				DP[i - 2 - j, i] = Rec(i - 2 - j, i);
			}
		}
		
		Console.WriteLine(DP[1,n]);
	}
	
	public static int Rec(int r, int c)
	{
		int min = int.MaxValue;
		
		for(int i = 0; i < (c-r); i++) {
			min = Math.Min(min, DP[r,r+i] + DP[r+i+1,c] + p[r-1] * p[r+i] * p[c]);
		}
		
		return min;
	}
}

Measured memory_bytes: 9172
module UF = struct
  type node = {
    mutable par: int;
    mutable rank: int;
  };;


  let make n = Array.init n (fun i -> { par = i; rank = 0 })
  ;;

  (* 根を求める *)
  let rec find uf x =
    if uf.(x).par == x
    then x
    else
      let par = uf.(x).par in
      let v = find uf par in
      uf.(x).par <- v;
      v
  ;;

  (* xとyの集合を併合 *)
  let unite uf x y =
    let x = find uf x in
    let y = find uf y in
    if x != y then
      if uf.(x).rank < uf.(y).rank
      then (
        uf.(x).par <- y;
        ()
      )
      else (
        uf.(y).par <- x;
        if uf.(x).rank == uf.(y).rank then (
          uf.(x).rank <- uf.(x).rank + 1;
          ()
        )
      )
  ;;

  let some uf x y = find uf x == find uf y
  ;;
end

let dec x = x -1
;;

let tuple2map fa fb (a, b) = (fa a, fb b)
;;

let tuple2 a b = (a, b)
;;

let curry2 f a b = f (a, b)
;;

let uncurry2 f (a, b) = f a b
;;

let (>>) f g x = g (f x)
;;

let (>>>) f g x y = g (f x y)
;;

let list_init n f = Array.init n f |> Array.to_list
;;

let tuple3 a b c = (a, b, c)
;;

let tuple4 a b c d = (a, b, c, d)
;;

let rec f a_list min n m list =
  if Array.length a_list == n
  then
    list
    |> List.filter_map
      (fun (a, b, c, d) -> if a_list.(b-1) - a_list.(a-1) == c then Option.some d else Option.none) 
    |> List.fold_left (+) 0
  else
    List.init (m - min + 1) ((+) min)
    |> List.map (fun min -> f (Array.append a_list [|min|]) min n m list)
    |> List.fold_left max 0
;;

let () =
  let n, m, q = Scanf.scanf "%d %d %d\n" tuple3 in
  let list = list_init q (fun _ -> Scanf.scanf "%d %d %d %d\n" tuple4) in
  let res = f [||] 1 n m list in
  Printf.printf "%d\n" res
;;


Measured memory_bytes: 5888
# 色の塗り方は全部で何通りか。O(C^3)で、C^3 = 27000通り。
# 各塗り方に対していちいち計算していると最大25000マスで、これだと間に合わない。
# 3つに別れた各部分を各色に変えるコスト合計を前計算しておけば良い。O(C^3 + N^2 C)。
# 一ひねりした全探索。

n, c = list(map(int, input().split()))
change_cost = [list(map(int, input().split())) for _ in range(c)]
init_color = [list(map(int, input().split())) for _ in range(n)]

cost = [[0 for _ in range(c)] for _ in range(3)]

for row in range(n):
    for col in range(n):
        before = init_color[row][col] - 1
        for after in range(c):
            idx = (row + col) % 3
            cost[idx][after] += change_cost[before][after]

ans = 1000 * 500 * 500 * 10
for ci in range(c):
    for cj in range(c):
        for ck in range(c):
            if (ci != cj != ck != ci):
                ans = min(ans, cost[0][ci] + cost[1][cj] + cost[2][ck])

print(ans)


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

// macros
#define overload_rep(va_0, va_1, va_2, va_3, name, ...) name
#define rep_0_(i, n) for(int i = 0; i < (n); ++i)
#define rep_1_(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep_2_(i, x, y, z) for(int i = (x); i >= (y); --i)
#define rep(...) overload_rep(__VA_ARGS__, rep_2_, rep_1_, rep_0_)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N)cin >> x[i] >> y[i];

    vector<int> ord(N);
    iota(all(ord), 0);

    long double ans = 0.0;
    do{
        rep(i, N - 1){
            ans += hypotl(x[ord[i + 1]] - x[ord[i]], y[ord[i + 1]] - y[ord[i]]);
        }
    }while(next_permutation(all(ord)));

    int tmp = 1.0;
    rep(i, 1, N)tmp *= i;
    cout << ans / tmp << '\n';
    return 0;

}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int n,i,a,b,ap,bp;
	ap=0;
	bp=0;
	while(1){
		scanf("%d",&n);
		if(n==0)
			return 0;
		for(i=0;i<=n-1;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				ap=ap+a+b;
			}else if(a<b){
				bp=bp+a+b;
			}else{
				ap=ap+a;
				bp=bp+b;
			}
		}
		printf("%d %d\n",ap,bp);
		ap=0;
		bp=0;
	}
}

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

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

    return( gcd( b, a % b ) );
}

int main( int argc, char *argv[] )
{
    int n;
    long long tot = 0;

    scanf( "%d", &n );

    for( int i=1; i<=n; i++ )
    for( int j=1; j<=n; j++ )
    for( int k=1; k<=n; k++ ) {

        int g = gcd( gcd( i, j ), k );

        tot += g;
    }

    printf( "%lld\n", tot );
}


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

int main() {
	int a[10] = {0}, i = -1, n;
	while(cin >> n) {
		if(n == 0) {
			cout << a[i--] <<endl;
		} else{
			i++;
			a[i] = n;
		}
	}
	return 0;
}

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

int main(){

    int n;
    cin>>n;
    int ans=0;
    int before=n+1;
    vector<int> a(n),b(n),c(n-1);

    for(int i=0;i<n;i++) cin>>a.at(i);
    for(int i=0;i<n;i++) cin>>b.at(i);
    for(int i=0;i<n-1;i++) cin>>c.at(i);

    for(int i=0;i<n;i++){

        ans+=b.at(a.at(i)-1);
        if(a.at(i)-1==before) ans+=c.at(a.at(i)-2);
        before=a.at(i);

    }
    cout<<ans<<endl;





    return 0;
}

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

int main(){
	string s;
	int n;
	cin >> s;
	n = s[s.size() -1] - '0';
	if(n == 2 or n == 4 or n == 5 or n == 7 or n == 9){
		cout << "hon\n";
	}else if(n == 3){
		cout << "bon\n";
	}else{
		cout << "pon\n";
	}
   return 0; 
}



Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W; cin>>H; cin>>x; cin>>y; cin>>r;
    if(x+r>W){
     cout<<"No";
    }
    else if(r>x){
        cout<<"No";
    }
    else if (H<y+r){
       cout<<"No";
    }
    else if(r>y){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
      cout<< endl;
       return 0;
} 


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 35000;
const int K = 19;
int mod =  998244353;
int a[N], n, b[N], p[N];
int binpow(int x, int y, int mod){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1, mod) % mod;
    int z = binpow(x, y / 2, mod);
    return z * z % mod;
}
bool prime(int x){
    for (int i = 2; i * i <= x; i++){
        if (x % i == 0) return 0;
    }
    return 1;
}
int poly(int x, int mod){
    int res = 0;
    int p = 1;
    for (int i = 0; i <= n; i++){
        res = (res + b[i] * p) ;
        p = 1LL * p * x % mod;
    }
    return res % mod;
}
bool check (int x){
    int r = min(x - 1, n);
    for (int i = 0; i <= n; i++) b[i] = a[i] % x;
    for (int i = 0; i <= r; i++) p[i] = i;
    random_shuffle(p, p + r + 1);
    double t = clock() * 1.0 / CLOCKS_PER_SEC;
    int z;
    if (t < 0.4) z = 1; else z = 3;
    for (int i = 0; i <= r / z; i++){
        if (poly(p[i], x) != 0) return 0;
    }
    return 1;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    cin >> n;
    int s = 0;
    for (int i = n; i >= 0; i--){
        cin >> a[i];
        s += a[i];
    }
    int l = 0;
    while(a[l] == 0) l++;
    int x = a[l];
    vector < int > ans;
    set < int > r;
    x = abs(x);
    for (int i = 2; i * i <= x; i++){
        if (x % i == 0){
            r.insert(i);
            while(x % i == 0) x /= i;
        }
    }
    if (x != 1) r.insert(x);
    int d = 0;
    for (int i = 2; i <= n; i++){
        if (prime(i)){
            r.insert(i);
            d += i;
        }
    }
    for (auto i: r) if (check(i)){
        ans.pb(i);
    }

    for (auto i: ans) cout << i << " ";
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int A,B;
	scanf("%d", &A);
	scanf("%d", &B);
	if(A >= -100 && B >= -100 && 100>= A  && 100>=B &&(A+B) >= (A*B) && (A+B)>=(A-B))
	{printf("%d", A+B);}
    else if(A >= -100 && B >= -100 && 100>= A  && 100>=B && (A-B)>=(A+B) && (A-B)>=(A*B))
	{printf("%d", A-B);}
    else if(A >= -100 && B >= -100 && 100>= A  && 100>=B && (A*B)>=(A+B) && (A*B)>=(A-B))
    {printf("%d", A*B);}
    else {printf("error");}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

  for (int i = 0; i <= n; i++) {
    int cost = i * 1.08;
    if (cost == n) {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
}


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

vector<pair<int,int> > l,r;
bool used[100005];
int n;

int main(){
    scanf("%d",&n);
    for (int x = 0; x<n; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        l.push_back({a,x});
        r.push_back({b,x});
    }
    sort(l.begin(),l.end(),greater<pair<int,int> >());
    sort(r.begin(),r.end());
    long long try1 = 0;
    int curpos = 0;
    for (int x = 0; x<n; x++){
        if (!used[l[x].second]) {
            used[l[x].second] = true;
            if (l[x].first>curpos){
                try1 += l[x].first-curpos;
                curpos = l[x].first;
            }
        }
        if (!used[r[x].second]){
            used[r[x].second] = true;
            if (r[x].first<curpos){
                try1 += curpos-r[x].first;
                curpos = r[x].first;
            }
        }
    }
    try1 += abs(curpos);
    long long try2 = 0;
    curpos = 0;
    memset(used,false,sizeof(used));
    for (int x = 0; x<n; x++){
        if (!used[r[x].second]){
            used[r[x].second] = true;
            if (r[x].first<curpos){
                try2 += curpos-r[x].first;
                curpos = r[x].first;
            }
        }
        if (!used[l[x].second]) {
            used[l[x].second] = true;
            if (l[x].first>curpos){
                try2 += l[x].first-curpos;
                curpos = l[x].first;
            }
        }
    }
    try2 += abs(curpos);
    printf("%lld",max(try1,try2));



}


Measured memory_bytes: 5096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Convert.ToInt32(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                var A = Convert.ToInt32(Console.ReadLine());
                var B = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(A + B);
            }
        }
    }
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  //
  int n;
  cin >> n;
  vector<ll> va(n), vb(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
    if (i == 0) {
      vb[i] = va[i];
    } else {
      vb[i] = max(vb[i - 1], va[i]);
    }
  }

  ll ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    ans += max(0ll, vb[i] - va[i]);
  }

  cout << ans << '\n';
  return 0;
}

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

ll INF=10000005;


int main(void){
    int n, m;
    cin>>n>>m;
    vector<int> dp(n+1, -INF);
    vector<int> v(m);
    rep(i, m) cin>>v[i];
    vector<int> num={2, 5, 5, 4, 5, 6, 3, 7, 6};
    dp[0]=0;
    for(int i=1;i<=n;i++){
        rep(j, m){
            int number=num[v[j]-1];
            if(i-number<0) continue;
            dp[i]=max(dp[i-number]+1, dp[i]);
        }
    }
    vector<int> ans(dp[n]);
    sort(v.begin(), v.end(), greater<int>());
    int matchnum=n;
    for(int i=1;i<=dp[n];i++){//最上位から数えて何桁目かを示している
        rep(j, m){//どの数字を使うかをループしている
            //cout<<i<<j<<endl;
            if(matchnum-num[v[j]-1]<0) continue;
            if(dp[matchnum-num[v[j]-1]]==dp[n]-i){
                //cout<<i<<", "<<j<<endl;
                ans[i-1]=v[j];
                matchnum-=num[v[j]-1];
                break;
            }
        }
    }
    //rep(i, n) cout<<dp[i]<<endl;
    rep(i, dp[n]) cout<<ans[i];
    cout<<endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<time.h>
#include<sstream>
#define MINN -1e8 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=0x3f3f3f3f3f3f;
const int P=1e9+7;
const int MAXN=32000;
const double pi=3.1415926;
//const int MINN=-1e8;
const ll mod=1000000007;

//map<string,ll> m;
//map<ll,ll> m;

//set<ll> s;

//vector<ll> v;

//scanf("%lld",&t);
//scanf("%lld%lld",&,&);
ll n,k,ans;
ll a[2001];
ll powmod(ll a,ll b)     //快速幂 
{
	ll tmp=a%mod;
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*tmp%mod;
		tmp=tmp*tmp%mod;
		b>>=1;
	}
	return ans%mod;
}
ll f(ll k)
{
	return k%mod*(k-1)%mod*powmod(2,mod-2)%mod;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	int x=0,y=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[j]<a[i])x++;
		}
	}
	if(k==1)
	{
		cout<<x;return 0;
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(a[j]<a[i])y++;
			}
		}
		ans=(k*x%mod+f(k)*y%mod)%mod;
		cout<<ans<<"\n";
	}
	return 0;
}
//ll n,m,t,a,x,ans,res;
//ll powmod(ll a,ll b)     //快速幂 
//{
//	ll tmp=a%mod;
//	ll ans=1;
//	while(b)
//	{
//		if(b&1)ans=ans*tmp%mod;
//		tmp=tmp*tmp%mod;
//		b>>=1;
//	}
//	return ans%mod;
//}


//bool is_prime(ll a)     //判断素数 
//{
//	if(a==2)return 1;
//	else if(a==1||a%2==0)return 0;
//	else
//	{
//		for(ll i=3;i*i<=a;++i)
//		{
//			if(a%i==0)return 0;
//		}
//	}
//	return 1;
//}



Measured memory_bytes: 256