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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

int main() {
    ll n;
    cin >> n;
    vector<queue<ll>> g(n);
    map<P, ll> graph;

    rep(i, n-1) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        graph[P(a,b)] = c;
        graph[P(b,a)] = c;
        g[a].push(b);
        g[b].push(a);
    }

    vector<ll> d(n, INF);
    ll q, k; cin >> q >> k;
    k--;
    d[k] = 0;
    queue<ll> que;
    que.push(k);
    while(!que.empty()) {
        ll t = que.front();
        que.pop();
        while(!g[t].empty()) {
            ll nx = g[t].front();
            g[t].pop();
            if(d[nx] == INF) {
                que.push(nx);
                d[nx] = d[t]+graph[P(t,nx)];
            }
        }
    }
    rep(i, q) {
        ll x, y; cin >> x >> y;
        x--; y--;
        cout << d[x]+d[y] << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 84528
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b, c;
            cin >> a >> b >> c;
                if(a == b && b == c){
                    cout << 1;
                        return 0;
                }else if(a == b || a == c || b == c){
                    cout << 2;
                        return 0;
                }else{
                    cout << 3;
                        return 0;
                }
    return 0;}

Measured memory_bytes: 256
#include <stdio.h>

#define ARC(i,a,b) for(int i=(a);i<(b);++i)
#define ARCH(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RC(i,n) ARC(i,0,n)
#define RCH(i,n) ARCH(i,n,0)
#define SRC(i,s) for(Int i=0;(s)[i];++i)
#define ATH(a,b) ((a)>(b)?(a):(b))
#define OTH(a,b) ((a)<(b)?(a):(b))
#define ANTH(a,b) {if((a)<(b))(a)=(b);}
#define ONTH(a,b) {if((a)>(b))(a)=(b);}
#define ACH printf
#define ECH scanf
#define AC putchar
#define EC getchar
#define _ AC('\n');

int main() {
	int n;
	int a[120], b[120], as = 0, bs = 0, ans = 0;
	ECH("%d", &n);
	RC(i, n) ECH("%d", a + i);
	RC(i, n) ECH("%d", b + i);
	RC(i, n) bs += b[i];
	RC(i, n){
		as += a[i];
		ANTH(ans, as + bs);
		bs -= b[i];
	}
	ACH("%d\n", ans);
}

Measured memory_bytes: 128
#include <cstdio>

int k, n;
int a[200005];
int max=0;

inline void cmp(int x) {
	max=(x>max)?x:max;
}

int main() {
	scanf("%d%d", &k, &n);
	for(int i=0; i<n; i++) {
		scanf("%d", a+i);
	}
	for(int i=0;i<n;i++) {
		int distance;
		if(i==0) {
			distance=a[0]+(k-a[n-1]);
		} else {
			distance=a[i]-a[i-1];
		}
		cmp(distance);
	}
	printf("%d", k-max);
}

Measured memory_bytes: 896
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    double a[n];
    for(int i = 0; i < n; i++){
        scanf("%lf",&a[i]);
    }
    double ans = 0;
    for(int l = 0; l < n; l++){
        ans += (double)(1/a[l]);
        fprintf(stderr,"%lf\n",ans);
    }
    printf("%lf\n",1/ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define int long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,k,ans=-Inf;
int a[5010],b[5010];
int mxc[5010];
int vis[5010];
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1,j,cur,sc;i<=n;i++){
		cur=i,sc=0;
		memset(vis,0,sizeof vis);
		for(j=1;j<=k&&j<=n+3;j++){
			if(vis[cur]){j--;break;}
			sc+=b[cur];
			vis[cur]=1;
			cur=a[cur];
//			cout<<ans<<endl;
			ans=max(ans,sc);
		}
		if(sc<=0)continue;
		if(j!=k+1){
			int rem=k-k/j*j;
			if(rem==0)rem=j,sc*=(k/j-1);
			else sc*=(k/j);
			cur=i;
//			cout<<i<<' '<<j<<' '<<rem<<endl;
			ans=max(ans,sc);
			for(j=1;j<=rem;j++){
				sc+=b[cur];
				cur=a[cur];
//				cout<<ans<<endl;
				ans=max(ans,sc);
			}
		}
//		cout<<ans<<endl;
//		cout<<i<<' '<<j<<' '<<k/j<<endl;
//		ans=max(ans,sc*(k/j));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


	
	int ans = 0;
	int n;
	cin >> n;

	string s;
	s = to_string(n);
	map<pair<char, char>, int>deep;

	for(int i = 1; i <= n; i++){
		if(i % 10 == 0) continue;
		string r = to_string(i);
		deep[{r[0], r[r.length() - 1]}]++;
	}



	for(int i = 1; i <= n; i++){
		if(i % 10 == 0) continue;
		string r = to_string(i);
		//cout << i << ' ' << deep[{r[r.length() - 1], r[0]}] << endl;
		ans += deep[{r[r.length() - 1], r[0]}];
	}

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

Measured memory_bytes: 256
a,b,x=map(int,input().split())
s=x/a
import math
if s<=(a*b/2):
  ans=math.degrees(math.atan(b**2/(2*s)))
else:
  s_=a*b-s
  ans=math.degrees(math.atan(2*s_/a**2))
print(ans)

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

int main() {
  int64_t n;
  cin >> n;
  
  int64_t num = 0, ans = 1000000000001;
  for(int i=1; i<=sqrt(n); i++) {
    if(n%i==0) num = (i-1)+(n/i-1);
    ans = min(num, ans);
  }
  
  cout << ans << endl;
  return 0;
}

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

class Polygon : IEquatable<Polygon>
{
    public Polygon(int p1, int p2, int p3)
    {
        this.p1 = p1;
        this.p2 = p2;
        this.p3 = p3;
    }

    public int p1 { get; set; }
    public int p2 { get; set; }
    public int p3 { get; set; }

    public bool Equals(Polygon other)
    {
        return this.p1 == other.p1 && this.p2 == other.p2 && this.p3 == other.p3;
    }
}

class Program
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var h = new List<Polygon>();
        for (int i = 0; i < N; i++)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).OrderBy(_ => _).ToArray();
            var p = new Polygon(input[0], input[1], input[2]);
            if (!h.Contains(p))
            {
                h.Add(p);
            }
        }
        Console.WriteLine(N - h.Count);
    }
}


