akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> ans(N);
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      int tmp = min(j - i, abs(X - i) + abs(Y - j) + 1);
      ans[tmp]++;
    }
  }
  debug(ans);
  for (int i = 1; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import java.util.*;
 
public class Main{
  static int N;
  static Set<Long> set;
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    N = Integer.parseInt(sc.nextLine());
    set = new HashSet<>();
    
    long n = 0;
    func(n);
    System.out.println(set.size());
  }
  public static void func(long n){
    if(n > N){
      return;
    }
    boolean c3 = false;
    boolean c5 = false;
    boolean c7 = false;
    String s = n + "";
    for(int i = 0; i < s.length(); i++){
      if(s.charAt(i) == '3'){
        c3 = true;
      }else if(s.charAt(i) == '5'){
        c5 = true;
      }else if(s.charAt(i) == '7'){
        c7 = true;
      }
    }
    if(c3 && c5 && c7){
      set.add(n);
    }
    
    func(n*10+3);
    func(n*10+5);
    func(n*10+7);
  }
}

Measured memory_bytes: 35024
#include <bits/stdc++.h>
using namespace std;
int n,m,a[12345],b;
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
        b+=a[i];
    }
    b=n-b;
    if(b<0)cout<<-1<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 3624
n, m = [ int(v) for v in input().split() ]
a_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

