akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    map<ll, ll> mp, mm;
    rep(i, n) {
        ll a; cin >> a;
        if(!mp.count(i+a)) mp[i+a] = 1;
        else mp[i+a]++;
        if(!mm.count(i-a)) mm[i-a] = 1;
        else mm[i-a]++;
    }
    ll ans = 0;
    map<ll, ll> sum;
    for(auto x : mp) {
        if(!sum.count(x.first)) sum[x.first] = x.second;
        else sum[x.first] += x.second;
    }
    for(auto x : mm) {
        if(!sum.count(x.first)) sum[x.first] = x.second;
        else sum[x.first] += x.second;
    }
    for(auto x : sum) if(x.second > 1) ans += mp[x.first] * mm[x.first];
    cout << ans << endl;
}


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

using ll = long long;
const ll INF = 1LL << 60;

inline bool chmin(ll& a, ll b) { if (a > b) { a = b; return true; } return false; }
inline bool chmax(ll& a, ll b) { if (a < b) { a = b; return true; } return false; }

int N;
vector<ll> height;
vector<ll> cost;

int main() {

  cin >> N;

  height = vector<ll>(N+10,0);
  cost = vector<ll>(N+10, INF);

  for (ll i=0; i<N; i++){
    cin >> height.at(i);
  }

  cost.at(0) = 0;

    for (ll i=0; i<N; i++){
      chmin(cost.at(i+1),cost.at(i)+abs(height.at(i+1) - height.at(i)));
      chmin(cost.at(i+2),cost.at(i)+abs(height.at(i+2) - height.at(i)));
    }

  cout << cost.at(N-1) << endl;
}

Measured memory_bytes: 1792
a = gets.chomp
b = []
c = []

d = false

("a".."z").each do |i|
  b << i
end

("A".."Z").each do |j|
  c << j
end

c.each do |j|
  if a == j
    d = true
    break
  end
end

puts d ? "A": "a"

Measured memory_bytes: 14368
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()


struct edge {
    int to;
    int cost;
};

void dijkstra(const vector<vector<edge>>& edges, vector<int>& distance, int start_point) {
    distance[start_point] = 0;

    // P -> first : 最短距離, second : 頂点の番号
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    que.emplace(0, start_point);

    while (!que.empty()) {
        pair<int, int> p = que.top();
        que.pop();
        int next = p.second;
        if (distance[next] < p.first){
            continue;
        }
        for(const auto e : edges[p.second]){
            if(distance[e.to] > distance[next] + e.cost){
                distance[e.to] = distance[next] + e.cost;
                que.emplace(distance[e.to], e.to);
            }
        }
    }
}

int main() {

	int v, e, r;
	cin >> v >> e >> r;
    vector<vector<edge>> edges(v);
	rep(i, e){
		int s, t, w;
		cin >> s >> t >> w;
		edges[s].emplace_back((edge){t, w});
	}
	
	vector<int> distance(v, 1000000000);
	dijkstra(edges, distance, r);
	
	for(auto x : distance){
		if(x == 1000000000){
			cout << "INF" << endl;
		}
		else{
			cout << x << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 12916
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll h,n,i,x,y,j,k;
cin>>h>>n;
vector<pair<int,int> > v;
for(i=0;i<n;i++){
    cin>>x>>y;
    v.pb({x,y});
}
ll dp[20005];
fill(dp,dp+20005,1e9+7);
dp[0]=0;
for(i=0;i<n;i++){
    for(k=0;(1<<k)*v[i].ff<=2e4;k++){
        for(j=2e4-(1<<k)*v[i].ff;j>=0;j--){
            dp[j+(1<<k)*v[i].ff]=min(dp[j+(1<<k)*v[i].ff],dp[j]+(1<<k)*v[i].ss);
        }
    }
}
ll mini=1e9+7;
for(i=h;i<=2e4;i++){
    mini=min(mini,dp[i]);
}
cout<<mini<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#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 all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r,g,b,n;
    cin >> r >> g >> b >> n;
    ll cnt = 0;
    rep(i,3001){
        rep(j,3001){
            if (i*r+j*g <= n && (n-i*r-j*g)%b == 0){
                cnt++;
            }
        }
    }
    PRINT(cnt);
}




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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


int main()
{
    string s,t;

    cin >> s>>t;

    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i]!=t[i]) {
            count++;
        }

   }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();




