akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main(){
	ll a; double b;
	cin >> a >> b;
	b *= 100;
	ll res = (ll)(a * int(round(b)));
	cout << ll(res/100) << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
static const double pi = 3.14159265358979323846264338327950288419716939937510;
#define Sort(a) sort(a.begin(), a.end())

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
   
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  h = h * 5 + 5 * m/60;
  double cosin = cos(abs(h-m)*6/180 * pi);
  double ans = sqrt(a*a + b*b - 2*a*b*cosin);
  cout << fixed << setprecision(10) << ans << '\n';
}

Measured memory_bytes: 4148
#include<bits/stdc++.h>
    #define MAX_N 100005
    #define ll long long
    using namespace std;
     
    int main()
    {
     //freopen("t.txt","r",stdin);
     int n,a[MAX_N],b[MAX_N]={0}; cin>>n;
     int cnt[10]={0};
     for (int i=1;i<=n;i++) 
     {
     	int d; cin>>d;
     	 if (d>=1  && d<=399) cnt[1]=1;
     	 if (d>=400  && d<=799) cnt[2]=1;
     	 if (d>=800  && d<=1199) cnt[3]=1;
     	 if (d>=1200  && d<=1599)cnt[4]=1;
     	 if (d>=1600  && d<=1999)cnt[5]=1;
     	 if (d>=2000  && d<=2399)cnt[6]=1;
     	 if (d>=2400  && d<=2799)cnt[7]=1;
     	 if (d>=2800  && d<=3199)cnt[8]=1;
     	 if (d>=3200) cnt[9]++;
     }
     int max=0,min=0; 
     for (int i=1;i<=8;i++){
     	 min+=cnt[i];
	 }
	 if (min==0){
	 	cout<<1<<" "<<cnt[9]; return 0;
	 }
     max= min+cnt[9];
     cout<<min<<" "<<max;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	string s;
	vector<char> vec;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != 'B') {
			vec.push_back(s[i]);
		}
		else if (vec.size() != 0) {
			vec.pop_back();
		}
	}
	int ans = vec.size();
	for (int j = 0; j < ans; j++) {
		cout << vec[j];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll R, G, B, N;
  cin >> R >> G >> B >> N;

  // r*R + g*G + b*B = N

  ll ans = 0;
  REP(r, N/R+1){
    REP(g, N/G+1){
      ll b = (N-r*R-g*G)/B;
      if(b<0) continue;
      if(r*R+g*G+b*B==N){
        ans++;
      }
    }
  }

  cout << ans << "\n";

  return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;

ll int GCD(ll int a,ll int b)
{
    if(a==0) return b;
    else return GCD(b%a,a);
}

ll int LCM(ll int a,ll int b)
{
    ll int res=1,x,y;
    x=a;
    y=b;
    while(b){
        res=a%b;
        a=b;
        b=res;
    }
    return x*(y/a);
}
int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	ll int n,m,T,res;

	ll int maxi=-mx,mini=mx,count=0;

	ll int i,j,k,gcd,lcm;

	bool flag;

	string s1,s2;

	char s[100000];

	ll int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1) cin>>ara[i];

	//lcm=LCM(ara[0],ara[1]);

    lcm=1;

	f(i,0,n-1){
        lcm=LCM(lcm,ara[i]);
	}

	cout<<lcm<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const int INFTY = (1 << 30);
ll N, Q;
void func()
{
    cin >> N;
    ll A, table[100001] = {}, ans(0);
    rep(i, 0, N)
    {
        cin >> A;
        ++table[A];
        ans += A;
    }
    cin >> Q;
    ll B, C;
    rep(i, 0, Q)
    {
        cin >> B >> C;
        table[C] += table[B];
        ans += (C - B) * table[B];
        table[B] = 0;
        cout << ans << endl;
    }
}
int main()
{
    func();
}

Measured memory_bytes: 4392
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int,long long> > g[n];
  int u,v;
  long long w;
  for(int i=0;i<n-1;i++){
    cin >> u >> v >> w;
    u -= 1;
    v -= 1;
    g[u].push_back(make_pair(v,w));
    g[v].push_back(make_pair(u,w));
  }
  int ans[n];
  for(int i=0;i<n;i++){
    ans[i] = -1;
  }

  queue<int> q;
  q.push(0);
  ans[0] = 0;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int j=0;j<g[u].size();j++){
      v = g[u][j].first;
      if(ans[v] != -1) continue;
      q.push(v);
      w = g[u][j].second;
      if(w%2 == 0) ans[v] = ans[u];
      else ans[v] = 1 - ans[u];
    }
  }

  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
void solve() {
    string s; cin >> s;
 
    int n = s.size();
    if (s[0] == s[n-1]) n--;
    if (n % 2) {cout << "First\n"; return;}
    else {cout << "Second\n"; return;}
}
 
signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int t = 1;
    while (t--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 512
using System;
namespace abc{
    class C{
        static void Main(){
            char[] s = Console.ReadLine().ToCharArray();
            int tans = 0;
            int ans = 0;
            bool tobe0 = true;
            for(int i=0;i<s.Length;i++){
                if(tobe0){
                    if(s[i]=='1')tans++;
                    tobe0 = false;
                }
                else{
                    if(s[i]=='0')tans++;
                    tobe0 = true;
                }
            }
            ans = tans;
            tans = 0;
            tobe0 = false;
            for(int i=0;i<s.Length;i++){
                if(tobe0){
                    if(s[i]=='1')tans++;
                    tobe0 = false;
                }
                else{
                    if(s[i]=='0')tans++;
                    tobe0 = true;
                }
            }
            if(ans>tans)Console.WriteLine(tans);
            else{Console.WriteLine(ans);}
        }
    }
}

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

int main(void){

  int n, i, w[100], k;
  int min, dif;
  int sum = 0;
  int sum_1 = 0;
  int sum_2 = 0;

  scanf("%d", &n);

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

  min = 10000;

  for(i = 0; i < n - 1; i++){
    sum_1 = 0;
    for(k = 0; k <= i; k++){
      sum_1 += w[k];
    }
    sum_2 = sum - sum_1;
    dif = sum_2 - sum_1;
    if(abs(dif) < min){
      min = abs(dif);
    }
  }



  printf("%d", min);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n;
	cin>>n;
	vec(int) a[n];
	int dp[1<<n];
	init(dp,0);
	loop(i,0,n) loop(j,0,n) 
	{
		int x;
		cin>>x;
		if(x==1) a[i].pb(j);
	}
	dp[0] = 1;
	loop(mask,0,(1<<n) - 1)
		for(auto j:a[__builtin_popcount(mask)])
			if((mask & (1<<j))==0)
				dp[mask + (1<<j)] = (dp[mask + (1<<j)] + dp[mask])%mod;
	cout<<dp[(1<<n)-1]<<endl;
	return 0;		
}

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



int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);

  rep(i,n){
    cin>>a[i];
  }
  ll now=a[0];
  ll id=1;
  ll ans=n;
//  cout<<(now&a[id])<<endl;
  rep(i,n){

    if (id<=i){
      id=i+1;
      now=a[i];
    }

     while(id<n){
       /*
       if (id==n-1){
        // cout<<(now&a[id])<<' '<<i<<' '<<id<<endl;
         b[i]=id;
         if ((now&a[id])==0) {
           ans+=id-i;
           now-=a[i];
           cout<<id-i<<endl;
         }

         break;
       }
       */
       if ((now&a[id])!=0){
      //   cout<<'l'<<' '<<(now&a[id])<<' '<<i<<' '<<id<<endl;
         b[i]=id;
         now-=a[i];
         //cout<<id-i-1<<endl;

         break;
       }
        if ((now&a[id])==0){
      //    cout<<'k'<<' '<<(now&a[id])<<' '<<i<<' '<<id<<' '<<now<<endl;
          now=now|a[id];
          ans+=id-i;
          id++;
        //  cout<<now<<'n'<<endl;
        }


     }
  }

