akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<int> dp(100005, INF);
int main() {
  int n; cin >> n;
  set<int> s; s.insert(1);
  int a=6,b=9;
  while(a <= n) { s.insert(a); a*=6; }
  while(b <= n) { s.insert(b); b*=9; }

  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for(auto x: s) {
      if (i-x >= 0) dp[i] = min(dp[i], dp[i-x]+1);
    }
  }
  COUT(dp[n]);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long gcd(long long a,long long b){if(b==0)return a;return gcd(b,a%b);}
long long lcm(long long a,long long b){return a*b/gcd(a,b);}
int mod_pow(long long a,long long n,long long p){if(n == 1){return a%p;}if(n%2==1){return(a*mod_pow(a,n-1,p))%p;}long long t=mod_pow(a,n/2,p);return (t*t)%p;}
long long mod(long long v,long long p){long long res=v%p;if(res<0){res+=p;}return res;}

template < typename T > void coutVector(vector<T> v){for(int i=0;i<int(v.size());++i){if(i>0)cout<<" "<<v[i];else cout<<v[i];}cout<<endl;}
template < typename T > void coutVectorWithEndl(vector<T> v){for(int i=0;i<int(v.size());++i){cout<<v[i]<<endl;}}
template < typename T > vector<T> cinVector(int n) {vector<T> res(n);for(int i=0;i<n;++i){cin>>res[i];}return res;}
const int MAX = 510000;
const ll MOD = 1e9+7;
int main() {
    int N; cin >> N;
    for (long long i = 1; i < 3501; ++i) {
        for (long long j = 1; j < 3501; ++j) {
            long long p = i * j * N;
            long long q = (4 * i * j - j * N - i * N);
            if (q <= 0 || p % q != 0) continue;
            long long k = p / q;
            cout << i << " " << j << " " << k;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int n;
int t=0;
int a[N][N],b[N],c[N],d[N];
void set(int );
void inp(int );
void cal(int );
int main(){
  int i,j;
  scanf("%d",&n);
  set(n);
  inp(n);
  for(i=0;i<n;i++){
    if(d[i]==0){
       cal(i);
     }
   }
  for(i=0;i<n;i++){
   printf("%d %d %d\n",i+1,b[i],c[i]);
 }
  return 0;
}

void set(int x){
    int i,j;
    for(i=0;i<x;i++){
        d[i]=0;
        for(j=0;j<x;j++){
          a[i][j]=0;
        }
    }
}

void inp(int x){
    int i,j,k,l,m;
    for(i=0;i<x;i++){
        scanf("%d%d",&k,&l);
        for(j=0;j<l;j++){
          scanf("%d",&m);
          a[k-1][m-1]=1;
        }
    }
}
void cal(int x){
  int i,j;
  d[x]=1;
  b[x]= ++t;
  for(i=0;i<n;i++){
    if(a[x][i]==1 && d[i]==0){
    cal(i);
  d[x]=2;
}
}
  c[x]= ++t;
}



Measured memory_bytes: 2104
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //具材
		int [] v = new int[n];
		
		for(int i = 0; i < n; i++) {
			v[i] = stdIn.nextInt();
		}
		
		Arrays.sort(v);
		
		double [] tmp = new double[n-1];
		
		tmp[0] = (v[0]+v[1])/2.0;
		
		
		for(int i = 1; i < n-1; i++) {
			tmp[i] = (tmp[i-1]+v[i+1])/2;
		}
		System.out.println(tmp[n-2]);
		
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{

    while (true)
    {
        int w, d;
        cin >> w >> d;
        if (w == 0 && d == 0)
            break;
        int hw[w], hd[d];
        bool used[w];
        rep(i, w) cin >> hw[i];
        rep(i, d) cin >> hd[i];
        int ans = 0;

        rep(i, w)
        {
            ans += hw[i];
            used[i] = false;
        }
        rep(i, d)
        {
            int add = hd[i];
            rep(j, w)
            {
                if (hd[i] == hw[j] && used[j] == false)
                {
                    used[j] = true;
                    add = 0;
                    break;
                }
            }
            ans += add;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    map <int,int> pref ; 
    int  n, d, distroy, ans = 0 ; 
    cin >> n >> d >> distroy ; 
    int x[n],h[n];
    vector <pii> v(n);
    for (int i=0;i<n;i++){
    	cin >> v[i].ff >> v[i].ss ; 
    	pref[v[i].ff] = 0 ;
    }
    sort(all(v));
    for (int i=0;i<n;i++){
    	x[i] = v[i].ff ; 
    	h[i] = v[i].ss ; 
    }
    for (int i=0;i<n;i++){
    	h[i] -= pref[x[i]];
    	if (h[i]>0){
    		int c = ( h[i] + distroy - 1 ) / distroy ; 
    		int r = x[i] + d + d + 1 ; 
    		pref[r] -= c*distroy;
    		pref[x[i]] += c*distroy ; 
    		h[i] = 0 ; 
    		ans += c; 
    	}
    	int pre = -1;
    	for (auto &it: pref) { 
    		if (pre != -1){
    			pref[it.ff] += pref[pre] ; 
    			pref.erase(pre) ; 
    			if (i==n-1 or it.ff>=x[i+1]) break ; 
    		} 
    		pre = it.ff ; 
    	}
    }
    co (ans) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 22012
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

// find(all(s, ":"))

void Main()
{
  ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
  if(a <= b&&a + v * t >= b + w * t||a >= b&&a - v * t <= b - w * t) fin("YES");
  fin("NO");
  return;
}

//前処理
int main()
{
  //int ti = clock();
  //srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b; cin>>a>>b;
  string s; cin>>s;
  
  if(s[a]!='-'){
    cout<<"No"<<endl;
    return 0;
  }
  
  ll n=s.size();
  rep(i,n){
    if(i==a) continue;
    if(s[i]=='-'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

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

	int ans = INT32_MAX/2;
	for( int P = 0; P <= 100; P++ ) {
		int s = 0;
		for( int j = 0; j < N; j++ ) {
			int n = (X[j] - P);
			s += n * n;
		}
		ans = min( ans, s );
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int parent(int);
int left(int);
int right(int);
void buildMaxHeap(int*,int);
void maxHeapify(int*,int,int);
void swap(int*,int,int);
void printHeap(int*,int);
int main(void)
{
  int i;//counter
  int n;//the size of heap
  int *arr;//array (1-origin)
  scanf("%d",&n);
  arr=(int*)malloc(sizeof(int)*(n+1));
  for(i=1;i<=n;i++) scanf("%d",&arr[i]);
  buildMaxHeap(arr,n);
  printHeap(arr,n);
  return 0;
}
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}
void buildMaxHeap(int *arr,int n)
{
  int i;//counter
  for(i=n/2;i>=1;i--) maxHeapify(arr,i,n);
}
void maxHeapify(int *arr,int i,int n)
{
  int l=left(i);
  int r=right(i);
  int largest;
  if(l<=n&&arr[l]>arr[i]) largest=l;
  else largest=i;
  if(r<=n&&arr[r]>arr[largest]) largest=r;
  if(largest!=i)
    {
      swap(arr,i,largest);
      maxHeapify(arr,largest,n);
    }
}
void swap(int *arr,int x,int y)
{
  int temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void printHeap(int *arr,int n)
{
  int i;
  for(i=1;i<=n;i++) printf(" %d",arr[i]);
  printf("\n");
}


Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
    int a;  scanf("%d", &a);
    int max = a;
    int b;  scanf("%d", &b);
    max = (max < b) ? b : max;
    int c;  scanf("%d", &c);
    max = (max < c) ? c : max;

    printf("%d\n", a + b + c - max);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll a[N],prime[N],vis[N];
int n,flag=0,k;
bool isprime[N];

void Prime()
{ 	memset(isprime,1,sizeof(isprime));
	k=0;
	prime[1]=0;
    for(int i=2;i<N;i++){
        if(isprime[i]){
            prime[k++]=i;
            for(int j=2;i*j<N;j++)
                isprime[i*j]=0;
        }
    }
}//筛法 

void solve(ll n){
    for(int i=0;i<k&&prime[i]*prime[i]<=n;i++){
        if(n%prime[i]==0){
            if(vis[prime[i]]==0) vis[prime[i]]=1;
            else{
                flag=1;
                return;
            }
            while(n%prime[i]==0){
                n/=prime[i];
            }
        }
    }
    if(n>1){
         if(vis[n]==0) vis[n]=1;
        else{
            flag=1;
            return;
        }
    }
}

//inline ll gcd(ll a,ll b)
//{
//    return (a%b==0)?b:gcd(b,a%b);
//}

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	Prime();
    cin>>n;
    ll GCD=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!flag) solve(a[i]);
        if(GCD==0) GCD=a[i];
        else GCD=__gcd(GCD,a[i]);
    }
    if(!flag) cout<<"pairwise coprime"<<endl;
    else if(flag&&GCD==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
	return 0;
} 

Measured memory_bytes: 13612
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
using namespace std;

int main(void){
    string s;
    cin>>s;
    map<char, int> ch;
    rep(i, 4){
        ch[s[i]]+=1;
       
    }

    if (ch.size()==2 and ch[s[0]]==2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int D;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));
int t[365];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> D;
	rep(i, 26) cin >> c[i];
	rep(i, D) {
		rep(j, 26) cin >> s[i][j];
	}
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}
	
	int Q;
	cin >> Q;
	int last[26];
	while(Q--) {
		int d, q;
		cin >> d >> q;
		d--; q--;
		t[d] = q;
		int score = 0;
		rep(i, 26) last[i] = -1;
		rep(i, D) {
			score += s[i][t[i]];
			last[t[i]] = i;
			rep(j, 26) {
				score -= c[j] * (i - last[j]);
			}
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 3700
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val dp = Array(s.length + 1) { IntArray(t.length + 1) { 0 } }

    for (i in 0 until s.length) {
        for (j in 0 until t.length) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i + 1][j])
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j + 1])
        }
    }

    var res = ""
    var i = s.length
    var j = t.length
    while (i > 0 && j > 0) {

        if (dp[i][j] == dp[i - 1][j]) {
            i--
            continue
        }

        if (dp[i][j] == dp[i][j - 1]) {
            j--
            continue
        }

        res = s[i - 1] + res
        i--
        j--
    }

    println(res)
}


Measured memory_bytes: 93032
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
/*
ソートする
順番に数えていく


*/

#define max 2147483647

void merge(int *a,int left,int mid,int right){
        int n1 = mid - left;
        int n2 = right - mid;
        int L[n1+1],R[n2+1];
        int i;
        for(i=0;i<n1;i++){
            L[i] = a[left + i];
        }
        for(i=0;i<n2;i++){
            R[i] = a[mid + i];
        }
        L[n1]=max;
        R[n2]=max;
        int j=0,k=0;
        for(i=left;i<right;i++){
            if(L[j]<R[k]){
                a[i] = L[j];
                j++;
            }
            else{
                a[i] = R[k];
                k++;
            }
        }

}


void merge_sort(int *a,int left,int right){
    int middle;
    if(left + 1 < right){
        middle = (left + right)/2;
        merge_sort(a,left,middle);
        merge_sort(a,middle,right);
        merge(a,left,middle,right);
    }
}

/*
最後に更新する時
a[n]の分が更新されない->counter += 1

最後に更新されない

*/

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    merge_sort(a,0,n);
    int now,c = 1,counter = 0;
    now = a[0];
    for(i=1;i<n;i++){
        if(a[i] == now){
            c++;
        }else{
            now = a[i];
            counter += c%2;
            c=1;
        }
    }
    counter += c%2;

    printf("%d\n",counter);

    return 0;
}

Measured memory_bytes: 896
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(a[k-1])

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

int top = 0,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];
  
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}
      


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