def p2(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

n = len(a_list)

p2_list = [p2(i) for i in a_list]

p2_set = set(p2_list)
if len(p2_set) != 1:
    print(0)
else:
    p = 1
    for i in a_list:
        p = lcm(p, i//2)
        if p > m:
            print(0)
            break
    if p <= m:
        m -= p
        print(m//(p*2)+1)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m;

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

    ll result = 0LL;
    for(ll i=1LL;i*i<=m;i++) {
        if(m % i == 0) {
            if(n * i <= m) result = max(result, i);
            if(m % (m/i) == 0 && (m/i)*n <= m) result = max(result, m/i);
        }
    }
    cout<<result;
    return 0;
}


Measured memory_bytes: 256
def main():
    l = [
        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
    ]
    N = int(input())
    print(l[N-1])



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, c; cin >> n >> c;
  vi w(n), v(n);
  for(int i=0;i<n;++i) {
    cin >> w[i] >> v[i];
  }
  vvll dp(n+1, vll(c+1));
  for(int i=1;i<n+1;++i) {
    for(int j=0;j<=c;++j) {
      if(j-w[i-1] >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  ll ans = 0;
  for(int i=0;i<=c;++i) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  if(n<1000) cout<<"ABC"<<endl;
  else cout<<"ABD"<<endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
static const int MAX_N = 1e5;
static const int MOD = 1000000007;
using namespace std;

int main()
{
    bool safe[MAX_N + 1];
    int n, m;
    long long dp[MAX_N + 1];
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
    {
        safe[i] = true;
    }
    for (int i = 0; i < m; ++i)
    {
        int a;
        cin >> a;
        safe[a] = false;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        if (!safe[i])
        {
            dp[i] = 0;
        }
        else
        {
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= MOD;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	
	char c; cin >> c;
	if (c >= 'a' and c <= 'z') {
		cout << "a\n";
	} else {
		cout << "A\n";
	}
	
}


Measured memory_bytes: 3604
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]


ab=[]

for i in a:
    for j in b:
        ab.append(i+j)
ab.sort()
ab.reverse()
ans=[]
for i in range(min(k,len(ab))):
    for j in c:
        ans.append(ab[i]+j)
ans.sort()
ans.reverse()

for i in range(k):
    print(ans[i])



Measured memory_bytes: 147364
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;



int main() {
	long long int n, m, d = 0, q, t[200006] = {}, time=0, b[200006] = {}, leng = 0, goal, two = 0, three = 0, temp = 0,mi=100000000000000;
	string str[600];
	cin >> n>>m;
	
	for (int i = 0; i <= n-1; i++) {
		
		cin >> str[i];
		
	}

	for (int i = 0; i <= n - 1; i++) {
		for (int j = 0; j <= m - 1; j++) {

			if (str[i][j] == '#') {
				if (i != 0) {
					if (str[i - 1][j] == '#') { continue; }
				}
				if (j != 0) {

					if (str[i][j-1] == '#') { continue; }
				}
				if (str[i][j + 1] == '#') { continue; }
				if (str[i+1][j] == '#') { continue; }
				cout << "No"; return 0;
			}

		}
		

	}
	cout << "Yes";
} 

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


int main() {
    int N; cin >> N;
    vector<long long> P_table(N + 1);
    for (int i = 1; i < N + 1; i++) {
        int p; cin >> p;
        P_table[p] = i;
    }

    long long ans = 0;
    multiset<int> S{0, 0, N + 1, N + 1};
    int ip[2], in[2];

    for (int i = N; i > 0; i--) {
        S.insert(P_table[i]);
        auto it = S.find(P_table[i]);
        for (int j = 0; j < 2; j++) {
            ip[j] = *prev(it, j + 1);
            in[j] = *next(it, j + 1);
        }
        ans += (long long)i * (*it-ip[0]) * (in[1] - in[0]);
        ans += (long long)i * (ip[0] - ip[1]) * (in[0]-*it);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void)
{

 int n, i, s;
 int a[100];
 int f = 1;
 int c = 0;

 scanf("%d", &n);

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

 while(f == 1)
{
 f = 0;
 
 for(i = n - 1; i > 0; i--)
{
 if(a[i] < a[i-1])
{
 s = a[i];
 a[i] = a[i-1];
 a[i-1] = s;
 f = 1;
 c++;
 s = 0;
}


}

 }

 for(i = 0; i < n; i++)
if(i < n - 1)
 printf("%d ", a[i]);
 else
 printf("%d", a[i]);

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

 return 0;

}




Measured memory_bytes: 1984
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b;
	if((a*b)%2==0)
	cout<<"Even";
	else
	cout<<"Odd";
	//system("pause");
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
int main()
{
    int A,B,C,D,sum=1,sum2=1;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    sum=A*B;
    sum2=C*D;
    if(sum >= sum2)
        printf("%d\n",sum);
    else
        printf("%d\n",sum2);

    return 0;
}


Measured memory_bytes: 128
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N; string A, B, C;

int main() {
    cin >> N >> A >> B >> C;

    int count = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] == B[i] && B[i] == C[i]) {
        } else if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
            count++;
        } else {
            count += 2;
        }
    }
    cout << count << endl;
    return 0;
}


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

using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> c(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cin>>c[i][j];
    }
    ll res=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            res+=min(c[i][j],c[j][i]);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3180
#include<stdio.h>
#define MAX 10000

int main(){
    int x[MAX];
    int i;

    for(i = 0; i < MAX; i++){
        scanf("%d", &x[i]);
        if(x[i] == 0) break;
    }

    for(i = 0; i < MAX; i++){
        if(x[i] == 0) break;
        printf("Case %d: %d\n", i + 1, x[i]);
    }
    return 0;
}


Measured memory_bytes: 2132
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
s = [0]*(n-k+1)
u = 0
for j in range(0,k):
    s[0]+=p[j]
for i in range(1,n-k+1):
    s[i] = s[i-1]-p[i-1]+p[i+k-1]
print((max(s)/2)+(k/2))

Measured memory_bytes: 71792
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef unsigned long long ull;
typedef set <int> si;
typedef multiset<int>msi;
typedef pair<int,int> pi;
typedef vector <int> vi;
string read (char x[]){
    scanf ("%s",x);
    return x;
}
const int N = 1e5+3;
int n, a[N], dp[N];
void solve () {
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",a+i);
    dp [1] =   abs (a[1]-a[0]);
    dp [0] = 0;
    for (int i=2;i<n;i++) {
        dp [i] = dp[i-2] + abs(a[i-2] - a[i]);
        dp [i] = min (dp[i] , dp[i-1] + abs(a[i]-a[i-1]));
    }
    printf ("%d",dp[n-1]);
 }
int main () {
    solve();
}


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

struct graph{
	int point;
	int num;
	int *node;
};

int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	
	struct graph *pointer[n];
	
	//構造体の作成
	for(int i=0;i<n;i++){
		pointer[i]=(struct graph*)malloc(sizeof(struct graph));
		pointer[i]->point=i+1;
		pointer[i]->node=(int*)malloc(m*sizeof(int));
		pointer[i]->num=0;
	}
	
	//入力
	int temp1,temp2;
	for(int i=0;i<m;i++){
		scanf("%d",&temp1);
		scanf("%d",&temp2);
		pointer[temp1-1]->node[pointer[temp1-1]->num]=temp2-1;
		pointer[temp1-1]->num+=1;
		pointer[temp2-1]->node[pointer[temp2-1]->num]=temp1-1;
		pointer[temp2-1]->num+=1;
	}
	
	int *list,*que;
	int head=0,tail=0;
	
	que=(int*)malloc(n*sizeof(int));	
	list=(int*)malloc(n*sizeof(int));
	
	for(int i=0;i<n;i++){
		list[i]=-1;
	}
	
	que[0]=0;
	list[0]=0;
	tail=1;
	
	do{
		for(int i=0;i<pointer[que[head%n]]->num;i++){
			if(list[pointer[que[head%n]]->node[i]]==-1){
				list[pointer[que[head%n]]->node[i]]=que[head%n];
				que[tail%n]=pointer[que[head%n]]->node[i];
				tail+=1;
			}
		}
		/*for(int i=head;i<tail;i++){
			printf("%d ",que[i]);
		}
		printf("\n");*/

		head+=1;
	}while(head!=tail);
	
	printf("Yes\n");
	for(int i=1;i<n;i++){
		printf("%d\n",list[i]+1);
	}
	
	return 0;
}

Measured memory_bytes: 559452
number = int(input())

num_eight_divisors = 0

numbers = list(range(9, number + 1, 2))

for i in range(9, number + 1, 2):
    divisors = [1, i]

    for j in range(2, i):
        q, mod = divmod(i, j)

        if mod == 0:
            divisors.append(j)
            divisors.append(q)

    if len(set(divisors)) == 8:
        num_eight_divisors = num_eight_divisors + 1

print(num_eight_divisors)


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

int gcd(int a, int b){
  if(a<b)
    swap(a,b);
  while(a%b){
    a %= b;
    swap(a,b);
  }
  return b;
}

int main(){
  int n,k;
  cin >> n >> k;
  v a(n);
  bool ok = false;
  int g;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]>=k)ok = true;
    
    if(i) g = gcd(g,a[i]);
    else  g = a[0];
  }
  
  if(!ok)cout << "IMPOSSIBLE" << endl;
  else{
    if(g==1)cout << "POSSIBLE" << endl;
    else if(k%g==0)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }

    int main()
    {
        ll n;
        cin>>n;
        vector<ll>arr(n);
        for(int i=0;i<n;i++)cin>>arr[i];
        map<ll,ll>mp;
        for(ll i=0;i<n;i++)
        {
            if(mp.find(i+1-arr[i]) != mp.end())mp[i+1-arr[i]]++;
            else mp.insert({i+1-arr[i],1});
        }
        ll ans = 0;
        for(int i=0;i<n;i++)
        {
            ans+=mp[arr[i]+i+1];
        }
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 27364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    rep(i, s.length() - 1)
    {
        if (s[i] == s[i + 1])
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
template <typename T> bool chmin(T& a, const T& b) {if(a>b){a=b; return true;} return false;}

using int64 = long long;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    vector<vector<int64>> dp(h, vector<int64>(w, INT_MAX));
    dp[0][0] = (s[0][0] == '#');

    const vector<int> dx = {+1, 0};
    const vector<int> dy = { 0,+1};

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {

            if (i+1 < h) {
                int64 d = dp[i][j];
                if (s[i][j] == '.' && s[i+1][j] == '#') d++;

                chmin(dp[i + 1][j], d);
            }

            if (j+1 < w) {
                int64 d = dp[i][j];
                if (s[i][j] == '.' && s[i][j+1] == '#') d++;
                chmin(dp[i][j + 1], d);
            }
        }
    }
    
    cout << dp[h-1][w-1] << endl;
}

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