cout<<ans;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,j,n) for(int i = (int)(j); i < (int)(n); i++)
#define mrep(i,n) for (int i = (int)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int n; cin >> n;
	vint p(n);
	rep(i,n) cin >> p[i];
	int ans = 0;
	for(int i=1; i<n-1;i++) {
		if((p[i - 1] < p[i]) && (p[i] < p[i + 1])) ans++;
		else if((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int cnt;

void merge(vector<int>& v, int l, int m, int r)
{
    int nl = m - l;
    int nr = r - m;
    
    vector<int> v1(nl + 1);
    copy(v.begin() + l, v.begin() + m, v1.begin());
    vector<int> v2(nr + 1);
    copy(v.begin() + m, v.begin() + r, v2.begin());

    v1[nl] = numeric_limits<int>::max();
    v2[nr] = numeric_limits<int>::max();

    int i {};
    int j {};

    for (int k = l; k < r; ++k)
    {
        ++cnt;
        if (v1[i] <= v2[j])
            v[k] = v1[i++];
        else
            v[k] = v2[j++];
    }
    
}


void mergeSort(vector<int>& v, int l , int r)
{
    if (l + 1 < r)
    {
        int mid = (l + r) / 2;
        mergeSort(v, l, mid);
        mergeSort(v, mid, r);
        merge(v, l, mid, r);
    }
}

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

    vector<int> v(n);
    for (int i = 0, in; i < n && cin >> in; ++i)
        v[i] = in;

    mergeSort(v, 0, n);

    for (int i = 0; i < n; ++i)
    {
        cout << v[i] << (i != n - 1 ? " " : "");
    }

    cout << '\n' << cnt << endl;

    return 0;
}

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

const int N = 21; 
const int M = (1 << 21);

vector< vector<int> > dp(N, vector<int> (M, -1));
const int mod = 1e9+7; 

int n ;
int arr[N][N]; 

int find(int index, int bitmask)
{
	
   if(index == n ) return 1; 
   if( dp[index][bitmask] != -1) return dp[index][bitmask]; 
    
   int res = 0 ; 
   for(int i = 0 ; i < n ; i ++)
   {
       if( ( (bitmask >> i) &1 ) and (arr[index][i]) ) 
       {
           res = ( 0l + res + find(index+1,bitmask ^ (1 << i)) )%mod;
       }
   }

   return dp[index][bitmask] = res; 

}


void solve()
{
       cin >> n;

       for(int i = 0 ; i < n ; i ++)
          for(int j = 0 ; j < n; j ++)
              cin >> arr[i][j];

        cout << find(0,(1<<n)-1);

}

int main()
{

	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);

	 solve();
	 return 0;
}

/**


*/




Measured memory_bytes: 183384
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int S[13], H[13], C[13], D[13];
	memset(S, 0, sizeof(int) * 13);
	memset(H, 0, sizeof(int) * 13);
	memset(C, 0, sizeof(int) * 13);
	memset(D, 0, sizeof(int) * 13);

	char n;
	int index, num;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		cin >> n >> index;
		switch (n)
		{
		case 'S':
			S[index - 1] = 1;
			break;
		case 'H':
			H[index - 1] = 1;
			break;
		case 'C':
			C[index - 1] = 1;
			break;
		case 'D':
			D[index - 1] = 1;
			break;
		}
	}
	for (int i = 0; i < 13; i++)
	{
		if (S[i] == 0)
			cout << "S " << i + 1 << endl;
	}

	for (int i = 0; i < 13; i++)
	{
		if (H[i] == 0)
			cout << "H " << i + 1 << endl;
	}

	for (int i = 0; i < 13; i++)
	{
		if (C[i] == 0)
			cout << "C " << i + 1 << endl;
	}

	for (int i = 0; i < 13; i++)
	{
		if (D[i] == 0)
			cout << "D " << i + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>

#define MAX 44
#define NIL -1

long long S(int n);
long long R[MAX];

int main(){
  int n,i;

  scanf("%d",&n);

  for(i=0;i<=n;i++){
    R[i]=NIL;
  }
  R[n]=S(n);
  printf("%d\n",R[n]);
  return 0;
}
 
long long S(int n){
  int y;
  if(R[n]!=NIL) return R[n];
  else if(n==0 || n==1) y=1;
  else if(R[n]==NIL && n>1){
    y=S(n-1)+S(n-2);
  }
  R[n]=y;
  return y;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
long long target;
int answer = 0;
void dfs(string current)
{
    bool vis[3];
    memset(vis, false, sizeof(vis));
    int length = current.length();
    long long curnum = 0;
    for(int i = 0; i < length; i++)
    {
        int digit = current[i] - '0';
        curnum = curnum * 10 + digit;
        if(digit == 3)
            vis[0] = true;
        if(digit == 5)
            vis[1] = true;
        if(digit == 7)
            vis[2] = true;
    }
    if(curnum > target)
        return;
    if(vis[0] && vis[1] && vis[2])
        ++answer;
    dfs("3" + current);
    dfs("5" + current);
    dfs("7" + current);
    return;
}
int main(void)
{
    scanf("%lld", &target);

    dfs("");

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

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  const int kMaxSize = 50;
  char a[kMaxSize][kMaxSize];
  char b[kMaxSize][kMaxSize];
  for (int y = 0; y < n; ++y) {
    for (int x = 0; x < n; ++x) {
      cin >> a[y][x];
    }
  }
  for (int y = 0; y < m; ++y) {
    for (int x = 0; x < m; ++x) {
      cin >> b[y][x];
    }
  }
  bool exist = false;
  for (int ay = 0; ay < n; ++ay) {
    for (int ax = 0; ax < n; ++ax) {
      if (ay + m - 1 >= n || ax + m - 1 >= n) continue;
      bool match = true;
      for (int by = 0; by < m; ++by) {
        for (int bx = 0; bx < m; ++bx) {
          if (a[ay+by][ax+bx] != b[by][bx]) match = false;
        }
      }
      if (match) exist = true;
    }
  }
  cout << (exist ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
	int a,b,c;
	char op;
	while(1)
	{
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?') break;
		if(op=='+') c=1;
		if(op=='-') c=2;
		if(op=='*') c=3;
		if(op=='/') c=4;
		switch(c)
		{
			case 1:
				printf("%d\n",a+b);
				break;
			case 2:
				printf("%d\n",a-b);
				break;
			case 3:
				printf("%d\n",a*b);
				break;
			case 4:
				printf("%d\n",a/b);
				break;
		}
	}
}


Measured memory_bytes: 2740
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val k = sc.nextInt()

    val one = (1 to k).map { x => gcd(x, x, x) }
    val two = (1 to k).combinations(2).map(v => gcd(v(0), v(1), v(1)) + gcd(v(0), v(1), v(1)))
    val three = (1 to k).combinations(3).map(v => gcd(v(0), v(1), v(2)))
    println(one.sum + 3 * two.sum + 6 * three.sum)

    //
    //    val sum = (1 to k).flatMap { a =>
    //      (1 to k).flatMap { b =>
    //        (1 to k).map { c =>
    //          gcd(a, b, c)
    //        }
    //      }
    //    }.sum
    //    println(sum)
  }

  def gcd(a: Int, b: Int, c: Int): Int = gcd(gcd(a, b), c)

  def gcd(x: Int, y: Int): Int = y match {
    case 0 => x
    case _ => gcd(y, x % y)
  }

}


Measured memory_bytes: 58508
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B cout << "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( int _x ){ printf("%d\n",_x); }
_tp<_tyn T>void print( T _data[] , int _size ){
	for( int i = 1 ; i <= _size ; i++ )
		cout << _data[i] << " ";
	cout << endl;
}
#define MOD ((ll)(1e9+7))
#define MAXN 45
#define MAXMASK

int n , x , y , z;
ll cutmask;

// 5 7 5
// isban: 10000 1000000 10000
struct State{
	ll bt;
	State(){
		bt = 0;
	}
	State( ll bti ){
		bt = bti;
	}
	bool isban(){
		ll ls = bt;
		ls >>= z-1;
		if( !( ls & 1 ) ) return 0;
		ls >>= y;
		if( !( ls & 1 ) ) return 0;
		ls >>= x;
		if( !( ls & 1 ) ) return 0;
		return 1;
	}
	State addnum( int num ){
		State ret = State( bt );
		ret.bt <<= num;
		ll add = 1 << (num-1);
		ret.bt |= add;
		return ret;
	}
	void print(){
		cout << "[State] " << bitset<20>(bt) << endl;
	}
	State cut(){
		ll ft = ( bt & cutmask );
		return State( ft );
	}
};

ll mem[MAXN][1<<18];
ll dfs( int pos , State nowst ){
	if( nowst.isban() ) return 0LL;
	if( pos == n + 1 ) return 1LL;

	if( mem[pos][nowst.bt] != -1 ) return mem[pos][nowst.bt];

	ll ret = 0LL;
	for( int i = 1 ; i <= 10 ; i++ ){
		ret += dfs( pos + 1 , nowst.addnum(i).cut() );
		if( ret >= MOD ) ret -= MOD;
	}

	return mem[pos][nowst.bt] = ret;
}

int main(){
	//fin( "E.txt" );
	while( scanf("%d %d %d %d",&n,&x,&y,&z) != EOF ){
		msn( mem , -1 );

		cutmask = 0LL;
		for( int i = 0 ; i < x + y + z ; i++)
			cutmask |= ( 1 << i );

		ll u = 1LL;
		for( int i = 1 ; i <= n ; i++ ){
			u *= 10LL;
			u %= MOD;
		}

		u -= dfs( 1 , State(0) );
		u = (u+MOD) % MOD;
		printf("%lld\n",u);
	}

	return 0;
}


Measured memory_bytes: 92416
/*
input
125
ans
176

input
12
ans
15

input
7
ans
7

input
9999999999
ans
12656242944

end*/
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


long long getFormulaResult(int bit, vector<int>& s) {
    int N = s.size();
    long long result = 0, tmp = 0;
    // cout << bit << ": " << bitset<9>(bit) << endl;

    for (int i = 0; i < N-1; i++) {
        if (bit & (1<<i)) { // +
            result += tmp + s[i];
            tmp = 0;
        } else { // no +
            tmp += s[i];
            tmp *= 10;
        }
    }
    result += tmp + s[N-1];
    // cout << result << endl;
    return result;
}


int main() {
    // inputs
    string S;
    cin >> S;

    int N = S.size();
    vector<int> s(N);
    for (int i = 0; i < N; i++) {
        s[i] = S[i] - '0';
    }

    long long ans;
    if (N == 1) {
        ans = s[0];
    } else {
        ans = 0;
        for (int bit = 0; bit < (1<<(N-1)); ++bit) {
            ans += getFormulaResult(bit, s);
        }
    }

    // outputs
    cout << ans << endl;

    return 0;
}

// :!tp %



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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int ret = 0;
        for (int i = 1; i <= N; i++)
        {
            int tmp = 0;
            if (i % 2 == 1)
            {
                for (int j = 1; j <= i; j++)
                {
                    if (i % j == 0)
                    {
                        tmp++;
                    }
                }
            }
            if (tmp == 8)
            {
                ret++;
            }
        }
        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#define MAXN 15
#define Point pair<int, int>
#define x first
#define y second
#define INF 1e20
using namespace std;

struct Edge {
    int u, v;
    double cost;

    Edge(int u, int v, double cost): u(u), v(v), cost(cost) {}
};

int dad[MAXN], sz[MAXN];
int n, liters[MAXN];
double ccBest[1 << MAXN], dp[1 << MAXN];
Point pos[MAXN];

double dist(const Point &A, const Point &B) {
    int dx = A.x - B.x;
    int dy = A.y - B.y;
    return sqrt(1LL * dx * dx + 1LL * dy * dy);
}

bool Comp(Edge a, Edge b) {
    return a.cost < b.cost;
}

int root(int x) {
    int y = x;
    while(dad[y] != y)
        y = dad[y];

    while(x != y) {
        int aux = dad[x];
        dad[x] = y;
        x = aux;
    }

    return y;
}

bool unify(int x, int y) {
    if((x = root(x)) == (y = root(y))) return 0;

    if(sz[x] < sz[y])
        dad[x] = y;
    else {
        dad[y] = x;
        if(sz[x] == sz[y])
            ++sz[x];
    }

    return 1;
}

double getMstCost(int mask) {
    vector<int> nodes;
    vector<Edge> edges;

    for(int i = 0; i < n; ++i) {
        if(mask & (1 << i))
            nodes.push_back(i);
    }

    if((int) nodes.size() < 2)
        return 0;

    for(int i = 0; i < (int) nodes.size(); ++i) {
        for(int j = i + 1; j < (int) nodes.size(); ++j) {
            edges.push_back(Edge(nodes[i], nodes[j], dist(pos[nodes[i]], pos[nodes[j]])));
        }
    }

    sort(edges.begin(), edges.end(), Comp);
    
    for(auto node: nodes) {
        dad[node] = node;
        sz[node] = 0;
    }

    double ans = 0;
    for(auto edge: edges) {
        if(unify(edge.u, edge.v)) {
            ans += edge.cost; 
        }
    }

    return ans;
}

int main() {

    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        scanf("%d %d %d", &pos[i].x, &pos[i].y, &liters[i]);

    for(int mask = 1; mask < (1 << n); ++mask) {
        double mstCost = getMstCost(mask);
        
        long long totLiters = 0;
        int cnt = 0;
        for(int i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                totLiters += liters[i];
                ++cnt;
            }
        }

        ccBest[mask] = (totLiters - mstCost) / cnt;
    }

    dp[0] = INF;
    for(int mask = 1; mask < (1 << n); ++mask) {
        vector<int> bits;

        for(int i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                bits.push_back(i);
            }
        }

        dp[mask] = 0;

        int nn = (int) bits.size() - 1;
        for(int submask = 0; submask < (1 << nn); ++submask) {
            int mask1 = 0;

            for(int i = 0; i < nn; ++i) {
                if(submask & (1 << i)) {
                    mask1 |= (1 << bits[i]);
                }
            }

            int mask2 = mask & (~mask1);
            dp[mask] = max(dp[mask], min(dp[mask1], ccBest[mask2]));
        }
    }

    printf("%.20f\n", dp[(1 << n) - 1]);

    return 0;
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

