akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ARainySeason {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int ret = 0;
      int now = 0;
      rep(i, 3) {
        if (s[i] == 'R') {
          now++;
        } else {
          now = 0;
        }
        chmax(ret, now);
      }
      cout << ret << endl;
    }
};

signed main() {
  ARainySeason solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n;
    int x;
    int t;
    cin >> n >> x >> t;
    int times = 0;
  	int result = 0;
    if(n % x == 0){
        times = n / x;
    }
    else{
        times = n / x + 1;
    }
    result = times * t;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3604
# ABC166 C

def main():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))
    
    towers = []
    for _ in range(n):
        towers.append([])
    
    good_tower_count = 0

    for _ in range(m):
        a, b = map(int, input().split())
        #print(a, b)
        towers[a-1].append(b-1)
        towers[b-1].append(a-1)
        #print(towers)
    
    # for each of the towers
    for i in range(n):
        good_flags = []

        # check if the tower is taller than the neighbour towers
        for j in range(len(towers[i])):
            if H[i] > H[towers[i][j]]:
                good_flags.append(True)
            else:
                good_flags.append(False)
        
        if (False not in good_flags) or len(towers[i]) == 0:
            good_tower_count += 1
            #print(i)
    
    print(good_tower_count)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 29956
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Node {
	char ch;
	bool used = false;
	vector<int> nexts, sames, others;
	unordered_set<int> sameSet;
};

Node nodes[200010];

bool dfs(int now, unordered_set<int> &visited) {
	if (visited.count(now)) return true;
	visited.insert(now);
	for (int same : nodes[now].sames) {
		for (int other : nodes[same].others) {
			if (nodes[other].used) continue;
			if (dfs(other, visited)) return true;
		}
	}
	visited.erase(now);
	nodes[now].used = true;
	return false;
}