Measured memory_bytes: 18308
use std::collections::*;

// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = read();
    let mut hashmap = HashMap::new();
    let mut combination_count: u64 = 0;

    for _ in 0..n as usize
    {
        let si: String = read();
        let mut si_chars: Vec<char> = si.chars().collect();
        si_chars.sort();
        let sorted_si: String = si_chars.into_iter().collect();

        // 初出のキーであればハッシュマップに挿入する
        let count = hashmap.entry(String::from(sorted_si)).or_insert(0);
        if *count > 0 {
            combination_count += *count;
            *count += 1;
        }

        if *count == 0 { *count = 1; }
    }

    println!("{}", combination_count);
}


Measured memory_bytes: 15420
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))


def runLength(in_str):
    kukan = 1
    start = 0
    ret = []
    for i in range(1,len(in_str)):
        if in_str[i-1]!=in_str[i]:
            ret.append([in_str[i-1],kukan,start])
            start = i
            kukan=0
        kukan+=1
    ret.append([in_str[-1],kukan,start])
    return ret

N, K = ints_raw()
S = input()
cts = []
ctree = {}

def main():
    global cts
    ans = 0
    kukan = 1
    start = 0
    if S[0]=="0":
        cts.append(["1",0,0])
    cts += runLength(S)
    if S[-1]=="0":
        cts.append(["1",0, N-1])
    if K*2+1 >= len(cts):
        return N
    buf = sum([cts[i][1] for i in range(K*2+1)])
    ans = buf
    for i in range(K*2+1,len(cts)):
        n_buf = buf-cts[i-(K*2+1)][1]+cts[i][1]
        if cts[i][0]=="1":
            ans =max(ans,n_buf)
        buf = n_buf
    return ans

print(main())



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

template <typename T> void max_self(T& a,T b){
  a = max(a,b);
}
bool first_row_or_column(pair<int,int> p){
    return p.first == 0|| p.second == 0;
}
const int INF = 1e9+ 5;
int main(){
  string a, b;
  cin>>a>>b;
  vector<vector<pair<int,pair<int,int>>>> dp(a.length()+1,vector<pair<int,pair<int,int>>>(b.length()+1,{-INF,{0,0}}));
  dp[0][0] = {0,{0,0}};
  for(int i=0;i<(int)a.length();++i){
      for(int j=0;j<(int)b.length();++j){
          if(a[i]==b[j]){
              max_self(dp[i+1][j+1],make_pair(dp[i][j].first+1,make_pair(i,j)));
          }
          max_self(dp[i+1][j],make_pair(dp[i][j].first,make_pair(i,j)));
          max_self(dp[i][j+1],make_pair(dp[i][j].first,make_pair(i,j)));
      }
  }
  pair<int,pair<int,int>> answer = {0,{0,0}};
  for(int i=0;i<=(int)a.length();i++){
      for(int j=0; j<=(int)b.length();j++){
          max_self(answer, make_pair(dp[i][j].first,make_pair(i,j)));
      }
  }
//   for(int i=0;i<=(int)a.length();i++){
//       for(int j=0; j<=(int)b.length();j++){
//           cout<<dp[i][j].first<<" ";
//       }
//       cout<<endl;
//   }
  string s = "";
  pair<int,int> cur = answer.second;
  while(!first_row_or_column(cur)){
      int i = cur.first;
      int j = cur.second;
      pair<int,int> prev = dp[i][j].second;
      if(prev == make_pair(i-1,j-1)){
          assert(a[i-1]==b[j-1]);
          s+= a[i-1];
      }
      cur = prev;
  }
  reverse(s.begin(),s.end());
  cout<<s;
}


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