typedef __int128 State;

int N, M;
int G[110][110];

int calc(State s){
    int res = 0;
    for(int i=0; i<N; i++) if((s>>i)&1){
        int x = 1e9;
        for(int j=0; j<N; j++) if(i!=j && (s>>j)&1){
            x = min(x, G[i][j]);
        }
        res += x;
    }
    return res;
}

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int x, y, w;
        cin >> x >> y >> w; x--; y--;
        G[x][y] = G[y][x] = w;
    }
    
    int ans = 0;
    set<State> states;
    for(int i=0; i<N; i++){
        states.insert((State)1<<i);
    }
    
    while(states.size()){
        set<State> tmp;
        for(auto u: states){
            for(int i=0; i<N; i++) if(!((u>>i)&1)){
                bool ok = true;
                for(int j=0; j<N; j++) if((u>>j)&1){
                    ok &= G[i][j] != 0;
                }
                if(ok){
                    State v = u;
                    v |= ((State)1<<i);
                    ans = max(ans, calc(v));
                    tmp.insert(v);
                }
            }
        }
        states = tmp;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    char S[5];
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
n = raw_input()
a = map(int, raw_input().split(' '))
import collections
q = 0
cc = collections.Counter(a)
for k in cc:
	q += cc[k] * (cc[k]-1) /2


for e in a:
	print q - cc[e] * (cc[e]-1) /2 + (cc[e]-1)*(cc[e]-2)/2 
	



Measured memory_bytes: 63280
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3941934
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

class LazySegmentTree{
private:
    int size_;
    vector<LL> v, lazy;
    void update(int a, int b, LL x, int k, int l, int r){
        push(k, l, r);
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            lazy[k] = x;
            push(k, l, r);
        }else{
            update(a, b, x, k * 2,                l, (l + r) >> 1);
            update(a, b, x, k * 2 + 1, (l + r) >> 1,            r);
            v[k] = merge(v[k * 2], v[k * 2 + 1]);
        }
    }
    LL query(int a, int b, int k, int l, int r){
        push(k, l, r);
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return v[k];
        LL lc = query(a, b, k * 2,                l, (l + r) >> 1);
        LL rc = query(a, b, k * 2 + 1, (l + r) >> 1,            r);
        return merge(lc, rc);
    }

public:
    LazySegmentTree() : v(vector<LL>()), lazy(vector<LL>()) {};
    LazySegmentTree(int n){
        for(size_ = 1; size_ < n;) size_ <<= 1;
        v.resize(size_ * 4,0);
        lazy.resize(size_ * 4,0);
    }
    inline void push(int k, int l, int r){
        if(lazy[k] != 0){
            v[k] += lazy[k];
            if(r - l > 1){
                lazy[k * 2]     += lazy[k];
                lazy[k * 2 + 1] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    inline LL merge(LL x, LL y){
        return max(x, y);
    }
    inline void update(int l, int r, LL x){
        update(l, r, x, 1, 0, size_);
    }
    inline LL query(int l, int r){
        return query(l, r, 1, 0, size_);
    }
};

LL h[222222];
LL dp[222222];
LL a[222222];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%lld", &h[i]);
        h[i]--;
    }
    for(int i = 0; i < N; i++) scanf("%lld", &a[i]);
    
    // 2. dp更新.
    LazySegmentTree st(N + 1);
    LL ans = 0;
    for(int i = 0; i < N; i++){
        // for(int j = 0; j < N; j++) printf("dp[%d]=%lld ", j, dp[j]);
        // printf("\n");
        dp[i] = st.query(0, h[i]) + a[i];
        st.update(h[i], h[i] + 1, dp[i]);
        ans = max(ans, dp[i]);
    }
    // for(int i = 0; i < N; i++) printf("dp[%d]=%lld ", i, dp[i]);
    // printf("\n");
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
 
const int N = 1e5 + 123;
int n, m, used[N];
vi adj[N];
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	int l, r;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
		l = x, r = y;
	}
	used[l] = used[r] = 1;
	deque <int> path;
	path.push_front(l);
	path.pb(r);
	while (true) {
		int changes = 0;
		for (int to : adj[l]) {
			if (!used[to]) {
				l = to;
				used[l] = 1;
				changes = 1;
				path.push_front(l);
				break;
			}
		}
		for (int to : adj[r]) {
			if (!used[to]) {
				r = to;
				used[r] = 1;
				changes = 1;
				path.pb(r);
				break;
			}
		}
		if (!changes) {
			break;
		}
	}
	cout << path.size() << '\n';
	for (int i : path) {
		cout << i << ' ';
	}
}


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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >>u;
  
  if(u==s)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
}


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