signed main() {
	int N, M;
	cin >> N >> M;

	string S;
	cin >> S;

	rep(i, N) nodes[i].ch = S[i];

	rep(i, M) {
		int a, b;
		scanf("%lld %lld", &a, &b);
		a--; b--;
		nodes[a].nexts.push_back(b);
		nodes[b].nexts.push_back(a);
	}

	rep(i, N) {
		for (int next : nodes[i].nexts) {
			if (nodes[next].ch == nodes[i].ch) nodes[i].sames.push_back(next);
			else nodes[i].others.push_back(next);
		}
		nodes[i].sameSet.insert(all(nodes[i].sames));
	}
	 
	rep(i, N) {
		unordered_set<int> visited;
		if (dfs(i, visited)) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 58536
n,a,b = map(int,input().split())
sum = 0

for i in range(1, n + 1):
    tmp = i
    x = 0
    for j in range(5)[::-1]:
        x += tmp // (10**j)
        tmp = tmp - (tmp // (10**j))*(10**j)
        
    if a <= x <= b:
        sum += i
        
print(sum)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
bool check(char s[]) {
	int len=strlen(s+1);
	if(s[1]!='A') return 0;
	int cnt=0;
	for(int i=1;i<=len;i++)
		if(s[i]!='A'&&s[i]!='C')
			if(s[i]>='A'&&s[i]<='Z') return 0;
	for(int i=3;i<len;i++)
		if(s[i]=='C') cnt++;
	return (cnt==1)?1:0;
}
int main() {
	int t; scanf("%d",&t);
	t=1;
	while(t--) {	
		char s[10];
		scanf("%s",s+1);
		if(check(s)) puts("AC");
		else puts("WA");
	}
}

Measured memory_bytes: 128
import java.util.*;
public class Main 
{
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26304
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

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

    ll aa[n];
    ll s=0;
    for(ll i=0; i<n; i++)
    {
        cin>>aa[i];
        s+=aa[i];
    }
    if(n<=a)
        cout<<"0"<<endl;
    else
    {
        sort(aa,aa+n);
        ll p=0;
        for(ll i=0; i<a; i++)
        {
            p+=(aa[n-i-1]);
        }
        cout<<s-p<<endl;
    }
}
/* pray for me
All is well
*/


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


int main(){
int n;
cin >> n;
vector <int> enemy(n+1);
vector<int> fighter(n);

rep(i,n+1)cin>>enemy.at(i);
rep(i,n)cin >>fighter.at(i);
ll answer =0;
for(int i =0;i<n;i++){
    int left = min(enemy.at(i),fighter.at(i));
    answer +=left;
    enemy.at(i)-=left;
    fighter.at(i) -= left;
    int right = min(enemy.at(i+1),fighter.at(i));
    answer += right;
    enemy.at(i+1) -= right;
    fighter.at(i)-=right;
}
cout << answer<<endl;
}

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

int main() {
    int s;
    cin >> s;
    vector<int> v = {s};

    for(int i=2;;i++) {
        if(s % 2 == 0) {
            s /= 2;
        }
        else if(s % 2 == 1) {
            s = s*3 + 1;
        }

        auto result = find(v.begin(), v.end(), s);
        if(result != v.end()) {
            cout << i << endl;
            return 0;
        }
        v.push_back(s);
    }
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

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

int main(){

  
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   ll n,a,b;
   cin>>n>>a>>b;
   if(n*a<=b){
    cout<<n*a;
   }
   else
    cout<<b;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final int t = scanner.nextInt();

        for (int i = 0; i < t; i++) {
            final int n = scanner.nextInt();
            int up = 0;
            int down = 0;
            int previous = scanner.nextInt();
            for (int j = 0; j < n - 1; j++) {
                int current = scanner.nextInt();
                up = Math.max(up, current - previous);
                down = Math.max(down, previous - current);
                previous = current;
            }
            System.out.println(up + " " + down);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int N, M, an = 0;
	int K[31], A[31][31];
	int count[31];
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++) {
		count[i] = 0;
	}
	for (int i = 1; i <= N; i++) {
		scanf("%d", &K[i]);
		for (int j = 1; j <= K[i]; j++) {
			scanf("%d", &A[i][j]);
			count[A[i][j]]++;
		}
	}
	for (int i = 1; i <= M; i++) {
		if (count[i] == N) {
			an++;
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
ll dp[M],seg[4*M];
vector<pair<int,ll>> st[M];
void build(ll i,ll s,ll e)
{
	seg[i] = 1e18;
	if(s==e)
	{
		if(s==1)
			seg[i]=0;
		return;
	}
	ll m=(s+e)/2;
	build(2*i,s,m);
	build(2*i+1,m+1,e);
}
void update(ll i,ll s,ll e,ll l,ll r,ll x)
{
	if(s>r || l>e)
		return;
	if(s>=l && e<=r)
	{
		seg[i]=min(seg[i],x);
		return;
	}
	ll m=(s+e)/2;
	update(2*i,s,m,l,r,x);
	update(2*i+1,m+1,e,l,r,x);
}
ll query(ll i,ll s,ll e,ll x)
{
	if(s==e)
		return seg[i];
	ll m=(s+e)/2;
	if(x<=m)
		return min(seg[i],query(2*i,s,m,x));
	else
		return min(seg[i],query(2*i+1,m+1,e,x));
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int l,r;ll c;
		cin>>l>>r>>c;
		st[l].pb({r,c});
	}
	build(1,1,n);
	for(ll i=1;i<n;i++)
	{
		ll z=query(1,1,n,i);
		if(z==1e18)
			continue;
		for(auto u:st[i])
		{
			update(1,1,n,i+1,u.ff,z+u.ss);
		}
	}
	ll z=query(1,1,n,n);
	if(z==1e18)
		cout<<"-1\n";
	else
		cout<<z<<"\n";
	return 0;
}

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

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
		if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}
typedef pair<LL, LL> pii;

pii a[1123456];
int main() {
	LL n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) scanf("%lld", &a[i].X), a[i].Y = 0;
	for(int i = n + 1; i <= n + m; i ++) scanf("%lld", &a[i].X), a[i].Y = 1;
	sort(a + 1, a + 1 + n + m);
	LL c[2];
	c[0] = m + 1;
	c[1] = n + 1;
	LL ans = 0;
	for(int i = 1; i <= n + m; i ++) {
		ans += a[i].X * c[a[i].Y];
		c[a[i].Y ^ 1] --;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	int n;
	ll a[300][300];

	cin >> n;
	REP(i, n){
		REP(j, n){
			cin >> a[i][j];
		}
	}

	REP(k, n){
		REP(i, n){
			REP(j, n){
				if(a[i][j] > a[i][k] + a[k][j]){
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}

	REP(k, n){
		REP(i, n){
			REP(j, n){
				if(a[i][j] > 0 && a[i][k] > 0 && a[k][j] && a[i][j] == a[i][k] + a[k][j]){
					a[i][j] = 0;
				}
			}
		}
	}

	ll sum = 0;
	REP(i, n){
		REP(j, n){
			sum += a[i][j];
		}
	}

	cout << sum / 2 << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
void solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> adj(n);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u;--v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    queue<int> tochk;
    vector<int> sign(n, -1);
    sign[0]=0;
    int size=1;
    tochk.push(0);
    while(!tochk.empty()){
        int u=tochk.front();
        for(const auto &node : adj[u]){
            if(sign[node]==-1){
                sign[node]=u;
                tochk.push(node);
                ++size;
            }
        }
        tochk.pop();
    }
    if(size!=n){
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";
    for(int i=1;i<n;i++){
        cout<<sign[i]+1<<"\n";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 10092
#include<bits/stdc++.h>
using namespace std;
long long a[200000],b[200000];
int main()
{
	long long n,m,k;
	cin>>n>>m>>k;
	long long s = 0;
	std::vector<long long> sum1,sum2;
	for (long long i = 0; i < n; ++i)
	{
		cin>>a[i];
		s+= a[i];
		sum1.push_back(s);
	}
	s = 0;
	long long ans = 0;
	for (long long i = 0; i < m; ++i)
	{
		cin>>b[i];
		s+= b[i];
		sum2.push_back(s);
		if(s<=k)
			ans = i+1;
	}
	// printf("ans is %lld\n",ans );
	for (long long i = 0; i < n; ++i)
	{
		if(sum1[i]<=k)
		{
			// printf("%lld %lld\n",i,sum1[i] );
			long long w = i+1;
			auto it = upper_bound(sum2.begin(),sum2.end(),k-sum1[i]);
			long long ind = it - sum2.begin();
			ans = max(ans,w+ind);
		}
	}
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 10528
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 0;
	if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") ans = 1;
	if (S == "RRS" || S == "SRR") ans = 2;
	else if (S == "RRR") ans = 3;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s,t;
  cin >> s >> t;
  reverse(all(t));
  bool f=true;
  rep(i,3){
      if (s[i]!=t[i]) f=false;
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=0;
  bool flag=false;
  while(!(a==b && b==c)){
    ll aa,bb,cc;
    aa=b+c;
    bb=a+c;
    cc=a+b;
    if(aa%2!=0||bb%2!=0||cc%2!=0){
      flag=true;
      break;
    }
    a=aa/2; b=bb/2; c=cc/2;
    ans++;
  }
  if(flag){
    cout<<ans<<endl;
  }else{
    if(a%2==0){
      cout<<-1<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int a,b;
  cin >> a >>b;
  if(a<=8 && b<=8){cout << "Yay!" << endl;}else{cout << ":(" << endl;}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}


// crossing point 
// verified: AOJ CGL_2_C
P cross(L a,L b){
	R u=det(a.s,b.s,b.t)/det(O,a.t-a.s,b.t-b.s);
	return (1-u)*a.s+u*a.t;
}

// Polygon

// area 
// verified: AOJ 1100 CGL_3_A
R area(const VP& pol){
	int n=pol.size();
	R sum=0.0;
	rep(i,n) sum+=det(O,pol[i],pol[(i+1)%n]);
	return abs(sum/2.0L);
}


// convex_cut 
// verified: AOJ CGL_4_C
VP convex_cut(const VP& pol,const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i],b=pol[(i+1)%n];
		int da=sdet(l.s,l.t,a),db=sdet(l.s,l.t,b);
		if(da>=0) res.emplace_back(a);
		if(da*db<0) res.emplace_back(cross({a,b},l));
	}
	return res;
}

int main(void){
	int n,q;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	cin >> q;
	cout.precision(20);
	rep(i,q){
		P a,b;
		cin >> a >> b;
		L l={a,b};
		cout << fixed <<  area(convex_cut(pol,l)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3232
N,M = map(int,input().split())

maxl = 1
minr = N
for i in range(0,M):
  l,r = map(int,input().split())
  if l > maxl:
    maxl = l
  if r < minr:
    minr = r
if minr-maxl+1 < 0:
  print(0)
else:
  print(minr-maxl+1)
#print(maxl,minr)

Measured memory_bytes: 3060
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll lg=14;
const ll N=1e5+5;
const ll INF=1e9;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%lld",&n)
#define longp(n) printf("%lld\n",n)

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

ll n,k,a[N],dp[N];

int main()
{
  ll n;
  cin>>n>>k;
  for(ll i=1;i<=n;i++){cin>>a[i];dp[i]=INF;}
  dp[1]=0;
  for(ll i=1;i<=n;i++)
  {
    for(ll j=i+1;j<i+1+k;j++){dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));}
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
# Skill Up
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

costs = []

for i in range(1 << n): #全パターン
    cost = 0
    total = [0] * m #値段とm冊の本についてのリスト
    for j in range(n):
        if (i>>j) & 1 == 1 : #iをjだけ右にシフト。j冊目を買う場合
            cost += ca[j][0]
            for k in range(m):
                total[k] += ca[j][k+1]
    if all(total[l] >= x for l in range(m)):
        costs.append(cost)

if len(costs) == 0:
    print(-1)
else:
    print(min(costs))

Measured memory_bytes: 9232
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<string> s;
	int n = next<int>();
	while(n--) s.insert(next<string>());
	cout<<s.size()<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 19228
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n, k;
int a[100000 + 5];
int sum[100000 + 5], ps[100000 + 5];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		if (a[i] >= 0) ps[i] += a[i];
		sum[i] += a[i];
		ps[i + 1] += ps[i];
		sum[i + 1] += sum[i];
	}
	int ans = -INFLL;
	rep(i, n - k + 1) {
		int p = sum[i + k - 1] - sum[i] + a[i];
		int gr = ps[n] - (ps[i + k - 1] - ps[i] + max(a[i], 0LL));
		ans = max(ans, max(0LL, p) + gr);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int H, W, K;
	cin >> H >> W >> K;

	string S[10];
	rep(i, H) cin >> S[i];

	int saidai = 1 << (H - 1);

	int kotae = 1e9; ce(saidai);

	rep(p, saidai) {
		int kazu[10] = {};

		int ret = __builtin_popcount(p);
		int OK = 1;

		rep(i, W) {

			int tmp[10] = {};
			int k = 0;
			rep(j, H) {
				tmp[k] += (S[j][i] == '1');
				if (tmp[k] > K) OK = 0;
				if (p >> j & 1) k++;
			}
			bool waru = 0;
			rep(j, k + 1) {
				kazu[j] += tmp[j];
				if (kazu[j] > K) {
					waru = 1;
				}
			}
			if (waru) {
				ret++;
				rep(j, k + 1) {
					kazu[j] = tmp[j];
				}
			}
		}
		if (OK) chmin(kotae, ret);



	}

	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input())-1])

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  ll ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    ans += (a.at(i) % 1000000007) * (n - 1);
    ans %= 1000000007;
  }
  
  map<ll, ll> mp;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 60; j++){
      if((a.at(i) >> j) & 1){
        //cout << i << " " << j << endl;
        ans += 1000000007;
        ans -= (2 * mp[j] * ((ll) pow(2, j) % 1000000007)) % 1000000007;
        //cout << mp[j] * ((ll) pow(2, j) % 1000000007) << endl;
        mp[j]++;
        ans %= 1000000007;
        //for(int i = 0; i < 5; i++) cout << i << " " << mp[i] << endl;
      }
      
    }//cout << ans << endl;
  }
  
  ans %= 1000000007;
  cout << ans << "\n";
}

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

typedef complex<double> C;

const double EPS = 1e-9;

int solve(int N, vector<double>& x, vector<double>& y) {
    vector<C> point(N);

    for (int j = 0; j < N; ++j) {
        point[j] = C(x[j], y[j]);
    }

    int ret = 1;

    for (int j = 0; j < N; ++j) {
        for (int k = j+1; k < N; ++k) {
            C mid = (point[j] + point[k]) * 0.5;

            C normal = (point[j] - point[k]) * C(0, 1);
            normal /= abs(point[j] - point[k]);

            double a = sqrt(1 - norm(mid - point[j]));

            C centre1 = mid + a * normal;
            int count = 0;
            for (int l = 0; l < N; ++l) {
                if (abs(centre1 - point[l]) < 1.0+EPS) {
                    ++count;
                }
            }
            ret = max(ret, count);

            C centre2 = mid - a * normal;
            count = 0;
            for (int l = 0; l < N; ++l) {
                if (abs(centre2 - point[l]) < 1.0+EPS) {
                    ++count;
                }
            }
            ret = max(ret, count);

        }
    }

    return ret;
}

int main () {
    int N;
    vector<double> x, y;

    while (true) {
        cin >> N;
        if (N == 0) break;

        x.resize(N);
        y.resize(N);

        for (int j = 0; j < N; ++j) {
            cin >> x[j] >> y[j];
        }

        cout << solve(N, x, y) << endl;
    }

    return 0;
}

Measured memory_bytes: 1296
#include <algorithm>
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
  size_t N;
  cin >> N;

  unordered_set<size_t> s;
  for (size_t i = 0; i < N; i++) {
    size_t a;
    cin >> a;
    if (s.find(a) != s.end()) {
      cout << "NO" << endl;
      return 0;
    }
    s.emplace(a);
  }

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


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

int main(void){
    int n,q,time=0;
    cin>>n>>q;
    queue<pair<string,int>> que;
    string s;
    int x;
    for(int i=0;i<n;i++){
        cin>>s>>x;
        que.push(make_pair(s,x));
    }
    while(!que.empty()){
        s=que.front().first;
        x=que.front().second;
        if(x>q){
            time+=q;
            x-=q;
            que.pop();
            que.push(make_pair(s,x));
        }else{
            time+=x;
            que.pop();
            cout<<s<<" "<<time<<endl;
        }
    }
}


Measured memory_bytes: 6356
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
int64_t N;

int64_t search(int64_t n, bool seven, bool five, bool three) {
  if(n > N) {
    return 0;
  }
  
  int ret0 = search(n*10 + 7, true, five, three);
  int ret1 = search(n*10 + 5, seven, true, three);
  int ret2 = search(n*10 + 3, seven, five, true);
  int ret3 = 0;
  if(seven && five && three)
    ret3 = 1;
  return ret0 + ret1 + ret2 + ret3;
}

int main(void) {
  scanf("%ld", &N);
  printf("%ld\n", search(0, false, false, false));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


vector<vector<P> > g;

bool has_positive_cycle(int target,int pos,vector<int> flag,int cost){
	flag[pos]++;
	for (int i = 0; i < g[pos].size(); i++){
		int x = g[pos][i].first;
		if(x==target){
			return cost+g[pos][i].second>0;
		}
		if(flag[x]<0){
			return has_positive_cycle(target,x,flag,cost+g[pos][i].second);
		}
	}
	return false;
}

bool go_target(int target,int pos,vector<int> flag){
	flag[pos]++;
	for (int i = 0; i < g[pos].size(); i++){
		int x = g[pos][i].first;
		if(x==target){
			return true;
		}
		if(flag[x]<0){
			return go_target(target,x,flag);
		}
	}
	return false;
}




int main()
{
	int n,m,p;
	cin>>n>>m>>p;
	g.resize(n);
	for (int i = 0; i < m; i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		c = c-p;
		g[a].push_back(P(b,c));
	}

	// for (int i = 1; i < n-1; i++){
	// 	vector<int> flag1(n,-1),flag2(n,-1);
	// 	if(!go_target(i,0,flag1) || !go_target(i,n-1,flag2)){
	// 		for (int j = 0; j < g[i].size(); j++){
	// 			g[i][j].second= 0;
	// 		}
	// 	}
	// }

	// for (int i = 0; i < n; i++){
	// 	vector<int> flag(n,-1);
	// 	if(has_positive_cycle(i,i,flag,0)){
	// 		cout<<-1<<endl;
	// 		return 0;
	// 	}
	// }

	for (int i = 0; i < n; i++){
		for (int j = 0; j < g[i].size(); j++){
			g[i][j].second *= -1;
		}
	}
	int ret = 1e9;
	vector<int> dist(n,1e9);
	dist[0] = 0;
	vector<bool> update(n,false);
	for(int k = 0;k < n*2;k++){
		for(int i = 0;i < n; i++)update[i] = false;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < g[i].size(); j++){
				int to = g[i][j].first;
				int cost = g[i][j].second;
				if(dist[i]!=1e9 && dist[to] > dist[i] + cost){
					dist[to] = dist[i] + cost;
					if(k>=n) update[to] = true;
				}
			}
			// if(update){
			// 	// cout<<dist[n-1]<<endl;
			// 	if(k>=n && dist[n-1]<ret){
			// 		cout<<-1<<endl;
			// 		return 0;
			// 	}
			// 	ret = dist[n-1];
			// 	// break;
			// }
		}
		if(k>=n){
			for (int i = 0; i < n; i++){
				if(update[i]){
					for (int j = 0; j < g[i].size(); j++){
						update[g[i][j].first] = true;
					}
				}
			}
			if(update[n-1]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}

	cout<<max(0,-1*dist[n-1]) << endl;


	return 0;
}


Measured memory_bytes: 384
/* In the name of Allah */

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define LL_INF 1LL << 62
#define INF 1 << 30
#define SetBit(x, k) (x |= (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define CheckBit(x, k) (x & (1LL << k))
#define mod 1000000007

int n, k;
ll x[100005];
ll dp[100005];

ll solve(int pos){
  if(pos>=n-1) return 0;
  if(dp[pos]!=-1) return dp[pos];

  ll res = LL_INF;
  for(int i = 1; i <= k; i++)
    if(pos+i<n)
      res = min(res, abs(x[pos+i]-x[pos])+solve(pos+i));
  
  return dp[pos] = res;
}

int main()
{
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> x[i];

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

  return 0;
}

Measured memory_bytes: 12900
n,m=map(int,input().split())
A=list(map(int,input().split()))

dp=[-1]*(n+1)
dp[0]=0

info=[0,2,5,5,4,5,6,3,7,6]

for i in range(n+1):
  for a in A:
    if i+info[a]<n+1:
      dp[i+info[a]]=max(dp[i+info[a]],dp[i]*10+a)

print(dp[n])    

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

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

    int n;
    cin >> n;
    string s = "";
    while(n != 0){
        if(n % 2 != 0){
            n--;
            s += "1";
        }else{
            s += "0";
        }
        n /= -2;
    }
    if(s == "") s = "0";

    reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	// 200000
	// 20,000,000,000
	N := readInt()

	table := map[int]map[int]int{}
	for n := 1; n <= N; n++ {
		top, bottom := topAndBottom(n)
		if bottom == 0 {
			continue
		}

		if bottomMap, ok := table[top]; ok {
			bottomMap[bottom]++
		} else {
			table[top] = map[int]int{bottom: 1}
		}
	}

	//fmt.Println(table)

	var count int
	for n := 1; n <= N; n++ {
		top, bottom := topAndBottom(n)
		if bottom == 0 {
			continue
		}
		count += table[bottom][top]
	}

	fmt.Println(count)
}

func topAndBottom(n int) (int, int) {
	bottom := n % 10
	var top int
	if n < 10 {
		top = n
	} else if n < 100 {
		top = n / 10
	} else if n < 1000 {
		top = n / 100
	} else if n < 10000 {
		top = n / 1000
	} else if n < 100000 {
		top = n / 10000
	} else {
		top = n / 100000
	}
	return top, bottom
}


Measured memory_bytes: 640
#include<cstdio>
#include<map>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
map<int,int> id;
const int MAXN=100000;
int a[MAXN+5],b[MAXN+5];
int n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
		id[b[i]]=i;
	for(int i=1;i<=n;i++)
	{
		int f1=0,f2=0;
		if(i%2!=0)
			f1=1;
		if(id[a[i]]%2!=0)
			f2=1;
		if(f1!=f2)
			ans++;
	}
	printf("%d\n",ans/2);
	return 0;
}


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

int a[110];

void solve()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	int ans = 1e9;
	for (int i = 1; i <= 100; i++)
	{
		int cur = 0;
		for (int j = 1; j <= n; j++)
		{
			cur += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, cur);
	}

	cout << ans;
}

int main()
{
	//freopen("Testin.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))

    amax = max(a)
    amax_arg = a.index(amax)
    amin = min(a)
    amin_arg = a.index(amin)

    output = []

    if abs(amax) >= abs(amin):
        for i in range(N):
            a[i] += amax
            output.append([amax_arg+1, i+1])
        for i in range(N-1):
            a[i+1] += a[i]
            output.append([i+1, i+2])
    else:
        for i in range(N):
            a[i] += amin
            output.append([amin_arg+1, i+1])
        for i in range(N-1):
            a[-i-2] += a[i-1]
            output.append([N-i, N-i-1])

    print(len(output))
    for i in range(len(output)):
        print(str(output[i][0])+" "+str(output[i][1]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
from math import gcd
from collections import Counter
def printYes():
    print("YES")
def printNo():
    print("NO")

t = int(input())
ans=0
for i in range(1,t+1):
    for j in range(1,t+1):
        r=gcd(i,j)
        for s in range(1,t+1):
            ans=ans+gcd(r,s)
print(ans)



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

using namespace std;

int main()
{
	int nA, nB;
	int A[5000], B[5001];
	
	scanf("%d %d", &nA, &nB);
	
	for (int i = 0; i < nA; i++) scanf("%d", A + i);
	for (int i = 0; i < nB; i++) scanf("%d", B + i);
	B[nB] = -1;
	
	int res = 0;
	for (int st = 0; st < nB; st++){
		int idx = st;
		for (int i = 0; i < nA; i++){
			if (A[i] == B[idx]) idx++;
		}
		res = max(res, idx - st);
	}
	
	printf("%d\n", res);
	
	return (0);
}

Measured memory_bytes: 1064
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

S = read_str()

def solve():
    ans = ''
    for i in range(len(S)):
        ans += 'x'
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3760
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;

  cin >> N;

  switch (N % 10) {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;

  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;

  case 3:
    cout << "bon" << endl;
    break;
  }


  return 0;
}

Measured memory_bytes: 3588
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc165_f
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000


const int nax = 200005;
vector<vector<int>> g(nax);
vector<int> a(nax), rs(nax), dp(nax, INF);
int n;


void dfs(int v, int p) {
    int idx = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
    int prev = dp[idx];
    dp[idx] = a[v];
    rs[v] = idx+1;
    for(int u: g[v]) {
        if(u==p) continue;
        dfs(u, v);
    }
    dp[idx] = prev;
}

void dfs2(int v, int p) {
    for(int u: g[v]) {
        if(u==p) continue;
        rs[u] = max(rs[u], rs[v]);
        dfs2(u, v);
    }
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i=0; i<n-1; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    dfs(1, -1);
    dfs2(1, -1);
    for(int i=1; i<=n; i++) {
        printf("%d\n", rs[i]);
    }
    // printf("\n");
}


Measured memory_bytes: 27924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#include <functional>

using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n, m);
    map<int, int> c;
    Rep(n){
        Cin(int, a, b);
        c[a] += b;
    }
    ll ans = 0;
    for(auto e : c){
        if(m == 0) break;
        ll k = min(m, e.second);
        ans += k * e.first;
        m -= k;
    }
    Cout(ans);
}


Measured memory_bytes: 4992
#define IO std::ios::sync_with_stdio(false);
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k;
ll gcd(ll x,ll y){
	return x%y==0?y:gcd(y,x%y);
}
int main(){
	IO;
	cin>>n;
	ll x,y;
	cin>>x;
	for(int i=1;i<n;i++){
		cin>>y;
		x=gcd(x,y);
	}
	cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    map<char,ll> m;
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,n){
        m[s.at(i)]++;
    }
    ll ans=1;
    for (auto itr=m.begin();itr!=m.end();itr++){
        ans=(ans*(itr->second+1))%MOD;
    }
    cout << ans-1 << endl;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,m,k,a,memo[30],ans;

main() {
    cin >> n >> m;
    rep(i,n) {
        cin >> k;
        rep(j,k) {
            cin >> a;
            memo[a-1]++;
        }
    }
    rep(i,m) if (memo[i] == n) ans++;
    ct(ans)
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int x[10], y[10];

double dist(int i, int j) {
	int dx = x[i] - x[j];
	int dy = y[i] - y[j];
	return pow(dx*dx + dy*dy, 0.5);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];

	vector<int> v;
	int factorial = 1;
	for (int i = 1; i <= n; i++) {
		v.pb(i);
		factorial *= i;
	}

	double ans = 0;
	do {
		double d = 0;
		for (int i = 0; i < n-1; i++) {
			d += dist(v[i], v[i+1]);
		}
		d /= factorial;
		ans += d;
	} while (next_permutation(ALL(v)));

	printf("%8lf", ans);
    return 0;
}


Measured memory_bytes: 256