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

int main(){
    int n,m;
    cin >> n >> m;
    int wa[n+1];
    bool ac[n+1];
    for(int i=1;i<=n;i++){
        wa[i]=0;
        ac[i]=false;
    }
    int wacount=0;
    int account=0;
    while(m--){
        int p;
        string s;
        cin >> p >> s;
        if(ac[p]) continue;
        if(s=="AC"){
            ac[p]=true;
            account++;
            wacount+=wa[p];
        }
        else if(s=="WA"){
            wa[p]++;
        }
    }
    cout << account << " " << wacount << endl;
}

Measured memory_bytes: 768
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
function sieveOfEratosthenes(e){const t=new Array(e+1).fill(!0);t[0]=!1,t[1]=!1;const n=[];for(let r=2;r<=e;r+=1)if(!0===t[r]){n.push(r);let f=r*r;for(;f<=e;)t[f]=!1,f+=r}return n}

var primes = sieveOfEratosthenes(100000);
function main(input) {
  var o = new I(input);

  var n = o.a();
  var a = [];

  for (var i = 0; i <= n; i++) {
    a.push(o.a());
  }

  a = a.reverse();

  let agcd = a[0];
  for (var i = 1; i <= n; i++) {
    agcd = Math.abs(gcd(agcd, a[i]));
  }

  a = a.map(x => x/agcd);


  var ans = [];
  primes.filter(p => p <= n).forEach(prime => {
    if (a[0] % prime !== 0) return;
    for (var i = 1; i < prime; i++) {
      var j = i;
      var ajsum = 0;
      while (j <= n) {
        ajsum += a[j];
        j += prime - 1;
      }
      if (ajsum % prime !== 0) return;
    }
    ans.push(prime);
  });

  var i = 0;
  while (agcd > 1 && i < primes.length) {
    if (agcd % primes[i] === 0) {
      ans.push(primes[i]);
      while(agcd % primes[i] === 0) {
        agcd = agcd / primes[i];
      }
    }
    i += 1;
  }
  if (agcd > 1) {
    ans.push(agcd);
  }

  ans.sort((a,b) => a - b);
  var prev;
  for (var i = 0; i < ans.length; i++) {
    if (prev !== ans[i]) {
      console.log(ans[i]);
    }
    prev = ans[i];
  }
}

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


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 19900
#define _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a); }
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;//СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚
					//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 1e5 + 228;
const ll inf = 1e9;
const ld EPS = 1e-4;
const ld PI = acos(-1);
const int mod = (int)998244353;
//const int MOD = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ll MOD = 1000000007;
const int maxelem = 12000000;
const int fsconst = 12000;
signed main()
{
	fastio();
	int n;
	cin >> n;
	vector<int> a(n);
	vin(a);
	for (int i = n - 2; i >= 0; --i)
	{
		if (a[i + 1] >= a[i])
		{
			continue;
		}
		if (a[i] > a[i + 1] + 1)
		{
			cout << "No";
			return 0;
		}
		a[i] --;
	}
	cout << "Yes";
	//sp;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int>a;

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	int ai;
	scanf(" %d",&ai);
	a.push_back(ai);
	}

	sort(a.begin(),a.end());

	int Alice=0;
	int Bob=0;

	for(i=0;i<N;i++){
		if(i%2==0){Alice+=a[N-1-i];}
		else{Bob+=a[N-1-i];}
	}

	printf("%d\n",Alice-Bob);

return 0;
}

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

int dp[200000];

const int MOD = 1000000007;