int main(){
ll n,a=0,b=0; cin>>n; 
vector<int> p(n); REP(i,n)cin>>p[i];
vector<int> r(n); REP(i,n)r[i]=i+1;
vector<int> q(n); REP(i,n)cin>>q[i];

  
ll count=1;
 while(next_permutation(ALL(r))){

   bool equalp = r.size() == p.size() && equal(r.cbegin(), r.cend(), p.cbegin());
   if(equalp)a=count;
   bool equalq = r.size() == q.size() && equal(r.cbegin(), r.cend(), q.cbegin());
   if(equalq)b=count;

   count++;
 }


cout<<abs(a-b)<<endl; 

}

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

using namespace std;

int n, a[10005];

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	sort(a, a + n);
	
	vector <int> v;
	
	for(int i = 0; i < min(n, 4); i++){
		for(int j = 0; j < min(n, 4); j++){
			if(i == j) continue;
			string v1 = to_string(a[i]);
			string v2 = to_string(a[j]);
			string v3 = v1 + v2;
			
			v.push_back(stoi(v3));
		}
	}
	
	sort(v.begin(), v.end());
	
	printf("%d\n", v[2]);
}



Measured memory_bytes: 3352
function f(E,D)
	for d=D
		for (a,b,c)=E
			if D[b]>D[a]+c
				D[b]=D[a]+c
			end
		end
	end
end
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	E=Tuple{Int,Int,Int}[]
	for s=readlines()
		a,b,c=map(x->parse(Int,x),split(s))
		push!(E,(a,b,-c))
	end
	D=[1145141919810931893 for _=1:N]
	D[1]=0
	f(E,D)
	ans=D[N]
	f(E,D)
	println(ans>D[N]?"inf":-ans)
end
main()


Measured memory_bytes: 116168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){
  int r, D, x2000;
  cin >> r >> D >> x2000;

  ll ans;
  ll before = x2000;
  REP(i, 0, 10){
    ans = r * before - D;
    cout << ans << endl;
    before = ans;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
T = list(map(int, input().split()))

import itertools

a, b = 0, 0
for i, s in enumerate(itertools.permutations(sorted(P))):
  if s == tuple(P):
    a = i
  if s == tuple(T):
    b = i

print(abs(a-b))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  
  int A,B;
  
  scanf("%d %d", &A, &B);
  
  if(A > 12){
    printf("%d", B);
  }else if((A > 5) && (A < 13)){
    printf("%d", B/2);
  }else{
    printf("0");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    String a = sc.next();
	    String b = sc.next();
	    
	    if(a.equals("H") && b.equals("H")){
	    	System.out.println("H");
	    }else if (a.equals("D") && b.equals("H")) {
			System.out.println("D");
		}else if (a.equals("D") && b.equals("D")) {
			System.out.println("H");
		}else {
			System.out.println("D");
		}
	}
}

Measured memory_bytes: 21204
#include <stdio.h>

#define MAX 100000

int partition(int A[], int p, int r){

  int x,i,j,t;

  x = A[r];

  i = p - 1;

  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }

  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return (i + 1);

}