int main(){
    char a,b; cin >> a >> b;
    if(a-'0' > b-'0') cout << '>';
    else if (a-'0' < b-'0') cout << '<';
    else cout << "=";
}

Measured memory_bytes: 256
package main

import (
	"errors"
	"fmt"
)

var errNoBase = errors.New("no such base exists")

func digitSum(n, b int64) int64 {
	var ret int64
	for n > 0 {
		ret += n % b
		n /= b
	}
	return ret
}

func solve(n, s int64) (int64, error) {
	if s > n {
		return 0, errNoBase
	} else if s == n {
		return n + 1, nil
	}

	d := n - s
	var ans int64
	for i := int64(1); i*i <= d; i++ {
		if d%i != 0 {
			continue
		}

		if digitSum(n, i+1) == s {
			return i + 1, nil
		}
		if di := d / i; digitSum(n, di+1) == s {
			ans = di + 1
		}
	}

	if ans != 0 {
		return ans, nil
	}
	return 0, errNoBase
}

func main() {
	var n, s int64
	fmt.Scan(&n, &s)

	res, err := solve(n, s)
	if err == nil {
		fmt.Println(res)
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int a = s.indexOf("A");
		int z = s.lastIndexOf("Z");
		String r = s.substring(a, z+1);
		int ans = r.length();
		System.out.println(ans);
	}
}


