akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a, b, c;
string s[N];
string ans[N];

void dfs(int now, int a, int b, int c)
{
    if (now > n) 
    {
        puts("Yes");
        for (int i = 1; i <= n; i+=1) cout << ans[i] << endl;
        exit(0);
    }
    if (s[now] == "AB")
    {
        if (b > 0) ans[now] = "A", dfs(now + 1, a + 1, b - 1, c);
        if (a > 0) ans[now] = "B", dfs(now + 1, a - 1, b + 1, c);
    }
    else if (s[now] == "AC")
    {
        if (c > 0) ans[now] = "A", dfs(now + 1, a + 1, b, c - 1);
        if (a > 0) ans[now] = "C", dfs(now + 1, a - 1, b, c + 1);
    }
    else 
    {
        if (c > 0) ans[now] = "B", dfs(now + 1, a, b + 1, c - 1);
        if (b > 0) ans[now] = "C", dfs(now + 1, a, b - 1, c + 1);
    }
}

int main()
{
    n = gi(), a = gi(), b = gi(), c = gi();
    for (int i = 1; i <= n; i+=1) cin >> s[i];
    dfs(1, a, b, c);
    puts("No");
    return 0;
}

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second

int main()
{
    ios::sync_with_stdio(false);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    veci v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());

    cout << v[0]+v[1] << endl;
}}

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


int main()
{
  	int A, B, answer;
	cin >> A >> B;
	answer = 0;
	if (A >= B){
		answer += A;
		A -= 1;
	}
	else{
		answer += B;
		B -= 1;
	}
	
	if (A >= B){
		answer += A;
		A -= 1;
	}
	else{
		answer += B;
		B -= 1;
	}
	cout << answer << endl;

	return 0;
}

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