int main(){

  int A[MAX],n,i,q;

  scanf("%d",&n);

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

  q = partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    
    if(i == q){
      printf("[");
    }

    printf("%d",A[i]);

    if(i == q){
      printf("]");
    }
  }

  printf("\n");




  return 0;
}



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

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<double> v(n);
        for (int i = 0; i < n; i++) {
            cin >> v[i];
        }
        double m = accumulate(v.begin(), v.end(), 0.0) / v.size();
        double ans = 0;
        for (int i = 0; i < n; i++) {
            ans += (v[i] - m) * (v[i] - m) / n;
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3284
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
const int inf= 1e9 +7;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    vector<int> dp(n,inf);
    for(int i=0;i<n;i++){
        cin>>h[i];
        //cout<<h[i]<<" ";
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=min(i,k);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
 
int n;
int p[210];
 
void in(){
	int t; read(t);
	int last;
	read(last);
	p[++n] = last;
	for(;--t;){
		int x; read(x);
		if(last+1 < x){
			p[++n] = last+1;
			p[++n] = x;
		}
		last = x;
	}
	p[++n] = last+1;
}
 
bool is_prime(int x){
	if(x==1) return 0;
	if(x==2) return 0;
	for(int i=2; i*i<=x; ++i) if(x%i==0) return 0;
	return 1;
}
vector<int>edge[210];
int vis[210];
int rev[210];
 
bool dfs(int x){
	if(vis[x]) return 0;
	vis[x]=1;
	for(int y:edge[x]){
		if(!rev[y] || dfs(rev[y])){
			rev[y]=x;
			return 1;
		}
	}
	return 0;
}
 
int MM(){ int ret = 0;
	for(int i=1; i<=n; ++i){
		fill(vis+1, vis+n+1, 0);
		if(dfs(i)) ret += 1;
	}
	return ret;
}
 
int main()
{
	in();
	int oc=0, ec=0;
	for(int i=1; i<=n; ++i){
		((p[i]%2)?oc:ec)++;
		for(int j=i+1; j<=n; ++j){
			if(is_prime(p[j]-p[i])){
				int a=i, b=j;
				if(p[a]%2) swap(a, b);
				edge[a].pb(b);
			}
		}
	}
	int mm = MM();
	int ans = 2e9;
	for(int pu=0; pu<=mm; ++pu){
		int cur = 0;
		cur += (oc-pu)/2*2;
		cur += (ec-pu)/2*2;
		cur += ((oc-pu)%2)*((ec-pu)%2)*3;
		cur += pu;
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
mod = 2019

lm = l % mod
rm = r % mod

ans = 2019
for i in range(min(mod, r - l)):
    for j in range(1, min(mod, (r - l - i)) + 1):
        ans = min(ans, (lm + i) * (lm + i + j) % mod)
print(ans)

Measured memory_bytes: 40940
import numpy as np
 
xy = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [list(map(int, input().split())) for _ in range(n)] 
result = [[0,0,0],[0,0,0],[0,0,0]]
 
def input_b(xy:list, num:int, result:list):
    for i in range(3):
        if num in xy[i]:
            for j in range(3):
                if num==xy[i][j]:
                    result[i][j]=1
    return result
  
def check_result(result:list):
    for i in range(3):
        if 3 == np.array(result[i]).sum():
            return "Yes" 
    if 3 in np.array(result[0]) + np.array(result[1]) + np.array(result[2]):
        return "Yes"
    if 3 == result[0][0] + result[1][1] + result[2][2]:
        return"Yes"
    if 3 == result[0][2] + result[1][1] + result[2][0]:
        return"Yes"
    return "No"
 
for k in num:
    result=input_b(xy,k[0],result)
 
print(check_result(result))

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    ll cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i]) cnt1 += (b[i] - a[i]) / 2;
        else cnt2 += a[i] - b[i];
    }

    if (cnt1 >= cnt2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e9;
const ll MOD = 1e9;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vector(vector<int> & a) {
	forn(i, (int)a.size()) {
		cout << a[i] << " ";
	}
	cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
	ll h;
	forn(i, n) {
		cin >> h;
		a.pb(h);
	}
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
//#define DEBUG
int main(){
	FastIO;
	#ifdef DEBUG
		freopen("input.txt", "r", stdin);
	#endif // DEBUG
	ll l, r;
	cin >> l >> r;
	if (r / 2019 == l / 2019){
		ll ans = 2020;
		for (ll i = l; i < r; ++i){
			for (ll j = i + 1; j <= r; ++j){
				ans = min(ans, (i * j) % 2019);
			}
		}
		cout << ans << endl;
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}


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

#define max 100

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int w[max], n, ans=0, i, j, tmp=INT_MAX;
    
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &w[i]);
    }
    
    for (i=1; i<n; i++) {
        ans=0;
        for (j=0; j<i; j++) {
            ans=ans+w[j];
        }
        for (j=i; j<n; j++) {
            ans=ans-w[j];
        }
        if (abs(ans)<tmp) {
            tmp=abs(ans);
        }
    }
 
    
    
    printf("%d", tmp);
    
    return 0;
}




Measured memory_bytes: 128
s = list(input())
a = 0
for i in range(len(s)):
  if i%2 == 0:
    if s[i] == "h":
      continue
    else:
      a += 1
  elif i%2 == 1:
    if s[i] == "i":
      continue
    else:
      a += 1
if s[-1] == "h":
  a += 1
if a == 0:
  print("Yes")
else:
  print("No")


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

int main() {
  string a;
  cin >> a;
  string b;
  cin >> b;
  
   for(int i=0; i<a.size();i++){
     
  if( a == b){
    cout << "Yes" <<endl;
    
    return 0;
  }
    a = a.back() + a.substr(0, a.size()-1);

  }
  cout << "No" << endl;
}
  
 

Measured memory_bytes: 256
N = int(input())

v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a = [v[i]-c[i] for i in range(N)]

ans = 0
for i in range(N):
    if a[i]>=0:
        ans += a[i]

print(ans)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
// #define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

int gg[201][201];

void solve() {
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      gg[i][j] = __gcd(i, j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int th = gg[i][j];
      for (int k = 1; k <= n; k++) {
        sum += gg[th][k];
      }
    }
  }

  cout << sum << endl;
}

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  int n;
  // cin >> n;
  n = 1;
  int i = 1;
  while (n--) {
    solve();
  }
}