int sum(int a, int b, vector<int>ashiq)
{
    int sum = 0;
    for(int i = a; i< b; i++)
    {
        sum += ashiq[i];
    }
    return sum;
}

int main()
{
    int a;
    cin >> a;
    vector<int>ashiq;
    int amk = a;
    while(amk--)
    {
        int b;
        cin >> b;
        ashiq.push_back(b);
    }
    int mn = 9999999;
    for(int i = 1; i < a; i++)
    {
        int def = abs(sum(0, i,ashiq)- sum(i, a,ashiq));
       //cout << "i is " << i << " and  " << def << endl;
        mn = min(mn, def);
    }
    cout << mn << endl;
}

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


int mygcd(vector<int> v, int n){
  
}

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

 // for(int n = 0; n< n;n++){
  	vector<int> Ls(N+1,0);
    vector<int> Rs(N+1,0);
    int L = 0;
    int R = 0;
    
    for(int i =1; i <N;i++){
       //0-i-1までのgcd L
       Ls.at(i) = __gcd(Ls.at(i-1),A.at(i-1));    
       //i+1 - Nまでのgcd R
       Rs.at(N-i-1) = __gcd(Rs.at(N-i),A.at(N-i));
      
    }
//  }
  int max = 0;
  for(int i =0;i < N;i++){
    int ans = __gcd(Ls.at(i),Rs.at(i));
    if(ans > max)  max = ans;
  }
  
  cout << max;
  
  return 0;
}


Measured memory_bytes: 1408
X, N = map(int, input().split())
if N != 0:
    P = [int(i) for i in input().split()]
else:
    P = []
m = float("inf")
ans = 0
l = set(range(-1000, 1001)) - set(P)
for p in sorted(l):
    d = abs(p-X)

    if d < m:
        m = d
        ans = p

print(ans)


Measured memory_bytes: 9208
#include<iostream>
#include<numeric>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std ; 


int main() {
  
  vector<int> vec(3) ; cin >> vec[0] >> vec[1] >> vec[2] ; 
  int k ; cin >> k ; int p = 1<<k;
  int m = *max_element(vec.begin(),vec.end()) * p ;
  
  
  int sum = accumulate(vec.begin(),vec.end(),0) - *max_element(vec.begin(),vec.end()) + m;
  cout << sum ; 


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
int main(void){
  int N,M;
  cin >> N >> M;
  vi P(M);
  vi Y(M);
  rep(i,M){
      cin >> P[i] >> Y[i];
      --P[i];
  }

  vvi vals(N);
  rep(i,M) vals[P[i]].push_back(Y[i]);
  //県ごとの情報を集めてる
  //vals[0] = [32,12],vals[1] = [63]

  rep(v,N){
      //vals[0]を例とすると
        sort(vals[v].begin(),vals[v].end());//[12,32]
        vals[v].erase(unique(vals[v].begin(),vals[v].end()),vals[v].end());
  }

  rep(i,M){
      int v = P[i];//1つ目の市、p[0]=1県、Y[0]=32の時
      printf("%06d",v+1);//Pは--してたので
      
      //ここでvals[v]で県の情報をとってくる
      int id = lower_bound(vals[v].begin(),vals[v].end(),Y[i])-vals[v].begin();
      printf("%06d\n",id+1);//lowerboundは境界の満たさない側の値なので+1
  }

}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> v[],int vis[],int p,int ct){
    if(!vis[p]){
        vis[p]=ct;
        for(auto it=v[p].begin();it!=v[p].end();it++){
            dfs(v,vis,*it,ct);
        }
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v[n+1];
    int vis[n+1]={0};
    while(m--){
      int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ct=1;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(v,vis,i,ct);
            ct++;
        }
    }
    map<int ,int>mp;
    for(int i=1;i<=n;i++){
        mp[vis[i]]++;
    }
    int temp=-1;
    for(auto it=mp.begin();it!=mp.end();it++){
    temp=max(temp,it->second);
    }
    cout<<temp;

}

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

