akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];
        for (int i = 0; i < 3; i++) {
            arr[i] = sc.nextInt();
        }

        // 1. 1つ選んで1減らす or 2. 2つ増やすと同じ
        // 最小回数は出来るだけ、2を使うこと
        Arrays.sort(arr);

        int cnt = 0;

        // 2.
        cnt += (arr[2] - arr[0]) / 2;
        arr[0] += ((arr[2] - arr[0]) / 2) * 2;

        cnt += (arr[2] - arr[1]) / 2;
        arr[1] += ((arr[2] - arr[1]) / 2) * 2;

        // 1.
        // x - 1, x - 1 , x
        // x - 1, x     , x
        // x    , x     , x
        if (arr[0] == arr[1] && arr[1] != arr[2]) {
            cnt += 1;
        } else if (arr[0] != arr[1]) {
            cnt += 2;
        }

        out.println(cnt);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

bool is_palindrome(string_view prefix, string_view suffix) {
    string_view s = prefix.empty() ? suffix : prefix;
    REP(i, s.size()/2) {
        if (s[i] != s[s.length()-i-1]) {
            return false;
        }
    }
    return true;
}

int common_length(string_view prefix, string_view suffix) {
    int i = 0, j = suffix.length() - 1;
    while (i < (int)prefix.length() && j >= 0 && prefix[i] == suffix[j]) {
        ++i; --j;
    }
    return i;
}

int main() {
    int N; cin >> N;
    vector<string> S(N);
    vector<int64_t> C(N);
    REP(i, N) cin >> S[i] >> C[i];

    // (prefix, suffix) を状態として持つ。
    // ただし prefix == "" || suffix == "" でなければならない。
    struct State {
        string_view prefix;
        string_view suffix;
        bool start;
        int64_t weight;
        bool operator<(const State& rhs) const noexcept {
            return weight > rhs.weight;
        }
    };

    priority_queue<State> Q;
    set<tuple<string_view, string_view, bool>> visited;
    map<tuple<string_view, string_view, bool>, int64_t> dist;

    Q.push({"", "", true, 0});
    dist.insert({{"", "", true}, 0});

    int64_t ans = numeric_limits<int64_t>::max();
    while (!Q.empty()) {
        auto [prefix, suffix, start, _] = Q.top(); Q.pop();

        if (auto it = visited.find({prefix, suffix, start}); it != visited.end()) {
            continue;
        }
        visited.insert({prefix, suffix, start});
        if (!start && is_palindrome(prefix, suffix)) {
            ans = dist[{prefix, suffix, start}];
            break;
        }

        REP(i, N) {
            string_view new_prefix = prefix.empty() ? S[i] : prefix;
            string_view new_suffix = prefix.empty() ? suffix : S[i];
            int l = common_length(new_prefix, new_suffix);
            if (l != (int)new_prefix.length() && l != (int)new_suffix.length()) {
                continue;
            }
            new_prefix = new_prefix.substr(l);
            new_suffix = new_suffix.substr(0, new_suffix.length() - l);
            int64_t new_dist = dist[{prefix, suffix, start}] + C[i];
            if (auto it = dist.find({new_prefix, new_suffix, false}); it != dist.end() && new_dist >= it->second) {
                continue;
            }
            dist[{new_prefix, new_suffix, false}] = new_dist;
            Q.push({new_prefix, new_suffix, false, new_dist});
        }
    }

    if (ans == numeric_limits<int64_t>::max()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3724
#include <stdio.h>

int main(){

  int n,m,l,s,A[100][100],B[100][100],i,j,k;
  long long sum;
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&s);
      A[i][j]=s;
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&s);
      B[i][j]=s;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      sum=0;
      for(k=0;k<m;k++)sum += A[i][k]*B[k][j];
      printf("%lld",sum);
      if(j+1!=l)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 680
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.valueOf(sc.next());
    int b = Integer.valueOf(sc.next());

    if (a < b) {
        for (int i = 0; i < b; i++) {
            System.out.print(a);
        }
        System.out.println();
      } else {
        for (int i = 0; i < a; i++) {
            System.out.print(b);
        }
        System.out.println();
      }
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <bitset>
#include <complex>
using namespace std;
int main(int argc, char *argv[]) {
  while (true) {
  int n, n2;
  cin >> n;
  if (n == 0) break;
  n2 = n + n;
  
  bitset<246912> p;
  vector<int> vec;

    int root = sqrt(n2);
    p[0] = true;
    p[1] = true;
    p[2] = true;
    int first;
    first = 2;
    
    while (true) {
      for (size_t i = first; i <= n2; i+=first) {
	p[i] = true;
      }
      vec.push_back(first);
      size_t j = first;
      while (p[j]) {
	j++;
      }
      first = j;
      if ( root < first )
	break;
    }
    for (size_t i = first; i <= n2; i++)
      if (!p[i])
	vec.push_back(i);
    bool f,e;
    f = false;
    e = false;
    int x,y;
    for (size_t i = 0; i < vec.size(); i++) {
      // cout << vec[i] << endl;
      if (!f && vec[i] > n) {
	f = true;
	x = i;
      }
      if(vec.size()-1 == i) {
	y = i;
	break;
      }
      if (!e && vec[i] >= n2) {
	e = true;
	y = i;
	break;
      }
    }
    cout << y-x+1 << endl;
  }
			      
  return 0;
}

Measured memory_bytes: 3184
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int i1 = sc.nextInt();

        List<Integer> listX = new ArrayList<>();
        List<Integer> listY = new ArrayList<>();

        for (int i = 0; i < i1; i++) {
            listX.add(sc.nextInt());
        }

        for (int i = 0; i < i1; i++) {
            listY.add(sc.nextInt());
        }
        int max = 0;

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

            int tmpMax = 0;

            for (int j = 0; j < i1; j++) {
                if (i > j) {
                    tmpMax = tmpMax + listX.get(j);
                } else if (i == j) {
                    tmpMax = tmpMax + listX.get(j);
                    tmpMax = tmpMax + listY.get(j);
                } else {
                    tmpMax = tmpMax + listY.get(j);
                }
            }
            if (max < tmpMax) {
                max = tmpMax;
            }
        }
        System.out.println(max);
    }
}