/*


00100
00

*/

Measured memory_bytes: 3756
#include <iostream>

using namespace std;

void print(int* array, int N)
{
    for(int i=0;i<N;++i)
    {
        if(i) cout << " ";
        cout << array[i];
    }
    cout << endl;
}

void sort(int* array, int N)
{
    for(int i=0;i<N;++i){
        int v = array[i];
        int j = i - 1;
        while(j >= 0 && array[j] > v)
        {
            array[j+1] = array[j];
            --j;
        }
        array[j + 1] = v;
        print(array, N);
    }
}

int main()
{
    int array[100];
    int N;
    cin >> N;
    for(int i=0;i<N;++i)
    {
        cin >> array[i];
    }
    sort(array, N);

}



Measured memory_bytes: 3092
use std::collections::HashMap;
use std::collections::btree_map::Entry;
use std::collections::BTreeMap;
use std::cmp::max;

#[derive(Debug, PartialEq)]
struct Section {
    a: i64,
    b: i64
}

impl Section {
    fn new(a: i64, b: i64) -> Section {
        Section { a: a, b: b }
    }

    pub fn len(&self) -> i64 {
        self.b - self.a + 1
    }
}

struct SectionList {
    map: BTreeMap<i64, i64>
}

impl SectionList {
    fn new () -> SectionList {
        SectionList { map: BTreeMap::new() }
    }

    fn insert(&mut self, a: i64, b: i64) {
        assert!(a <= b);
        match self.map.entry(a) {
            Entry::Occupied(mut x) => {
                let value = x.get_mut();
                *value = max(*value, b);
            },
            Entry::Vacant(x) => {
                x.insert(b);
            }
        };
    }

    fn merge(&self) -> Vec<Section> {
        match self.map.len() {
            0 => vec![],
            1 => {
                let mut iter = self.map.iter();
                let (a, b) = iter.next().unwrap();
                vec![Section::new(*a, *b)]
            },
            _ => {
                let mut iter = self.map.iter();
                let (mut current_a, mut current_b) = iter.next().unwrap();
                let mut result = vec![];
                for (a, b) in iter {
                    if a <= &(current_b + 1) {
                        current_b = max(b, current_b);
                    } else {
                        result.push(Section::new(*current_a, *current_b));
                        current_a = a;
                        current_b = b;
                    }
                }
                result.push(Section::new(*current_a, *current_b));
                result
            }
        }
    }
}

fn len_sum(sections: Vec<Section>) -> i64 {
    sections.iter().fold(0, |sum, section| { section.len() + sum })
}

fn solve(n: i64, mut x: i64, mut d: i64) -> i64 {
    if d == 0 {
        if x == 0 {
            return 1;
        } else {
            return n + 1;
        }
    }

    if d < 0 {
        d = -d;
        x = -x;
    }

    let d = d;
    let x = x;

    let mut map = HashMap::new();

    for k in 0 .. n + 1 {
        let a = (k * (k - 1)) / 2;
        let b = k * (2 * n - k - 1) / 2;

        let (q, r) = if x < 0 {
            let kx = -x * k;
            (-(kx / d), kx % d)
        } else {
            let kx = x * k;
            (kx / d, kx % d)
        };

        map.entry(r).or_insert(SectionList::new()).insert(a + q, b + q);
    }

    map.iter().fold(0, |sum, (_key, section_list)| {
        sum + len_sum(section_list.merge())
    })
}

fn main() {
    let (n, x, d): (i64, i64, i64) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut s = s.trim().split_whitespace();
        (s.next().unwrap().trim().parse().unwrap(), s.next().unwrap().trim().parse().unwrap(), s.next().unwrap().trim().parse().unwrap())
    };

    print!("{}", solve(n, x, d));
}

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

using Graph = vector<vector<int>>;

