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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007


void solve()
{
    int s;
    cin>>s;
    
    ll dp[s+1];
    
    if(s==1 or s==2)
    {
        cout<<0;
        return;
    }
    
    else if(s==3)
    {
        cout<<1;
        return;
    }
    
    dp[0] = dp[1] = dp[2] = 0;
    
    dp[3] = 1;
    
    
    
    for(int i = 4;i<=s;i++)
    {
        dp[i] = 0;
        for(int j = i-3;j>=3;j--)
        {
            dp[i] += (dp[j])%mod;
            dp[i]%=mod;
        }
        dp[i] = (dp[i]+1)%mod;
    }
    cout<<dp[s];
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int stoa(string s) {
	int ret = 0, t = 1;
	for(int i = s.size()-1; i >= 0; i--) {
		ret += (s[i] - '0') * t;
		t *= 10;
	}
	return ret;
}

int n;
string s;
int vmin = INF, vmax = 0, ans = 0, cnt = 0;
vector<int> res;

void dfs(int i, int sum, vector<int> v) {
	if(i == s.size()) {
		vmin = min(vmin, sum);
		vmax = max(vmax, sum);

		if(sum <= n) {
			if(ans < sum) {
				ans = sum;
				cnt = 1;
				res.clear();
				rep(i, v.size()) res.push_back(v[i]);
			} else if(ans == sum) {
				cnt++;
			}
		}
		return;
	}

	REP(j, 1, s.size() + 1) {
		// cout << "i:" << i <<  " j:" << j << " sum:" << sum << " " << s.substr(i, j) << " " << stoa(s.substr(i, j)) << endl;
		if(i + j <= s.size() ) {
			vector<int> t(v.begin(), v.end());
			t.push_back(stoa(s.substr(i, j)));
			dfs(i + j, sum + stoa(s.substr(i, j)), t);
		} else return;
	}
}

int main() {
	while(cin >> n >> s) {
		if(n == 0 && s == "0") break;

		vmin = INF, vmax = 0, ans = 0, cnt = 0;
		res.clear();

		vector<int> v;
		dfs(0, 0, v);

		if(vmin > n) {
			cout << "error" << endl;
		} else if(cnt >= 2) {
			cout << "rejected" << endl; 
		} else {
			cout << ans;
			rep(i, res.size()) {
				cout << " " << res[i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; ll k; cin >> s >> k;
    set<string> st;
    for(ll i=0; i<s.size(); i++){
        for(ll j=1; j<=k; j++) st.insert(s.substr(i, j));
    }
    auto it = st.begin();
    rep(i, k-1) it++;
    cout << *it << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,m; cin >> n >> m;
	vvl G(n);
	vl indeg(n,0);
	rep(i,m){
		ll u,v; cin >> u >> v;
		G[u].push_back(v);
		indeg[v]++;
	}
	queue<ll> q;
	rep(i,n){
		if(!indeg[i]) q.push(i);
	}
	vl ans;
	while(!q.empty()){
		ll u = q.front(); q.pop();
		ans.push_back(u);
		for(auto v : G[u]){
			indeg[v]--;
			if(!indeg[v]) q.push(v);
		}
	}
	for(auto i : ans) cout << i << "\n";
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No")<<endl;
}


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

using namespace std;

int main(){
    long long n,c,k,tmp,count,current,load;
    cin >> n >> c >> k;
    vector<long long> t;
    for(int i=0;i<n;i++){
        cin >> tmp;
        t.push_back(tmp);
    }
    sort(t.begin(), t.end());
    count = 1;
    load = 1;
    current = t[0];
    for(auto itr = t.begin();itr!=t.end();itr++){
        if(itr == t.begin()){
            continue;
        }
        if(*itr <= current + k && load < c){
            load++;
            continue;
        } else {
            count++;
            current = *itr;
            load = 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1400
import sys
from heapq import heappush, heappop

readline = sys.stdin.readline


def solve():
    N = int(readline())

    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    ans = 0
    for _ in range(N):
        K, L, R = map(int, readline().split())
        if L > R:
            ans += R
            left[K - 1].append(L - R)
        else:
            ans += L
            if 0 <= N - K - 1:
                right[N - K - 1].append(R - L)

    for vec in (left, right):
        hq = []
        n = len(vec)
        for idx in range(N):
            for p in vec[idx]:
                heappush(hq, p)
            while len(hq) > min(idx + 1, n):
                heappop(hq)

        ans += sum(hq)

    return ans


def main():
    T = int(readline())

    ans = [0] * T
    for i in range(T):
        ans[i] = solve()

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 106624
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int usi[221001]; string test[210012], cou[213456], ans[213456];
signed main() {
	int n, a, b; cin >> n >> a >> b;
	if (a == b && b == n) { cout << "No" << endl; return 0; }
	if (n == a) { cout << "Yes" << endl; return 0; }
	if (n == b) { cout << "Yes" << endl; return 0; }
	if (a == b) { cout << "Yes" << endl; return 0; }
	cout << "No" << endl;
}

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

int main(){
    int N;  cin >> N;
    vector<int> D(N+1,0);
    for(int i=1; i<=N; i++)
        cin >> D[i];
    
    vector<int> used(13, 0);
    for(int i=0; i<=N; i++){
        used[D[i]]++;
    }

    if(used[0] > 1 || used[12] > 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1; i<=11; i++){
        if(used[i] > 2){
            cout << 0 << endl;
            return 0;
        }
    }

    vector<int> pos1(24), pos2(24);
    if(used[0]){
        pos1[0] = 1;
        pos2[0] = 1;
    }
    if(used[12]){
        pos1[12] = 1;
        pos2[12] = 1;
    }
    bool right = true;
    for(int i=1; i<=11; i++){
        if(used[i] == 0) continue;
        else if(used[i] == 2){
            pos1[i] = 1;
            pos1[24-i] = 1;
            pos2[i] = 1;
            pos2[24-i] = 1;
        }else {
            if(right){
                pos1[i] = 1;
                pos2[24-i] = 1;
            }else{
                pos1[24-i] = 1;
                pos2[i] = 1;
            }
            right = !right;
        }
    }

    int ans1 = 25;
    for(int i=0; i<24; i++) for(int j=i+1; j<24; j++){
        if(pos1[i] == 0 || pos1[j] == 0) continue;
        ans1 = min(ans1, min(j-i, i+24-j));
    }

    int ans2 = 25;
    for(int i=0; i<24; i++) for(int j=i+1; j<24; j++){
        if(pos2[i] == 0 || pos2[j] == 0) continue;
        ans2 = min(ans2, min(j-i, i+24-j));
    }
    cout << max(ans1, ans2) << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)

struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>

void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}

mat getRzMat(mat mt, ll m,ll n, ll ini=0){mt.assign(m,vector<ll>(n,ini));return mt;}

ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}

vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
mat mt;
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1000000007;
ll cas=0;

void solve(){
    string s;
    cin>>s;n=s.size();
    ans=0;
    F(i,n)ans+=(s[i]-'0');
    if(ans%9==0)prs("Yes");
    else prs("No");
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}



Measured memory_bytes: 3748
from collections import Counter

n,m,q = map(int,input().split())
c = [[0] * (n+1) for i in range(n+1)]
da = [[0] * (n+1) for i in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    c[l][r] += 1

da[1][1] = c[1][1]
        
for i in range(2,n+1):
    da[1][i] = da[1][i-1] + c[1][i]    
for i in range(2,n+1):
    co = 0
    for j in range(1,n+1):
        co += c[i][j]
        da[i][j] = da[i-1][j] + co
    
for i in range(q):
    pp,qq =  map(int,input().split())
    ans = 0
    ans = da[qq][qq] - da[pp-1][qq] - da[qq][pp-1] + da[pp-1][pp-1]
    
    print(ans)

Measured memory_bytes: 58584
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, D, A;
  cin>>N>>D>>A;
  vector<pair<ll, ll> > arr(N);
  ll X, H;
  for(int i=0;i<N;++i) {
    cin>>X>>H;
    arr[i] = mp(X, H);
  }
  sort(arr.begin(), arr.end());
  int l=0;
  ll befsum = 0;
  ll ans[N];
  for(int i=0;i<N;++i) ans[i] = 0;
  for(int i=0;i<N;++i) {
    X = arr[i].fi;
    H = arr[i].se;
    while(l<i) {
      if(arr[i].fi-arr[l].fi>2*D) {
        befsum -= A*ans[l];
        l++;
      }
      else break;
    }
    H -= befsum;
    if(H<=0) ans[i] = 0;
    else if(H%A==0) ans[i] = H/A;
    else ans[i] = H/A+1;
    befsum += A*ans[i];
  }
  ll ans1 = 0;
  for(int i=0;i<N;++i) {
    ans1 += ans[i];
  }
  cout<<ans1<<endl;
}



Measured memory_bytes: 7964
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
  int n,m;
  while(cin>>n>>m){
    int ans = 0;
    for(int i=0;i<n;i++){
      int sum = 0;
      for(int j=0;j<m;j++){
        int x;
        cin>>x;
        sum += x;
      }
      ans = max(ans,sum);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,R,C;
int p[200000],f[200000];
int find(int u){
	if(p[u]==u)
		return u;
	return p[u]=find(p[u]);
}
int main(){
	scanf("%d%d%d",&n,&R,&C);
	vector<vector<int> > v(n,vector<int>(3));
	for(auto &x:v){
		for(auto &y:x)
			scanf("%d",&y);
		swap(x[0],x[2]);
		swap(x[1],x[2]);
	}
	sort(v.rbegin(),v.rend());
	ll res=0;
	for(int i=0;i<R+C;++i)
		p[i]=i;
	for(auto &e:v){
		int u=e[1]-1;
		int v=e[2]-1+R;
		u=find(u);
		v=find(v);
		if(u!=v && f[u]+f[v]<2){
			res+=e[0];
			p[u]=v;
			f[v]|=f[u];
		}else if(u==v && !f[u]){
			res+=e[0];
			f[u]=true;
		}
	}
	cout<<res<<endl;
	return 0;
}

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


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b*0.5 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
bool myfunc(std::pair<int,int> i, std::pair<int,int> j){return i.first < j.first;}

int main(){
  int N,in;
  std::vector<std::pair<int,int> > A;
  std::cin >> N;
  for (int i = 1; i < N+1; i++){
    std::cin >> in;
    A.push_back(std::make_pair(in,i));
  }
  std::sort(A.begin(),A.end(),myfunc);
  for (auto&& i: A) std::cout << i.second << " ";
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;



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

	printf("%d", r * r);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(s)         s.size()
int main()
{
  string s,k,d;
  cin>>s>>k>>d;
  if(s[SZ(s)-1]==k[0]&&k[SZ(k)-1]==d[0])
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
int main(void){
  int n,a,ans;
  cin>>n>>ans;
  for(int i=0;i<n-1;i++){
    cin>>a;
    ans=gcd(max(a,ans),min(a,ans));
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() 
{
	long long n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0 ; i  < n ;  i++)
		cin >> s[i] , sort(s[i].begin(),s[i].end());
	sort(s.begin(),s.end());
	long long ans = 0 , counter = 1;
	for(int i = 1 ; i < n ; i++)
	{
		if(s[i]==s[i-1])
			counter++;
		else
			ans+=(counter*(counter-1))/2 , counter = 1;
	}
	ans+=(counter*(counter-1))/2;
	cout << ans << '\n';
}

Measured memory_bytes: 7296
import math as mt
A,B,H,W = [int(x) for x in input().split(' ')]

ha = mt.pi * 2 / 12 * H + mt.pi * 2 / 12 * (W/60)
ma = mt.pi * 2 / 60 * W
da = ha-ma

dist = mt.sqrt(A**2 + B**2 - 2*A*B*mt.cos(da))

print(dist)

Measured memory_bytes: 9444
m,d = map(int,input().split())
ans = 0
for i in range(22,d+1):
  d0 = i%10
  d1 = int(i/10)
  if d0 == 1 or d0 == 0:
    continue
  if m >= d0 * d1:
    ans += 1
    #print(i)
print(ans)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
 
int main(void)
{
  long long N;
  cin >> N;
  char S[N];

  long long r=0;
  long long g=0;
  long long b=0;
  for(int i=0;i<N;i++)
  {   
    cin >> S[i];
      if(S[i]=='R'){  r++;}   
      else if(S[i]=='G'){  g++;}      
      else if(S[i]=='B'){  b++;}
  }
//  cout << r <<" "<< g << " " << b <<endl;
  
  long long num = r*g*b;
  long long minus = 0;

  for(int i=0;i<N;i++)
  {   
    for(int j=i+1;j<N;j++)
    {   
  long long k=2*j-i;
      if(S[i] == S[j]){ continue; }
      else if(j>k-1){ continue;}
      else if(k>N-1){ continue;}
      else if(S[i] == S[k]){ continue;}
      else if(S[j] == S[k]){ continue;}
      minus++;
    }
  }
//  cout << minus <<endl;
  
  cout << num - minus;
  
  return 0; 
}


Measured memory_bytes: 3632
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H
Y = [0] * W
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = []
C = []
for h, x in enumerate(X):
    if x == maxX:
        R.append(h)
for w, y in enumerate(Y):
    if y == maxY:
        C.append(w)

if len(R) * len(C) > M:
    ans = maxX + maxY
else:
    done = set()
    for r in R:
        for c in C:
            done.add((r, c))
    for b in bomb:
        if b in done:
            done.remove(b)
    if len(done) > 0:
        ans = maxX + maxY
    else:
        ans = maxX + maxY - 1
print(ans)


Measured memory_bytes: 226440
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    let n: i64 = iter.next().unwrap().parse().unwrap();
    //let p: i64 = iter.next().unwrap().parse().unwrap();
            
    write!(out, "{}", (n - 2) * 180 );
 
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))

class UnionFind {
    vector<int> data;
public:
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){

    int N,K,L; cin>>N>>K>>L;
    UnionFind inst1(200010);
    UnionFind inst2(200010);
    REP(i,K){
        int p,q; cin>>p>>q;
        inst1.unionSet(p,q);
    }
    REP(i,L){
        int r,s; cin>>r>>s;
        inst2.unionSet(r,s);
    }
    
    map<int,vector<int> > same_g;
    for(int i=1;i<=N;i++){
        same_g[inst1.root(i)].push_back(i);
    }
    
    int ans[200010]={};
    FOREACH(i,same_g){
        vector<int> t=i->second;
        map<int,int> root;
        REP(j,t.size()){
            int r=inst2.root(t[j]);
            if(root.find(r)==root.end())root[r]=1;
            else root[r]++;
        }
        REP(j,t.size())ans[t[j]]=root[inst2.root(t[j])];
    }
    
    for(int i=1;i<N;i++){
        cout<<ans[i]<<" ";
    }
    cout<<ans[N]<<endl;
    
    return 0;
}


Measured memory_bytes: 23040
def gcd a,b
  a,b=b,a if a<b
  res = 0
  while b!=0
    res+=1
    a,b=b,a%b
  end
  [a,res]
end

loop do
  a,b=gets.chomp.split.map{|x| x.to_i }
  break if a|b==0
  puts (gcd a,b).join(' ')
end

Measured memory_bytes: 6108
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, K, S;

int dfs(int cnt, int n, int sum){
  if(cnt == K && sum == S) return 1;
  int res = 0;
  if(cnt < K && sum + n <= S) FOR(i, n, N + 1) res += dfs(cnt + 1, i + 1, sum + i);
  return res;
}

int main() {
  while(cin >>N >>K >>S && N) cout <<dfs(0, 1, 0) <<endl;
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const ll mod = 1e9+7;

ll power(ll a, ll b){
	ll result = 1;
	while(b>0){
		if(b%2){
            result *= a;
		    result %= mod;
        }
        a*=a;
        a%=mod;
		b/=2;
	}
	return result;
}

// 10^n possible strings, 9^n sequences with no 0 and 9^n sequence with no 9,
// and 8^n sequenec with no 0 or 9 (double count)
void solve(){
    ll n; cin >> n;
    ll p10 = power(10,n);
    ll p9 = power(9,n);
    ll p8 = power(8,n);
    p8%=mod,p9%=mod,p10%=mod;
    ll ans = p10%mod - (2*p9)%mod + p8%mod;
    cout << (ans+mod)%mod;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
bool sosu(int q);
int mem[10005]={0};
main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    int q;
    for(q=n-((n+1)%2);q-2>1;q-=2){
      if(sosu(q)&&sosu(q-2)){
	cout<<q-2<<" "<<q<<endl;
	break;
      }
    }
  }
}
bool sosu(int q){
  if(mem[q]==1){
    return 1;
  }
  else if(mem[q]==-1){
    return 0;
  }
  else{
    for(int i=3;i<=sqrt(q);i+=2){
      if(mem[i]==0||mem[i]==1){
	for(int j=i;j<=q;j+=i){
	  mem[j]=0;
	  if(j==q){
	    return 0;
	  }
	}
      }
    }
    if(mem[q]==0){
      mem[q]=1;
      return 1;
    }
  }
}

Measured memory_bytes: 1204
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力(スペース改行関係なし)
		String a = sc.next();

		if(Character.isUpperCase( a.charAt( 0 ) )){
			// 出力
        	System.out.println("A");
		}else{
			System.out.println("a");
		}
		
	}
}

Measured memory_bytes: 35656
import sys

def solve(N,M,E):
    def dfs(v, visited = set()):
        nonlocal cnt
        if len(visited) + 1 == N:
            cnt += 1
        for u in E[v]:
            if not u in visited:
                dfs(u, visited | {v})

    stack = [1]
    cnt = 0
    dfs(1)
    print(cnt)

def main():
    N, M = map(int, input().split())
    E = [ set() for _ in range(N+1) ]
    for _ in range(M):
        a, b = map(int, input().split())
        E[a].add(b)
        E[b].add(a)
    solve(N,M,E)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;string s;cin>>n>>s;
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }else{
    for(int i=0;i<n/2;++i){
      if(s[i]!=s[n/2+i]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

void swap(int *,int *);

int main(){
	int n,a[100],c=0,minj;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
			}
		}
		swap(&a[i],&a[minj]);
		if(i!=minj)c++;
	}



	for(int i=0;i<n;i++){
		cout << a[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
	cout << c << endl;
	return 0;
}

void swap(int *a,int *b){
	int w;
	w= *a;
	*a=*b;
	*b=w;
}

Measured memory_bytes: 1164
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int a, b;
		cin >> a >> b;
		cout << max(0, a-b*2);
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    speed;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
        cout << "Yes";
    else
        cout << "No";
    ed;
    return 0;
}

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

int main()
{
	int a, b, c;
	int count = 0;

	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c % i == 0) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
    int h,w;
    
    while (cin >> h >> w && h!=0 && w!=0){
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j!=0 && j!=w-1 && i!=0 && i!=h-1) cout << ".";
                else cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main()
{
	int i,j,k=0,n;
	cin>>n;
	int a[n],x[n],y[n];
	for(i=0;i<n;i++)
	{
		j=0;
		cin>>a[i]>>x[i]>>y[i];
		j+=x[i];
		j+=y[i];
		//cout<<j<<" "<<a[i]<<endl;
		if((a[i]-j)%2!=0||j>a[i])
		{
			k=1;
		}
	}	
	if(k==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl; 
	return 0;
} 

Measured memory_bytes: 1408
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long LL;
const LL N = 1e6 + 10;
LL a[N];
LL n, m;

int main() {
	cin >> n >> m;
	LL s = 0;
	for (LL i = 0; i < m; i++) {
		cin >> a[i];
		s += a[i];
	}

	if (s > n)
		puts("-1");
	else
		cout << n - s << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	ll x[5],ans=0;
	f(i,0,5){
		cin >> x[i];
		if(x[i]==0){
			ans=i+1;
		}
	}

	cout <<ans;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int N, M; cin >> N >> M;
  Graph G(M, vi(3));
  rep(i,M) rep(j,2) cin >> G[i][j];
  rep(i,M) G[i][2] = i;

  sort(all(G));

  Graph ans(M, vi(2));

  int pref = 0;
  int idx = 0;
  rep(i,M) {
    if (G[i][0] != pref) {
      pref = G[i][0];
      idx = 0;
    }
    ans[G[i][2]][0] = pref;
    ans[G[i][2]][1] = ++idx;
  }

  rep(i,M) {
    rep(j,2) {
      cout << setfill('0') << right << setw(6) << ans[i][j];
    }
    cout << "\n";
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;

const int INF = 1e9;
typedef long long ll;

int main(void){
  double lat1, lat2, lng1, lng2;
  const double r = 6378.1, pi = 3.1415926535;
  while(cin >> lat1 >> lng1 >> lat2 >> lng2 && lat1 != -1 && lng1 != -1 && lat2 != -1 && lng2 != -1){
    double x1, y1, z1, x2, y2, z2;
    double len1, len2, theta;
    x1 = r * cos(lat1 * pi / 180) * cos(lng1 * pi / 180);
    x2 = r * cos(lat2 * pi / 180) * cos(lng2 * pi / 180);
    y1 = r * cos(lat1 * pi / 180) * sin(lng1 * pi / 180);
    y2 = r * cos(lat2 * pi / 180) * sin(lng2 * pi / 180);
    z1 = r * sin(lat1 * pi / 180);
    z2 = r * sin(lat2 * pi / 180);
    len1 = sqrt(x1 * x1 + y1 * y1 + z1 * z1);
    len2 = sqrt(x2 * x2 + y2 * y2 + z2 * z2);
    theta = acos((x1 * x2 + y1 * y2 + z1 * z2) / (len1 * len2));
    cout << int(r * theta + 0.5)<< endl;
  }
  return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define mod 1000000007
#define pi 3.14159265358979
#define float double
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
int main()
{
    fastio;
    ll i,j,k,n,m,t;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()>k)
    {
        cout<<s.substr(0,k);
        cout<<"...";
        cout<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); i < (end); i++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; i >= (end); i--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  if (a % 2) {
    ans ^= a;
    a++;
  }
  if (b % 2 == 0) {
    ans ^= b;
    b--;
  }

  if ((b - a + 1) % 4) {
    ans ^= 1;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
template<typename Elem>
Elem min(Elem a,Elem b){
	return a<b?a:b;
}
template<typename Elem>
void read(Elem &a){
	a=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		a=(a<<1)+(a<<3)+(c^48);
		c=getchar();
	}
}
//const long long One=1;
const __int128 One=1;
template<typename Elem>
Elem quick_power(Elem a,Elem b,Elem Mod){
	Elem ans=1;
	while(b){
		if(b&1){
			ans=One*ans*a%Mod;
		}
		b>>=1;
		a=One*a*a%Mod;
	}
	return ans;
}
const int Maxn=100;
typedef long long ll;
const ll Inf=0x3f3f3f3f3f3f3f3fll;
ll s;
ll p[Maxn+5],q[Maxn+5];
int len;
void work(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			p[++len]=1;
			q[len]=i;
			while(n%i==0){
				n/=i;
				p[len]*=i;
			}
		}
	}
	if(n>1){
		p[++len]=n;
		q[len]=n;
	}
}
int main(){
	scanf("%lld",&s);
	ll ans=Inf;
	if(s&1){
		ans=s;
	}
	else{
		ans=s-1;
	}
	work(s<<1);
	for(int i=0;i<(1<<len);i++){
		ll p_1=1,p_2=1,phi_p=1;
		for(int j=1;j<=len;j++){
			if((i>>(j-1))&1){
				p_1*=p[j];
			}
			else{
				p_2*=p[j];
				phi_p*=p[j]/q[j]*(q[j]-1);
			}
		}
		if(p_2==1){
			continue;
		}
		ll k=One*(p_2-1)*quick_power(p_1,phi_p-1,p_2)%p_2;
		ans=min(ans,k*p_1);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    string s;
    cin>>s;
    f(i,s.length()){
        if(i%2 && s[i] == 'R'){cout<<"No";return ;}
        if(i%2 == 0 && s[i] == 'L'){cout<<"No";return ;}
    }
    cout<<"Yes";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}

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

int main()
{
  int n , a;
  cin >> n >> a;
  n = n % 500;
  //cout << a << endl;
  if(n <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 1e6 + 10;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  vector<int> cnt(N);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  for (int i = 1; i < N; ++i) {
    if (!cnt[i]) continue;
    for (int j = i + i; j < N; j += i) {
      cnt[j]++;
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret += cnt[a[i]] == 1;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 7612
#include <iostream>
#include <string>
#include <typeinfo>

int main() {
  int r, g, b;
  std::cin >> r >> g >> b;
  std::cout << (!(std::stoi(std::to_string(g) + std::to_string(b)) % 4) ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256
import math
ls = [int(input()) for _ in range(5)]
ans = 0
num = []

for i in ls:
    ans += math.ceil(i/10)*10
    if str(i)[-1] != '0':
        num.append(str(i)[-1])

if num:
    print(ans-10+min([int(i) for i in num]))
else:
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int r,d,x2;
	cin >> r >> d >> x2;
	int x[20] = {r*x2-d};
	cout << x[0] << endl;
	for(int i = 1; i <= 9; i++){
		x[i] = r*x[i-1]-d;
		cout << x[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }
    else {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
C = input()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
           , 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i, a in enumerate(alphabet):
  if C == a:
    print(alphabet[i + 1])
    exit()

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX1 100000
#define MAX 500000
#define INFTY 1000000001

typedef struct pp{
    char mark;
    int num;
}list;

void quicksort(list *,int,int);
int partition(list *,int,int);
void merge(list *,int ,int ,int );
void mergeSort(list *,int ,int );
void swap(list *,int,int);

int main()
{
    int a,flag=0;
    int i;
    list A[MAX1],B[MAX1];

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%s%d",&A[i].mark,&A[i].num);
        B[i]=A[i];
    }

    quicksort(A,0,a-1);
    mergeSort(B,0,a);

    for(i=0;i<a;i++)
    {
      if(A[i].mark==B[i].mark){ }
      else { flag=1; break; } 
    }

    if(flag==1) printf("Not stable\n");
    else printf("Stable\n");

    for(i=0;i<a;i++)
    {
    printf("%s %d\n",&A[i].mark,A[i].num);
    }

    return 0;
}

void quicksort(list *A,int p,int r)
{
    int q;
    if(p<r)
    {
        q=partition(A,p,r);
        quicksort(A,p,q-1);
        quicksort(A,q+1,r);
    }
}

int partition(list *A,int p,int r)
{
    list x,temp;
    int i,j;

    x=A[r];
    i=p-1; //i=-1
    for(j=p;j<=r-1;j++) //j=0
    {
        if(A[j].num<=x.num)
        {
            i=i+1;
            swap(A,i,j); //A[i]とA[j]を交換
        }
    }
    swap(A,i+1,r); //A[i+1]とA[r]を交換
    return i+1; //pivotの添え字を返す
}

void swap(list *A,int i,int j)
{
    list temp;
    temp=A[i];
    A[i]=A[j];
    A[j]=temp;
    return;
}

void mergeSort(list *array,int left,int right)
{
    int mid;

    if(left+1<right)
    {
        mid = (left+right)/2;
        mergeSort(array,left,mid);
        mergeSort(array,mid,right);
        merge(array,left,mid,right);
    }
    return;
}

void merge(list *array,int left,int mid,int right)
{
    int n1,n2;
    int i,j,k;
    static list L[MAX/2+2],R[MAX/2+2];   //LとRの配列を保存しておくためにstatic変数を使う

    n1 = mid-left;
    n2 = right-mid;

    for(i=0;i<n1;i++) L[i] = array[left+i];
    for(i=0;i<n2;i++) R[i] = array[mid+i];
    i=j=0;

    L[n1].num=R[n2].num=INFTY;          //最大の値を入れる事によって必ず配列に入れた値を比較しマージできる
    for(k=left;k<right;k++)
    {
        if(L[i].num<=R[j].num)
        {
            array[k]=L[i]; i++;
        }
        else
        {
            array[k]=R[j]; j++;
        }
    }
    return;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll arr[n];
	ll sum =0;
	ll hash[100005]={0};
	for(i=0;i<n;i++)
		{
			cin>>arr[i];
			sum += arr[i];
			hash[arr[i]]++;
		}
	ll q;
	cin>>q;
	ll a,b;
	vector<ll>ans;
	//cout<<sum<<endl;
	for(i=0;i<q;i++)
	{
		cin>>a>>b;

		sum = sum + (b-a)*hash[a];
		hash[b] += hash[a];
		hash[a]= 0;
		ans.pb(sum);
	}
	for(i=0;i<q;i++)
	{
		cout<<ans[i]<<endl;
	}
	
	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 5816
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	r := getInt()

	if r < 1200 {
		fmt.Println("ABC")
	} else if r < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int T;scanf("%d",&T),T;){
		int t[30];
		rep(i,T)	scanf("%d",t+i);
		int n;	scanf("%d",&n);
		int sche[100];
		rep(i,100)	sche[i]=INF;
		{
			int d,m;
			rep(i,n){
				scanf("%d%d",&d,&m);
				sche[d-1]=min(sche[d-1],m);
			}
		}

		int dp[100][30];
		rep(j,T)	dp[0][j]=(j==0?0:INF);
		for(int i=1;i<100;i++){
			dp[i][0]=dp[i-1][T-1];
			rep(j,T-1)	dp[i][0]=min(dp[i][0],dp[i-1][j]+1);
			for(int j=1;j<T;j++){
				if(sche[i]<t[j])	dp[i][j]=INF;
				else				dp[i][j]=dp[i-1][j-1];
			}
		}

		int ans=INF;
		rep(j,T)	ans=min(ans,dp[99][j]);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
list_s = []
list_e = []

for i in range(M):
	a, b = map(int, input().split())
	list_s.append(a)
	list_e.append(b)

res = min(list_e) -  max(list_s) + 1
if res < 0:
	res = 0
print(res)

Measured memory_bytes: 10984