Measured memory_bytes: 23124
import sys
input = sys.stdin.readline

N = int(input())
I = input()

R =0
G =0
B =0
for i in range(N):
    if (I[i] == 'R'):
        R+=1
    if (I[i] == 'G'):
        G+=1
    if (I[i] == 'B'):
        B+=1


sum = R * G * B

for i in range(N):
    for j in range(i+1,N):
        if I[i] != I[j]:
            k = j + j - i
            if k >= N:
                continue
            if I[i] != I[k] and I[j] != I[k]:
                sum -= 1

print(sum)

Measured memory_bytes: 9220
/**
 *   created: 24 November 2019  09:33:01
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define int long long
#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int32_t main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT",};
		string s;
		cin>>s;
		if(s=="SUN"){
			cout<<7;
			return 0;
		}
		int ind =0;
		while(v[ind]!=s)
			ind++;
		int cnt = 0;
		while(v[ind]!="SUN"){
			ind++,cnt++;
			ind %= v.size();
		}
		cout<<cnt;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.contentEquals("Sunny")) System.out.println("Cloudy");

		if(s.contentEquals("Cloudy")) System.out.println("Rainy");

		if(s.contentEquals("Rainy")) System.out.println("Sunny");
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
int ans=0,N;
void dfs(int A){
	ll B[3]={A*10+3,A*10+5,A*10+7};
	REP(i,3){
		int X=B[i];
		//cout<<X<<endl;
		bool C[3]={true,true,true};
		while(X>0){
			//cout<<X<<endl;
			if(X%10==3)C[0]=false;
			if(X%10==5)C[1]=false;
			if(X%10==7)C[2]=false;
			X/=10;
		}
		bool F=true;
		REP(i,3){
			if(C[i]){
				F=false;
				//cout<<i<<endl;
			}
		}
		if(F && B[i]<=N){
			ans++;
			//cout<<B[i]<<endl;
		}
		if(B[i]*10<=N)dfs(B[i]);
	}
}
	
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	cin>>N;
	int a[3]={3,5,7};
	REP(i,3){
		dfs(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()};
var stdout = [];
function print(x){stdout.push(x)};


var tmp = input().split(" ").map(n=>parseInt(n));
var t = tmp[0];
var x = tmp[1];
print(t / x);


stdout = stdout.join("\n");
console.log(stdout);

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

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

int main(){
  int N;cin >> N;
  int A[N];
  rep(i, N)cin >> A[i];
  int right[N+1],left[N+1];//right[i] : N - i - 1より右にあるやつの最大値right[N-1] = 0
  //left[i]iより左にあるやつの最大値left[0] = 0
  right[0] = 0;
  left[0] = 0;
  for(int i = 1;i <= N;++i){
    left[i] = max(left[i - 1], A[i-1]);
    right[i] = max(right[i - 1], A[N-i]);
  }
  rep(i, N)cout << max(right[N-i - 1], left[i]) << endl;
}


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


int main(){
  int n,m,c;cin>>n>>m>>c;
  int b[m];rep(i,m)cin>>b[i];
  int ans=0;
  int a[n][m];
    rep(i,n){
      int sum=0;
      rep(j,m){
        cin>>a[i][j];
        sum += a[i][j]*b[j];
      }
      if(sum+c>0)ans ++;
    }
  cout <<ans;
}




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

typedef unsigned long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

void fail() {
	cout << -1 << endl;
	exit(0);
}

bool get(ll x, ll k) {
	return (x >> k) & 1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl s(n), t(n), u(n), v(n);
	FOR(i,0,n) cin >> s[i];
	FOR(i,0,n) cin >> t[i];
	FOR(i,0,n) cin >> u[i];
	FOR(i,0,n) cin >> v[i];
	
	vvl res(n, vl(n));

	FOR(k,0,64) {
		vector<vector<int>> a(n, vector<int>(n, -1));
		
		auto fix = [&](ll i, ll j, int x) {
			if (a[i][j] != -1) {
				if (a[i][j] != x) fail();
			} else {
				a[i][j] = x;
			}
		};

		FOR(i,0,n) if (s[i] != get(u[i],k)) {
			FOR(j,0,n) fix(i, j, get(u[i],k));
		}
		
		FOR(j,0,n) if (t[j] != get(v[j],k)) {
			FOR(i,0,n) fix(i, j, get(v[j],k));
		}
		
		set<ll> is, js;
		FOR(i,0,n) FOR(j,0,n) if (a[i][j] == -1) {
			is.insert(i), js.insert(j);
		}
		
		if (sz(is) == 1) {
			ll i = *begin(is);
			for (ll j: js) {
				bool sat = false;
				FOR(ii,0,n) if (ii != i && a[ii][j] == t[j]) sat = true;
				fix(i, j, sat ? s[i] : t[j]);
			}
		} else if (sz(js) == 1) {
			ll j = *begin(js);
			for (ll i: is) {
				bool sat = false;
				FOR(jj,0,n) if (jj != j && a[i][jj] == s[i]) sat = true;
				fix(i, j, sat ? t[j] : s[i]);
			}
		} else {
			ll ci = 0;
			for (ll i: is) {
				ll cj = 0;
				for (ll j: js) {
					fix(i, j, (ci+cj)%2);
					cj++;
				}
				ci++;
			}
		}
		
		FOR(i,0,n) FOR(j,0,n) {
			assert(a[i][j] != -1);
			res[i][j] |= ll(a[i][j]) << k;
		}
	}
	
	FOR(i,0,n) {
		ll x = res[i][0];
		FOR(j,0,n) if (!s[i]) x = x & res[i][j]; else x = x | res[i][j];
		if (x != u[i]) fail();
	}
	FOR(j,0,n) {
		ll x = res[0][j];
		FOR(i,0,n) if (!t[j]) x = x & res[i][j]; else x = x | res[i][j];
		if (x != v[j]) fail();
	}

	FOR(i,0,n) FOR(j,0,n) cout << res[i][j] << " \n"[j+1==n];

}



Measured memory_bytes: 8596
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

const int INF = 1 << 30;

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

    vector<int> b(n), x(n), y(n);
    for (int i = 0; i < n; ++i)
      cin >> b[i] >> x[i] >> y[i];

    vector<vector<pair<int, double> > > cost(1001);
    for (int i = 0; i < n; ++i) {
      for (int j = i+1; j < n; ++j) {
	int dist = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
	if (dist <= 50*50) {
	  cost[b[i]].push_back(make_pair(b[j], sqrt(dist)));
	  cost[b[j]].push_back(make_pair(b[i], sqrt(dist)));
	}
      }
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
      int s, g;
      cin >> s >> g;

      bool valid = false;
      priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que;
      que.push(make_pair(0, s));
      vector<double> dp(1001, 1e10);
      vector<int> path(1001, -1);
      while (!que.empty()) {
	const pair<double, int> v = que.top();
	que.pop();

	if (v.second == g) {
	  valid = true;
	  break;
	}

	if (dp[v.second] < v.first)
	  continue;

	dp[v.second] = v.first;
	for (unsigned int j = 0; j < cost[v.second].size(); ++j) {
	  double next = v.first + cost[v.second][j].second;
	  if (dp[cost[v.second][j].first] > next) {
	    dp[cost[v.second][j].first] = next;
	    que.push(make_pair(next, cost[v.second][j].first));
	    path[cost[v.second][j].first] = v.second;
	  }
	}
      }

      if (valid) {
	vector<int> ans;
	for (int j = g; j != -1; j = path[j])
	  ans.push_back(j);
	reverse(ans.begin(), ans.end());
	for (int j = 0; j < ans.size()-1; ++j)
	  cout << ans[j] << " ";
	cout << ans.back() << endl;
      } else {
	cout << "NA" << endl;
      }
    }

  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a*b*1%2==1||a*b*2%2==1||a*b*3%2==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int dp[1000010][2];

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.length();

  rep(i, 1000010) rep(j, 2) {
    dp[i][j] = INF;
  }
  dp[0][0] = 0;
  rep(i, n) rep(j, 2) {
    int ni = i + 1;
    int c = s[i] - '0';
    c += j;
    if (c < 10) chmin(dp[ni][0], dp[i][j] + c);
    if (c > 0)  chmin(dp[ni][1], dp[i][j] + (10 - c));
  }
  cout << dp[n][0] << endl;
}

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

int main(){
  
  long long n;
  long long tmp;
  long long count = 0;
  long long que=-1;
  char *str;
  
  cin>>n;
  que = n;
  tmp = que;
  count = 1;
  while(que){
    que /= 26;
    count++;
  }
  
  str = (char *)malloc(count);
  que = n;
  //tmp = que;
  count = 0;
  while( que > 0){
  	que--;
    //tmp %= 26;
    
    //cout << tmp << " " << que <<endl;
    str[ count++ ] = 'a'  + (que%26); 
    que /= 26;
    //tmp = que;
  }

  
  for(long long i=count-1; i>=0; i--)
  	cout << str[i];
  
  return 0;
  
}


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

void Main()
{
	string tmp, s; cin >> tmp >> s >> tmp;
	cout << "A" << s[0] << "C" << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    int score_T = 0, score_H = 0;
    int round_num;
    scanf("%d", &round_num);
    int i;
    for(i=0; i<round_num; i++){
        char str_T[105], str_H[105];
        scanf("%s %s", str_T, str_H);
        if(!strcmp(str_T, str_H)){
            score_T += 1;
            score_H += 1;
        }
        else if(strcmp(str_T, str_H)>0)
            score_T += 3;
        else
            score_H += 3;
    }
    printf("%d %d\n", score_T, score_H);
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
using namespace std;
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;


int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> data(h,vector<char>(w));
    rep(i,h) {
        rep(j,w) {
            cin >> data.at(i).at(j);
        }
    }
    rep(i,h) {
        int count = 0;
        while(count != 2) {
            rep(j,w) {
                cout << data.at(i).at(j);
            }
            cout << endl;
            count++;
        }
    }
     return 0;
    }


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

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

  int A, B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/abc137/tasks/abc137_a
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int a, b;
		cin >> a >> b;
		int ans = a + b;
		ans = max(ans, a * b);
		ans = max(ans, a - b);
		cout << ans << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 256
include Math
require 'prime'

n = gets.to_i
root_prime = Prime.each(10000).to_a
c = 0

n.times {
  catch(:next) do
    x = gets.to_i
    if (x <= 10000)
      c += 1 if (root_prime.include?(x))
      throw :next
    end
    xs = sqrt(x).floor
    root_prime.each{ |rp|
      break if (rp > xs)
      throw :next if (x % rp == 0)
    }
    c += 1
  end
}
puts c

Measured memory_bytes: 9028
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll a, b;
	cin >> a >> b;
	if(a <= 5) co(0);
	else if(a <= 12) co(b/2);
	else co(b);

	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

template <typename T> void s_min(T& a, T b) {
	if (a > b) a = b;
}

template <typename T> void s_max(T& a, T b) {
	if (a < b) a = b;
}

const ll INF = 1e18;

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

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<ll> dp(n, 0);
	for (int i = 1; i < n; i++) {
		dp[i] = INF;
		for (int j = 1; j <= min(i, 2); j++) {
			s_min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 4592
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine( );
 
        s = s.replaceAll("eraser", "");
        s = s.replaceAll("erase", "");
        s = s.replaceAll("dreamer", "");
        s = s.replaceAll("dream", "");

        if(s.equals("")){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

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

using namespace std;


bool funcao(int a, int b){
    return (a < b);
}

int main(){

    string s;

    cin >> s;
    
    if(s.size() & 1 != 0){
        s.resize(s.size() - 1);
    } else{
        s.resize(s.size() - 2);
    }

    for(int i = s.size(); i >= 0; i -= 2){
        if(s.substr(0, i/2) == s.substr(i/2, i/2))
            break;
        else
            s.resize(i-2);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a;
 cin >> a;
 string s;
 cin >> s;
 int count = 0;
 rep(i,a){
   if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
     count ++;
   }
 }
 cout << count << endl;
 return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod

    def combination(self, n, r):
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod

    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod

    def factorial(self, i):
        return self.fac[i]

    def invfactorial(self, i):
        return self.invfac[i]


def main():
    n, k = mi()
    mod = 10**9 +7
    c = Combination(n)
    for i in range(k):
        if n-k < i:
            print(0)
            continue
        tmp = c.combination(n-k+1, i+1)
        tmp *= c.combination(k-1, i)
        tmp %= mod
        print(tmp)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9352
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0 ; i < n ; i++){
            a[i] = sc.nextInt() - 1;
        }
        sc.close();
        int yono = 0;
        for(int i = 0 ; i < n ; i++){
            if(i == a[a[i]]){
                yono++;
            }
        }
        System.out.println(yono / 2);
    }
}

Measured memory_bytes: 59844
#include <iostream>
 
int main(){
     
    long double x1,y1,x2,y2,x3,y3,x4,y4;
int a;
    std::cin>>a;
    for(int s=0;s<a;s++){
        std::cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)){
            std::cout<<"YES"<<std::endl;
        }else{
            std::cout<<"NO"<<std::endl;
        }
         
    }
    return 0;
}
 

Measured memory_bytes: 3080
S=input()
if 1 <= int(S[:2]) <=12 and 1 <= int(S[2:]) <= 12:
  print("AMBIGUOUS")
elif 1 <= int(S[:2]) <= 12:
  print("MMYY")
elif 1 <= int(S[2:]) <= 12:
  print("YYMM")
else:
  print("NA")

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  int cnt = 1;
  int ans = 0;
  rep(i,n){
    if(a[i] == cnt){
      cnt++;
    }
    else{
      ans++;
    } 
  }

  if(ans == n) ans = -1;

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int H, A;
    cin >> H >> A;
    cout << (H+A-1)/A <<endl;
    
  	return 0;
}



Measured memory_bytes: 256
function Main(input){
	input=input.trim().split(" ");
	let a = parseInt(input[0], 10);
	let b = parseInt(input[1], 10);
	let d = a / b | 0;
	let r = a % b;
	let f = a / b;
	console.log("%d %d %d",d, r, f.toFixed(6));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15404
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, l, r;
    cin >> n;
    vector<ll> left;
    vector<ll> right;
    for(int i = 0; i < n; i++) {
        cin >> l >> r;
        left.push_back(l);
        right.push_back(r);
    }
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());
    if (n % 2 == 1) {
        cout << abs(left[n/2]-right[n/2]) + 1 << endl;
    } else {
        cout << abs((left[n/2]+left[n/2-1]) - (right[n/2]+right[n/2-1])) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6644
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ok -5


// included '_'

//string HOGE("_.!\"#&%&'()*+,-/:;<=>?"); // ok more -5
//string HOGE("_.!\"#&%&'()*+,-/:"); // ok more -5 
//string HOGE("_.!\"#&%"); // ok more -5 
//string HOGE("_.!"); // bad 
//string HOGE("_.!\"#&%"); // bad 
//string HOGE("_.!\"#&%&'()"); // ok
//string HOGE("_.!\"#&%&'("); // ok
string HOGE("_.!\"#&%&'"); // ok


int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1224
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()

	ans=[0]*(10**4+10)

	for x in range(1,105):
		for y in range(1,105):
			for z in range(1,105):
				a=x**2+y**2+z**2+x*y+y*z+z*x
				if a<=10**4:
					ans[a]+=1

	for i in range(1,n+1):
		print(ans[i])









if __name__ == "__main__":
	main()


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

const int N = 50;
int d[N], t[N];

int main(){
	int n, r, p, c;
	while(cin >> n >> r, n){
		for(int i = 0;i < n;++i){
			d[i] = n - i;
			t[i] = 0;
		}
		for(int i = 0;i < r;++i){
			cin >> p >> c;
			for(int j = 0;j < n;++j){
				if(j < c){
					t[j] = d[p - 1 + j];
				}
				else if(j < p - 1 + c){
					t[j] = d[j - c];
				}
				else{
					t[j] = d[j];
				}
			}
			for(int j = 0;j < n;++j){
				d[j] = t[j];
				t[j] = 0;
			}
		}
		cout << d[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] > threshold:
            right = mid
        else:
            left = mid
    return right

ans = 0

BtoC = [None] * N
for i in range(0, N):
    BtoC[i] = N - binsearch(B[i], C)
#print(BtoC)

cumulative=[0]
for i in range(N):
    cumulative.append(cumulative[i] + BtoC[N-i-1])
#print(cumulative)
cumulative.reverse()
#print(cumulative)

for j in range(0, N):
    temp = binsearch(A[j], B)
    ans += cumulative[temp]

print(ans)

Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
double dp[301][301][301];

int main()
{
    int n,i,j,k,x=0,y=0,z=0;
    cin>>n;
    fo(i,0,n)
    {
        cin>>k;
        if(k==1) x++;
        else if(k==2) y++;
        else z++;
    }
    fo(i,0,n+1)
    {
        fo(j,0,n+1)
        {
            fo(k,0,n+1)
            {
                if(k>0) dp[i][j][k]+=(k)*(dp[i][j][k-1]);
                if(j>0) dp[i][j][k]+=(j)*(dp[i][j-1][k+1]);
                if(i>0) dp[i][j][k]+=(i)*(dp[i-1][j+1][k]);
                if(i+j+k>0) {
                    dp[i][j][k]=(n+dp[i][j][k])/((double)(i+j+k)) ;
                }
            }
        }
    }
    cout<<fixed<<setprecision(15)<<dp[z][y][x]<<endl;
}


Measured memory_bytes: 213248
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
long long dp[101][5][2];
int main()
{
	string n;
	int k;
	cin >> n >> k;
	dp[0][0][1] = 1;
	for(int i = 0; i < n.size(); ++i)
	{
		for(int j = 0; j <= k; ++j)
		{
			for(int l = 0; l < 2; ++l)
			{
				for(int m = (l ? n[i] - '0' : 9); m > 0; --m)
				{
					dp[i + 1][j + 1][l & (m == n[i] - '0')] += dp[i][j][l];
				}
				dp[i + 1][j][l & (0 == n[i] - '0')] += dp[i][j][l];
			}
		}
	}
	cout << dp[n.size()][k][0] + dp[n.size()][k][1] << "\n";
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int a; cin >> a;
	cout << a + a * a + a * a*a << endl;
}

Measured memory_bytes: 3620
from copy import deepcopy


def printer(A):
    ret = str(A[0][1]) + str(A[0][0])
    for i in range(1, len(A)):
        ret += " " + str(A[i][1]) + str(A[i][0])
    print(ret)
    return True


def devide(card):
    ret = []
    for c in card:
        num = int(c[1])
        pic = c[0]
        ret.append((num, pic))
    return ret


def bubblesort(A):
    ret = 0
    flag = True
    num = len(A)
    while flag is True:
        flag = False
        for i in reversed(range(1, num)):
            if A[i - 1][0] > A[i][0]:
                tmp = A[i - 1]
                A[i - 1] = A[i]
                A[i] = tmp
                flag = True
                ret += 1
                # print(A)
        # num -= 1
    return ret


def selection_sort(A):
    ans = 0
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[minj][0] > A[j][0]:
                minj = j
        if i != minj:
            ans += 1
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
    return ans


def isStable(card, sorted_card):
    if len(card) != len(sorted_card):
        return False
    for i in range(len(card)):
        c = card[i]
        s = sorted_card[i]
        if c[0] != s[0] or c[1] != s[1]:
            return False
    return True


n = int(input())
card = list(map(str, input().split()))

card = devide(card)
card_bubble = deepcopy(card)
card_selection = deepcopy(card)

bubblesort(card_bubble)
selection_sort(card_selection)

# print(card_bubble)
printer(card_bubble)
print("Stable")

printer(card_selection)
if isStable(card_bubble, card_selection) is True:
    print("Stable")
else:
    print("Not stable")


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

constexpr ll INF = 1LL << 60;

int main(void) {
    ll N;
    cin >> N;

    // dp[i]: i円を引き出すために必要な最小の回数
    vecll dp(N + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);

        ll n = 6;
        while (i + n <= N) {
            dp[i + n] = min(dp[i + n], dp[i] + 1);
            n *= 6;
        }

        n = 9;
        while (i + n <= N) {
            dp[i + n] = min(dp[i + n], dp[i] + 1);
            n *= 9;
        }
    }

    cout << dp[N] << endl;
    return 0;
}


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

int main()
{   
    int A,B;
    cin >> A >> B;
    switch (A*B)
    {
    case 2:cout << 3 <<endl; break;
    case 3:cout << 2 <<endl; break;
    case 6:cout << 1 <<endl; break;
    }
}

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

int main(){
  int a, b, Ccm; // Circular measure
  double s, l, h, crad; // radian
  double pi = acos(-1); // pi = 3.1415926535...
  
  cin >> a >> b >> Ccm;

  crad = pi / 180 * Ccm;
  s = a * b * sin(crad) / 2;
  l = a + b + sqrt( a*a + b*b - 2 * a * b * cos(crad) );
  h = 2 * s / a; // OR h = b * sin(crad);
  
  printf("%f\n%f\n%f\n", s, l, h);
  
  return 0;
}

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

using namespace std;

int N, A, B, C;
vector<int> L;

int solve(int n, int a, int b, int c) {
  if (n == N) {
    if (a == 0 or b == 0 or c == 0) {
      return 1e9;
    }
    return abs(A - a) + abs(B - b) + abs(C - c) - 30;
  }
  int s1 = solve(n + 1, a, b, c);
  int s2 = solve(n + 1, a + L[n], b, c) + 10;
  int s3 = solve(n + 1, a, b + L[n], c) + 10;
  int s4 = solve(n + 1, a, b, c + L[n]) + 10;
  return min(s1, min(s2, min(s3, s4)));
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (auto &l : L) cin >> l;
  cout << solve(0, 0, 0, 0) << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
n = int(input())

def isPrime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

def f(n):
    if n == 0:
        return 0
    i = 1
    while not(i * (i + 1) // 2 <= n and n < (i + 1) * (i + 2) // 2):
        i += 1
    return i

p = {}

answer = 0
if n % 2 == 0:
    c = 0
    while n % 2 == 0:
        n //= 2
        c += 1
    answer += f(c)

q = 3
while q * q <= n:
    c = 0
    while n % q == 0:
        n //= q
        c += 1
    answer += f(c)
    q += 2

if n > 1:
    answer += 1
print(answer)

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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  100000000000000007

typedef long double ld;

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

int w,h;


ld sp_calc(vector<string> &v,vector<vector<ld> > &dp){
	ld ans = 0;
	ld d = 0.0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(v[i][j]=='.'){
				d += 1.0;
				ans += dp[i][j];
			}
		}
	}
	ans /= d;
	return ans;
}


int main(){
	cin >> w >> h;
	vector<string> v(h);
	for(int i=0;i<h;i++){
		cin >> v[i];
	}
	vector<vector<ld> > d1(h,vector<ld>(w,inf)),d2(h,vector<ld>(w,inf)),dp(h,vector<ld>(w));
	queue<pair<int,int> > q1,q2;
	int x_s,y_s;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(v[i][j]=='g'){
				d1[i][j] = 0.0;
				q1.push(MP(i,j));
			}
			if(v[i][j]=='*'){
				d2[i][j] = 0.0;
				q2.push(MP(i,j));
			}
			if(v[i][j]=='s'){
				x_s = i;
				y_s = j;
				v[i][j] = '.';
			}
		}
	}
	while(!q1.empty()){
		pair<int,int> p;
		p = q1.front();
		q1.pop();
		int x,y;
		x = p.first;
		y = p.second;
		for(int i=0;i<4;i++){
			if(v[x+dx[i]][y+dy[i]]=='.'){
				if(d1[x+dx[i]][y+dy[i]]==inf){
					d1[x+dx[i]][y+dy[i]] = d1[x][y]+1.0;
					q1.push(MP(x+dx[i],y+dy[i]));
				}
			}
		}
	}

	while(!q2.empty()){
		pair<int,int> p;
		p = q2.front();
		q2.pop();
		int x,y;
		x = p.first;
		y = p.second;
		for(int i=0;i<4;i++){
			if(v[x+dx[i]][y+dy[i]]=='.'){
				if(d2[x+dx[i]][y+dy[i]]==inf){
					d2[x+dx[i]][y+dy[i]] = d2[x][y]+1.0;
					q2.push(MP(x+dx[i],y+dy[i]));
				}
			}
		}
	}

	if(d2[x_s][y_s]==inf){
		cout << fixed << setprecision(15) << d1[x_s][y_s] << endl;
		return 0;
	}
	ld up = 100000000000.0;
	ld low = 0.0;
	ld mid;
	int counter = 0;
	while(1){
		counter++;
		if(counter >1000)break;
		mid = (up+low)/2.0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				dp[i][j] = 0.0;
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(d1[i][j]<d2[i][j]+mid){
					dp[i][j] = d1[i][j];
				}else{
					dp[i][j] = d2[i][j]+mid;
				}
			}
		}
		if(sp_calc(v,dp)>mid){
			low = mid;
		}else{
			up = mid;
		}
	}
	cout << fixed << setprecision(15) << dp[x_s][y_s] << endl; 
	return 0;
}

Measured memory_bytes: 15216
#include <stdio.h>
void Shortest(int,int);
int n,u,d[100],k[100],v[100][100],c[100][100];
int main(){
  int i,j,u;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k[u]);
    for(j=0;j<k[u];j++){
      scanf("%d %d",&v[u][j],&c[u][j]);
    }
  }
  for(i=0;i<n;i++){
    d[i] = 1000000;
  }
  Shortest(0,0);
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}
void Shortest(int p,int x){
  int i;
  d[p] = x;
  for(i=0;i<k[p];i++){
    if(d[v[p][i]] > x+c[p][i]){
      Shortest(v[p][i],x+c[p][i]);
    }
  }
  return;
}



Measured memory_bytes: 2056
N = int(input())
A = list(map(int, input().split()))

tmp = []
index = 0

for i in range(N):
  tmp.append([index, A[i]])
  if N % 2:
    if index <= 0:
      index = - index + 1
    else:
      index *= -1
  else:
    if index >= 0:
      index = - index - 1
    else:
      index *= -1

tmp.sort()
#print("tmp:", tmp)

answer = []
for i in range(N):
  answer.append(tmp[i][1])
print(*answer)

Measured memory_bytes: 123348
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
ll a,b;
/**/
ll solve(ll x)
{
	if(x==-1) return 0;
	ll tmp=x,len=0;
	while(tmp) {++len; tmp>>=1ll;}
	ll ans=0;
	for(ll i=1ll;i<=len;i++)
	{
		ll tt=(i==1ll?(x%4ll)+1ll:(x%(1ll<<i))+1ll);
		if(i==1ll) ans|=((tt==2ll)|(tt==3ll));
		else
		{
			tt-=(1ll<<(i-1ll));
			if(tt>0&&tt&1ll) ans|=(1ll<<(i-1ll));
		}
	}
	return ans;
}
int main()
{
	cin>>a>>b;
	ll c=solve(b),d=solve(a-1);
	cout<<(c^d);
	return 0;
}

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