int main() {
  int N, M;
  cin >> N >> M;
  
  int ans[N+2] = {0}; // 答えをおさめるdict. 0 で初期化
  // G: Graph, 頂点のつながりをおさめている
  Graph G(N+2);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  
  queue<int> q; // キュー
  q.push(1);
  
  
  while (q.size() > 0) { // q が空っぽでない限り
    int cur = q.front(); // 先頭を取りだす(curとする)
    q.pop();  // qからcurを捨てる．
    for (int i : G[cur]) {     // それにつながっている頂点それぞれについて
      if (ans[i] != 0) continue; // もしそのans == 0(未チェック)でないなら continue

      // 未チェック
      ans[i] = cur;  // ans の繋ぎ先を cur にする
      q.push(i);  // この頂点をq に入れる
    }
  }
  
  for (int i = 1; i < N+1; i++) {
    if (ans[i] == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
    
  cout << "Yes" << endl;
  for (int i = 2; i < N+1; i++) {
    cout << ans[i] << endl;
         // １個ずつ出力
  }
}

Measured memory_bytes: 10164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  int l=0;
  int r=1;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    r=max(a.at(i),r);
  }
  while(r-l>1){
    int h=(l+r)/2;
    int64_t c=0;
    for(int i=0;i<n;i++)
      c+=(a.at(i)+h-1)/h-1;
    if(c<=k)
      r=h;
    else
      l=h;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'&&s[i+1]=='C')cnt++;
  }
  if(cnt>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

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

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define dle(a,b) (equals(a, b) || a < b)
static const double PI = acos(-1);

class Point {
 public:
  double x, y;
  
  Point (double x = 0, double y = 0): x(x), y(y){}
  
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  
  double abs() { return sqrt(norm()); }
  double norm() { return x*x+y*y; }
  
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;

class Segment {
public:
  Point p1, p2;
  Segment(Point s = Point(), Point t = Point()): p1(s), p2(t) {}
};

double norm( Vector a ) { return a.x*a.x + a.y*a.y; }
double abs( Vector a ) { return sqrt(norm(a)); }
double getDistance( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
double dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; }

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0, Point p1, Point p2 ) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a, b) < -EPS ) return CLOCKWISE;
  if( dot(a, b) < -EPS ) return ONLINE_BACK;
  if( norm(a) < norm(b) ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

int main() {
  double x1, y1, x2, y2, x3, y3, x, y;
  
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x>>y) {
    int ccw1 = ccw( Point(x1,y1), Point(x2,y2), Point(x,y) );
    int ccw2 = ccw( Point(x2,y2), Point(x3,y3), Point(x,y) );
    int ccw3 = ccw( Point(x3,y3), Point(x1,y1), Point(x,y) );
    if( ccw1 == ccw2 && ccw2 == ccw3 ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
def prime_bunkai(num):
    temp = num
    ans_list = []
    for i in range(2, int(-(-temp**0.5)//1)+1):
        if num % i == 0:
            ans_list.append(i)
            while num % i == 0:
                num //= i

    if num != 1:
        ans_list.append(num)

    if ans_list == []:
        ans_list.append(temp)
    ans_list.append(1)
    return ans_list

A, B = list(map(int, input().split()))   

ans = set(prime_bunkai(A)) & set(prime_bunkai(B))
print(len(ans))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back 
signed main()
{
  	int n,m ; cin>>n>>m;
  	vector<int>adj[n+1];
  	for(int i = 0 ; i < m ;i++)
    {
    	int u , v;cin>>u>>v;
      	adj[u].pb(v);
      	adj[v].pb(u);
    }
  	
  	vector<int>dis(n+1,INT_MAX);
  	vector<int>par(n+1);
  	vector<int>vis(n+1);
  	priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int>>>pq;
  	pq.push({0,1});
  	dis[1] = 0; 
  	while(!pq.empty())
    {
    	int cost = pq.top().first;
      	int tp = pq.top().second;
      	pq.pop();
      	vis[tp] = 1;
      	for(auto it : adj[tp])
        {	
          if(dis[it] > dis[tp] + 1) 
          {
          	dis[it] = dis[tp] +1 ;
            par[it] = tp;
            pq.push({dis[tp] + 1 ,it});
          }
        }
    }
  	for(int i = 2 ; i <=n ;i++ )
    { if(vis[i] != 1  ) { cout<<"No"<<endl; return 0 ;}  }
  	cout<<"Yes"<<endl;
  	for(int i = 2 ; i <=n ;i++)
      cout<<par[i]<<endl;

}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s1[15];
int a[15];
int main()
{
	scanf("%s",s1);
	int n=strlen(s1)-1;
	for(int i=0;i<=n;i++)
	{
		a[i]=s1[i]-'0';
	}
	int num=1<<n;
	ll res=0;
	for(int i=0;i<num;i++)
	{
		ll temp=a[0];
		for(int j=0;j<n;j++)
		{
			if(i & (1<<j))
			{
				res+=temp;
		//		printf("%lld\n",temp);
				temp=a[j+1];
			}
			else
			{
				temp=temp*10+a[j+1];
			}
		}
		res+=temp;
	//	printf("%lld\n",temp);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  long n,s;
  cin>>n>>s;
  if(s>n){ cout<<-1<<endl; return 0;}
  if(s==n){ cout<<n+1<<endl; return 0;}
  long sqrtn = sqrt(n);

  // b < sqrt(n) に解がある場合
  for(long b=2; b<=sqrtn; b++){
    long nn = n;
    long sum = 0;
    while(nn>0){
      sum += nn%b;
      nn /= b;
    }
    if(sum == s){
      cout<<b<<endl;
      return 0;
    }
  }

  // b > sqrt(n) に解がある場合
  // 1次式に必ずなり，b（1次の項）の係数で全探索
  for(long x = sqrtn; x>= 1; x--){
    if((n-s)%x==0){
      long b = (n-s)/x + 1;
      long y = s-x;
      if(b > y && b > x && y >= 0){
        cout << b << endl;
        return 0;
      }
    }
  }

  cout<<-1<<endl;

  return 0;
}


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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(l == N && k == Ans) { cnt++; return; }
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans, N||Ans) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;

string[] C = ["dreamer", "eraser", "dream", "erase"];

bool judge(string sub_str) {
  if (sub_str.length == 0)
    return true;

  bool ok = false;
  foreach(c; C) {
    if (sub_str.length < c.length)
      continue;

    if (sub_str[0..c.length] == c)
      ok = ok || judge(sub_str[c.length..$]);
  }

  return ok;
}

void main() {
  string S; readlnTo(S);
  writeln(judge(S) ? "YES" : "NO");
}

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}


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

signed main() {
    int N, Q;
    cin >> N >> Q;
    
    int head = 0;
    while (Q--) {
        int q, k;
        cin >> q >> k;
        if (q == 0) {
            cout << (head + k - 1) % N + 1 << endl;
        } else {
            head = (head + k) % N;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
N = int(input())
p = list(map(int,input().split()))
cnt = 0
h = [p[i] == i + 1 for i in range(N)]
i = 1
while(i < N):
    if h[i] and h[i - 1]:
        cnt += 1
        i += 1
    i += 1
ans = sum(h) - cnt
print(ans)

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

int s( int n ){
  int ans = 0;
  while ( n != 0 ){
    ans += n % 10;
    n /= 10;
  }
  
  return ans;
}

int main(){
  int n;
  cin >> n;
  
  if ( n % s(n) == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}




int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll a, b;
	cin >>n >>a >>b;
	
	VL x(n);
	rep(i, n) cin >>x[i];
	
	VL df(n-1) ,sm(n);
	rep(i, n-1) df[i] = (x[i+1]-x[i]) * a;
	sort(all(df));
	rep(i, n-1) sm[i+1] = sm[i] + df[i];
	for(auto x :sm) cerr<<x<<" "; dbg("");
	auto cal=[&](ll m){
		rep(i, n){
			if(sm[n -1 - i] + i*b <= m) return true;
		}
		return false;
	};
	
	ll lf = 0, rg=1LL<<60;
	while(rg - lf >1){
		ll md = (rg + lf) >> 1;
		if( cal(md) ) rg = md; else lf = md; 
	}

	//dbg(lf, rg);
	cout << rg <<"\n";
	return 0;
}


Measured memory_bytes: 2688
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000
#define MOD 998244353



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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 3002
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

vector<double> head(inp+1),tail(inp+1);
double dp[inp][inp];
bool vis[inp][inp];

double solve(int coin,int h)
{
    if(coin<h) return 0.0;
    if(h<0) return 0.0;
    if(vis[coin][h]) return dp[coin][h];
    vis[coin][h]=true;
    return dp[coin][h] = head[coin]*solve(coin-1,h-1) + tail[coin]*solve(coin-1,h);
}

int main()
{
    jaldi

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>head[i];
        tail[i]=1.0-head[i];
    } 
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++) { dp[i][j]=0.0; vis[i][j]=false; }
    }
    dp[0][0]=1;
    vis[0][0]=1;

    double ans;
    for(int i=n/2+1;i<=n;i++)
    {
        ans += solve(n,i);
    }

    cout << fixed << setprecision(10) << ans;

    return 0;
}

Measured memory_bytes: 79616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;



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

   int h,w;
   cin>>h>>w;
   int c[h][w];
   int ans = 0;
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           cin>>c[i][j];
           if(c[i][j]==0) ans = 1;
       }
   }
   int dp[h][w] = {};
   for(int i=0;i<h;i++){
       dp[i][0] = (c[i][0]==0);
   }
    for(int i=0;i<w;i++){
       dp[0][i] = (c[0][i]==0);
   }
   for(int i=1;i<h;i++){
       for(int j=1;j<w;j++){
           if(c[i][j] == 1) continue;
           dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
           ans = max(ans,dp[i][j]);
       }
   }
   ans *= ans;
   cout<<ans<<endl;

   
}


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

int main() {
    int n, a, b, ans;

    scanf("%d", &n);

    a = n / 10;
    b = n % 1000;

    ans = a * b % 111;

    if (ans == 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
ll mod = 1000000007;

int main(){
  ll n, W;
  cin >> n >> W;
  vll w(n), v(n);
  rep(i, 0, n) cin >> w.at(i) >> v.at(i);
  vvll dp(n + 1, vll(W + 1, 0));
  rep(i, 1, n + 1) rep(j, 1, W + 1){
    if(j - w.at(i - 1) >= 0) chmax(dp.at(i).at(j), dp.at(i - 1).at(j - w.at(i - 1)) + v.at(i - 1));
    chmax(dp.at(i).at(j), dp.at(i - 1).at(j));
  }
  cout << dp.at(n).at(W) << endl;
}

Measured memory_bytes: 80256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-01-11 19:41:55

---------------------------------*/

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int MAXN = 1e5+7;
const int MAXM = 1e5+7;

int main(int argc, char const *argv[])
{
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
	return 0;
}

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

using namespace std;

int main() {
    // Input
    int N, K;
    vector<int> d;
    vector<vector<int>> A;

    cin >> N >> K;
    d = vector<int>(K);
    for (int i = 0; i < K; i++) {
        cin >> d[i];
        vector<int> a(d[i]);
        for (int j = 0; j < d[i]; j++) cin >> a[j];
        A.push_back(a);
    }

    // Process
    vector<bool> flags(N, false);
    for (vector<int> a : A) {
        for (int n : a) {
            flags[n - 1] = true;
        }
    }

    int ans = 0;
    for (bool flag : flags) {
        if (!flag) ans++;
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
//CazadorDivino
#include "bits/stdc++.h"
#include <cmath>
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<long,long> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


int tab[35][35];

bool binSearch(int l, int r, int x, int f){
	if(l>r)
		return false;
	int m = (l + r)/2;
	if(tab[f][m] == x)
		return true;
	else{
		if(tab[f][m] > x)
			return binSearch(l,m-1,x,f);
		else
			return binSearch(m+1,r,x,f);
	}
	
}

int main(){
	std::set<int>::iterator it;
	int n, m, cont = 0;
	cin>> n >> m;
	set<int> st;
	rep(i,1,n){
		int k, j;
		cin >> k;
		tab[i][0] = k;
		j = 1; 
		while(k > 0){
			cin>> tab[i][j];
			st.insert(tab[i][j]);
			k--;
			j++;
		}
		sort(tab[i]+1,tab[i]+1+tab[i][0]);
	}
	
	for (it=st.begin(); it!=st.end(); ++it){
		int k = *it;
		bool ok = true;
		//~ cout<< k<< endl;
		rep(i,1,n){
			ok &= binSearch(1,tab[i][0],k,i);
			//~ cout<< ok <<" "; 
		}
		//~ cout<<endl;
		if(ok)
			cont++;
	}
	cout<< cont;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

struct node
{
	int key;
	node* lc, * rc, * p;
};

node* root = 0;

void insert(int x)
{
	node* pre = root;        //设当前节点为根，以根为起点
	node* temp = pre;        //用来保存当前节点的临时指针

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = 0;     
	in->rc = 0;     

	while (pre != 0)
	{
		temp = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}
	pre = temp;

	if (pre == 0)
		root = in;
	else
	{
		if (in->key < pre->key)
			pre->lc = in;
		else
			pre->rc = in;
	}
}

void Inorder(node* r)
{
	if (r->lc != 0)
		Inorder(r->lc);

	cout << " " << r->key;

	if (r->rc != 0)
		Inorder(r->rc);
}

void Preorder(node* r)
{
	cout << " " << r->key;

	if (r->lc != 0)
		Preorder(r->lc);
	if (r->rc != 0)
		Preorder(r->rc);
}

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

	int n, x;
	string p;

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

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 26472
#!/usr/bin/env python3
# coding:utf-8
# Reverse Polish Notation

def main():
    RPM = input().split()
    stack = []
    operator = ['+', '-', '*']
    
    while len(RPM) > 0:
        value = RPM.pop(0)
        if value not in operator:
            stack.append(value)
        else:
            x, y = str(stack.pop()), str(stack.pop())
            stack.append(eval(y + value + x))
    
    print(stack[0])

if __name__ == "__main__":
    main()

Measured memory_bytes: 7536
def c_synthetic_kadomatsu(N, A, B, C, L, INF=float('inf')):
    def dfs(cur, a, b, c):
        # cur本目まで竹を見たとき、長さA, B, Cにしたい竹のそれぞれの長さがa, b, cの状態
        if cur == N:
            # すべての竹を見終わった。長さが違う分だけ伸縮する
            # 最終的にできる3本の竹について、1本も竹を使わないことがあってはいけない
            return abs(a - A) + abs(b - B) + abs(c - C) if min(a, b, c) > 0 else INF
        # cur番目の竹をどれかの竹と合成するか、何もしない。そのときのMP
        # 第2項の条件式は、竹の長さ0のときに竹を合成することはないことを反映
        ret0 = dfs(cur + 1, a, b, c)
        ret1 = dfs(cur + 1, a + L[cur], b, c) + (10 if a > 0 else 0)
        ret2 = dfs(cur + 1, a, b + L[cur], c) + (10 if b > 0 else 0)
        ret3 = dfs(cur + 1, a, b, c + L[cur]) + (10 if c > 0 else 0)
        return min(ret0, ret1, ret2, ret3)
    return dfs(0, 0, 0, 0)  # 最初は竹に注目しておらず、どの竹も長さ0

N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]
print(c_synthetic_kadomatsu(N, A, B, C, L))

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static int[] par;
    public static int[] sizes;

	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      par = new int[n];
      sizes = new int[n];
      unionFind uf = new unionFind(n);
      int m = sc.nextInt();
      int k = sc.nextInt();
      int a,b,c,d;
      
      int[] no = new int[n];
      for(int i=0;i<m;i++){
        a =sc.nextInt()-1;
        b =sc.nextInt()-1;
        uf.unite(a,b);
        no[a]++;
        no[b]++;
      }
      for(int i=0;i<k;i++){
        c = sc.nextInt()-1;
        d = sc.nextInt()-1;
        if(!(uf.same(c,d))) continue;
        no[c]++;
        no[d]++;
      }
      for(int i=0;i<n;i++){
        int ans = uf.size(i)-1-no[i];
        System.out.print(ans+" ");
      }
    }
}
  
class unionFind{
    unionFind(int n){
		for(int i=0;i<n;i++) Main.par[i]=i;
		for(int i=0;i<n;i++) Main.sizes[i]=1;
	}
	
	int root(int x){
		if(Main.par[x]==x) return x;  //xが根ならばxを返す
		return Main.par[x] = root(Main.par[x]);  //経路圧縮
	}
	
	void unite(int x,int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return ;
		if(Main.sizes[rx]<Main.sizes[ry]){
			int temp;
			temp=rx;
			rx=ry;
			ry=temp;	
		}
		Main.par[ry] = rx;  //根rxと根ryが別物だったならryをrxに付ける
		Main.sizes[rx]+=Main.sizes[ry];
	}
	
	boolean same(int x,int y){
		int rx = root(x);
	    int ry = root(y);
	    return rx==ry;
	}

	int size(int x){
		return Main.sizes[root(x)];
	}
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=1;i<=n;i+=2){
		if(a[i]%2==1)sum++;
	}
	cout<<sum;
	return 0;
}

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


int main()
{
   int i,la,lb,n;
   char a[110],b[110],tmp;
   cin>>a>>b;
   la=strlen(a);
   lb=strlen(b);
   n=la;
   if(strcmp(a,b)==0){
    cout<<"Yes"<<endl;
    return 0;
   }
   //cout<<la;
   while(n--){
        tmp=a[la-1];
        for(i=la-2; i>=0; i--){
            a[i+1]=a[i];
        }
        a[0]=tmp;
        //puts(a);
        if(strcmp(a,b)==0){
            cout<<"Yes"<<endl;
            return 0;
        }

   }

    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

def min(ans, arr)
  d = arr.minmax.inject(&:-).abs
  return ((d < ans) ? d : ans)
end

def solver(h, w)
  ans = 1e11
  (h + 1).times do |i|
    sa = w * i
    # tate
    wi = w / 2
    sb = (h - i) * wi
    sc = (h - i) * (w - wi)
    ans = min(ans, [sa, sb, sc])
    # yoko
    hi = (h - i) / 2
    sb = hi * w
    sc = (h - hi - i) * w
    ans = min(ans, [sa, sb, sc])
  end
  ans
end
p [solver(h, w), solver(w, h)].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  int ans = x;
  rep(i,n){
    ans+=((d-1)/a.at(i))+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256