int MAX=1000;
int top,S[1000];
/*void show (int A[]){
    for (int i = 0; i < top+1; i++) {
      printf("stats " );
          printf("%d\t",A[i]);
    }

  }


/*  int isEmpty(){
    return top==0;
  }

  int isFull(){
    return top>=MAX-1;
  }
*/
void push(int x){
  S[++top]=x;
}
  int pop(){
    top--;
    return S[top+1];
  }

  int main(){
    int a,b;
    top =0;
  char s[100];

    while(scanf("%s",s)!=EOF){
      if (s[0]=='+'){
         a=pop();
         b=pop();
         push(a+b);
      }
      else if (s[0]=='-'){
         b=pop();
         a=pop();
         push(a-b);
      }
      else if (s[0]== '*'){
         a=pop();
         b=pop();
         push(a*b);
      }else{
        push(atoi(s));
      }
    }
  printf("%d\n",pop());
return 0;
  }


Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 xx, ans = 0;
	cin >> xx;
	ans = xx / 11;
	ans *= 2;
	xx %= 11;
	if(xx == 0)
	{
		0;
	}
	else if(xx <= 6)
	{
		ans++;
	}
	else
	{
		ans += 2;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;
int num[100001];
int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)cout << "Yes" << endl;
	else {
		if ((abs(a - b) <= d) && (abs(b - c) <= d))cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

ll a[1000], b[1000], c[1000];
int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  repi(x) cin >> a[i];
  repi(y) cin >> b[i];
  repi(z) cin >> c[i];
  vll sxy;
  repi(min(x, k)) repj(min(y, k)) sxy.push_back(a[i] + b[j]);
  int sxylen = sxy.size();
  sort(sxy.begin(), sxy.end(), greater<ll>());
  vll sxyz;
  repi(min(sxylen, k)) repj(min(z, k)) sxyz.push_back(sxy[i] + c[j]);
  sort(sxyz.begin(), sxyz.end(), greater<ll>());
  repi(k) cout << sxyz[i] << endl;
}