using namespace std;

int a[4][1000];	

int main() {
	int n;
	cin >> n;
	for(int i = 0 ; i < 3 ; i++)
		for(int j = 0 ; j < n - ((i > 1) ? 1 : 0) ; j++)
			cin >> a[i][j];
	int ans = 0; 
	for(int i = 0 ; i < n ; i++) {
		ans += a[1][i];
	}
	for(int i = 0 ; i < n - 1; i++) {
		if(a[0][i] + 1 == a[0][i + 1]) ans += a[2][a[0][i] - 1];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#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 int long long
const int MOD=1e9+7;
const int INF=1e20;

signed main(){
    string S;
    cin>>S;
    int am=INF;
    int zm=0;
    REP(i,S.size()){
        if(S[i]=='A')am=min(am,i+1);
        if(S[i]=='Z')zm=max(zm,i+1);
    }
    cout<<zm-am+1<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i)
    cin >> v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n;++i){
    if(v[i]==v[i+1]){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.arange(1, N+1)
A = A[A%3 != 0]
A = A[A%5 != 0]
answer = A.sum()
print(answer)


Measured memory_bytes: 43192
#include <stdio.h>

int main(void)
{
  int S, hour, minuite, second;

  scanf("%d", &S);
  hour = S / (60 * 60);
  S = S % (60 * 60);
  minuite = S / 60;
  S = S % 60;
  second = S;

  printf("%d:%d:%d\n", hour, minuite, second);

  return 0;
}

Measured memory_bytes: 592
import sys

s = input()
t = input()
s_len = len(s)
t_len = len(t)
index_list = [0]*t_len
rt1 = 0
rt2 = 0
s = s + s
for m in range(t_len):
	rt1 = s.find(t[m],rt1)
	if rt1 == -1:
		print(rt1)
		sys.exit()
	else:
		#rt1 = rt1 % s_len + 1
		#index_list[m] = rt1
		if rt1 < s_len:
			pass
		else:
			rt1 = rt1 % s_len
			rt2 += 1
	rt1 += 1
rt = rt1 + rt2 * s_len
print(rt)

Measured memory_bytes: 4340