int main(int argc, char *argv[]) {
	int menu[4], sum, min = 9, minpoint = 0;
	
	for(int i = 0; i < 5; i++){
		cin >> menu[i];
		if(menu[i]%10 < min && menu[i]% 10 != 0){
			min = menu[i]%10;
			minpoint = i;
		}
	}
	
	for(int i = 0; i < 5; i++){
		if(menu[i] % 10 != 0 && i != minpoint){
			menu[i] = menu[i] + (10 - menu[i] % 10);
		}
		sum += menu[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Saurav Paul 
 *    created       : August 06, 2020 10:36 PM
 *    Problem Name  : B - Frog 2
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_b
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int n , k ;
    cin >> n >> k ;

    const int INF = 1e9 + 90 ;
    vector<int> v(n) , dp(n,INF) ;

    for(auto &x : v) cin >> x;

    dp[0] = 0 ;
    for(int i = 1 ; i < n; i++){
        for(int j = 1 ; j <= k ; j++){
            if(i - j >= 0)
                dp[i] = min(dp[i] , dp[i-j] + abs(v[i]-v[i-j])) ;
        }
    }

    cout << dp[n-1] << endl ;

    return 0 ;
}


Measured memory_bytes: 4004
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

num = [[a,0],[b,1],[c,2],[d,3],[e,4]]
index = 0
f = 10
for n,i in num:
    if n%10==0:
        continue
    if f > n%10:
        index = i
        f = n%10

sm = 0
for n,i in num:
    if index == i:
        sm += num[i][0]
    elif n%10==0:
        sm += num[i][0]
    else:
        sm += num[i][0] + (10 - num[i][0]%10)
print(sm)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<pair<int, int>> itv(M);
  rep (i, M) {
    int a, b;
    cin >> a >> b;
    pair<int, int> p(b, a);
    itv[i] = p;
  }
  
  sort(itv.begin(), itv.end());
  
  int start = 0;
  int res = 0;
  for (int i = 0; i < M; i++) {
    if (itv[i].second >= start) {
      res ++;
      start = itv[i].first;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  string ans="Yes";
  if(A!=B&&B!=C&&A!=C)ans="No";
  if(A==B&&B==C)ans="No";
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(void)
{
 
  ll a, b, r, x, tmp;
 

  cin >> a >> b;
 
  x = a * b;
 

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  
  cout << x/b << endl;

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

int main(void) {
    int n;
    int i;
    double sum;
    vector<int> x, y;
    
    //Read input
    cin >> n;
    
    for(i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    
    for(i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        y.push_back(tmp);
    }
    
//    //Test display
//    for(int i=0; i<n; i++) {
//        cout << x[i] << " ";
//    }
//    cout << endl;
//    for(i=0; i<n; i++) {
//        cout << y[i] << " ";
//    }
//    cout << endl;
    
    //Calc. p=1
    sum = 0;
    for(i=0; i<n; i++) {
        sum += abs(x[i]-y[i]);
    }
    cout << fixed << setprecision(6) << sum << endl;
    
    //Calc. p=2
    sum = 0;
    for(i=0; i<n; i++) {
        sum += pow( x[i]-y[i], 2);
    }
    sum = sqrt(sum);
    cout << fixed << setprecision(6) << sum << endl;
    
    //Calc. p=3
    sum = 0;
    for(i=0; i<n; i++) {
        sum += pow(abs(x[i]-y[i]), 3);
    }
    sum = pow( sum, 1.0/3.0);
    cout << fixed << setprecision(6) << sum << endl;
    
    //Calc. p=INF
    sum = 0;
    for(i=0; i<n; i++) {
        double tmp = abs(x[i]-y[i]);
        if(sum < tmp)
            sum = tmp;
    }
    cout << fixed << setprecision(6) << sum << endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3344
module mod_priority_queue
  implicit none
  type t_priority_queue
    private
    integer :: num = 0 !中に入ってる物の数
    integer, pointer :: heap(:) => null()!pqの容量
  contains
    procedure :: offer => offer
    procedure :: clear => clear
    procedure :: poll => poll
    procedure :: peek => peek
    procedure :: size => size_of
  end type t_priority_queue
  
contains
 
  subroutine offer(pq,item)
    class(t_priority_queue), intent(inout) :: pq
    integer, intent(in) :: item
    integer :: n, i, t
    integer, allocatable :: tmp(:)
    if (.not.associated(pq%heap)) allocate(pq%heap(1))
    
    !いっぱいいっぱいのときには拡張している
    if (pq%num == size(pq%heap)) then
      allocate(tmp(pq%num))
      tmp = pq%heap
      deallocate(pq%heap)
      allocate(pq%heap(2*pq%num))
      pq%heap(1:pq%num) = tmp
      deallocate(tmp)
    end if
    
    pq%num = pq%num+1
    pq%heap(pq%num) = item
    n = pq%num
    do while (n > 1)
      i = n/2
      if (pq%heap(n) > pq%heap(i)) then
        t = pq%heap(n)
        pq%heap(n) = pq%heap(i)
        pq%heap(i) = t
      end if
      n = i
    end do
    return
  end subroutine offer
  
  subroutine clear(pq)
    class(t_priority_queue), intent(inout) :: pq
    if (associated(pq%heap)) deallocate(pq%heap)
    pq%num = 0
    return
  end subroutine clear
 
  function poll(pq) result(item)
    class(t_priority_queue), intent(inout) :: pq
    integer :: item, n, i, j, tmp
    n = pq%num
    item = pq%heap(1)
    pq%heap(1) = pq%heap(n)
    pq%num = pq%num-1
    i = 1
    do while (2*i < n)
      j = 2*i
      if (j+1 < n .and. pq%heap(j+1) > pq%heap(j)) j = j+1
      if (pq%heap(j) > pq%heap(i)) then
        tmp = pq%heap(j)
        pq%heap(j) = pq%heap(i)
        pq%heap(i) = tmp
      end if
      i = j
    end do
  end function poll
  
  function peek(pq) result(item)
    class(t_priority_queue), intent(inout) :: pq
    integer :: item
    item = pq%heap(1)
  end function peek
  
  integer function size_of(pq)
    class(t_priority_queue), intent(in) :: pq
    size_of = pq%num
  end function size_of
end module mod_priority_queue
 
use mod_priority_queue
integer N,M
integer,allocatable,dimension(:)::A
type(t_priority_queue) :: pq
integer(16) ans
integer tmp

read*,N,M
allocate(A(N))
read*,A
do i=1,N
  call offer(pq,A(i))
end do
do i=1,M
  tmp=poll(pq)
  tmp=tmp/2
  call offer(pq,tmp)
end do

ans=0
do i=1,N
  ans=ans+poll(pq)
end do
print"(i0)",ans
end

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 3001
#define int ll
int R,C,K,val[maxn][maxn];
int dp[maxn][maxn][4];

int dpf(int i,int j,int k){
	if (i == R + 1 || j == C + 1) return 0;
	if (dp[i][j][k] != -1) return dp[i][j][k];
	
	dp[i][j][k] = 0;
	
	dp[i][j][k] = max({dp[i][j][k], dpf(i + 1, j, 0), dpf(i, j+1,k)});
	if (k != 3) dp[i][j][k] = max({dp[i][j][k], dpf(i + 1, j, 0) + val[i][j], dpf(i,j+1,k+1) + val[i][j]});
	return dp[i][j][k];

}
int32_t main(){
	fast;
	
	cin>>R>>C>>K;
	
	
	FOR(i,0,K-1){
		int r,c,v;
		cin>>r>>c>>v; val[r][c] = v;
	}
	mem(dp,-1);
	
	cout<<dpf(1,1,0);
	
}



Measured memory_bytes: 355812
S = gets.chomp

N = S.length
# 回文判定
if S != S.reverse
  puts 'No'
  exit
end

# 回文判定2
s2 = S[0...((N-1)/2)]

if s2 != s2.reverse
  puts 'No'
  exit
end

# 回文判定3
s3 = S[(((N+3)/2)-1)...N]
if s3 != s3.reverse 
  puts 'No'
  exit
end

puts 'Yes'


Measured memory_bytes: 1788
clist1 = []
dlist1 = []
while 1:
    try:
        c, d = map(int, input().split(","))
    except:
        break

    clist1.append(c)
    dlist1.append(d)

clist2 = []
dlist2 = []
while 1:
    try:
        c, d = map(int, input().split(","))
    except:
        break

    clist2.append(c)
    dlist2.append(d)

clist1_unique = list(set(clist1))
clist1_unique.sort()

for c in clist1_unique:
    if c in clist2:
        count = clist1.count(c) + clist2.count(c)
        print(c, count)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
long long int h,n;
long long int f[2000005];
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	f[0]=0;	
	for(int i=1;i<=2000000;i++){
		f[i]=0x7ffffffffffffff;
	}
	cin>>h>>n;
	long long int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(int j=1;j<=n;j++){
		for(int i=a[j];i<=20000;i++){
			f[i]=min(f[i-a[j]]+b[j],f[i]);
		}
	}
	long long int minv=0x7ffffffffffffff;
	for(int i=h;i<=20000;i++){
		if(f[i]<minv){
			minv=f[i];
		}
	}
	cout<<minv;
    return 0;
}


Measured memory_bytes: 15872
A, B, K = map(int, input().split())
x = 0
i = 0
ans = [0] * 100
while i < max(A, B, 100):
    i += 1
    if ((A % i) == 0) and ((B % i) == 0):
        ans[x] = i
        x += 1
print(ans[x - K])

Measured memory_bytes: 3060
#include <iostream>
#include <string>

typedef long long ll;

using namespace std;

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

int main() {
	int n,m;
	string s,t;
	cin >> n >> m >> s >> t;
	int kyoyaku = gcd(n,m);
	ll kobai = (ll)n / (ll)kyoyaku * (ll)m;
	for(int i = 0; i < kyoyaku; i++) {
		if(s[(n/kyoyaku)*i]!=t[(m/kyoyaku)*i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << kobai << endl;
	return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

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

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int a, b, n;

    cin >> a >> b >> n;

    int ans = 0;
    int x = n / b;
    x *= b;
    --x;
    // debug(x);
    int v1 = ((a * x) / b) - (a * (x / b));
    if (x < 0)
      v1 = 0;
    int v2 = ((a * n) / b) - (a * (n / b));

    cout << max(v1, v2) << endl;
  }
}

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

using namespace std;

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    int i = 0;
    while (1) {
        int start = 1 + i;
        int end = m + 1 - i;
        if (start >= end)
            break;
        cout << start << ' ' << end << endl;
        i++;
    }
    i = 0;
    while (1) {
        int start = m + 2 + i;
        int end = 2 * m + 1 - i;
        if (start >= end)
            break;
        cout << start << ' ' << end << endl;
        i++;
    }
    return 0;
}


Measured memory_bytes: 3592
h,w =map(int, input().split())
a =['#'*(w+2)] + ['#'+input()+'#' for i in range(h)]+['#'*(w+2)]
ans=0
for ii in range(h):
    for jj in range(w):
        if a[ii+1][jj+1]=='#':
            continue
        count=1
        n=[(ii+1,jj+1)]
        route={n[0]:0}
        p=[[1,0],[0,1],[-1,0],[0,-1]]
        while count != 1000:
            route2 = route.copy()
            n2=[]
            for i in n:
                for j in p:
                    np=(i[0]+j[0],i[1]+j[1])
                    if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                        n2.append(np)
                        route[np]=count
            n=n2
            count+=1
            if route == route2:
                break
        ans=max(ans,max(route.values()))
        #print(ans, route)
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,x,r;
      cin>>n>>x>>r;
      if(r<0){
            r=-r;
            x=-x;
      }
      if(r==0){
        	if(x==0)cout<<1;
        	else
            cout<<n+1;
            return 0;
      }
      vector<int>arr(n+1,0);
      for(int i=2;i<=n;i++){
            arr[i]=i-1;
      }
      for(int i=2;i<=n;i++)arr[i]+=arr[i-1];
      map<int,map<int,int>>data;
      for(int i=0;i<=n;i++){
            int M=x*i%r;
            int L=arr[i];
            int R=arr[n]-arr[n-i];
            if(data[M].count(x*i+L*r))
            data[M][x*i+L*r]=max(x*i+R*r,data[M][x*i+L*r]);
            else data[M][x*i+L*r]=x*i+R*r;
      }
      int ans=0;
      for(map<int,map<int,int>>::iterator it=data.begin();it!=data.end();it++){
            map<int,int>::iterator itr=it->second.begin();
            while(itr!=it->second.end()){
                  int R=itr->second;
                  int L=itr->first;
                  while(itr!=it->second.end()&&R>=itr->first){
                        R=max(itr->second,R);
                        itr++;
                  }
                  ans+=(R-L)/r+1;
            }
      }
      cout<<ans;
}



Measured memory_bytes: 33024
class Heap
  attr_reader :size
  def initialize
    @heap = []
    @size = 0
  end
  def sum
    x = 0
    @size.times do |i|
      x += @heap[i]
    end
    x
  end
  def push(n)
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    top
  end
end

gets
a = gets.split.map(&:to_i)
h = Heap.new
a.each do |x|
  h.push(-x)
end
while h.size > 1
  u = h.pop
  v = h.pop
  h.push(u + 1) if u + 1 < 0
  h.push(v + 1) if v + 1 < 0
end
p (h.pop + 1).abs

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate nPm
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, a; cin >> n >> a;
    int m = 0;
    vector<int> x(n);
    rep(i, n) {cin >> x[i]; chmax(m, x[i]); x[i]-=a; }
    int nx = n*m;
    vector<vector<ll>> dp(n+1, vector<ll>(2*nx+1));
    dp[0][nx] = 1;
    rep(i, n) rep(j, 2*nx) {
        if (0<=j+x[i] && j+x[i]<2*nx)
            dp[i+1][j] = dp[i][j] + dp[i][j+x[i]];
        else
            dp[i+1][j] = dp[i][j];
        // else dp[i+1][j] = 0;
    }
    cout << dp[n][nx]-1 << endl;
    return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, d, x = sc.nextInt()
    val as = List.fill(n)(sc.nextInt())

    var ans = x
    as.foreach(a => {
      for (i <- 0 to d) {
        if (1 + i * a <= d) ans += 1
      }
    })

    println(ans)
  }
}


Measured memory_bytes: 27304
#include <bits/stdc++.h>
using namespace std;
#define abs(a) ((a) > 0 ? (a) : -(a))

int dp[100000];
int h[100000];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k; cin >> n >> k;
    cin >> h[0];
    dp[0] = 0;

    for (int i = 1; i < n; i++){
        cin >> h[i];
        dp[i] = 1e9;
        //cout << endl << i << endl;
        for (int a = 1; a <= k; a++){
            if (i-a < 0) break;
            //cout << i - a << ' ' << dp[i-a] << ' ' << h[i-a] << ' ';
            dp[i] = min(dp[i], dp[i-a] + abs(h[i-a]-h[i]) );
        }
        //cout << dp[i] << ' ';
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        int[] bs = new int[n - 1];
        bs[0] = s.nextInt();
        
        int sum = bs[0];
        
        for (int i = 1; i < n - 1; i ++) {
            bs[i] = s.nextInt();
            if (bs[i] > bs[i - 1])
                sum += bs[i - 1];
            else
                sum += bs[i];
        }
        
        sum += bs[n - 2];
        
        System.out.println(sum);

	}

}

Measured memory_bytes: 21972
N, M = map(int, input().split())
D = [[0]*(N+1) for i in range(M)]
cnts = [0]*M
for i in range(N):
    v = int(input())
    cnts[v-1] += 1
    D[v-1][i+1] = 1
for i in range(M):
    d = D[i]
    for j in range(1, N+1):
        d[j] += d[j-1]
memo = [None]*(2**M)
memo[2**M-1] = 0
def dfs(state, idx):
    if memo[state] is not None:
        return memo[state]
    res = N
    for i in range(M):
        if state & (1 << i) == 0:
            need = cnts[i] - (D[i][cnts[i] + idx] - D[i][idx])
            res = min(res, need + dfs(state | (1 << i), idx + cnts[i]))
    memo[state] = res
    return res
print(dfs(0, 0))

Measured memory_bytes: 122932
# coding: utf-8
# Your code here!
count= 1
ans = 0
N = int(input())
for i in range(1,N+1):
    for k in range(1,i+1,2):
        if i % k ==0:
            count+=1
    #print(i,count)
    if count == 8:
        ans+=1
    count=0
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i < (int)(n); i++)
typedef long long ll;
#define NP next_permutation
#define MP make_pair

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  ll n;
  cin >> n;
  vector<ll> a(5);
  rep(i, 5) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = (n + a[0] - 1) / a[0] + 4;
  cout << ans << endl;
}




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

int main() {

    string S;
    cin >> S;

    int ans_a = 0;
    for (int i=0; i<S.length(); i++) {
        if (i%2 == 0) {
            if (S[i] == '0') {
                ans_a++;
            }
        }
        else {
            if (S[i] == '1') {
                ans_a++;
            }
        }
    }

    if (S.length() - ans_a > ans_a) {
        cout << ans_a << endl;
    }
    else {
        cout << S.length() - ans_a << endl;
    }

    return 0;
}


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

int main() {
  int N,a,b=0;
  int count=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a >> b;
    count = count + b - a + 1;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

struct E {
    int s, e;
    int v;
};

int l;
int a[20];
int po[20];
vector<E> e;

int main() {
    po[0] = 1;
    for (int i = 1; i < 20; i++) po[i] = po[i-1]*3;
    cin >> l;
    l--;
    int now = 1;
    int p = 0;
    while (now*3 <= l+1) {
        E ed;
        ed.s = p+1; ed.e = p;
        ed.v = 0;
        e.push_back(ed);
        ed.v += po[p];
        e.push_back(ed);
        ed.v += po[p];
        e.push_back(ed);
        now *= 3;
        p++;
    }
    if (now == l+1) {
        cout << p+1 << " " << e.size() << endl;
        rep(i,e.size()) {
            cout << p+1-e[i].s << " " << p+1-e[i].e << " " << e[i].v << endl;
        }
        return 0;
    }
    int x = po[p]-1;
    {
        E ed;
        ed.s = p+1; ed.e = p;
        ed.v = 0;
        e.push_back(ed);
        p++;
    }
    int sum = po[p-1];
    for (int i = p-1; i >= 0; i--) {
        while (x+po[i] <= l) {
            E ed;
            ed.s = p; ed.e = i;
            ed.v = sum;
            e.push_back(ed);
            x += po[i];
            sum += po[i];
        }
    }
    cout << p+1 << " " << e.size() << endl;
    rep(i,e.size()) {
        cout << p+1-e[i].s << " " << p+1-e[i].e << " " << e[i].v << endl;
    }
}



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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> path;
	path = vector<vector<int>>(n, vector<int>(n, 0));

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		path[a][b]++;
		path[b][a]++;
	}

	vector<int> v;
	for (int i = 0; i < n; i++) {
		v.push_back(i);
	}

	int cnt = 0;

	do {
		for (int i = 0; i < n-1; i++) {
			if (!path[v[i]][v[i + 1]])
				break;
			if (i == n - 2) {
				cnt++;
			}
		}
	} while (next_permutation(v.begin(), v.end()) && v[0] == 0);

	cout << cnt << endl;

}