int fact(int N)
{
    if(N == 0)  return 1;
    return (1LL * fact(N - 1) * N) % mod;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int N, M;
    scanf("%d%d", &N, &M);
    if(abs(N - M) > 1)
    {
        printf("0\n");
        return 0;
    }

    if(N == M)
    {
        int f = fact(N);
        int ans = (2LL * f * f) % mod;
        printf("%d\n", ans);
        return 0;
    }

    int f = fact(N);
    int k = fact(M);
    int ans = (1LL * f * k) % mod;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner

fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  scanner.next()
  val s = scanner.next()
  var R = 0
  var B = 0
  for(c in s.toCharArray()) {
    if(c == 'R') R++ else B++
  }
  print(if(R > B) "Yes" else "No")
}


Measured memory_bytes: 29604
#include <cstdio>

const char c[]={'R','Y','G','B'};
int n,m,d,b;

int main(){
	scanf("%d%d%d",&n,&m,&d);b=10000*d;
	for(int i=0;i<n;++i,putchar(10))
	for(int j=0;j<m;++j)
		putchar(c[(((i+j)/d&1)<<1)|((i-j+b)/d&1)]);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i < n + 1; i++) {
		if (1 <= i && i < 10) {
			ans++;
		}
		if (100 <= i && i <1000 ) {
			ans++;
		}
		if (10000 <= i && i < 100000) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  char y[5], m[3], d[3], s[11];
  int ye, mo, da;
  scanf("%s", s);
  for(int i = 0; i < 4; ++i) y[i] = s[i];
  m[0] = s[5];
  m[1] = s[6];
  d[0] = s[8];
  d[1] = s[9];
  ye = atoi(y);
  mo = atoi(m);
  da = atoi(d);
  if(ye > 2019){
    puts("TBD");
    return 0;
  }
  if(mo > 4){
    puts("TBD");
    return 0;
  }
  if(da > 30){
    puts("TBD");
    return 0;
  }
  puts("Heisei");
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int a;

int main() {
  cin >> a;

  cout << a * a * a + a * a + a << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int count;
        for(;;){
            int n = scan.nextInt();
            int x = scan.nextInt();
            count = 0;
            if(n == 0 && x == 0){
                break;
            }else{
                for(int i = 1; i <= n; i++){
                    for(int j = i + 1; j <= n; j++){
                        for(int k = j + 1; k <= n; k++){
                            if(i + j + k == x){
                                if(i != j && j != k && i != k){
                                    //System.out.println("i = " + i + ", j = " + j + ", k = " + k);
                                    count++;
                                }
                            }
                        }
                    }
                }
                System.out.println(count);
            }
        }

    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
#define ADD(a,b) (a)=((a)+(b))%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

// rest, used
int n,m;
ll dp[2][353][353];

int main(){
  scanf("%d%d",&n,&m);
  int cur = 0;
  dp[cur][n-1][1] = 1;
  cur ^= 1;
  REP(_,m){
    REP(i,n+1)REP(j,n+1)dp[cur][i][j] = 0;
    int bef = cur^1;
    REP(i,n+1)REP(j,n+1){
      int rest = i;
      int used = j;
      int trail = n-i-j;
      if(dp[bef][rest][used]==0)continue;
      // go to used
      int cnt = 0;
      ADD(dp[cur][rest][used+trail],dp[bef][rest][used]*used%MOD);
      // DEBUG(dp[cur][rest][used+trail]);
      // cnt += dp[bef][rest][used]*used%MOD;
      // go to rest
      if(rest>0){
        ADD(dp[cur][rest-1][used],dp[bef][rest][used]*rest%MOD);
        // DEBUG(dp[cur][rest-1][used]);
        // cnt += dp[bef][rest][used]*rest%MOD;
      }
      // go to trail
      if(trail>0){
        ADD(dp[cur][rest][used],dp[bef][rest][used]*trail%MOD);
        // DEBUG(dp[cur][rest][used]);
        // cnt += dp[bef][rest][used]*trail%MOD;
      }
      // DEBUG(cnt);
    }
    // DEBUG(dp[cur][1][1]);
    // DEBUG(dp[cur][0][1]);
    // DEBUG(dp[cur][0][2]);
    cur ^= 1;
  }
  cout<<dp[cur^1][0][n]<<endl;
  return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
    BigDecimal[][] memo;
    BigDecimal one = new BigDecimal(1);
    BigDecimal zero = new BigDecimal(0);

    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt(), s;
	    if(n == 0){
		break;
	    }
	    int[] a = new int[n];
	    for(int i = 0; i < n-1; i++){
		a[i] = sc.nextInt();
	    }
	    s = sc.nextInt();
	    BigDecimal c = zero;
	    memo = new BigDecimal[21][];
	    for(int i = 0; i < 21; i++){
		memo[i] = new BigDecimal[n];
		for(int j = 0; j < n; j++){
		    memo[i][j] = new BigDecimal(-1);
		}
	    }

	    c = func(a, n-1, s, 1, a[0]);
	    System.out.println(c.toString());
	}
    }

    BigDecimal func(int[] a, int n, int s, int p, int t){
	if(p == n){
	    if(t == s){
		return one;
	    } else {
		return zero;
	    }
	}
	if(!(new BigDecimal(-1)).equals(memo[t][p])){
	    return memo[t][p];
	}
	BigDecimal bd = new BigDecimal("0");
	if(t-a[p] >= 0){
	    bd = bd.add(func(a, n, s, p+1, t-a[p]));
	}
	if(t+a[p] <= 20){
	    bd = bd.add(func(a, n, s, p+1, t+a[p]));
	}
	memo[t][p] = bd;
	
	return bd;
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <math.h>
#include <string.h>

#define M 1000001

int main(void)
{
    int x, i, j;
    int p[M];
    
    for (i = 0; i < M; i++) {
        p[i] = 1;
    }
    p[0] = p[1] = 0;
    for (i = 2; i * i < M; i++) {
        if (p[i] == 1) {
            for (j = i * i; j < M; j += i) {
                p[j] = 0; 
            }
        }
    } 
    for (i = 0; i < M-1; i++) {
        p[i+1] += p[i];
    }
    while (scanf("%d", &x) != EOF) {
        printf("%d\n", p[x]);
    } 
    return (0);
}

Measured memory_bytes: 4928
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll cnt[26];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0;i<n;i++){
        int x = s[i] - 'a';
        cnt[x]++;
    }
    ll ans = 1;
    for(int i=0;i<26;i++){
        if(cnt[i]){
            ans += ((n - cnt[i]) * cnt[i]);
        }
    }
    cout << ans/2 + 1  << endl;
}

