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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No");
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	queue<P> que;
	que.emplace(0, 0);
	vector<vector<int>> dist(h, vector<int>(w, inf));
	dist[0][0] = 0;
	const int dx[] = { 0,1,0,-1 };
	const int dy[] = { 1,0,-1,0 };
	while (que.size()) {
		P p = P(get<0>(que.front()), get<1>(que.front()));
		que.pop();
		rep(i, 4) {
			int nh = p.first + dx[i], nw = p.second + dy[i];
			if (nh < 0 || nw < 0 || nh >= h || nw >= w) continue;
			if (s[nh][nw] == '#') continue;
			if (dist[nh][nw] != inf) continue;
			dist[nh][nw] = dist[p.first][p.second] + 1;
			que.emplace(nh, nw);
		}
	}
	int res = dist[h - 1][w - 1];
	if (res == inf) {
		cout << -1 << endl;
		return 0;
	}
	res++;
	int cnt = 0;
	rep(i, h)rep(j, w) if (s[i][j] == '#') cnt++;
	int ans = h * w - res - cnt;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

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

    char grid[H][W];
    bool len[W],row[H];
    for(int i = 0; i < H; i++) row[i] = false;
    for(int i = 0; i < W; i++) len[i] = false;
    
    for(int i = 0; i < H; i++){
        for(int n = 0; n < W; n++){
            cin >> grid[i][n];
            if(grid[i][n] == '#'){
                row[i] = true;
                len[n] = true;
            }
        }
    }


    for(int i = 0; i < H; i++){
        for(int n = 0; n < W; n++){
            if(row[i] && len[n]){
                cout << grid[i][n];
            }
        }
        if(row[i]) 
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a = input().split(' ')
for i in range(len(a)):
    a[i] = int(a[i])
if (a[2]>=a[4] and a[3]>=a[4]) and (a[0]>=a[2]+a[4] and a[1]>=a[3]+a[4]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include <stdio.h>

int main(void){

    int N = 0;
    int M = 0;
    
    scanf("%d %d", &N, &M);

    int A[M];

    for (int i = 0; i < M; i++){
        scanf("%d", &A[i]);      
        N -= A[i];  
    }

    if (N < 0) {
        printf("-1\n");         
    } else {
        printf("%d\n", N);
    }

    return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int N;
double mx,my;
double x[21],y[21];
bool endFlag;

const double EPS=1e-8;
bool input(){
    scanf("%d",&N);
    scanf("%lf%lf%lf%lf",&x[N],&y[N],&mx,&my);
    if(!(N||x[N]||y[N]||mx||my))return false;
    for(int i=0;i<N;i++)scanf("%lf%lf",&x[i],&y[i]);
    return true;
}

void dfs(int S,int pos,double total){
    if(S==(1<<N)-1){
        endFlag=true;
        return;
    }
    if(endFlag)return;

    for(int i=0;i<N;i++){
        if((S>>i)&1)continue;
        double mao=hypot(mx-x[i],my-y[i]);
        double yu=hypot(x[pos]-x[i],y[pos]-y[i]);
        if(yu+total+EPS>mao)return;
    }


    for(int i=0;i<N;i++){
        if((S>>i)&1)continue;
        double yu=hypot(x[pos]-x[i],y[pos]-y[i]);
        dfs(S|(1<<i),i,total+yu);
    }
}
void solve(){
    endFlag=false;
    dfs(0,N,0);
    puts(endFlag?"YES":"NO");
}
int main(){
    while(input())solve();
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll h, w, k;
    cin>>h>>w>>k;
    string s[h];
    ll r[h]={}, c[w]={};
    forn(i,0,h){
        cin >> s[i];

    }
    ll ans=0;
    for(ll i=0; i<(1<<h); i++){
        for(ll j=0;j<(1<<w); j++){
            ll c=0;
            for(ll ii=0;ii<h;ii++){
                for(ll jj=0;jj<w;jj++){
                    if(!((1<<ii) & i) && !((1<<jj) & j)){
                        if(s[ii][jj]=='#')c++;
                    }
                }
            }
            if(c==k){
                // cout<<i<<" "<<j<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3640
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v = procon_read();
	let r:i32 = v[0];
	let d:i32 = v[1];
	let x:i32 = v[2];
	let mut ret = x;
	for i in 0..10 {
		ret = r*ret - d;
		println!("{}", ret);
	}
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  map<ll, ll> m;
  REP(i, s.size())
    m[s[i]-'a'] += 1;

  REP(i, 26){
    if(m[i] == 0){
      char ans = 'a' + i;
      cout << ans << endl;
      return 0;
    }
  }

  cout << "None" << endl;
}


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

vector<int>graph[200005];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0, a, b; i < m; i++) {
		cin >> a >> b; a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (int i = 0; i < graph[0].size(); i++) {
		int v = graph[0][i];
		for (int j = 0; j < graph[v].size(); j++) {
			int u = graph[v][j];
			if (u == n - 1) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

int main(){
   vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
   string s; cin >> s;
   for(int i = 0; i < 7; i++){
       if(s[0] == day[i][0] && s[1] == day[i][1]){
           cout << 7-i << endl;
           return 0;
       }
   }
}

Measured memory_bytes: 256
import java.util.Scanner;

//Era Name Transformation
public class Main{

	static class E implements Comparable<E>{
		public int y,m,d;
		public E(int y, int m, int d) {
			this.y = y;
			this.m = m;
			this.d = d;
		}
		public int compareTo(E o) {
			return y!=o.y?y-o.y:m!=o.m?m-o.m:d-o.d;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		E[] e = {new E(1868,9,7), new E(1912,7,29), new E(1926,12,24), new E(1989,1,7)};
		int[] t = {0,1867,1911,1925,1988};
		String[] n = {"pre-meiji","meiji","taisho","showa","heisei"};
		while(sc.hasNext()){
			E f = new E(sc.nextInt(),sc.nextInt(),sc.nextInt());
			int k=0;
			while(k<4&&f.compareTo(e[k])>0)k++;
			if(k==0)System.out.println(n[k]);
			else System.out.println(n[k]+" "+(f.y-t[k])+" "+f.m+" "+f.d);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    long long res = min(a*b, a*c);
    res = min(res, b*c);
    cout << res << endl;
}


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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 2; i * i <= n; i++) {
        ll cnt = 0;
        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            // 1 + 2 + ... + k <= cntであるような最大のkを探す
            ll ok = 1, ng = cnt;
            while (abs(ok - ng) > 1) {
                ll mid = (ok + ng) / 2;
                if (mid * (mid + 1) / 2 <= cnt) ok = mid;
                else ng = mid;
            }
            ans += ok;
        }
    }
    if (n != 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3548
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func refbit(i int, b int) int {
	return (i >> uint8(b)) & 1
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	k := make([]int, m)
	s := make([][]int, m)
	p := make([]int, m)

	for i := 0; i < m; i++ {
		k[i] = nextInt()
		s[i] = make([]int, k[i])
		for j := 0; j < k[i]; j++ {
			s[i][j] = nextInt()
		}
	}
	for i := 0; i < m; i++ {
		p[i] = nextInt()
	}

	patternNum := int(math.Pow(2, float64(n)))
	switches := make([]bool, n)
	nums := 0

	for i := 0; i < patternNum; i++ {
		for j := 0; j < n; j++ {
			if refbit(i, j) == 1 {
				switches[j] = true
			} else {
				switches[j] = false
			}
		}

		onLightNum := 0
		for light := 0; light < m; light++ {
			count := 0
			for sw := 0; sw < k[light]; sw++ {
				if switches[s[light][sw]-1] {
					count++
				}
			}
			if (count % 2) == p[light] {
				onLightNum++
			}
		}
		if onLightNum == m {
			nums++
		}
	}
	fmt.Println(nums)

}


Measured memory_bytes: 640
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

class Hp
  def initialize(len)
    @main = na(len,[99999999,nil])
    @ind = 1
    @size = len - 5
  end

  def push(n)
    p "wa" if(@ind > @size)
    @main[@ind+1] = n
    sind = @ind+1
    while(sind >= 2)
      nind = sind/2
      if(@main[sind][0] < @main[nind][0])
        @main[sind], @main[nind] = @main[nind], @main[sind]
      else
        break
      end
      sind /= 2
    end
    @ind += 1
  end

  def put()
    return @main
  end

  def pop()
    ans = @main[1]
    @main[1] = @main[@ind]
    @main[@ind] = @main[-1]
    sind = 1
    while(true)
      nind = sind*2
      break if(nind > @ind)
      l = @main[nind]
      nind += 1
      if(nind > @ind)
        ind = nind-1
        if(@main[ind][0] < @main[sind][0])
          @main[sind], @main[ind] = @main[ind], @main[sind]
        end
        break
      end
      r = @main[nind]
      ind = (l[0] > r[0])? nind : nind-1
      if(@main[ind][0] < @main[sind][0])
        @main[sind], @main[ind] = @main[ind], @main[sind]
      end
      sind = ind
    end
    @ind -= 1
    return ans
  end

  def res()
    @ind = 1
    push([99999999,nil])
  end
end

hp = Hp.new(100005)
n,m = inp
a = inp
a.each do |d|
  hp.push([d*-1,0])
end
m.times do
  u = hp.pop
  if(u[0] == 0)
    puts 0
    exit
  end
  hp.push([((u[0]*-1)/2)*-1,0])
end
ans = 0
while true
  u = hp.pop

  break if(u[1] == nil)
  ans += u[0]
end
p ans * -1


Measured memory_bytes: 17776
//?????????
//??????00-440415D???Smart_Calculator.cpp

#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <stdio.h>

using namespace std;

string S = "1+2*(3+4)";
size_t cur = 0;

int expression();

int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur++]-'0';
	return n;
}

int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur])){
		n = n*10 + digit();
	}
	return n;
}

int factor(){
	if(S[cur] != '('){
		return number();
	}else{
		cur++;
		int n = expression();
		assert(S[cur]==')');
		cur++;
		return n;
	}
}

//??????????????????????????????
int term(){
	int a = factor();
	while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if(op == '*'){
			a *= b;
		}else if(op == '/'){
			a /= b;
		}
	}
	return a;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur++];
		int b = term();
		if(op == '+'){
			sum += b;
		}else if(op == '-'){
			sum -= b;
		}
	}
	return sum;
}

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  int ans = 0;
  int lim = max(a,b);
  for (int i=lim;i>=1;i--) {
    if (a % i == 0 && b % i == 0) cnt++;
    if (cnt == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [int(i) - 1 for i in input().split()]

ans = 0
for i in range(N - 1):
    if p[i] == i:
        ans += 1
        p[i + 1] = p[i]

if p[N - 1] == N - 1:
    ans += 1

print(ans)

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


int main(){
  int n,m;
  cin>>n>>m;
  vector<P> v(m);
  int now;
  rep(i,m){
    now=0;
    int a1,b1;
    cin>>a1>>b1;
    rep(j,b1){
      int c1;
      cin>>c1;
  //    cout<<c1<<endl;
      c1--;

      now=now|(1<<c1);
    }
    v[i]=make_pair(a1,now);
    //cout<<now;

  }
  vector<int> dp(1<<n,INF);
  dp[0]=0;
  rep(i,1<<n){
    rep(j,m){
      int temp=i|v[j].second;
      dp[temp]=min(dp[i]+v[j].first,dp[temp]);
    }
  }
  if (dp.back()==INF)cout<<-1;
  else cout<<dp.back();



  }


Measured memory_bytes: 384
nlist = []
xlist = []

while(1):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    nlist.append(n)
    xlist.append(x)

for n, x in zip(nlist, xlist):
    cnt = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            k = x - i - j
            if j < k <= n:
                cnt += 1
    print(cnt)



Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>
#include <climits>
#include <string>

typedef long long ll;

using namespace std;

void solve(){
    string x;
    int sum = 0;
    while(cin >> x){
        if(x == "0"){
            return;
        }
        for(int i = 0; i < x.length(); i++){
            sum += x[i]-'0';
        }
        cout << sum << endl;
        sum = 0;
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3228
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int N, M, C;
  cin >> N >> M >> C;
  VI B(M);
  for (size_t i = 0; i < M; i++) {
    cin >> B[i];
  }
  VI A(M);
  int a;
  int r = 0;
  for (size_t i = 0; i < N; i++) {
    int ans = C;
    for (size_t j = 0; j < M; j++) {
      cin >> a;
      ans += B[j] * a;
    }
    if (ans > 0) {
      r++;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import*
n=int(input())
def ERATOSTHENES(n):
    is_prime=[0,0]+[1]*(n-1)
    for i in range(2,int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2,n+1,i):
                is_prime[j]=0
    return [k for k,v in enumerate(is_prime) if v]
    
x=ERATOSTHENES(10**6)
print(x[bisect_left(x,n)])

Measured memory_bytes: 55264
/* ex 9_2
   nnasy */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    //count: 取り除いたキューブの数
    int count = 0;
    //input: 入力文字列
    char input[SIZE];
    //入力
    scanf("%s", input);
    //最初のノードの指す先
    node *first = NULL;

    //取り除くキューブの数の計算
    for (int i=0; i<strlen(input); i++){
        //比較対象がないとき文字を入れるだけ
        if (first==NULL){
            push(&first, input[i]);
        }else{
            //文字が同じときはその文字を入れる
            if (input[i]==first->elem){
                push(&first, input[i]);
            //文字が異なるときは手前の文字を除き、カウントを増やす
            }else{
                pop(&first);
                count += 2;
            }
        }
    }

    //出力
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 4932
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def sRaw():
    return input().rstrip("\r")

def iRaw():
    return int(input())


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


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


def main():
    N = iRaw()
    for i in range(1,10):
        for j in range(1,10):
            if i*j == N:
                return "Yes"
    return "No"

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define MAX 151200
typedef long long ll;

int main(void){
  ll N;
  while(cin >> N, N){
    int ans = 0;
    for(int cube = 0; cube * cube * cube <= MAX; cube++){
      for(int tr = 0; tr * (tr+1) * (tr+2) / 6 <= MAX; tr++){
	int cuben = cube * cube * cube;
	int trn = tr*(tr+1)*(tr+2)/6;
	if(cuben <= N){
	  ans = max(ans, cuben);
	}
	if(trn <= N){
	  ans = max(ans, trn);
	}
	if(cuben + trn <= N){
	  ans = max(ans, cuben + trn);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_map>
int par_road[200001], par_rail[200001], num[200000];
std::pair<std::pair<int, int>,int> roots[200000];
int root(int* par, int x) {
	return par[x] == x ? x : par[x] = root(par, par[x]);
}
void unite(int* par, int x, int y) {
	int xp = root(par, x), yp = root(par, y);
	if (xp != yp)par[xp] = yp;
}
int main() {
	int n, k, l, i, j, a, b;
	scanf("%d%d%d", &n, &k, &l);
	for (i = 1; i <= n; i++) {
		par_road[i] = i;
		par_rail[i] = i;
	}
	for (i = 1; i <= k; i++) {
		scanf("%d%d", &a, &b);
		unite(par_road, a, b);
	}
	for (i = 1; i <= l; i++) {
		scanf("%d%d", &a, &b);
		unite(par_rail, a, b);
	}
	for (i = 1; i <= n; i++) {
		par_road[i] = root(par_road, i);
		par_rail[i] = root(par_rail, i);
		roots[i] = { {par_road[i],par_rail[i]},i };
	}
	std::sort(roots + 1, roots + n + 1);
	for (i = 1; i <= n; i = j) {
		for (j = i+1; j <= n; j++) {
			if (roots[j].first != roots[i].first)break;
		}
		for (k = i; k < j; k++)num[roots[k].second] = j - i;
	}
	for (i = 1; i <= n; i++)printf("%d%s", num[i], i == n ? "\n" : " ");
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    vector<vector<char>> c(3, vector<char>(3));
    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    rep(i,3){
        cout << c[i][i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n)cin>> l[i];
    sort(l.begin(),l.end());
    int cnt =0;
    rep(i,n) {
        FOR(j,i+1,n) {
            FOR(k,j+1,n) {
                if(l[i]==l[j] || l[i]==l[k]|| l[j]==l[k]) continue;
                if(l[i]+l[j]>l[k] && l[k]>abs(l[j]-l[i])) {
                    //cout << l[i]<<" "<<l[j] <<" "<<l[k] << endl;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
def num(m):
    return len(tuple(filter(lambda x: x >= m - 1, e)))


N = int(input())
e = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    for j in range(2, i + 1):
        while i % j == 0:
            i //= j
            e[j] += 1

ans = 0
ans += num(75)
ans += num(25) * (num(3) - 1)
ans += num(15) * (num(5) - 1)
ans += num(5) * (num(5) - 1) * (num(3) - 2) // 2
print(ans)


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    ll x;
    cin >> x;
    ll num = (x / 11) * 2;
    ll amari = x % 11;
    ll ans = num;
    if (amari <= 6  && amari != 0) {
        ans += 1;
    }
    else if (amari != 0) {
        ans += 2;
    }
    
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3624
sx, sy, tx, ty = map(int, input().split())
st1 = "U" * (ty - sy) + "R" * (tx - sx)
ts1 = "D" * (ty - sy) + "L" * (tx - sx)
st2 = "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
ts2 = "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"

print(st1 + ts1 + st2 + ts2)


Measured memory_bytes: 9164
#include <cstring>
#include <vector>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <cstring>
#include <map>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);++i)
#define mp(a,b) make_pair((a),(b))

typedef long long int lli;
typedef pair<int,int> P;

const int INF=100000000;
const long long int INF_=1000000000000000000;

int N,Q;

int Solve(int q,vector<int> &t,vector<int> &l,int m){
	int result=0;
	for(int i=m+1; i>=0;){
		int tmp=l[i]%q;
		//cout << tmp << endl;
		result=max(result,tmp);
		i-=tmp+1;
	}
	return result;
}

int main(){
	cin >> N >> Q;
	vector<int> t(300001);
	vector<int> l(300001);
	int m=-1;
	rep(i,N) {
		int tmp;
		cin >> tmp;
		t[tmp]=1;
		m=max(m,tmp);
	}
	rep(i,m+2){
		if(i==0) continue;
		/*
		if(t[i-1]==1) l[i]=i-1;
		else l[i]=l[i-1];
		* */
		if(t[i]==1) l[i]=i;
		else l[i]=l[i-1];
	}
	//rep(i,m+2) cout <<  << l[i] << (i==m?'\n':' ');
	rep(i,Q){
		int q;
		cin >> q;
		int ans=Solve(q,t,l,m);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3380
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    

    internal static void Main(string[] args)
    {



        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = inp[0];
        int B = inp[1];
        int C = inp[2];
        int X = inp[3];
        int Y = inp[4];

        int ans = 0;
        if ((A + B) > (C * 2)) {
            ans = (C * 2) * Math.Min(X, Y);
        } else {
            ans = (A * Math.Min(X, Y)) + (B * Math.Min(X, Y));
        }

        if (X > Y) {
            if (A > (C * 2)) {
                ans += (C * 2) * (X - Y);
            } else {
                ans += A * (X - Y);
            }
        } else if (Y > X) {
            if (B > (C * 2)) {
                ans += (C * 2) * (Y - X);
            } else {
                ans += B * (Y - X);
            }
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 13396
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using BS = bitset<500>;

ll solve1(ll N, ll M, const V<BS> &rec) {
    ll ans = 0;
    for (ll S = 0; S < (1ll << N); S++) {
        ll cnt = 0;
        BS bs(0);
        for (ll j = 0; j < N; j++) {
            ll mask = 1ll << j;
            if (!(S & mask)) continue;
            cnt++;
            bs ^= rec[j];
        }
        if (bs.count() == 0) chmax(ans, cnt);
    }
    return ans;
}

ll solve2(ll N, ll M, const V<BS> &rec) {
    map<ll, ll> dp;
    dp[0] = 0;
    for (ll i = 0; i < N; i++) {
        ll bit = (ll)(rec[i].to_ullong());
        auto dps = dp;
        for (auto &&ele : dp) {
            ll k, v;
            tie(k, v) = ele;
            chmax(dps[k ^ bit], v + 1);
        }
        dp = move(dps);
    }
    return dp[0];
}

bool solve() {
    ll N, M;
    cin >> N >> M;
    if (!(N + M)) return false;
    
    V<BS> rec(N);
    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        for (ll j = 0; j < M; j++) if (s[j] == '1') rec[i].set(j, 1);
    }

    DEBUG(make_tuple(N, M));
    if (N < M) cout << solve1(N, M, rec);
    else cout << solve2(N, M, rec);
    cout << endl;
    return true;
}

int main() {
    while (solve());
    return 0;
}



Measured memory_bytes: 101452
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return gcd(b, a % b);
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

pair<ll, ll> rev(pair<ll, ll> a) {
    if(a.first >= 0) return mp(-a.second, a.first);
    else return mp(a.second, -a.first);
}

int main() {
    int N; cin >> N;
    ll A[N], B[N];
    pair<ll, ll> iwashi[N];
    map<pair<ll, ll>, ll> dis;
    ll ans = 1, cnt00 = 0, cnt01 = 0, cnt10 = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
        if(A[i] == 0 || B[i] == 0) {
            if(A[i] == 0 && B[i] == 0) {
                ++cnt00;
            } else if(A[i] == 0) {
                cnt10++;
            }else {
                cnt01++;
            }
        } else {
            ll GCD = gcd(abs(A[i]), abs(B[i]));
            if(B[i] < 0) {
                A[i] *= -1;
                B[i] *= -1;
            }
            iwashi[i].first = A[i] / GCD;
            iwashi[i].second = B[i] / GCD;
            dis[iwashi[i]]++;
        }
    }
    //cout << endl;
    ans = (modpow(2, cnt10) + modpow(2, cnt01) - 1) % MOD;
    for(auto itr = dis.begin(); itr != dis.end(); ++itr) {
        //cout << (itr->first).first << ' ' << (itr->first).second << endl;
        ans = (ans * ((modpow(2, dis[rev(itr -> first)]) + modpow(2, dis[itr -> first]) - 1 + MOD) % MOD)) % MOD;
        dis[rev(itr -> first)] = 0;
        dis[itr -> first] = 0;
    }
    cout << (ans + cnt00 - 1 + MOD) % MOD << endl;
}


Measured memory_bytes: 34840
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e6+3)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

int fact[M+10];
int ifact[M+10];

main(){
  fact[0]=1;
  FOR(i,1,M+1){
    fact[i]=(1LL*fact[i-1]*i)%M;
    ifact[i]=power(fact[i],M-2);
  }

  int q;
  cin>>q;
  while(q--){
    int x,d,n;
    cin>>x>>d>>n;
    if(d==0){
      cout<<power(x,n)<<endl;
    }else{
      int t=(1LL*x*power(d,M-2))%M;
      
      if(t<=M&&M<=t+n-1){
        cout<<0<<endl;
      }else{
        cout<<(((1LL*fact[t+n-1]*ifact[t-1])%M)*power(d,n)%M)<<endl;
      }
    }
  }
}


Measured memory_bytes: 8704
#include <stdio.h>

#define INF 2001
#define M 100
#define NIL -1
#define W 2002
#define B 2003

struct gif{
  int c;
  int r[M][2];
};
typedef struct gif fig;

int C[M];
int P[M];
int D[M];
fig T[M];
int G[M][M];

void prim(int a);

int main(){
  int a,b,c,i,j,k,x=0;

  scanf("%d",&a);
  for(i=0;i<a;i++){
    for(j=0;j<a;j++){
      scanf("%d",&G[i][j]);
      //printf("%d ",G[i][j]);
      /* c=0;
	 for(j=0;j<a;j++){
	 scanf("%d",&b);
	 if(b!=-1)T[i].r[c][1]=b;
	 T[i].r[c][0]=j;
	 c++;*/
    }
    //printf("\n");
  }
  
  /*T[i].c=c;
    for(j=0;j<c-1;j++){
      if(T[i].r[c-1][1]>T[i].r[j][1]{}
  */
  prim(a);
  for(i=0;i<a;i++)x+=D[i];
  
  printf("%d\n",x);
}
void prim(int a){
  int i,j,v,u,mcos;
  for(i=0;i<a;i++){
    D[i]=INF;
    P[i]=NIL;
    C[i]=W;
}
  D[0]=0;
  while(1){
    mcos=INF;
    for(i=0;i<a;i++){
      if(C[i]!=B && D[i]<mcos){
	mcos=D[i];
	u=i;
      }
    }
    if(mcos==INF)break;
    C[u]=B;
    for(j=0;j<a;j++){
	if(G[u][j]!=NIL){
	  v=j;
	  if(C[v]!=B && G[u][v]<D[v]){
	    P[v]=u;
	    D[v]=G[u][v];
	  }
	}
      }
  }
}



Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(void){
  string S;
  cin >> S;

  int i;
  int C_count = 0, C_place; //Cの数とその場所を格納

  //先頭がAでないならWA
  if(S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }

  //Cの数
  for(i=0; i<S.size(); i++)
    if(S[i] == 'C'){
      //先頭から3文字目と末尾から2文字目の間ならOK
      if(2<=i && i<=S.size()-2){
	C_count++;
	C_place = i;
      }
      //それ以外の場所にあればWA
      else{
	cout << "WA" << endl;
	return 0;
      }
    }

  //Cが丁度1個でないならWA
  if(C_count != 1){
    cout << "WA" << endl;
    return 0;
  }

  //全て小文字かどうか調べる
  //先頭は飛ばす
  for(i=1; i<S.size(); i++){
    //Cの場所は見なくてよい
    if(i == C_place)
      continue;
    
    //大文字があれば終了
    if('A'<=S[i] && S[i]<='Z'){
      cout << "WA" << endl;
      return 0;
    }
  }

  //上のテストを抜ければAC
  cout << "AC" << endl;

  return 0;
}


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


int main() {
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n-1;i++){
        int j;
        cin>>j;
        vec.at(j-1)+=1;
    }
    for(int i=0;i<n-1;i++){
        cout<<vec.at(i)<<endl;
      	
    }
  cout<<"0"<<endl;
}

Measured memory_bytes: 4052
import java.util.*;

public class Main{
    
    public static final int MAX = 3501;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        for(long x=1; x<MAX; x++){
            for(long y=x; y<MAX; y++){
                long u = n*x*y;
                long d = 4L*x*y-n*x-n*y;
                if(d!=0 && u%d==0 && u/d>0){
                    long z = u/d;
                    System.out.println(x+" "+y+" "+z);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int a, p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
}

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    for (int i = 0; i < n; i++)
    {
        for (int e = 0; e < m; e++)
        {
            if ((i < b) ^ (e < a))
                cout << 1;
            else
                cout << 0;
        }
        cout << "\n";
    }
}


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

void trace(int A[], int N) {
  for (int i=0; i<N; i++) {
    if (i!=0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  for (int i=1; i<N; i++) {
    int v = A[i];
    int j = i-1;
    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main() {
  int N;
  int A[1010];
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  trace(A, N);
  insertionSort(A, N);
  return 0;
}


Measured memory_bytes: 3104
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())

a = []

for _ in range(n):
    a.append(int(input()))

a.sort()

i = 0
ans = 0
while i < n:
    num = 1
    i += 1
    while i < n and a[i] == a[i-1]:
        num += 1
        i += 1
    if num % 2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 77200
import java.util.*;
import java.lang.*;

class MathLib{
    public static long divCeil(long a, long b){
        return (a+b-1)/b;
    }

    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

    public static LinkedList<Long> divisors(long N){
        LinkedList<Long> ans = new LinkedList<>();
        for(long n = (long)(Math.sqrt(N)+2); n>0; n--){
            if(n*n>N) continue;
            else if(n*n==N) ans.add(n);
            else if(N%n==0){
                ans.addFirst(n);
                ans.addLast(N/n);
            }
        }
        return ans;
    }
}

public class Main {
    static int divBy2(int n){
        int a=0;
        while(n%2==0){
            n /= 2;
            a++;
        }
        return a;
    }
    static void answer(long n){
        System.out.println(n);
        System.exit(0);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] B = new int[N];
        for(int n=0; n<N; n++) B[n]=sc.nextInt()/2;

        for(int n=1; n<N; n++) if(divBy2(B[0])!=divBy2(B[n])) answer(0);

        long L = B[0];
        for(int n=1; n<N; n++){
            L = MathLib.lcm(L, B[n]);
            if(L>M) answer(0);
        }

        answer(((M/L)+1)/2);

    }

}


Measured memory_bytes: 52804
#include<stdio.h>
#include<string.h>
int main(){
char s[1010];
int i,a;
fgets(s,1005,stdin);
a=strlen(s)-1;
for(i=0;i<a;i++){
if('D'<=s[i] && s[i]<='Z'){
s[i]=s[i]-3;
}
else{
s[i]=s[i]+23;
}
printf("%c",s[i]);
}
printf("\n");
return 0;
}


Measured memory_bytes: 2036
class Node:

    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None
        self.parent = None

    def append(self, node):
        if self.value > node.value:
            if self.left is None:
                node.parent = self
                self.left = node
            else:
                self.left.append(node)
        else:
            if self.right is None:
                node.parent = self
                self.right = node
            else:
                self.right.append(node)

    def in_parse(self, node, lst):
        if node is None:
            return
        self.in_parse(node.left, lst)
        lst.append(str(node.value))
        self.in_parse(node.right, lst)

    def pre_parse(self, node, lst):
        if node is None:
            return
        lst.append(str(node.value))
        self.pre_parse(node.left, lst)
        self.pre_parse(node.right, lst)


class BinaryTree:

    def __init__(self):
        self.root = None

    def insert(self, value):
        node = Node(value)
        if self.root is None:
            self.root = node
        else:
            self.root.append(node)

    def in_parse(self):
        lst = []
        self.root.in_parse(self.root, lst)
        return lst

    def pre_parse(self):
        lst = []
        self.root.pre_parse(self.root, lst)
        return lst


def main():
    n = int(input())
    tree = BinaryTree()

    for _ in range(n):
        line = input().split(' ')
        command = line[0]
        if command == 'insert':
            v = int(line[1])
            tree.insert(v)
        else:
            print(' ' + ' '.join(tree.in_parse()))
            print(' ' + ' '.join(tree.pre_parse()))


if __name__ == '__main__':
    main()



Measured memory_bytes: 139932
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

int unkoi(int a){
  if(a%10!=0) return ((a/10)+1)*10;
  else return a;
}

signed main(){
  int a[5]={},maxi=-1,rec,ans=0;
  rep(i,5){
    cin >> a[i];
    int res = unkoi(a[i])-a[i];
    if(res>maxi){
      maxi=res;
      rec=i;
    }
  }
  rep(i,5){
    if(i==rec) ans+=a[i];
    else ans+=unkoi(a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

using ps = pair<string,string>;

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

    vector<string> name;
    map<ps,int> ct;
    rep(i,n)
    {
        int m;
        cin >>m;

        vector<string> s(m);
        rep(j,m)
        {
            cin >>s[j];
            name.pb(s[j]);
        }
        sort(all(s));

        rep(k,m)rep(j,k) ++ct[ps(s[j],s[k])];
    }

    sort(all(name));
    name.erase(unique(all(name)),name.end());

    int N = name.size();

    set<ps> ans;
    rep(j,N)rep(i,j)
    {
        ps p(name[i],name[j]);
        if(ct[p]>=f) ans.insert(p);
    }

    cout << ans.size() << endl;
    for(const auto &p:ans) cout << p.fi << " " << p.se << endl;
    return 0;
}

Measured memory_bytes: 34588
def DigitsSUM(Num):
    sumN = 0
    while Num > 0:
        sumN += int(Num) % 10
        Num /= 10
    return int(sumN)


N,A,B = input().split()
LowerLimit=int(A)
UpperLimit=int(B)
num = int(N)
sumary = []
counter = 0
for i in range(1,num+1):
    sumN = DigitsSUM(i)
    
    if LowerLimit <= sumN and sumN <= UpperLimit:
        counter+=int(i)
        
print(counter)

Measured memory_bytes: 3064
# coding: utf-8

import sys

def _main():
    N = int(input())

    total = 0

    for n in range(N):
        text = input()
        data = text.split(' ')
        
        if data[1] == 'JPY':
            total += int(data[0])
        elif data[1] == 'BTC':
            total += float(data[0]) * 380000

    print(total)

if __name__ == '__main__':
    _main()

Measured memory_bytes: 3060