Measured memory_bytes: 256
s = str(input())[::-1]
while True:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:6]=="resare":
        s=s[6:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:7]=="remaerd":
        s=s[7:]
        if len(s)==0:
            print("YES")
            exit()
    else:
        print("NO")
        exit()

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

int main()
{
    int n;
    scanf("%d", &n);
    for (long long i = 1;; i++)
    {
        if (i * i > n)
        {
            printf("%lld\n", (i - 1) * (i - 1));
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
program scoring
    implicit none
    integer(8)::D,C(26),last(26,365),last_sim(26,365),i,j,k,l,vmax,tbest,dadd,i_calc,vbest,add_best,score
    integer(8),allocatable::S(:,:),T(:),Tans(:),V(:)

    !入力
    read*,D,C
    allocate(S(26,D))
    allocate(T(D))
    allocate(Tans(D))
    allocate(V(D))
    read*,S
    T=0
    V=0
    last=0
    last_sim=0

    !貪欲法
    do dadd=0,0
        T=0
        V=0
        last=0
        last_sim=0
        !今日の日付+dadd日目のパラメータを使用して満足度を計算する
        do i=1,D
            i_calc=min(i+dadd,D)
            do j=1,26
                !得点の初期化
                if(i==1)V(i)=0
                if(i>1)V(i)=V(i-1)

                !lastの初期化
                if(i==1)last(:,i)=0
                if(i>1)last(:,i)=last(:,i-1)

                last(j,i)=i
                V(i)=V(i)+S(j,i)
                
                do k=1,26
                    do l=i,i_calc
                        V(i)=V(i)-C(k)*(l-last(k,i))
                    end do
                end do

                if(j==1)then
                    vmax=V(i)
                    tbest=j
                else if(V(i)>=vmax)then
                    vmax=V(i)
                    tbest=j
                end if
            end do
            if(i==1)last(:,i)=0
            if(i>1)last(:,i)=last(:,i-1)
            T(i)=tbest
            last(tbest,i)=i
        end do
        !print'(i0)',V(D)

        !得点の再計算
        score=0
        do i=1,D
            score=score+S(T(i),i)
            do j=1,26
                score=score-C(j)*(i-last(j,i))
            end do
        end do

        !print'(i0)',score
        if(dadd==0.or.score>vbest)then
            add_best=dadd
            vbest=score
            Tans(:)=T(:)
        end if
    end do
    !print'(i0)',vbest
    !print'(i0)',add_best
    !print'(A)',""

    do i=1,D
        print'(i0)',Tans(i)
    end do
end program scoring

Measured memory_bytes: 3148
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

ll m,k;
vector<ll> putans(){
    vector<ll>res;
    if((1ll<<m)<=k){
        res.pb(-1);return res;
    }
    if(m==0){
        rep(q,1,2)res.pb(0);return res;
    }
    if(m==1){
        if(k==0){
            rep(i,0,1)rep(j,0,1)res.pb(i);
        }else{
            res.pb(-1);
        }
        return res;
    }
    
    ll y=k/4*4;
    ll z=k-y;
    vector<ll>a;rep(i,0,3)rep(j,0,1)a.pb(i+y);
    do{
        bool flag=true;
        rep(i,y,y+3){
            ll s1=-1,s2=-1;
            rep(j,0,7){
                if(a[j]==i){
                    if(s1==-1)s1=j;
                    else s2=j;
                }
            }
            ll xo=0;
            rep(j,s1,s2){
                xo^=a[j];
            }
            if(xo!=k)flag=false;
        }
        if(flag)break;
    }while(next_permutation(a.begin(),a.end()));
    vector<ll>v;
    rep(i,0,7){
        v.pb(a[i]);
    }
    vector<ll>fro;
    rep(i,0,(1ll<<m)-1){
        if(y<=i&&i<=y+3)continue;
        fro.pb(i);
    }
    ll pos=0;
    rep(i,0,v.size()-1){
        if(v[i]==k){
            pos=i;break;
        }
    }
    rep(i,0,v.size()-1){
        if(i==pos){
            reverse(fro.begin(),fro.end());
            for(auto x:fro)res.pb(x);
            res.pb(v[i]);
            reverse(fro.begin(),fro.end());
            for(auto x:fro)res.pb(x);
        }else{
            res.pb(v[i]);
        }
    }
    return res;
}
bool check(vector<ll>a){
    rep(i,0,(1<<m)-1){
        ll s1=-1,s2=-1;
        rep(j,0,a.size()-1){
            if(a[j]==i){
                if(s1==-1)s1=j;
                else s2=j;
            }
        }
        ll xo=0;
        rep(j,s1,s2){
            xo^=a[j];
        }
        if(xo!=k)return false;
    }
    return true;
}
int main(){fastio
    cin>>m>>k;
    vector<ll>v=putans();
    for(auto x:v)cout<<x<<" ";
    return 0;
    //cin>>m>>k;
    rep(i,2,5){
        rep(j,0,(1<<i)-1){
            m=i;k=j;
            vector<ll>v=putans();
            //for(auto x:v)cout<<x<<" ";
            cout<<m<<" "<<k<<" "<<check(v)<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3952
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
ll A[100001], B[100000];
int main(void){
    cin >> N;
    for(int i=0;i<N+1;i++) scanf("%lld",&A[i]);
    for(int i=0;i<N;i++) scanf("%lld",&B[i]);

    ll monster = 0;
    rep(i,N){
        if(A[i] < B[i]){
            if(A[i] + A[i+1] >= B[i]){
                A[i+1] = A[i+1]-(B[i]-A[i]);
                monster += B[i];
            }
            else{
                monster += A[i] + A[i+1];
                A[i+1] = 0;
            }
        }else{
            monster += B[i];
        }
    }
    cout << monster << endl;
    return 0;
}



Measured memory_bytes: 1792
import Data.List

main :: IO ()
main = do
  s <- map read . map return <$> getLine
  print $ solve s

solve :: [Int] -> Int
solve xs = minimum $ map (abs . subtract 753) $ zipWith3 (\x y z -> 100 * x + 10 * y + z) xs ys zs
  where
    ys = tail xs
    zs = tail ys

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    ans[a[i]-1] = i+1;
  }
  rep(i,n){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
import io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, k) = readLine.split(" ").map(_.toInt)
    val trees = (for {_ <- 1 to n} yield readInt()).sorted
    val ans = (0 to n - k).map(i => trees(i + k - 1) - trees(i)).min
    println(ans)
  }
}

Measured memory_bytes: 40684