Measured memory_bytes: 42852
#include <stdio.h>
#include <array>
#include <algorithm>
#include <tuple>
 
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
 
using lli = long long int;

constexpr int N = 3000;
std::pair<int, int> A[N];
std::array<lli, N+1> R;

int main(void){
    int n, t; scanf("%d%d", &n, &t);
    REP(i, n) scanf("%d%d", &A[i].first, &A[i].second);
    std::sort(A, A+n);
    REP(i, n){
        int a = A[i].first, b = A[i].second;
        int j, e = (t > a) ? t - a : 0;
        for(j = t-1; j >= e; --j) if(R[t] < R[j] + b) R[t] = R[j] + b;
        for(; j >= 0; --j) if(R[j+a] < R[j] + b) R[j+a] = R[j] + b;
    }
    lli res = 0;
    for(int i = 0; i <= t; ++i) if(res < R[i]) res = R[i];
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    long long a;
    std::vector<long long> vec;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        vec.push_back(a);
    }
    std::sort(vec.begin(), vec.end());

    std::cout << std::abs(vec[vec.size() - 1] - vec[0]) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a>c){
    if(b<c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(b>c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

long search(long n, long x, vector<long> &f, vector<long> &p){
  if(x <= 1){
    if(n != 0) return 0;
    else return 1;
  }
  if(2 <= x && x <= 1 + f.at(n-1)) return search(n-1,x-1,f,p);
  if(x == 2 + f.at(n-1)) return p.at(n-1) + 1;
  if(3 + f.at(n-1) <= x && x <= f.at(n) - 1 ) return p.at(n-1)+1+search(n-1,x-2-f.at(n-1),f,p);
  if(x == f.at(n)) return 2*p.at(n-1)+1;
}

int main(){
  long n,x;
  cin >> n >> x;
  vector<long> level(n+1);
  vector<long> paty(n+1);
  level.at(0) = 1;
  paty.at(0) = 1;
  rep(i,n){
    level.at(i+1) = 3 + 2*level.at(i);
    paty.at(i+1) = 1 + 2*paty.at(i);
  }
  cout << search(n,x,level,paty) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	cout << (nn * nn * nn) << endl;
	return 0;
}


Measured memory_bytes: 3560
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n, k;
    cin >> n >> k;
    vll h(n);
    REP(i,n){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    if(n <= k){
        cout << 0 << endl;
        return 0;
    }
    ll s=0;
    REP(i,n-k){
        s += h[i];
    }
    cout << s << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(auto i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LONG_LONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int n, c;
	cin >> n >> c;
	int dp[c][100001] = {};
	rep (i, n) {
		int s, t, c;
		cin >> s >> t >> c;
		s--; t--; c--;
		dp[c][s]++;
		dp[c][t]--;
	}
	rep (i, c) rep (j, 100000) dp[i][j + 1] += dp[i][j];
	int ans = -INF;
	rep (i, 100001) {
		int cnt = 0, add = 0;
		bool flag = false;
		rep (j, c) {
			flag = dp[j][i] || flag;
			cnt += dp[j][i];
			add += i > 0 && dp[j][i - 1] && !dp[j][i];
		}
		if (flag) cnt += add;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int length;
    vector<int> array, coefficient0, coefficient1;
    int n;
    cin >> length;
    while(cin >> n){
        array.push_back(n);
    }
    sort(array.begin(), array.end());

    coefficient0.push_back(-1);
    coefficient1.push_back(1);
    for(int i = 1; i < length - 1; ++i)
    {
        if(i % 2){
            coefficient0.push_back(2);
            coefficient1.push_back(-2);
        }else{
            coefficient0.push_back(-2);
            coefficient1.push_back(2);
        }
    }

    if(length % 2){
        coefficient0.push_back(-1);
        coefficient1.push_back(1);
    }else{
        coefficient0.push_back(1);
        coefficient1.push_back(-1);
    }

    sort(coefficient0.begin(), coefficient0.end());
    sort(coefficient1.begin(), coefficient1.end());
    
    long long ans0 = 0;
    long long ans1 = 0;
    
    for(int i = 0; i < length; i++){
        ans0 += array[i] * coefficient0[i];
        ans1 += array[i] * coefficient1[i];
    }

    cout << max(ans0, ans1) << "\n";
    return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
#define INF 1000000000000
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

// void bfs(int src) {
//     qi q ;
//     q.push(src) ;
//     vis[src] = true ;
//     dis[src] = 0 ;
//     while(!q.empty()) {
//         int curr = q.front() ;
//         q.pop() ;
//         for(int i=0; i<v[curr].size(); i++) {
//             if(!vis[v[curr][i]]) {
//                 q.push(v[curr][i]) ;
//                 dis[v[curr][i]] = dis[curr] + 1 ;
//                 vis[v[curr][i]] = true ;
//             }
//         }
//     }
// }

signed main() {
    quickie   
    int n ;
    cin >> n ;
    int arr[n+1] ;
    rep(i, 0, n+1) arr[i] = 1 ;
    rep(i, 2, n+1) {
        for(int j=i; j<n+1; j+=i) {
            arr[j] += 1 ;
        }
    }
    int ans = 0 ;
    rep(i, 1, n+1) {
        ans += i*arr[i] ;
    }
    cout << ans << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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


Measured memory_bytes: 81740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int k, q, d[5005], n, m;
long long x, sm, cnt;
int main(){
	scanf("%d%d", &k, &q);
	rep(i,k) scanf("%d", d+i);
	rep(o,q){
		scanf("%d%lld%d", &n, &x, &m);
		cnt = sm = 0; x %= m;
		rep(i,k){
			if(i==(n-1)%k) x += sm;
			sm += (d[i] + m - 1) % m + 1;
		}
		cnt += (n-1) / k * (sm / m); sm %= m;
		cnt += ((n-1) / k * sm + x) / m;
		printf("%lld\n", n-1-cnt);
	}
}

Measured memory_bytes: 256
import math

a,b,x=map(int,input().split())
h=x/(a**2)
if(h*2>=b):
    y=(a/2)/math.sqrt((a/2)**2+(b-h)**2)
    ans=math.degrees(math.acos(y))
    print(ans)
else:
    y=(2*a*h/b)/math.sqrt(b**2+(2*a*h/b)**2)
    ans=math.degrees(math.acos(y))
    print(ans)    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    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 COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    ll N; cin>>N;
    string S,T; cin>>S>>T;
    ll ans;
    REP(i,N,2*N){
        bool flag=1;
        rep(j,i-N,N){
            if(S[j]!=T[j-i+N]) flag=0;
        }
        if(flag){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  long A,B,C,K;
  cin >> A >> B >> C >> K;
  long ans=0;
  
  ans += min(A,K);
  K = K - min(A,K);

  K = K - min(B,K);

  ans -= min(C,K);

  cout << ans << endl;
  return 0;
}

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

int main(){
    int a, b, k, counter=0;
    bool list_null=true;
    cin >> a >> b >> k;

    for(int i=min(a,b);i>=1;i--){
        if(a % i == 0 && b % i == 0){
            counter++;
            if(counter == k){
                cout << i << endl;
            }
        }
    }
    return 0;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	char c1,c2;
	cin>>c1>>c2;
	if(c1>c2) cout<<">"<<endl;
	else if(c1<c2) cout<<"<"<<endl;
	else cout<<"="<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 123456;
char S[MAXN], T[MAXN];

int main() {
    LL N, M;
    while (~scanf("%lld %lld", &N, &M)) {
          scanf("%s", S);
          scanf("%s", T);
          bool ans = true;
          LL gcd = __gcd(N, M);
          for (int i = 0; i < gcd; i++) {
              if (S[N / gcd * i] != T[M / gcd * i]) ans = false;
          }
          if (!ans) puts("-1");
          else printf("%lld\n", (LL)N * M / gcd);
    }
    return 0;
}


Measured memory_bytes: 384
X,K,D = map(int,input().split())
X =abs(X)
if X == 0:
    if K % 2 == 0:
        ans = 0
    else:
        ans = D
else:
    cnt = X//D
    if cnt >= K:
        ans = X - (D*K)
    else:
        K -= cnt
        if K % 2 == 0:
            ans = X - (D*cnt)
        else:
            ans = D -(X - (D*cnt))
    
print(ans)
        
    


Measured memory_bytes: 9156
#include <iostream>
#include <vector>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, T;
    cin >> N >> T;
    vector<lli> t(N);
    REP (i, 0, N) cin >> t[i];
    lli ans = 0;
    REP (i, 1, N) {
        if (t[i - 1] + T <= t[i]) {
            ans += T;
        } else {
            ans += (t[i] - t[i - 1]);
        }
    }
    ans += T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        //System.out.println(a);
        //System.out.println(b);
        int mennseki = a*b;
        int shuu = 2*a+2*b;
        System.out.println(mennseki+" "+  shuu );
        //System.out.println(2*a+2*b);
    }
}

Measured memory_bytes: 26072
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int F[n][10], P[n][11];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 10; ++j){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 11; ++j){
            cin >> P[i][j];
        }
    }
    int ans = -1e9;
    for(int i = 0; i < 1<<10; ++i){
        if(i == 0) continue;
        int sum = 0;
        for(int j = 0; j < n; ++j){
            int cnt = 0;
            for(int k = 0; k < 10; ++k){
                if((i>>k)&1 && F[j][k]) cnt++;
            }
            sum += P[j][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588