int main(){
	int N, K;
	string S;
	cin >> N >> K >> S;
	K -= 1;
	
	for( int i = 0; i < N; i++ ){
		if( i == K ){
			if( S.at(i) == 'A' ){
				cout << 'a';
			}
			else if( S.at(i) == 'B' ){
				cout << 'b';
			}
			else{
				cout << 'c';
			}
		}
		else{
			cout << S.at(i);
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $n, $r);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $r . "\n";
echo ++$c . "\n";
// echo $a . " " . $b . "\n";


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

using namespace std;
#define ll long long
#define N 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

vector<vector<int> > g(100001);
vector<vector<int> > gr(100001);
vector<int> col(100001,-1);
vector<vector<long> > w(100001);
vector<bool> vis(100001,0);
stack<int> s;
int n;

void dfs1(int root){
    vis[root]=1;
    for(int i=0;i<g[root].size();i++){
        if(!vis[g[root][i]]){
            dfs1(g[root][i]);   
        }
    }
    s.push(root);
}

void reverse(){
    for(int i=0;i<100005;i++){
        for(int j=0;j<g[i].size();j++){
            gr[g[i][j]].push_back(i);
        }
    }
}

void dfs2(int root){
    vis[root]=1;
    int a=1;
    for(int i=0;i<gr[root].size();i++){
        if(!vis[gr[root][i]]){
            dfs2(gr[root][i]);
        }
    }
}

int kosaraju(){
    int ans=0;
    for(int i=1;i<=n;i++){
	    if(!vis[i])
	        dfs1(i);
	}
	reverse();
	for(int i=1;i<=n;i++)    vis[i]=0;
	while(!s.empty()){
	    int node=s.top();
	    s.pop();
	    if(!vis[node]){
	        dfs2(node);
	        //cout<<node<<endl;
	        ans++;
	    }
	}
	return ans;
}

int main() {
	int m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
	    long a,b,c;
	    cin>>a>>b>>c;
	    g[a].pb(b);
	    g[b].pb(a);
	}
    cout<<kosaraju();
	return 0;
}


Measured memory_bytes: 19072
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int n,m;
inline void solve(){
  IN2(n,m);
  OUT((n-1)*(m-1));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
# include <cstdio>
# include <algorithm>
using namespace std;
const int N = 3e5 + 12;
int l[N],r[N],n;
bool cmp(int x,int y){return x > y;}
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)scanf("%d %d",&l[i],&r[i]);
	sort(l,l + n + 1,cmp);sort(r,r + n + 1);
	for(int i = 0;i <= n;i++)if(l[i] > r[i])ans += 2LL * (l[i] - r[i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
A,B,C,K = map(int,input().split())

def abc(A,B,C,K):
    result = 0
    #A分引く
    K = K - A
    result = A + result
    if K < 0:
        K = K + A
        result -= abs(abs(K)-A)
        return result
    K -= B
    if K < 0:
        return result
    K -= C
    result -= C
    if K < 0:
        K += C
        result += abs(abs(K)-C)
    return result
print(abc(A,B,C,K))

Measured memory_bytes: 9176
#include<cstdio>
#include<algorithm>
int gcd(int x,int y) {return y?gcd(y,x%y):x;}
int x[100005];
int main()
{
	int n;scanf("%d%d",&n,&x[0]);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	std::sort(x,x+n+1);
	int ans=x[1]-x[0];
	for(int i=2;i<=n;i++) ans=gcd(ans,x[i]-x[i-1]);
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
	int N, K, num[200001] = { 0 };
	int i,a, count = 0, n = 0,sum=0;

	cin >> N >> K;

	for ( i = 0; i < N; i++)
	{
		cin >> a;
		num[a]++;
		n++;
	}

	sort(num, num + i + 1);

	for (i = 0; i < K; i++)
	{
		sum += num[n - i];
		//cout << n << n - i<<num[n-(i+1)]<<" ";
	}

	cout << N - sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
while(getline(cin,s)){
if(s=="")break;
if(s[0]!='s'&&s[0]==s[1]&&s[1]==s[2]){cout<<s[0]<<endl;continue;}
if(s[3]!='s'&&s[3]==s[4]&&s[4]==s[5]){cout<<s[3]<<endl;continue;}
if(s[6]!='s'&&s[6]==s[7]&&s[7]==s[8]){cout<<s[6]<<endl;continue;}
if(s[0]!='s'&&s[0]==s[3]&&s[3]==s[6]){cout<<s[0]<<endl;continue;}
if(s[1]!='s'&&s[1]==s[4]&&s[4]==s[7]){cout<<s[1]<<endl;continue;}
if(s[2]!='s'&&s[2]==s[5]&&s[5]==s[8]){cout<<s[2]<<endl;continue;}
if(s[0]!='s'&&s[0]==s[4]&&s[4]==s[8]){cout<<s[0]<<endl;continue;}
if(s[2]!='s'&&s[2]==s[4]&&s[4]==s[6]){cout<<s[2]<<endl;continue;}
cout<<"d"<<endl;
}
return 0;
}

Measured memory_bytes: 1172
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}



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

int main(){
    int r,c;
    cin >> r>>c;
    int num[101][101] = {};
    for (int i=0;i<r;i++)
       for (int j =0;j<c;j++) cin >>num[i][j];

    for(int i =0 ;i<r;i++) 
       for (int j =0;j<c;j++) num[r][c] += num[i][j];
       
    for(int i=0;i<r;i++){
        int sum =0;
        for(int j=0;j<c;j++) sum += num[i][j];
        num[i][c] = sum;
     }

    for(int j=0;j<c;j++){
        int sum =0;
        for(int i=0;i<r;i++) sum += num[i][j];
        num[r][j] = sum;
     }

    for(int i =0;i<=r;i++){
       for(int j=0;j<=c;j++){
         if(j) cout <<" ";
         cout <<num[i][j];
        }
        cout <<endl;
     }
      return 0;
}


Measured memory_bytes: 3144
<?php
// Your code here!
$input = explode(" ",trim(fgets(STDIN)));
$a = $input[0];
$b = $input[1];
$c = $input[2];
$x = $input[3];
$y = $input[4];

$case1 = $a*$x + $b*$y; //単純に枚数のみを計算した場合

//もしyの方が大きければ
if($x<=$y){//3 2
    $case2 = $b * ($y - $x) + $c * 2 * $x;
}else{//xのほうが大きければ
    $case2 = $a * ($x - $y) + $c * 2 *$y;
}

if($x <= $y){
    $case3 = $c * 2 *$y; //1600*2*2
}else{
    $case3 = $c * 2 * $x;//1600 * 2 *3
}

echo min($case1,$case2,$case3);



?>


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,w;
	cin>>n>>w;
	vector<long> dp(w+1,0);
	for(int i=0;i<n;i++)
	{
		int weight,value;
		vector<long> new_dp(w+1,0);
		scanf("%d%d",&weight,&value);
		for(int j=1;j<=w;j++)
		{
			if(j>=weight)
				new_dp[j] = max(dp[j],dp[j-weight]+value);
			else
				new_dp[j] = dp[j];
		}
		dp = new_dp;
	}
	printf("%ld\n",dp[w]);
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int len = s.size();
    ll ans = 0;
    ll tmp;
    for (int i = 0; i < (1 << (len - 1)); ++i) {
        tmp = s[0] - '0';
        rep (j, len - 1) {
            if (i & (1 << j)) {
                ans += tmp;
                tmp = 0;
            }
            tmp =  tmp * 10 + (s[j + 1] - '0');
        }
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#define int_inf 1000000000 //10**9
#define ll_inf 100000000000000000 //10**17

using namespace std;





int main(){
	int n, k;
	cin >> n >> k;
	int ans=1;
	for(int i=0; i<n; i++){
		if(ans*2 < ans+k) ans*=2;
		else ans += k;
	}
	
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool dp[100005];
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	s=' '+s;
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	for(int i=5;i<=n;i++)
	{
		string ss;
		ss=s.substr(i-5+1,5);
		if(ss=="erase"||ss=="dream")
		{
			if(dp[i-5])dp[i]=1;
		}
		if(i>5)
		{
			ss=s.substr(i-6+1,6);
			if(ss=="eraser")
			{
				if(dp[i-6])dp[i]=1;
			}
		}
		if(i>6)
		{
			ss=s.substr(i-7+1,7);
			if(ss=="dreamer")
			{
				if(dp[i-7])dp[i]=1;
			}
		}
	}
	if(dp[n])printf("YES\n");else printf("NO\n");
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  n*=3;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(a.rbegin(),a.rend());
  ll ans=0;
  rrep(i,n/3){
    ans+=a[i*2+1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, m;
   cin >> n >> m;
   int a = n*(n-1)/2;
   int b = m*(m-1)/2;
   cout << a+b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;
    string sx[50],sy[50],q2;int c[50];
      int n,ans=MOD*MOD,ans2;
      bool z[2][50][50];
    void dfs(int a,bool x,int b){
        if(z[x][a][b])return;
        z[x][a][b]=true;
        if(x){
            q2=sx[a].substr(b);
        reverse(q2.begin(),q2.end());
        if(sx[a].substr(b)==q2){ans=min(ans2,ans);
         z[x][a][b]=false;
        return ;
        }
        
            for(int i=0;i<n;i++){
                 if(sx[a].size()-b<=sy[i].size()&&equal(begin(sx[a])+b,end(sx[a]),begin(sy[i]))){
                     ans2+=c[i];
                        dfs(i,false,sx[a].size()-b);
           
                        ans2-=c[i];
                 }
                 if(sy[i].size()<=sx[a].size()-b&&equal(begin(sy[i]),end(sy[i]),begin(sx[a])+b)){
                     ans2+=c[i];
                        dfs(a,true,b+sy[i].size());
           
                        ans2-=c[i];
                 }
            }
           
        }else{
             q2=sy[a].substr(b);
        reverse(q2.begin(),q2.end());
        if(sy[a].substr(b)==q2){ans=min(ans2,ans);
      z[x][a][b]=false;
        return ;
        }
            for(int i=0;i<n;i++){
                 if(sy[a].size()-b<=sx[i].size()&&equal(begin(sy[a])+b,end(sy[a]),begin(sx[i]))){
                     ans2+=c[i];
                        dfs(i,true,sy[a].size()-b);
     
                        ans2-=c[i];
                 }
                  if(sx[i].size()<=sy[a].size()-b&&equal(begin(sx[i]),end(sx[i]),begin(sy[a])+b)){
                     ans2+=c[i];
                        dfs(a,false,b+sx[i].size());
           
                        ans2-=c[i];
                 }
            }
        }
        z[x][a][b]=false;
    }

     signed main(){
     
       cin>>n;
   
       for(int i=0;i<n;i++){
           cin>>sx[i]>>c[i];
           sy[i]=sx[i];
           reverse(sy[i].begin(),sy[i].end());
       }
       for(int i=0;i<n;i++){
     
           ans2=c[i];
           dfs(i,true,0);
         
           ans2=c[i];
           dfs(i,false,0);
       
       }
       if(ans!=MOD*MOD)cout<<ans<<endl;
       else cout<<-1<<endl;
    



     }


 


 






    





      

        


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

const int a[32] = {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};

int main()
{
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
l = sorted([A, B, C])
rV = l[0]*l[1]*(l[2]//2)
bV = l[0]*l[1]*(-(-l[2]//2))
print(bV-rV)


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    REP(i, 3){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		Card[] card1 = new Card[n];

		for (int i = 0; i < n; i++) {
			card1[i] = new Card();
			String str = sc.next();
			card1[i].suit = str.substring(0, 1);
			card1[i].rank = Integer.valueOf(str.substring(1, 2));
		}

		Card[] card2 = card1.clone();

		bubble(card1, n);
		selection(card2, n);

		for (int i = 0; i < n; i++) {
			System.out.print(i==0 ? "" : " ");
			System.out.print(card1[i]);
		}
		System.out.println();
		System.out.println("Stable");

		boolean isStable = true;

		for (int i = 0; i < n; i++) {
			if (!(card1[i].suit.equals(card2[i].suit))) {
				isStable = false;
				break;
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(i==0 ? "" : " ");
			System.out.print(card2[i]);
		}
		System.out.println();
		System.out.println(isStable ? "Stable" : "Not stable");

	}

	static void bubble(Card[] card, int n) {
		Card temp = null;
		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j > i; j--) {
				if (card[j].rank < card[j - 1].rank) {
					temp = card[j];
					card[j] = card[j - 1];
					card[j - 1] = temp;
				}
			}
		}

	}

	static void selection(Card[] card, int n) {
		Card temp = null;
		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (card[j].rank < card[minj].rank) {
					minj = j;
				}
			}
			temp = card[i];
			card[i] = card[minj];
			card[minj] = temp;
		}

	}
}

class Card {
	String suit;
	int rank;

	public String toString() {
		return this.suit + this.rank;
	}
}



Measured memory_bytes: 26276
n, k = map(int, input().split())

# n面サイコロ, 全て等確率

# k - 1である限りサイコロ1回振る => コインを続ける
# 面: 2倍
# 裏: ZERO

# 今回勝つ確率 => 1/2 で勝ち続けていくのを計測すればいい

point = 0

dice = float(1/ n)

ans = 0
for i in range(1,n+1):
    point = i
    tmp = 1
    while point < k:
        point = point * 2
        tmp = tmp / 2
    ans += dice * tmp

print(ans)


Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B_fix
# CreatedDate:  2020-09-13 21:10:13 +0900
# LastModified: 2020-09-13 21:11:45 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    a, b, c, d = map(int, input().split())
    unko = []
    unko.append(a*c)
    unko.append(a*d)
    unko.append(b*c)
    unko.append(b*d)
    print(max(unko))



if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
solve :: [Int] -> [Int]
solve [x1, y1, x2, y2] = [x3, y3, x4, y4]
  where vector1to2 = (x2 - x1, y2 - y1)
        vector2to3 = (y1 - y2, x2 - x1)
        x3 = x2 + fst vector2to3
        y3 = y2 + snd vector2to3
        vector3to4 = (x1 - x2, y1 - y2)
        x4 = x3 + fst vector3to4
        y4 = y3 + snd vector3to4

main :: IO ()
main = do
  positions@[x1, y1, x2, y2] <- map read . words <$> getLine
  putStrLn $ unwords $ map show $ solve positions

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
 ll n,m ;cin>> n>>m ;
 vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
 vector<ll> ord(n) ;
 rep(i,n){
     while(A[i]%2==0){
         A[i]/=2 ;
         ord[i]++ ;
     }
 }
 bool ok=1 ;
 rep(i,n-1){
     if(ord[i]!=ord[i+1]) ok=0 ;
 }
 if(ok){
  ll ans=1ll ;
  rep(i,n){
      ans= lcm(ans,A[i]) ;
  }
  ans = ans* pow(2,ord[0]-1) ;
 ll bns= m/ans ;
 cout<< (bns+1)/2 <<endl ;
 }
 else cout<<0<<endl ;
 return 0 ; 
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

llong memo[100001];

template<class Type_k,class Type_p>
Type_p mod_pow(long long n,Type_k k,Type_p p){//n^k(mod p).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return res;
}

int main(){
	int n;
	llong k;
	cin>>n>>k;
	
	REP(i,k+1) memo[i]=mod_pow((llong)i,n,MOD);
	
	vector<llong> num(k+1);
	vector<llong> tmp(k+1);
	for(llong i=k;i>=1;--i){
		int numm=k/i;
		num[i]=memo[numm];
		for(llong j=i+i;j<=k;j+=i){
			num[i]-=num[j];
			while(num[i]<0) num[i]+=MOD;
		}
		tmp[i]=(num[i]*i)%MOD;
	}
	
	llong ans=0;
	REP(i,k) ans=(ans+tmp[i+1])%MOD;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 5640
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
l  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
c = collections.Counter(l)

cmc = c.most_common()

if cmc[0][1] == 1 or len(cmc) == 1:
    print(0)
else:
    cmc = sorted(cmc)[::-1]
    cmc = [(k, v) for k, v in cmc if v >= 2]
    print(cmc[0][0] * (cmc[0][0] if cmc[0][1] >= 4 else cmc[1][0]))



Measured memory_bytes: 22436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;

ll damages[200002];

int main(){
    cin>>n>>d>>m;
    VP vp;
    rep(i,n){
        cin>>x>>h;
        vp.pb({x,h});
    }
    sort(all(vp));
    //尺取り法でx_iが左端の場合の攻撃範囲を求める
    ll bombnum,nowhp,damage;
    rep(i,n){
        rep(j,r+1,n){
            if(vp[j].fi-vp[i].fi<=2*d)r++;
            else break;
        }
        //iからはrまで届く。
        nowhp=vp[i].se-damages[i];
        if(nowhp>0){
            bombnum=((nowhp%m)?nowhp/m+1:nowhp/m);
            sum+=bombnum;
            damage=bombnum*m;
            damages[i]+=damage;
            damages[r+1]-=damage;
        }
        damages[i+1]+=damages[i];
        //rep(i,n+1)d(damages[i]);
    }
    p(sum);
    return 0;
}


Measured memory_bytes: 6000
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(m, n) :
    if m < n :
        m, n = n, m
        
    while n != 0 :
        m, n = n, m % n
    return m

ret = 1
for i in range(N) :
    ret = ret * T[i] // gcd(ret, T[i])
    
print(ret)

Measured memory_bytes: 38384
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
l1=sorted(l)
if n%2==0:
  k=n//2
  sum=0
  for i in range(0,k):
    sum-=2*l1[i]
  for i in range(k,n):
    sum+=2*l1[i]
  sum-=l1[k]
  sum+=l1[k-1]
  print(sum)
else:
  k=n//2
  sum=0
  for i in range(k,n):
    sum+=2*l1[i]
  for i in range(k):
    sum-=2*l1[i]
  sum-=l1[k]
  sum-=l1[k+1]
  sum1=0
  for i in range(k+1,n):
    sum1+=2*l1[i]
  for i in range(k+1):
    sum1-=2*l1[i]
  sum1+=l1[k]
  sum1+=l1[k-1]
  print(max(sum,sum1))

Measured memory_bytes: 8296
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;

typedef int64_t ll;

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

vector<vector<int>> d, c;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, cn;
    cin >> n >> cn;
    for (int i = 0; i < cn; ++i) {
        d.push_back({});
        for (int j = 0; j < cn; ++j) {
            int tmp;
            std::cin >> tmp;
            d.back().push_back(tmp);
        }
    }
    for (int i = 0; i < n; ++i) {
        c.push_back({});
        for (int j = 0; j < n; ++j) {
            int tmp;
            std::cin >> tmp;
            c.back().push_back(tmp-1);
        }
    }


    vector<vector<ll>> iwakans(3,vector<ll>(cn));

    for (int c0 = 0; c0 < cn; ++c0) {
        for (int i = 0; i < c.size(); ++i) {
            for (int j = 0; j < c[i].size(); ++j) {
                int col = i + j + 2;
                col %= 3;
                iwakans[col][c0] += d[c[i][j]][c0];
            }
        }
    }
    ll mini_iwakan = INF;
    for (int c0 = 0; c0 < cn; ++c0) {
        for (int c1 = 0; c1 < cn; ++c1) {
            if(c0 == c1) continue;
            for (int c2 = 0; c2 < cn; ++c2) {
                if(c1 == c2 || c2 == c0) continue;
                ll iwa = iwakans[0][c0] + iwakans[1][c1] + iwakans[2][c2];
                mini_iwakan = min(iwa, mini_iwakan);
            }
        }
    }

    cout << mini_iwakan << endl;


}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	if(Integer.parseInt(str[0])==Integer.parseInt(str[1])){
            		System.out.println("a == b");
            	}else if(Integer.parseInt(str[0])>Integer.parseInt(str[1])){
            		System.out.println("a > b");
            	}else if(Integer.parseInt(str[0])<Integer.parseInt(str[1])){
            		System.out.println("a < b");
            	}
            	/*watch
            	 * int s=Integer.parseInt(line);
            	System.out.println(s/3600+":"+(s/60)%60+":"+s%60);
            	break;*/
            	break;
            }
        }
    }
}

Measured memory_bytes: 24344
#include "bits/stdc++.h"
using namespace std;

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion


int main() {
	ll n, m; put n >> m;
	ll a = n; ll b = m;
	ll ans = 0;
	ans += min(a, b / 2);
	b -= 2 * min(a, b / 2);
	putans(ans + ( b / 4 ));
	return 0;
}



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

int main() {
	ll N;
	cin >> N;
	set<string> X;
	rep(i, N) {
		string A;
		cin >> A;
		X.insert(A);
	}
	cout << X.size() << endl;
}


Measured memory_bytes: 19064
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll d, n;
  cin >> d >> n;
  ll ans = 1;
  REP(i, d) ans *= 100;
  ans *= (n != 100) ? n : (n+1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
import math
def eratos(A):
    isprime = [True for i in range(10**6+1)]
    # isprime[0] = False
    # isprime[1] = False
    for i in set(A):
        if isprime[i]:
            j = i + i
        while j <= 10**6:
            isprime[j] = False
            j = j + i
    return isprime        

N = int(input())
A = list(map(int, input().split()))
countA = Counter(A)
is_prime = eratos(A)
ans = 0
for ai in A:
    # print(ai)
    if is_prime[ai] and countA[ai] < 2:
        ans += 1
print(ans)

Measured memory_bytes: 168908
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int agediv(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    int n;  cin >> n;
    int x = 1, y = 1;
    REP(i,n){
        int a, b; cin >> a >> b;
        int n = max(agediv(x,a),agediv(y,b));
        x = n * a;
        y = n * b;
    }
    cout << x+y << endl;
}

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

using namespace std;

vector<int> num;

int main() {
	
	int n;
	
	while( cin >> n) {
		
		int a;
		num.clear();
		
		for(int i=0;i<n;i++) {
			
			cin >> a;
			num.push_back(a); 
			
		}
		
		for(int i=n;i>1;i--)
		cout << num[i-1] << " ";
		
		cout << num[0] << "\n";
	}
	
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

const int MAX_N=1e5,MAX_SQRTS=3e3;
const ll MAX_S=1e10;

int N;
ll S[MAX_N];

bool pflg[MAX_SQRTS+1];
vector<ll> prime;

void sieve()
{
    memset(pflg,true,sizeof(pflg));
    pflg[0]=pflg[1]=false;
    for (int i=2; i<=MAX_SQRTS; i++)
    {
        if (!pflg[i]) continue;
        prime.push_back(i);
        for (int j=i*2; j<=MAX_SQRTS; j+=i)
        {
            pflg[j]=false;
        }
    }
}

map<ll,int> mp;

int main()
{
    scanf("%d",&N);
    REP(i,N)
    {
        scanf("%lld",&S[i]);
    }
    sieve();
    REP(i,N)
    {
        for(int j=0; j<prime.size(); j++)
        {
            ll p=prime[j];
            while(S[i]%(p*p*p)==0)
            {
                S[i]/=p*p*p;
            }
        }
        mp[S[i]]++;
    }
    int ans=0;
    for(map<ll,int>::iterator ite=mp.begin(); ite!=mp.end(); ite++)
    {
        if (ite->first==1)
        {
            continue;
        }
        ll pa=ite->first*ite->first;
        for(int i=0; i<prime.size(); i++)
        {
            ll p=prime[i];
            while (pa%(p*p*p)==0)
            {
                pa/=p*p*p;
            }
        }
        ans+=max<ll>(ite->second,mp[pa]);
        ite->second=0;
        mp[pa]=0;
    }
    if (mp[1]>0)
    {
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 19456
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,h,m,x,y;
	string	s;
	cin >> a >> b >> h >> m;
	double hh,mm,deg,ans;

	hh = double(h*60+m) / 2.0;
	mm = m*6;

	deg = abs(hh-mm);
	//if (deg > 180) deg -= 180;

	deg = deg * ((double)M_PI/180.0);
	ans = sqrt( a*a + b*b - 2.0*a*b*cos(deg));

	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	printf("%.10f\n",ans);
	//cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4128
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	vector<int> A(SZ(S));

	rep(i, 0, SZ(S))
	{
		A[i] = S[i] - 'a';
	}

	rep(i, 0, 26)
	{
		int l = 0;
		int cnt = 0;
		rep(r, 0, SZ(A))
		{
			if (A[r] == i)
			{
				cnt++;
			}
			else
			{
				cnt--;
			}
			if (cnt < 0)
			{
				cnt = 0;
				l = r+1;
			}
			if (cnt>0&&r - l > 0)
			{
				cout << l + 1 << " " << r + 1 << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << endl;

	return 0;
}

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


void Y()
{
	printf("Yes\n");
}
void N()
{
	printf("No\n");
}

LL gcd(LL x,LL y)
{
	return x%y==0?y:gcd(y,x%y);
}
int main()
{
	//freopen("acmin","r",stdin);
	int T;
	cin>>T;
	while(T--)
	{
		LL a,b,c,d;
		cin>>a>>b>>c>>d;

		if(b>d)
		{
			N();
			continue;
		}
		else if(b==d)
		{
			if(c>=b)
				Y();
			else
			{
				if(a<=c)
					N();
				else
				{
					LL e = (a-c)%b+c;
					if(e<b)
						N();
					else
						Y();
				}
			}
		}
		else
		{
			if(c>=b)
			{
				if(a>=b)
					Y();
				else
					N();
			}
			else
			{
				if(a<b)
					N();
				else
				{
					if((a-c)%b)
						a= (a-c)%b+c-b;
					else
						a=c;
					if(a<0)
					{
						N();
					}
					else
					{
						LL x = d%b;
						if(!x)
							Y();
						else{
							x = gcd(x,b);
							LL e = (b-a)/x,f = (c-a)/x,flag=0;
							for(LL i=f;i<=e;i++)
								if(c-a<i*x&&i*x<b-a)
								{
									flag=1;
									break;
								}
							if(flag)
								N();
							else 
								Y();

						}
					}
				}
			}

		}
	}
	return 0;
}


Measured memory_bytes: 256
# maximum sum of minimum
n=int(input())
node={i:[]for i in range(n+1)}
visited=[False for i in range(n+1)]

#尋ねたことがあるかどうか確認するためのリスト
first=0

for _ in range(n-1):
    a,b=map(int,input().split())
    node[a].append(b)
    node[b].append(a)
    if _==0:
        first+=a
        

dictionary=[0 for i in range(n+1)]
#答を格納するためのリスト
clist=list(map(int,input().split()))
clist=sorted(clist,reverse=True)
counter=0
dictionary[first]=clist[0]
K=sum(clist[1:])
from collections import deque
d=deque()
e=deque()
d.append(first)
visited[first]=True
while d:
    for some in d:
        for point in node[some]:
            if visited[point]==False:
                #まだ訪れたことのない頂点にあった場合
                counter+=1
                visited[point]=True
                dictionary[point]=clist[counter]
                e.append(point)
            else:
                pass
    d=e
    e=deque()
print(K)
print(*dictionary[1:])


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

int main(){long N, M;
cin >> N >> M;
vector<long> a(N + 1); vector<long> b(N + 1);
vector<long> c(M + 1); vector<long> d(M + 1);
erep(i, N) cin >> a.at(i) >> b.at(i);
erep(i, M) cin >> c.at(i) >> d.at(i);
long tmp;
long ans;
erep(i, N){
    tmp = 1e9;
    erep(j, M){
        if(abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j)) < tmp){
            ans = j;
            tmp = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
        }
    }
    cout << ans << endl;
}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        float x1,x2,y1,y2,x3,x4,y3,y4;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        float m1=(y2-y1)/(x2-x1);
        float m2=(y4-y3)/(x4-x3);
        if(m1==m2)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }



    return 0;
}



Measured memory_bytes: 3196
import java.util.*;

public class Main{
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int[] array1 = new int[5];
      int[] array2 = new int[5];
      int sum =0;
      int num =0;
      int max =0;
      for(int i=0; i<5;i++){
        array1[i] = sc.nextInt();
        array2[i] = (array1[i]+9)/10 *10;
        if(max<array2[i]-array1[i]){
          max = array2[i]-array1[i];
          num = i;
        }
      }

      for(int i=0; i<5;i++){
        if(i==num){
          sum += array1[i];
        }else{
          sum += array2[i];
        }
      }

      System.out.println(sum);

   }

}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
typedef long long ll;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;

//#define cerr if (false) cerr

ll n;

vector<ll> possible = {1, 6, 6*6, 6*6*6, 36*36, 36*36*6, 36*36*36, 9, 9*9, 81*9, 81*81, 81*81*9};

bitset<100001> bs; 

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  sort(rall(possible));

  cin >> n;

  bs.set(0);


  for (int cur = 1; ; cur++) {
    bitset<100001> bs2;
    for (auto x: possible) {
      bs2 |= bs << x;
    }
    bs = bs2;
    if (bs.test(n)) {
      cout << cur << endl;
      exit(0);
    }
  }

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <map>
#define COMMAND_MAX_SIZE 7
#define WORD_MAX_SIZE 12
using namespace std;

// 記憶領域にはスタックとヒープがある。
// ## スタック領域
// - コンパイラやOSが自動割り当て、解放を行う。
// - サイズはプログラムをコンパイル、リンクする時点で決まっている。
// - ブロック内のローカル変数はスタック
//
// ## ヒープ領域
// - アプリケーションが必要になった時に確保し、不要になったら解放する。
// - サイズは確保する際に指定する。
// - mallacやcallocはヒープ領域にメモリを確保する。


// スタックはあからじめサイズを決める必要があるので、最大値を想定して確保するため無駄な領域を確保せざるを得ない場合がある。
// スタック領域はOSやコンパイラによるが1MB ~ 数MB程度なので、配列の要素数が1,000,000要素程度になるとスタックオーバーフローを起こす。
// intが32bit(4byte)の場合4MBほどになり確保されているスタック領域から溢れ出してしまう。

// Aは'0'でなく’1'
map<char, int> char_to_int = {{'A', 1}, {'C', 2}, {'G', 3}, {'T', 4}};

int convert_word_to_num(char word[]) {
  int word_size = strlen(word);
  int num = 0;

  for(int i = 0; i < word_size; i++) {
    num += char_to_int[word[i]] * pow(char_to_int.size(), i);
  }

  return num;
}


int main() {
  int command_num;
  // 4^12 == 16777216 is true
  bool dictionary[16777216] = {};

  scanf("%d", &command_num);

  for(int i = 0; i < command_num; i++) {
    char command[COMMAND_MAX_SIZE + 1];
    scanf("%s", command);

    if(command[0] == 'i') {
      char word[WORD_MAX_SIZE + 1];
      scanf("%s", word);

      dictionary[convert_word_to_num(word)] = true;
    } else if(command[0] == 'f') {
      char word[WORD_MAX_SIZE + 1];
      scanf("%s", word);

      bool is_found = dictionary[convert_word_to_num(word)];

      if (is_found) {
        puts("yes");
      } else {
        puts("no");
      }
    }
  }
}



Measured memory_bytes: 19712
import scala.io.StdIn

object Main{
  def fib(prev: (Long, Long), pos: Int)(n: Int): Long = {
    if(n < 2) 1
    else if(pos >= n) prev._1 + prev._2
    else fib((prev._2, prev._1+prev._2), pos+1)(n)
  }

  def main(args: Array[String]) {
    val n = StdIn.readInt()
    println(fib((1,1), 2)(n))
    //(0 to 10).map(fib((1,1), 2)).foreach(println)
  }
}

Measured memory_bytes: 43720