Measured memory_bytes: 720
#include<stdio.h>
int main(){
  
 int l,m,n;
  n=0;
  
  scanf("%d",&n);
 
  if(1<=n/100 && n/100<2){
    m=n-100;
    n=n+800;
    if(1<=m/10 && m/10<2){
      l=m-10;
      n=n+80;
      if(l==1) n=n+8;
      else if(l==9) n=n-8;
    }
    else if(1<=m/90 && m/90<2){
      l=m-90;
      n=n-80;
      
      if(l==1) n=n+8;
      else if(l==9) n=n-8;
    }
  }
  else if (1<=n/900 && n/900<2){
    m=n-900;
    n=n-800;
    if(1<=m/10 && m/10<2){
      l=m-10;
      n=n+80;
      if(l==1) n=n+8;
      else if(l==9) n=n-8;
    }
    else if(1<=m/90 && m/90<2){
      l=m-90;
      n=n-80;
      if(l==1) n=n+8;
      else if(l==9) n=n-8;
    }
  }
  
printf("%d",n);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,m;
  cin >> n >> m;
  pair<int, int> p[n];
  rep(i,n){
    int a,b;
    cin >> a >> b;
    p[i]=mp(a,b);
  }
  sort(p,p+n);
  ll cost=0;
  rep(i,n){
    ll a=p[i].first;
    ll b=p[i].second;
    if(m>b){
      cost += b*a;
      m-=b;
    }
    else{
      cost += m*a;
      break;
    }
  }
  cout << cost << endl;
  
  return 0;
    

}


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