int main() {
    long long N, K, ans;
    cin >> N >> K;
    ans = 0;
    long double th = (N + 1) / 2;
    for (long long i = K; i <= N + 1; i++) {
        long long j; 
        if (i > th) j = N - i + 1;
        else j = i;

        if (j == 0) {
            ans += 1;
            continue;
        }

        if (j == 1) {
            ans += N + 1;
            continue;
        }

        long long min = (j - 1) * j / 2;
        long long max = (N * 2 - j + 1) * j / 2;
        long long sum = max - min + 1;
        ans += sum;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 3632
use std::io::{stdin, Stdin, BufRead};

fn main() {
    let stdin = stdin();
    let a_num = read(&stdin);
    let b_num = read(&stdin);
    let c_num = read(&stdin);
    let x_num = read(&stdin);
    assert_eq!(x_num % 50, 0);

    let mut pairs = 0;

    for a in 0..a_num + 1 {
        if a * 500 > x_num {
            continue;
        }

        for b in 0..b_num + 1 {
            if a * 500 + b * 100 > x_num {
                break;
            }

            for c in 0..c_num + 1 {
                let cur_sum = a * 500 + b * 100 + c * 50;
                if cur_sum > x_num {
                    break;
                } else if cur_sum == x_num {
                    pairs += 1;
                }
            }
        }
    }

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

fn read(stdin: &Stdin) -> i32 {
    let mut buf = String::new();
    stdin.lock().read_line(&mut buf).unwrap();
    buf.pop();
    buf.parse().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,y;
	int s,r,t;
	double x;
	int i;
	int MAX,MAXi;
	int sum;
	while(1){
		cin>>n;
		if(n==0)	break;
		cin>>y;
		MAX=-1;
		MAXi=0;
		for(i=0;i<n;i++){
			cin>>s>>r>>t;
			if(t==1)	sum=10000+100*y*r;
			else{
				x=(double)(100+r)/100;
				x=(double)pow(x,y);
				//cout<<x<<endl;
				sum=10000*x;
			}
			//cout<<sum<<endl;
			if(MAX<sum){
				MAX=sum;
				MAXi=s;
			}
		}
		cout<<MAXi<<endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

vector <int> t;
int n, k;
	
int get(int l, int r) {
	int res = 0;
	for (l += n, r += n; l <= r; l /= 2, r /= 2) {
		if (l % 2) res += t[l++];
		if (r % 2 == 0) res += t[r--];
	}
	return res;
}

void change(int v, int x) {
	v += n;
	t[v] = x;
	do {
		v /= 2;
		t[v] = t[2 * v] + t[2 * v + 1];
	} while (v > 1);
}

int main(){
#ifdef LOCAL
	freopen("B_input.txt", "r", stdin);
	//freopen("B_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	t.resize(2 * n, 0);
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	set <int> q;
	int cnt = 1;
	ll sum = 0;
	for (int i = 0; i < k; i++) {
		q.insert(a[i]);
		change(a[i], 1);
		sum += get(a[i] + 1, n - 1);
		//cout << a[i] << " " << get(a[i + 1], n - 1) << " " << i << "\n";
	}
	//cout << sum << "\n";
	bool was_sorted = false;
	for (int i = k; i < n; i++) {
		bool need = true;
		if (a[i - k] != *q.begin()) {
			need = false;
		}
		sum -= get(0, a[i - k] - 1);
		change(a[i - k], 0);
		q.erase(a[i - k]);
		sum += get(a[i] + 1, n - 1);
		change(a[i], 1);
		q.insert(a[i]);
		if (a[i] != *q.rbegin()) {
			need = false;
		}
		if (sum == 0) {
			if (was_sorted) continue;
			was_sorted = true;
		}
		cnt += need ^ 1;
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 12032
import sys

input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a = [None] + a
a = tuple(a)

ans = set()
cnt = [0] * (n + 1)

for i in range(n, 0, -1):
    if cnt[i] % 2 != a[i] % 2:
        ans.add(i)

        st = set()
        j = 1
        while j * j <= i:
            if i % j == 0:
                st.add(j)
                st.add(i // j)
            j += 1
        for d in st:
            cnt[d] += 1

print(len(ans))
print(*ans)


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

int main() {
  int N = 1, A = 1, B = 1;
  cin >> N >> A >> B;

  if (N * A == B){
    cout << B << endl;
  }
  else if (N * A > B){
    cout << B << endl;
  }
  else{
    cout << N * A << endl;
  }
}


Measured memory_bytes: 256
//07-2 ?????????????????°???
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    int a[31] = {};
    for(int i=0; i<28; i++){
        int tmp;
        cin >> tmp;
        a[tmp] = 1;
    }
    for(int i=1; i<31; i++){
        if(a[i]==0){
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N),y(N);
    ll maxp=0, minp=3000000000, maxm=-2000000000, minm=2000000000;
    for(ll i=0; i<N; i++){
        cin >> x.at(i) >> y.at(i);
        if(x.at(i)+y.at(i)>maxp) maxp=x.at(i)+y.at(i);
        if(x.at(i)+y.at(i)<minp) minp=x.at(i)+y.at(i);
        if(x.at(i)-y.at(i)>maxm) maxm=x.at(i)-y.at(i);
        if(x.at(i)-y.at(i)<minm) minm=x.at(i)-y.at(i);
    }
    if(maxp-minp>maxm-minm) cout << maxp-minp << endl;
    else cout << maxm-minm << endl;
    return 0;
}

Measured memory_bytes: 6420
// $Timur$
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c=0,n,m,i,mx,mn,s,mn1,mx1,j;
	cin>>a>>b;
	if(a==0 && b==0)
	{
		cout<<0;
		return 0;
	}
	if(a>=0 && b>0)
	{
		if(b>a)
		{
		    cout<<b-a<<" ";
		    return 0;
		}
		else
		{
			cout<<a-b+2<<" ";
			return 0;
		}    
	}
	if(a<=0 && b>=0 || a>=0 && b<=0)
	{
		if(a==0 && b<0)
		{
			cout<<a-b+1;
			return 0;
		}
		mn1=min(a,b);
		mx=max(a,b);
		mn=min(a,b);
		if(mn<0) 
		{
		    mn=abs(mn);
		}
		if(mn>mx)
		{
			s=mn1-(mx-mx*2);
			if(mx!=0) c++;
			cout<<abs(s)+c<<" ";
			return 0;
		}
		else
		{
			cout<<mx-mn+1<<" ";
			return 0;
		}
	}
	if(a<0 && b<0)
	{
		if(a>b)cout<<a-b+2;
		else cout<<abs(a-b);
	}
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int c, n, m, s, d, a, b, f, dp[11][100]; vector<pair<int, int> > G[100];
int main() {
	while(scanf("%d%d%d%d%d", &c, &n, &m, &s, &d), s--, d--, c) {
		for(int i = 0; i < n; i++) G[i].clear();
		for(int i = 0; i <= c; i++) {
			for(int j = 0; j < n; j++) dp[i][j] = 1000000000;
		}
		dp[0][s] = 0;
		for(int i = 0; i < m; i++) {
			scanf("%d%d%d", &a, &b, &f);
			G[a - 1].push_back(make_pair(b - 1, f));
			G[b - 1].push_back(make_pair(a - 1, f));
		}
		priority_queue<vector<int> > que; que.push({0, s, 0});
		while(!que.empty()) {
			vector<int> v1 = que.top(); que.pop();
			for(int i = 0; i < G[v1[1]].size(); i++) {
				int u = G[v1[1]][i].first, w = G[v1[1]][i].second;
				if(dp[v1[2]][u] > dp[v1[2]][v1[1]] + w) {
					dp[v1[2]][u] = dp[v1[2]][v1[1]] + w;
					que.push({-dp[v1[2]][u], u, v1[2]});
				}
				if(v1[2] < c && dp[v1[2] + 1][u] > dp[v1[2]][v1[1]] + w / 2) {
					dp[v1[2] + 1][u] = dp[v1[2]][v1[1]] + w / 2;
					que.push({-dp[v1[2] + 1][u], u, v1[2] + 1});
				}
			}
		}
		int ret = 1000000000;
		for(int i = 0; i <= c; i++) ret = min(ret, dp[i][d]);
		printf("%d\n", ret);
	}
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int cost[110];
  rep(i,110) cost[i] = 0;
  rep(i,m) {
    int a;
    cin >> a;
    cost[a]++;
  }
  int tostart = 0;
  int toend = 0;
  for (int i = 0; i < x; i++) tostart += cost[i];
  for (int i = x + 1; i <= n; i++) toend += cost[i];
  cout << min(tostart, toend) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int r; cin >> r;
    cout << 3 * r * r << endl;
}


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

int main(){
    int N,W;
    cin >> N >> W;

    int v[N],w[N];
    for(int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }

    int dp[N][W+1];

    //１行目の初期化
    for (int i = 0; i <= W; i++)
    {
        if(w[0] <= i){
            dp[0][i] = dp[0][i-w[0]] + v[0];
        }else{
            dp[0][i] = 0;
        }
        //cout << dp[0][i] << " ";
    }
    //cout << endl;
    
    //DP
    for(int i = 1; i < N; i++) {
        for (int j = 0; j <= W; j++){
            if(j-w[i] >= 0){
                dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]] + v[i]);

            }else{
                dp[i][j] = dp[i-1][j];
            }
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
   cout << dp[N-1][W] << endl;


    return 0;
}


Measured memory_bytes: 7020
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

string s[8];
int h, w;

int dfs(int i, int j)
{
    if (i == h || j == w)
        return 0;
    if (s[i][j] == '.')
        return 0;
    int x = dfs(i + 1, j);
    if (x == 0)
        x = dfs(i, j + 1);
    return x + 1;
}

int main()
{
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; ++i)
    {
        cin >> s[i];
        cnt += count(all(s[i]), '#');
    }
    int x = dfs(0, 0);
    if (x < h + w - 1 || cnt > x)
        cout << "Impossible";
    else
        cout << "Possible";
}


Measured memory_bytes: 256
#include"iostream"
#include <algorithm>

using namespace std;
int main()
{
	int n, p[10], w = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p, p + n);
	for (int i = 0; i < n-1; i++) {
			w = p[i] + w;
	}
	w = w + (p[n - 1] / 2);
	cout << w << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,n,m;
  for(i=1;;i++){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;
    if(n>m)printf("%d %d\n",m,n);
    else printf("%d %d\n",n,m);
  }
  return 0;
}


Measured memory_bytes: 2036
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 07/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  vector<char> S(500000);
  size_t front = 200000;
  string s; cin>>s;
  for (auto i = 0; i < s.size(); i++)
    S[front+i] = s[i];
  size_t back = front + s.size();
  bool forward = true;

  int Q; cin>>Q;
  while (Q--) {
    int t; cin>>t;
    if (t == 1) {
      forward = !forward;
    } else if (t == 2) {
      int f; cin>>f;
      char c; cin>>c;
      if (forward xor (f == 1)) {
        S[back++] = c;
      } else {
        S[--front] = c;
      }
    }
  }
  if (forward) {
    for (int i = front; i < back; i++)
      cout << S[i];
    cout << endl;
  } else {
    for (int i = back-1; i > front-1; i--)
      cout << S[i];
    cout << endl;
  }

  return 0;
}


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

int main()
{
	int n;
	std::cin >> n;
	
	std::string str1, str2;
	std::cin.ignore(32797, '\n');
	std::getline(std::cin, str1);
	std::getline(std::cin, str2);
	
	long long int ans = 1;
	
	if (n == 1)
	{
		std::cout << 3;
		return 0;
	}
	else if (n == 2)
	{
		std::cout << 6;
		return 0;
	}
	
	bool horizontal = false;
	if (str1[0] == str2[0])
	{
		ans *= 3;
	}
	else
	{
		ans *= 6;
		horizontal = true;
	}
	
	long long int modul = 1000000007;
	int i;
	if (horizontal == true)
		i = 2;
	else
		i = 1;
	for (;i < n;)
	{
		if (str1[i] == str2[i])
		{
			if (!horizontal)
			{
				ans = ((ans % modul) * 2LL) % modul;
			}
			
			horizontal = false;
			++i;
		}
		else
		{
			if (!horizontal)
			{
				ans = ((ans % modul) * 2LL) % modul;
			}
			else
			{
				ans = ((ans % modul) * 3LL) % modul;
			}
			
			horizontal = true;
			i += 2;
		}
	}
	
	
	std::cout << ans;
}

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

using namespace std;

/* ?´???´?????¢?????´?????????
int gcd(int x,int y) {
  int n = min(x,y);
  for(int d=n;d>=1;d--)
    if(!(x%d || y%d))
      return d;
  return 0;
}
*/
int gcd(int x, int y) {
    if(x < y) swap(x, y);
    int r;
    while(y > 0) {
      r = x % y;
      x = y;
      y = r;
    }
    return x;
}

int main(void) {
  int x, y;
  cin >> x; cin >> y;
  cout << gcd(x,y) << '\n';
  return 0;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define FORR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 );
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int a, b; cin >> a >> b;
	if( a <= 5 ) cout << 0 << endl;
	else if( a >= 13 ) cout << b << endl;
	else cout << b / 2 << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll mod = 1000000007;

ll powmod(ll a, ll b, ll p){//a^b(mod p)
  if(b == 0) return 1;
  if(b%2 == 0){
    ll d = powmod(a,b/2,p);
    return (d*d)%p;
  }else return (a*powmod(a,b-1,p))%p;
}

ll maxs(ll a,ll b){
  int av = 0,bv = 0;
  string sa = to_string(a),sb = to_string(b);
  rep(i,sa.size()) av += (sa[i] - '0');
  rep(i,sb.size()) bv += (sb[i] - '0');
  if(av >= bv) return a;
  else return b;
}

main(){
  string s; cin >> s;
  ll siz = s.size();
  ll tmp = (s[siz-1] - '0');
  if(siz == 1){
    cout << s << endl;
    return 0;
  }
  /*
  bool flag = true;
  rep(i,siz) if(s[i] != '9') flag = false;
  if(flag){
    cout << 9 * siz << endl;
    return 0;
  }
  */
  ROF(i,siz-1,0){
    //cout << tmp << endl;
    if(s[i] == '0') continue;
    ll a = (s[i] - '0') * pow(10,siz-i-1);
    //cout << a << endl;
    tmp = maxs(a + tmp, a - 1);
  }
  int ansv = 0;
  string anss = to_string(tmp);
  rep(i,anss.size()) ansv += (anss[i] - '0');
  cout << ansv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=305;
int MOD;
inline int dmy(int x){return x>=MOD?x-MOD:x;}

int n,m;
int c[MAXN][MAXN],f[MAXN][MAXN],g[MAXN][MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n),readint(m),readint(MOD);
	++n,++m;
	c[0][0]=1;
	for(int i=1;i<=n;++i)
	{
		c[i][0]=1;
		for(int j=1;j<=i;++j)c[i][j]=dmy(c[i-1][j]+c[i-1][j-1]);
	}
	for(int j=1;j<=m;++j)f[1][j]=1,g[1][j]=j;
	for(int i=2;i<=n;++i)
	{
		for(int j=1;j<i;++j)
			for(int x=1;x<=m;++x)
				f[i][x]=(f[i][x]+1ll*f[j][x]*g[i-j][x-1]%MOD*c[i-2][j-1])%MOD;
		for(int x=1;x<=m;++x)
			g[i][x]=dmy(g[i][x-1]+f[i][x]);
	}
	printf("%d\n",f[n][m]);
	return 0;
}

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

using namespace std;

int solve(int x, int y) {
  int ret = INT_MAX;
  if (x <= y) {
    ret = std::min(y - x, ret);
  }
  if (-x <= -y) {
    ret = std::min(x - y + 2, ret);
  }
  if (-x <= y) {
    ret = std::min(y + x + 1, ret);
  }
  if (x <= -y) {
    ret = std::min(-y - x + 1, ret);
  }
  return ret;
}

int main() {
  int x, y;
  std::cin >> x >> y;
  std::cout << solve(x, y) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(dead_code, unused)]

use std::cmp::*;
use std::collections::*;
use std::collections::HashSet;
use std::io::stdin;
use std::io::Write;
use std::process::exit;
use std::ptr::read;
use std::str::FromStr;

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (x, n) = get!(isize, isize);
    let p = get!(isize;;);
    let mut ps = HashSet::new();
    for x in p {
        ps.insert(x);
    }

    let mut ans: isize = 0;
    let mut diff: isize = 10000;
    for i in -1000..1000 {
        if ps.contains(&i) {
            continue;
        }
        let df = (i - x).abs();
        if (i - x).abs() < diff {
            diff = df;
            ans = i;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2128
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


A = [int(x) for x in input().split()]
A.sort()
print(A[2]-A[0])


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 998244353;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll N, A;
    cin >> N >> A;
    vector<ll> x(N);
    rep(i,N) cin >> x[i];
    vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(N+1, vector<ll>(2505,0)));
    rep(i,N) dp[i][0][0] = 1;

    rep(i,N){
        rep(j,N){
            rep(k,2505){
                if(k-x[i] >= 0) dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-x[i]];
                else dp[i+1][j+1][k] = dp[i][j+1][k];
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ll sum = i*A;
        ans += dp[N][i][sum];
    }
    cout << ans << endl;
}

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

int V, E, d[20][20], dp[15][1<<15];

int main() {
    cin >> V >> E;
    REP(i,V) fill(d[i], d[i]+V, IINF/3);
    REP(i,E){
        int s, t;
        cin >> s >> t;
        cin >> d[s][t];
    }
    REP(i,V) fill(dp[i], dp[i]+(1<<V), IINF/3);
    dp[0][0] = 0;
    REP(S,(1<<V)){
        REP(i,V){
            REP(j,V){
                if(((S>>j)&1)==0){
                    dp[j][S|(1<<j)] = min(dp[j][S|(1<<j)], dp[i][S]+d[i][j]);
                }
            }
        }
    }
    cout << (dp[0][(1<<V)-1]<IINF/3?dp[0][(1<<V)-1]:-1) << endl;
    return 0;
}


Measured memory_bytes: 4968
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
bool prime[100000];
void furui() {
	int i = 2;
	while (i <= 100000) {
		int j = 2;
		while (j <= sqrt(i) && !prime[i]) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		int z = 2;
		while (!prime[i]) {
			if (i*z <= 100000) {
				prime[i*z] = true;
				z++;
			}
			else break;
		}
		i++;
	}
}
int main(void) {
	int n;
	cin >> n;
	furui();
	for (int i = 2;i <= 55555;i++) {
		if (n == 0)break;
		if (!prime[i]) {
			if (i % 10 == 1) {
				if (n != 1) {
					cout << i << " ";
					n--;
				}
				else {
					cout << i << endl;
					n--;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	string check = "MARCH";
	map<char, ll> mp;
	
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		
		for(int j = 0; j < (int)check.size(); ++j) {
			if( s[0] == check[j] ) { 
				mp[s[0]]++;
			}
		}
	}
	
	ll m = (ll)mp.size();
	
	if( m == 0 ) { 
		cout << 0 << endl;
	} else {
		ll ans = 0LL;
		
		for(int i = 0; i < 5; ++i) {
			for(int j = i + 1; j < 5; ++j) {
				for(int k = j + 1; k < 5; ++k) {
					ans += mp[check[i]] * mp[check[j]] * mp[check[k]];
				}
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#define ll long long
using namespace std;

int mp[105][105];
int main()
{
    int n,m,t,tx;
    scanf("%d%d",&n,&m);

    scanf("%d",&t);
    int x=1,y=1;
    int dir=1;
    for (int i=1;i<=t;i++)
    {
        scanf("%d",&tx);
        for (int j=1;j<=tx;j++)
        {
            mp[x][y]=i;

          // cout<<x<<" "<<y<<" "<<i<<endl;
            y+=dir;
            if (y==m+1)
            {
                dir=-dir;
                y=m;
                x+=1;
            }

            if (y==0)
            {
                dir=-dir;
                y=1;
                x+=1;
            }
        }
    }

    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        printf("%d%c",mp[i][j],j==m?'\n':' ');
    return 0;
}


Measured memory_bytes: 384
import numpy as np


def read():
    foods = np.empty((5, ), dtype=np.int32)
    for i in range(5):
        foods[i] = int(input().strip())
    return foods,


def solve(foods):
    mod_10 = (foods+9) % 10
    order_indice = np.argsort(mod_10)[::-1]

    # sort foods
    foods = foods[order_indice]

    order_time = np.empty((5, ), dtype=np.int32)
    for i, food in enumerate(foods):
        order_time[i] = (food + 9) // 10 * 10
    order_time[4] = foods[4]
    return np.sum(order_time)


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double n, d;
  cin >> n >> d;
  double tmp = d * 2 + 1;
  cout << ceil(n / tmp) << endl;
}


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

int		main(void)
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}


Measured memory_bytes: 256
/*
 *  Created on: 26-May-2019
 *      Author: ankur314
 */
#include<bits/stdc++.h>
#define lli long long int 
#define li long int
#define db double 
#define ldb long double
#define vr vector 
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007

#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"

using namespace std;

struct data{
	string city;
	int score;
	int idx;
};

bool comp(data a, data b)
{
	if(a.city != b.city) return (a.city < b.city);
	else return (a.score > b.score);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n;cin>>n;
    data p[n];
    fi(i,0,n)
    {
    	string city;int score;
    	cin>>city>>score;
    	p[i].city = city;
    	p[i].score = score;
    	p[i].idx=i;
    }
    sort(p,p+n,comp);
    int a[n];
    fi(i,0,n)
    {
    	//cout<<p[i].city<<" "<<p[i].score<<" "<<p[i].idx<<"\n";
    	a[i]=p[i].idx+1;
    }
    fi(i,0,n) cout<<a[i]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll ps[109][100009],N,K,a[10009],dp[109][100009];
ll sum(ll n, ll l, ll r){
    if(l==0)return ps[n][r]%mod;
    return (ps[n][r]%mod-ps[n][l-1]%mod+mod)%mod;
}

int main(){
    cin >> N >> K;
    for(int i=1; i<=N; i++)cin >> a[i];
    for(ll n=0; n<=N; n++){
        for(ll k=0; k<=K; k++){
            if(k==0)dp[n][k]=1;
            else if(n==0)dp[n][k]=0;
            else{
                dp[n][k]=sum(n-1,k-min(k,a[n]),k)%mod;
            }
            ps[n][k]=(ps[n][k-1]%mod+dp[n][k]%mod)%mod;
        }
    }
    cout << dp[N][K]%mod << endl;
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 5005, mod = 1e9 + 7;

	int n, F[N][N], V[N], Siz[N];
	vector<int> E[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	void dfs(const int u, const int f)
	{
		Siz[u] = 1;
		F[u][1] = 1;
		for (int v : E[u])
			if (v != f)
			{
				dfs(v, u);
				static int tmp[N];
				memcpy(tmp, F[u], sizeof(int[Siz[u] + 1]));
				memset(F[u], 0, sizeof(int[Siz[u] + 1]));
				for (int a = 1; a <= Siz[u]; a++)
					for (int b = 0; b <= Siz[v]; b++)
						(F[u][a + b] += int((ll)tmp[a] * F[v][b] % mod)) %= mod;
				Siz[u] += Siz[v];
			}
		for (int i = 2; i <= Siz[u]; i += 2)
			(F[u][0] += mod - int((ll)F[u][i] * V[i] % mod)) %= mod;
	}

	void work()
	{
		n = read();
		for (int i = 1; i < n; i++)
		{
			int u = read(), v = read();
			E[u].push_back(v);
			E[v].push_back(u);
		}
		V[2] = 1;
		for (int i = 4; i <= n; i += 2)
			V[i] = int((ll)V[i - 2] * (i - 1) % mod);
		dfs(1, 0);
		printf("%d\n", mod - F[1][0]);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 97536
s = int(input())


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(1, 2000):
    if s-3*i < 0:
        break

    ans += cmb(s-3*i+i-1, i-1, mod)
    ans %= mod

print(ans)


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

struct vec{
	long double x , y;
	vec(long double _x = 0 , long double _y = 0){x = _x; y = _y;}
	friend vec operator +(vec a , vec b){return vec(a.x + b.x , a.y + b.y);}
	friend vec operator -(vec a , vec b){return vec(a.x - b.x , a.y - b.y);}
	friend long double operator *(vec a , vec b){return a.x * b.x + a.y * b.y;}
	friend vec operator *(vec a , long double b){return vec(a.x * b , a.y * b);}
	long double len(){return sqrt(x * x + y * y);}
};

vec getvec(){int x , y; cin >> x >> y; return vec(x , y);}

int main(){
	vec A = getvec() , B = getvec(); B = B - A; int Q;
	for(cin >> Q ; Q ; --Q){
		vec Q = getvec() - A;
		long double T = Q * B / B.len();
		vec ans = A + B * (T / B.len());
		cout << fixed << setprecision(10) << ans.x << ' ' << ans.y << endl;
	}
	return 0;
}



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

struct Edge { int to, cap, rev; };

vector<Edge>G[1009]; bool used[1009];

void add_edge(int u, int v, int w) {
	G[u].push_back(Edge{ v, w, (int)G[v].size() });
	G[v].push_back(Edge{ u, 0, (int)G[u].size() - 1 });
}

int dfs(int pos, int to, int f) {
	if (pos == to) return f;

	used[pos] = true;
	for (int i = 0; i < G[pos].size(); i++) {
		if (G[pos][i].cap == 0 || used[G[pos][i].to] == true) continue;

		int D = dfs(G[pos][i].to, to, min(G[pos][i].cap, f));
		if (D >= 1) {
			G[pos][i].cap -= D;
			G[G[pos][i].to][G[pos][i].rev].cap += D;
			return D;
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int F = 0;
	while (true) {
		for (int i = 0; i < 1009; i++) used[i] = false;
		int F2 = dfs(s, t, (1 << 30));
		F += F2;
		if (F2 == 0) return F;
	}
	return 1000000007;
}

int N, M, A[1 << 17], B[1 << 17], C[1 << 17];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		add_edge(A[i], B[i], C[i]);
	}
	cout << max_flow(0, N - 1) << endl;
	return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define LIMIT 1000000000

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (h * w == 1) {
        cout << "No" << '\n';
        return 0;
    }
    long unit = (LIMIT - 1) / (h*w - 1),
         minus = (H / h) * (W / w),
         plus = (H % h) * W + (W % w) * H - (H % h) * (W % w);
    if (minus >= plus * unit) {
        cout << "No" << '\n';
        return 0;
    }
    cout << "Yes" << '\n';
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            cout << (i % h == 0 && j % w == 0 ? -(unit * (h*w - 1) + 1): unit) << ' ';
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<vector<int> > a(n, vector<int> (m));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = c;
        for(int j = 0; j < m; j++) sum += a[i][j] * b[j];
        if(sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

long long GCD(long long a,long long b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}

int main(void)
{
    long long x,y;
    int count = 1;
    scanf("%lld%lld",&x,&y);
    long long int n = GCD(x,y) ;
    for(long long i=2;i<sqrt(n);i++)
    {
        if(n%i==0){
            count++;
            while(n%i==0)
                n=n/i;
        }
    }
    if(n>1)
        count++;
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
n,m = gets.strip.split.map(&:to_i)
rec1 = []
recn = []
m.times do
  a,b = gets.strip.split.map(&:to_i)
  if a==1
    rec1 << b
  elsif b == 1
    rec1 << a
  elsif a==n
    recn << b
  elsif b==n
    recn << a
  end
end
recnew = rec1+recn
if recnew.size == recnew.uniq.size
  puts "IMPOSSIBLE"
else
  puts "POSSIBLE"
end



Measured memory_bytes: 26132
#include <cstdio>

int main(){

	int a, b, d, r;
	double f;

	scanf("%d %d", &a,&b);

	d = a / b;
	r = a % b;
	f = (double)a / b;

	printf("%d %d %f\n", d,r,f);

	return 0;

}

Measured memory_bytes: 2680
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
        long d = long.Parse(input[3]);
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        if(d%2==0){
            WriteLine(a-b);
        }else{
            WriteLine(b-a);
        }
    }
}

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

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

    long long L[87];
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=n;i++) L[i]=L[i-2]+L[i-1];
    cout<<L[n]<<endl;
}

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


int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A;
    rep(i, N) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    ll town = 1;
    vector<ll> done;
    rep(i, N) done.push_back(N);
    ll begin_times = N;
    ll loop_times = N;
    rep(i, N) {
        done.at(town-1) = i;
        town = A.at(town-1);
        if(i == K - 1) {
            cout << town << endl;
            return 0;
        }
        if(done.at(town-1) != N) {
            begin_times = done.at(town-1);
            loop_times = i - begin_times + 1;
            break;
        }
    }

    ll limit = (K - begin_times) % loop_times;
    rep(i, limit) town = A.at(town-1);
    cout << town << endl;
    return 0;
}

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

int main(void){
    int i, x, n;
    cin >> n;
    for(i=1; i<=n; i++){
        x = i;
        if (x%3==0) cout << " " << i;
        else{
            while(x){
                if(x%10==3){
                     cout << " " << i;
                     break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;
class Main{
	int a,b,x;
	String op;
	public void Germany() {
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		op = sc.next();
		b = sc.nextInt();
		while(!op.equals("?")) {
			if(op.equals("+")) {
				x = a + b;
				System.out.println(x);
					}else if(op.equals("-")){
				x = a - b;
				System.out.println(x);
					}else if(op.equals("*")){
				x = a * b;
				System.out.println(x);
					}else if(op.equals("/")){
				x = a / b;
				System.out.println(x);
			}
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
		}
	}
	public static void main(String[] args) {
			new Main().Germany();
	}
}

Measured memory_bytes: 18032
/******tech_knight18_@7******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}


lld maxProductSubarrayOfSizeK(lld A[],lld n,lld k) 
{ 
    sort(A, A + n); 
    lld product = 1,cou=1; 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
           { product *= A[i]; 
             cou=(cou*A[i]+MOD)%MOD;
           }
        return cou; 
    } 
  
    lld i = 0; 
    lld j = n - 1; 
  

    if (k & 1) { 
        product *= A[j]; 
        cou=(cou*A[j])%MOD;
        j--; 
        k--; 
    } 

    k >>= 1; 
  

    for (lld itr = 0; itr < k; itr++) { 
  
 
       lld left_product = A[i] * A[i + 1]; 
       lld lf=(A[i] * A[i + 1]+MOD)%MOD;
  

       lld right_product = A[j] * A[j - 1]; 
      lld rf=(A[j] * A[j - 1])%MOD;
 
        if (left_product > right_product) { 
            product *= left_product; 
            cou=(cou*lf+MOD)%MOD;
            i += 2; 
        } 
        else { 
            product *= right_product; 
            cou=(cou*rf+MOD)%MOD;
            j -= 2; 
        } 
    } 
  
    return cou; 
} 



int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
            lld n,k; cin>>n>>k;
            pls(n,a);
            cout<<(maxProductSubarrayOfSizeK(a, n, k)+MOD)%MOD; 
}

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

int main()
{
    long long int n, i, sum=0;
    cin>>n;
    for(i=1;i<sqrt(n);i++){
        if(n%i==0){
            if(n/i-1>i)
                sum+=n/i-1;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define L 110
#define LL long long
using namespace std;

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

int h, w, n, x, y, cnt, num[L * L], ans[L][L];

int main() {
  //freopen("Grid Coloring.in", "r", stdin);
  //freopen("Grid Coloring.out", "w", stdout);
  h = gi(), w = gi(), n = gi();
  for (int i = 1; i <= n; ++i) {
    x = gi();
    for (int j = 1; j <= x; ++j) num[++cnt] = i;
  }
  cnt = x = 0, y = w;
  while (cnt < h * w) {
    while (x + 1 <= h && !ans[x + 1][y]) ans[++x][y] = num[++cnt];
    while (y - 1 > 0 && !ans[x][y - 1]) ans[x][--y] = num[++cnt];
    while (x - 1 > 0 && !ans[x - 1][y]) ans[--x][y] = num[++cnt];
    while (y + 1 <= w && !ans[x][y + 1]) ans[x][++y] = num[++cnt];
  }
  for (int i = 1; i <= h; ++i){
    for (int j = 1; j <= w; ++j)
      cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
[H,W] = list(map(int,input().split()))

a = []
for i in range(H):
    a.append(list(input()))

line = [0]*H
colu = [0]*W
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            line[i]=1
            colu[j]=1

ans=[]
for i in range(H):
    dammy=[]
    for j in range(W):
        if line[i]==1 and colu[j]==1 :
            dammy.append(a[i][j])
    if dammy!=[]:
        ans.append(dammy)

for i in range(len(ans)):
    print(''.join(ans[i]))

Measured memory_bytes: 68744