Measured memory_bytes: 28472
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
string s[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3) cin >> s[i];
  FOR(i, 0, 3) cout << s[i][i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

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

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

template<class T> void print(vector<T>& a){
    int sz = a.size();
    for(int i=0;i<sz;i++)cout<<a[i] << (i<sz-1?' ':'\n');
}

template<class T> bool chmin(T& a,T b){
    if(a > b){ a = b; return true; } return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){ a = b; return true; } return false;
}

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

    int64_t k;cin >> k;
    string s;cin >> s;
    if(s.size() > k)cout << s.substr(0,k) + "..." << '\n';
    else cout << s << '\n';

}



Measured memory_bytes: 3640
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    cout << (n - k + 1);
    return 0;
}

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


int main() {
long long N,K,ans;
cin >> N >> K;
N--;
ans = K;
K--;
rep(i,N) {
  ans *= K;
}
cout << ans << endl;



return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
 
#define N  100005
signed main()
{
	fast;
	string s;
	cin>>s;
	int n=s.size();
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

//Compiler version g++ 6.3.0

int main()
{
    int a, b;
    string s;
    cin>>a>>s;
    
    
    if(a>=3200)
    {
      cout<<s;
      
    }
    else
    {
      cout<<"red";
    }
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd<T>(a: T, b: T) -> T
where
    T: Copy + std::cmp::PartialEq + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if b == T::from(0u8) {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a_s: [i64; n],
    }
    let mut lgcd = vec![a_s[0]; n];
    let mut rgcd = vec![a_s[n - 1]; n];
    for i in 1..n {
        lgcd[i] = gcd(lgcd[i - 1], a_s[i]);
    }
    for i in (0..n - 1).rev() {
        rgcd[i] = gcd(rgcd[i + 1], a_s[i]);
    }
    let ans = (0..n)
        .map(|i| {
            if i == 0 {
                rgcd[1]
            } else if i == n - 1 {
                lgcd[i - 1]
            } else {
                gcd(lgcd[i - 1], rgcd[i + 1])
            }
        })
        .max()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 6396
import math
S = input()
A = int(S.split()[0])
B = int(S.split()[1])
H = int(S.split()[2])
M = int(S.split()[3])
m = 60*H + M
theta = m*math.pi/360
phi = m*math.pi/30
d = math.sqrt((A*math.sin(theta)-B*math.sin(phi))**2 + (A*math.cos(theta)-B*math.cos(phi))**2)
print(d)


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

int main(){
  int N;
  cin >> N;
  
  long long int sum = 0;
  
  for(int i = 1; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
    
    cout << sum << endl;
}
  
  

Measured memory_bytes: 3648
MOD = 10**9 + 7

def fact(n)
  @facts ||= [1]
  (@facts.size).upto(n){|i| @facts << @facts[-1]*i % MOD}
  return @facts[n]
end

def modpow(x,n)
  ret = 1
  while n > 0
    ret = ret*x % MOD if n&1 == 1
    x = x*x % MOD
    n >>= 1
  end
  return ret
end

def modinv(x)
  return modpow(x,MOD-2)
end

def combin(n,k)
  return fact(n) * modinv(fact(n-k)) * modinv(fact(k)) % MOD
end

x,y = gets.split.map(&:to_i)
a = 0
while x < y * 2
  x -= 1
  y -= 2
  a += 1
end
#p [x,y]
if y * 2 != x || x < 0 || y < 0
  p 0
else
  p combin(a+y,a)
end

Measured memory_bytes: 8956
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include<iostream>
#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P)
#define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1010000000; // 0x3C33'6080
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


int main() {
	ll a, b, c, d, e, f, h;
	ll i, j, k, l, m, n, o, p, q;
	string r, s, t, u;
	ll v, w, x, y, z;

	cin >> a;
	if (a == 1) {
		puts("Hello World");
		return 0;
	}
	cin >> a >> b;
	cout << a + b << endl;


}

Measured memory_bytes: 256
/* Don't try to copy it!
                    nhi too,
                         goli maar ke cheed bana dunga...;););)
 
                 
    _/﹋\_
    (҂`_´)
    <,︻╦╤─҉- - - - - - - - => - => - =>
    _/﹋\_
                
*/
 
#include "bits/stdc++.h"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define T ll t; cin>>t; while(t--)
#define freeopen freopen("input.txt","r",stdin);
#define freeclose freopen("output.txt","w",stdout);
#define MOD 1000000007
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll n,cap;
ll v[100005],w[100005];
ll dp[100][100001];


main()
{
   //ll n;
   for(ll i=0;i<100;i++)
   {
    for(ll j=0;j<=100000;j++)
        dp[i][j]=1e18;
   }
   cin>>n>>cap;
   f(n)
   {
    cin>>w[i];
    cin>>v[i];
   }

   dp[0][0]=0;
   dp[0][v[0]]=w[0];

   for(ll i=1;i<n;i++)
   {
    dp[i][0]=0;
    for(ll j=1;j<=100000;j++)
    {
        dp[i][j]=dp[i-1][j];
        if(j>=v[i])
            dp[i][j]=min(dp[i][j],w[i]+dp[i-1][j-v[i]]);
    }
   }
   
   ll ans;
   for(ll i=100000;i>=0;i--)
   {
    if(dp[n-1][i]<=cap)
    {
        ans=i;
        break;
    }
   }
   cout<<ans;
}



Measured memory_bytes: 81756
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, z = 328;
    cin >> a >> b >> c;
    for (int i = 0; i <= 87; i++) {
        int y = 0;
        if (a > i) y += a - i;
        else {y += (i - a + 1) / 2;
            if (i % 2 != a % 2) y++;}
        if (b > i) y += b - i;
        else {y += (i - b + 1) / 2;
            if (i % 2 != b % 2) y++;}
        if (c > i) y += c - i;
        else {y += (i - c + 1) / 2;
            if (i % 2 != c % 2) y++;}
        z = min(z, y);
    }
    cout << z;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int v[N];
    for (int i=0; i<N; i++) v[i] = i;
    int adj_mat[N][N];
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            adj_mat[i][j] = 0;
        }
    }
    for (int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj_mat[a][b] = 1;
        adj_mat[b][a] = 1;
    }
    int ans = 0;
    bool perm_flag = true;
    while (perm_flag) {
        bool flag = true;
        for (int i=0; i<N-1; i++) {
            flag = flag && (adj_mat[v[i]][v[i+1]] == 1);
        }
        if (flag) ans++;
        perm_flag = next_permutation(v+1, v+N);
    }
    cout << ans << endl;
}

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

int col[8];

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i =0 ;i<n;i++)
	{
		int x;
		cin >> x;
		x /= 400;
		if(x<8)
		col[x]=1;
		else
		ans ++ ;
	}
	int an=0;
	for(int i = 0;i<8;i++)an+=col[i];
	cout<<max(an,1)<<' '<<ans+an<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