int main()
{
  int A, B, C, D, E, K;
  cin >> A >> B >> C >> D >> E >> K;

  if(E-A<=K)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

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

void solve() {
  int N;
  cin >> N;

  int maxi = 0;
  vector<int> A(N);
  map<int, int> m;
  for (int &a:A) {
    cin >> a;
    maxi = max(maxi, a);
    m[a]++;
  }

  sort(A.begin(), A.end());

  vector<bool> ng(maxi+1, false);

  for (int a:A) {
    for (int i = a + a; i <= maxi; i += a) {
      ng[i] = true;
    }
  }

  int ans = 0;
  for (int a:A) {
    if (!ng[a] && m[a] == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13004
W, H, N = map(int, input().split())
X = [0, W]
Y = [0, W]
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        X[0] = max(x, X[0])
    elif a == 2:
        X[1] = min(x, X[1])
    elif a == 3:
        Y[0] = max(y, Y[0])
    else:
        Y[1] = min(y, Y[1])
x = X[1] - X[0]
y = Y[1] - Y[0]
if x < 0:
    x = 0
if y < 0:
    y = 0
print(x*y)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll solve(){
    int n, t;
    cin >> n >> t;

    ll ans = 0;
    int last = 0;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        if(x - last < t){
            ans += 1ll * (x - last);
        }else{
            ans += 1ll * t;
        }
        last = x;
    }
    return ans + 1ll * t;
}

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

    cout << solve() << "\n";
    
    return 0;
}


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

using namespace std;

const int m = 1000;
vector<int> counts(m + 1);
const int mod = pow(10, 9) + 7;

void countDivisors(int n) {
  if (n <= 1) {
    return;
  }
  const int upper = n;
  for (int i = 2; i * i <= upper; i++) {
    while (n % i == 0) {
      n /= i;
      counts[i]++;
    }
  }
  if (n > 1) {
    counts[n]++;
  }
}

int main() {
  int x;
  cin >> x;
  for (int i = 2; i <= x; i++) {
    countDivisors(i);
  }
  long long r = 1;
  for (int i = 2; i <= m; i++) {
    r *= (counts[i] + 1);
    r %= mod;
  }
  cout << r << endl;
}


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

int main(){
	int n, m;
	int i, j;
	int A[100][100], B[100], C[100] = {0};
	
	cin >> n >> m;
	
		for(i = 0; i < n; i++){
			for(j = 0; j < m; j++){
				cin >> A[i][j];
			}
		}
		
		for(j = 0; j < m; j++){
			cin>>B[j];
		}
		
		for(i = 0; i < n; i++){
			for(j = 0; j < m; j++){
				C[i] += A[i][j] * B[j];
			}
		}
		
		for(i = 0; i < n;i++){
			cout<<C[i]<<endl;
		}
				

 	return 0;
}

Measured memory_bytes: 3112
#!/usr/bin/env python
# -*- coding: utf-8 -*-


# 最大公約数
def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


# 素因数分解
def primes(v):
  ps = []

  for i in range(2, int(v ** 0.5) + 1):
    if i ** 2 > v:
      break

    if v % i == 0:
      ps.append([i, 1])
      v //= i

      while v % i == 0:
        ps[-1][1] += 1
        v //= i

  if v > 1:
    ps.append([v, 1])

  return ps


def main():
  a, b = map(int, input().split())
  g = gcd(a, b)
  print(len(primes(g)) + 1)


if __name__ == '__main__':
  main()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> arr;
const int maxn = 1e5 + 1000;
int dp[maxn];
int f(int at)
{
	if(at >= n)
		return 1e9;
	if(at == n - 1)
		return 0;
	if(dp[at] != -1)
		return dp[at];
		
	int rez = 1e9;
	for(int i = at + 1; i <= min(n-1, at + k);i++)
		rez = min(rez, f(i) + abs(arr[at] - arr[i]));
	
	return dp[at] = rez;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i =0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 7416
#include <cstdio>

#define Int register int

const int MAXN = 2000;
int n, m, F[MAXN * 3 + 5][MAXN * 6 + 5];
bool Vis[MAXN * 3 + 5][MAXN * 6 + 5];

inline int DFS ( const int s, const int d ) {
	if ( ! s ) return d >= 0 && ! ( d % 3 );
	if ( Vis[s][d + 3 * n] ) return F[s][d + 3 * n];
	int ret = DFS ( s - 1, d + 1 );
	if ( s > 1 ) ret = ( ret + ( s - 1LL ) * DFS ( s - 2, d - 1 ) ) % m;
	if ( s > 2 ) ret = ( ret + ( s - 1LL ) * ( s - 2LL ) * DFS ( s - 3, d ) ) % m;
	return Vis[s][d + 3 * n] = true, F[s][d + 3 * n] = ret;
}

inline void Work () {
	scanf ( "%d %d", &n, &m );
	printf ( "%d\n", DFS ( 3 * n, 0 ) );
}

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

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

using namespace std;

int fr[100005] , n , q , bi , ci;

int main() 
{
    int x;
    long long s = 0;
   cin >> n;
   for(int i = 1 ; i <= n ; i++)
        cin >> x , ++fr[x] , s += x;
    cin >> q;
    while(q -- )
    {
        cin >> bi >> ci;
        s -= 1LL * bi * fr[bi];
        s += 1LL * fr[bi] * ci;
        cout << s << "\n";
        fr[ci] += fr[bi];
        fr[bi] = 0;
    }
    return 0;
}

Measured memory_bytes: 3996
#include<iostream>
#include<algorithm>
struct P{
long long A;
long long B;
};
bool operator< (const P&a, const P&b){
return a.A < b.A;
}
int main(){
    const long long N = 100100;
     P p[N];
     long long n;
     long long m;
     std::cin >> n >> m;
     long long i = 0;
     for( ;i < n; i++ ){
        std::cin >> p[i].A;
        std::cin >> p[i].B;
     }
     std::sort (&p[0],&p[n]);
     long long cost = 0;
     for(i = 0; i < n; i++){
        if(m >= p[i].B){
            cost += p[i].A * p[i].B;
            m -= p[i].B;
        }
        else{
            cost += m * p[i].A;
            break;
        }

     }
     std::cout << cost;
}

Measured memory_bytes: 1792
import math
from functools import reduce
N = int(input())
T = []

for _ in range(N):
    T.append(int(input()))

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

cur = 1

for t in T:
    cur = lcm(t, cur)

print(cur)

Measured memory_bytes: 38384
#include <cstdio>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;

int main() {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    printf(abs(a - b) <= 1 ? "Brown" : "Alice");
    return 0;
}


Measured memory_bytes: 128
S=gets.chomp.split("").map(&:to_i)
cnt = 0
cnt += 1 if 0<S[2]*10+S[3] && S[2]*10+S[3]<=12
cnt += 2 if 0<S[0]*10+S[1] && S[0]*10+S[1]<=12
puts ["NA","YYMM", "MMYY", "AMBIGUOUS"][cnt]


Measured memory_bytes: 1788
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    for(int i = 0;i<n;i++){
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    int count = 0;
    for(int i = n-1;i>=2;i--){
      for(int j = 0;j<=i-2;j++){
        for(int k = j+1;k<i;k++){
          if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k])continue;
          if(l[k]+l[j]>l[i])count++;
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 36456
#include<iostream>
#include<cstring> 
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++)
	cin>>a[i];
	int ans=0x3f3f3f3f;
	for (int i=1;i<=100;i++)
	{
		int k=0;
		for (int j=0;j<n;j++)
		{
			k=k+(a[j]-i)*(a[j]-i);
		}
		if (k<ans)
		ans=k;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256