ll n;
vector<vector<pll>> edge;
ll ans=0;
vector<ll> mid;

ll dfs(ll w,ll p){
    ll mx=0;
    ll cnt=1;
    for(auto &I:edge[w]){
        if(I.F==p){continue;}
        ll ret=dfs(I.F,w);
        mx=max(mx,ret);
        cnt+=ret;
        ans+=min(ret,n-ret)*I.S*2;
    }
    mx=max(mx,n-cnt);
    if(mx*2<=n){mid.push_back(w);}
    return cnt;
}


int main(){
    cin>>n;
    edge.resize(n);
    for(int i=1;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        edge[a].push_back({b,c});
        edge[b].push_back({a,c});
    }
    dfs(0,-1);
    if(mid.size()==2){
        for(auto &I:edge[mid[0]]){
            if(I.F==mid[1]){ans-=I.S; break;}
        }
    }
    else{
        ll mi=E;
        for(auto &I:edge[mid[0]]){
            mi=min(mi,I.S);
        }
        ans-=mi;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
int const N = 100000;

int main()
{
    int n, k; string s;
    cin >> n >> k >> s;
    int ans = 1;
    for (int i = 1; i < n; i++)
        if (s[i] != s[i - 1]) ans++;

    while (k > 0 && ans > 2) {
        ans -= 2; k--;
    }
    if (k > 0 && ans == 2) ans--;
    cout << n - ans;
}



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

int main(){

    int n,t,a,out;
    int h[1000];
    float hight = 100000;

    cin >> n >> t >> a;

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

        float tenp;
        float tmp;

        cin >> h[i];

        tenp = t - h[i]*0.006;

        if(a < tenp)tmp = tenp - a;
        else tmp = a- tenp;

        if(tmp < hight){
            hight = tmp;
            out = i+1;
        }
    }

    cout << out << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const ll MOD = 1e9+7;

inline ll mod (ll x) {
	return x%MOD;
}

char str[2][100];
int n;

int main () {
	scanf("%d", &n);
	scanf(" %s %s", str[0], str[1]);

	ll r = 1;

	int ls = 1;

	for (int i = 0; i < n; i++) {
		if (str[0][i] == str[1][i]) {
			if (!i)
				r = 3;
			else if (ls == 1)
				r = mod(r+r);
			
			ls = 1;
		} else {
			if (!i)
				r = 6;
			else if (ls == 1)
				r = mod(r+r);
			else
				r = mod(r+r+r);
			i++;

			ls = 2;
		}
	}

	printf("%lld\n", r);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//aの勝敗  1-win 2-lose 3-draw
int re(int a, int b) {
	int ret;
	switch (a) {
	case 1:
		ret = (b == 1) ? 3 : (b == 2) ? 1 : 2;
		break;
	case 2:
		ret = (b == 1) ? 2 : (b == 2) ? 3 : 1;
		break;
	case 3:
		ret = (b == 1) ? 1 : (b == 2) ? 2 : 3;
		break;
	}
	return ret;
}

int main() {
	while (true) {
		int x; cin >> x;
		if (x == 0)break;
		VI h(5); h[0] = x;
		rep(i, 4)cin >> h[i + 1];

		rep(i, 5) {
			int win = 0, lose = 0, draw = 0;
			rep(j, 5) {
				if (i != j) {
					switch (re(h[i], h[j])) {
					case 1:
						win++; break;
					case 2:
						lose++; break;
					case 3:
						draw++; break;
					}
				}
			}

			int ans;
			if ((win && lose) || (!win && !lose))ans = 3;
			else if (win)ans = 1;
			else ans = 2;
			Cout(ans);
		}
	}
}


Measured memory_bytes: 2984
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    int n;
    double a=0 , m=0;
    while(cin>>n && n!=0){
    int *s =new int[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        m+=s[i];
    }
    m/=n;
    for(int i=0; i<n ; i++){
        a+=((s[i]-m)*(s[i]-m))/n;
    }
    cout << fixed << setprecision(9) << sqrt(a) << endl;
    delete [] s;
    a=m=0;
    }
    return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <array>
#include <string>
#include <map>
#include <cmath>
//#include <iomainp>
using namespace std;

#define DB(x)
#define rep(i, n) for(int i = 0;i < n;i++)
typedef uint64_t LL;




int main()
{
    int N,R;
    cin >> N >> R;
    
    cout << R + 100 * ( N > 10 ? 0 : 10 - N ) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1<<30;
int main(){
  int hp;
  int n;
  int dp[10005];
  cin>>hp>>n;
  for(int i=0;i<=hp;i++){
    dp[i]=INF;
  }
  dp[hp]=0;
  
  int dmg[10005];
  int mp[10005];
  for(int i=0;i<n;i++){
    cin>>dmg[i]>>mp[i];
  }
  
  for(int i=hp;i>=0;i--){
    for(int j=0;j<n;j++){
      int next=max(0,i-dmg[j]);
      dp[next]=min(dp[next],dp[i]+mp[j]);
    }
  }
  
  cout<<dp[0]<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int a,b,c;
    cin>>a>>b>>c;

    if(a+b+c>=22)   cout<<"bust"<<endl;
    else    cout<<"win"<<endl;
    
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

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

    double ans = 0;
    for(int i=0; i<n ;++i){
        double tmp;
        string u;
        cin >> tmp >> u;
        
        if(u == "JPY")ans += tmp;
        else ans += tmp * 380000.0 ;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int s, w;
    cin >> s >> w;

    //cout << "Yes" << "No" << " " << endl;
    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a;
  rep(i, n){
    ll x;
    cin >> x;
    a.pb(x);
  }
  ll k = 0;
  while(true){
    ll s = 0;
    rep(i, n){
      s += a[i] / n;
    }
    k += s;
    bool flag = true;
    rep(i, n){
      a[i] = (a[i] % n) + s - (a[i] / n);
      if(a[i] >= n)flag = false;
    }
    if(flag)break;
  }
  cout << k << endl;
	return 0;
}


Measured memory_bytes: 256