akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll x;
    cin >> x;
    // if(x <= 6){
    //     pr(1);
    //     return 0;
    // }
    // if(x <= 11){
    //     pr(2);
    //     return 0;
    // }
    // if((x%11) == 0){
    //     pr((x/11)*2);
    //     return 0;
    // }
    // ll ans = x/11;
    // if(x%11 <= 6){
    //     pr(ans*2+1);
    // }else{
    //     pr(ans*2+2);
    // }
    if((x%11) == 0){
        pr((x/11)*2);
    }else if((x%11) <= 6){
        pr((x/11)*2+1);
    }else{
        pr((x/11)*2+2);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = 1000000009;
void solve()
{
	ll a,b,c,d,m,m2,m1,m3;
	cin>>a>>b>>c>>d;
	ll f[4];
	m=max(a,b);
	m1=min(a,b);
	m2=max(c,d);
	m3=min(c,d);
	f[0]=m*m2;
	f[1]=m*m3;
	f[2]=m1*m2;
	f[3]=m1*m3;
	sort(f,f+4);
	cout<<f[3]<<endl;return;
}

	

int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t=1;
	//cin >> t;

	while (t--)
	{
		solve();
	}


	return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

int main() {
	int a[9];
	rep(i, 9) cin >> a[i];
	
	int n;
	vb c(9);
	cin >> n;
	vi b(n);
	rep(i, n) {
		cin >> b[i];
		rep(j, 9) {
			if (b[i] == a[j]) {
				c[j] = true;
				break;
			}
		}
	}

	if (c[0] == true && c[1] == true && c[2] == true) cout << "Yes" << endl;
	else if (c[3] == true && c[4] == true && c[5] == true) cout << "Yes" << endl;
	else if (c[6] == true && c[7] == true && c[8] == true) cout << "Yes" << endl;
	else if (c[0] == true && c[3] == true && c[6] == true) cout << "Yes" << endl;
	else if (c[1] == true && c[4] == true && c[7] == true) cout << "Yes" << endl;
	else if (c[2] == true && c[5] == true && c[8] == true) cout << "Yes" << endl;
	else if (c[0] == true && c[4] == true && c[8] == true) cout << "Yes" << endl;
	else if (c[2] == true && c[4] == true && c[6] == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    string s;
    cin >> s;
    
    int ans = 0;

    irep(i, s.size()/2) {
        if(s[i] != s[s.size()-1-i]) {
            ans++; 
        }
    }
    cout << ans;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int f = 0, g = a;
    FOR(i, 2, 101){
        if(a % b == c){
            f = 1;
            break;
        }
        a += g;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	
	for(int i=0;i<n;i++) cin>>a[i];
	
	int cnt=0,i;
	
	do{
		for(i=0;i<n;i++)
		   if(a[i]%2==1){
		   	cout<<cnt;
		   	return 0;
		   }
		   else
		      a[i]=a[i]/2;
		      
		cnt++;
	}while (1);
	
 } 

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

using Real = long long;
using Point = complex<Real>;
ostream &operator<<(ostream &os, Point &p) { return os << real(p) << " " << imag(p); }
istream &operator>>(istream &is, Point &p) {
    Real x, y; is >> x >> y; p = Point(x, y); return is;
}
Point rot90(const Point &a) { return Point(-imag(a), real(a)); }

int main() {
    Point a, b; cin >> a >> b;
    Point d = rot90(b - a) + a, c = rot90(a - d) + d;
    cout << c << " " << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, M, X, Y, A[100], B[100];
bool V;

bool valid(int n){
	for(int i = 0; i < N; i++)
		if(n <= A[i]) return false;
	for(int i = 0; i < M; i++)
		if(n > B[i]) return false;
	return true;
}

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d%d", &N, &M, &X, &Y);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < M; i++) scanf("%d", &B[i]);
	for(int i = X + 1; i <= Y; i++)
		if(valid(i)) V = true;
	if(V) printf("No War\n");
	else printf("War\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc162/tasks/abc162_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();


		int ans = 0;

		for(int i =1;i<=n;i++) {
			for(int j =1;j<=n;j++) {
				for(int k =1;k<=n;k++) {
					ans = ans + gcd(i,j,k);
				}
			}
		}


		System.out.println(ans);
	}


	public static final int gcd(final int... param) {
	    final int len = param.length;
	    int g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}

	public static final int gcd(int a, int b) {
	    //a > b にする（スワップ）
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    //ユークリッドの互除法
	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;    //b には r=0 の値が入るため、a を返す
	}
}


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

N = INT()
xyh = [LIST() for _ in range(N)]
xyh.sort(key = lambda x:[x[0], x[1]])

for Cx in range(101):
	for Cy in range(101):
		H = 0
		H_max = INF
		for x, y, h in xyh:
			if h == 0:
				H_max = min(H_max, h + abs(x-Cx) + abs(y-Cy))
			else:
				if H == 0:
					H = h + abs(x-Cx) + abs(y-Cy)
				else:
					if H != h + abs(x-Cx) + abs(y-Cy):
						break
		else:
			if H <= H_max:
				print(Cx, Cy, H)
				break
	else:
		continue
	break



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

bool isBingo(vector<bool> board)
{
  for(int i=0; i<3; i++)
  {
    if(board[i] && board[i + 3] && board[i + 6])
      return true;
    if(board[i*3] && board[i*3 + 1] && board[i*3 + 2])
      return true;
  }
  if(board[0] && board[4] && board[8] || board[2] && board[4] && board[6])
    return true;
  
  return false;
}

int main()
{
  vector<int> board_num(9);
  vector<bool> board(9);
  int n;
  string res = "No";
  for(int i=0; i<board.size(); i++)
  {
    cin >> board_num[i];
    board[i] = false;
  }
  
  cin >> n;
  for(int i=0; i<n; i++)
  {
    int b;
    cin >> b;
    vector<int>::iterator it = find(board_num.begin(), board_num.end(), b);
    if(it != board_num.end())
    {
      board[distance(board_num.begin(), it)] = true;
      if(isBingo(board))
      {
        res = "Yes";
        break;
      }
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll dp[301][301][301];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	string s;
	cin>>n>>m;
	n++;
	vb v(n,true);
	cin>>s;
	rep(i,n)if(s[i]=='1')v[i]=false;
	ll cur=n-1,p;
	vl ans;
	while(cur!=0){
		rep(i,m){
			if(cur-m+i<0)i=-(cur-m);
			p=cur-m+i;
			if(v[p]){
				ans.push_back(cur-p);
				cur=p;
				i=m;
			}
			if(i==m-1){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	reverse(all(ans));
	puta(ans);


}


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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int n;
int arr[200001];

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int sum=0;
    int h;

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

    h=arr[0];
    for(int i=1;i<n;i++){
        h=max(h,arr[i]);
        sum+=h-arr[i];
    }

    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 5204
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if string(a[len(a)-1]) == string(b[0]) && string(b[len(b)-1]) == string(c[0]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
inf = float("inf")
H, W = map(int, input().split())
graph = np.array([list(map(int, input().split())) for _ in range(10)])

shortest_paths = shortest_path(csr_matrix(graph), method="D")
ans = 0

Alist = [list(map(int, input().split())) for _ in range(H)]
for line in Alist:
    for a in line:
        if a >= 0:
            ans += shortest_paths[a][1]
print(int(ans))


Measured memory_bytes: 17408
#include <stdio.h>
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    
    if (a > b) printf("a > b\n");
    
    else if (a < b) printf("a < b\n");
    
    else if (a == b) printf("a == b\n");
    
    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    ll ans = 0;
    REPS(A, N)
    {
        ans += (N-1) / A; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)

A, B, C, D = map(int, input().split())

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)

print((B-A+1) -(b_num - a_num))

Measured memory_bytes: 3060
X, Y = list(input().split())
L = [X, Y]
for i in range(2):
	if L[i] == "A":
		L[i] = 10
	elif L[i] == "B":
		L[i] = 11
	elif L[i] == "C":
		L[i] = 12
	elif L[i] == "D":
		L[i] = 13
	elif L[i] == "E":
		L[i] = 14
	else:
		L[i] = 15

if X > Y:
	print(">")
elif X == Y:
	print("=")
else:
	print("<")

Measured memory_bytes: 3064
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    s = ""
    t = ""
    for i in range(W):
        if i%2 == 0:
            s += "#"
            t += "."
        else:
            s += "."
            t += "#"
    for i in range(H):
        if i%2 == 0:
            print(s)
        else:
            print(t)
    print()


Measured memory_bytes: 5612
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
  int a[3];
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  sort(a, a+3);

  for(int i=0; i<3; i++){
    cout << a[i];
    if( i!=2)
      cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1228
import collections

n, k = map(int, input().split())
l = list(map(int, (input().split())))
count = 0
c = collections.Counter(l)
c = c.most_common()[::-1]


if len(c) > k:
    for i in range(len(c)-k):
        count += c[i][1]
print(count)

Measured memory_bytes: 39336
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[110][110];
int r[110];
int c[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='#')r[i]=c[j]=1;
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)if(r[i]&&c[j])printf("%c",in[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

vector<ll> yaru(ll b,ll s){
    vector<ll> ret;
    for(ll i=2;i<=b+1;i++){
        ll num=b,sum=0;
        while(num){
            sum+=num%i;
            num/=i;
        }
        // cout<<"n = "<<i<<" : "<<sum<<" =? "<<s<<endl;
        if(sum==s) ret.push_back(i);
    }
    return ret;
}

ll f(ll b,ll n){
    ll ret=0;
    while(b){
        ret+=b%n;
        b/=n;
    }
    return ret;
}

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

    ll b,s;cin>>b>>s;

    // cout<<"floor(sqrt(b)) = "<<floor(sqrt(b))<<endl;
    // debug(yaru(b,s));

    for(ll i=2;i*i<=b;i++){
        if(f(b,i)==s){
            cout<<i<<endl;
            return 0;
        }
    }
    ll m=b-s;
    if(m<0){
        cout<<-1<<endl;
        return 0;
    }

    ll ans=LINF;
    for(ll i=1;i*i<=m;i++)if(m%i==0){
        {
            ll a=i;
            ll x=m/a+1;
            if(0<a and a<x and f(b,x)==s){
                chmin(ans,x);
            }
        }
        {
            ll x=i+1;
            ll a=m/i;
            if(0<a and a<x and f(b,x)==s){
                chmin(ans,x);
            }
        }

    }
    if(f(b,b+1)==s) chmin(ans,b+1);
    cout<<(ans<LINF?ans:-1)<<endl;
    return 0;
}


Measured memory_bytes: 384
def main():
    expr = input()
    stack = []
    for s in expr.split():
        if s == '+':
            a = stack.pop()
            b = stack.pop()
            stack.append(a + b)
        elif s == '-':
            a = stack.pop()
            b = stack.pop()
            stack.append(b - a)
        elif s == '*':
            a = stack.pop()
            b = stack.pop()
            stack.append(a * b)
        else:
            stack.append(int(s))
    print(stack.pop())


if __name__ == '__main__':
    main()



Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  map<int, int> m;
  for (int a : A) {
    m[a]++;
  }
  auto it = m.rbegin();
  auto [k1, v1] = *it;
  ++it;
  for (int a : A) {
    if (a != k1 || v1 != 1) {
      cout << k1 << endl;
    } else {
      cout << it->first << endl;
    }
  }
}


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

const int N = 1e2;

int n;
char str[N + 5];

bool check(int x) {
    bool flg = false;
    for (int i = x - 1; str[i] != '.' && i >= 1; i--) {
        if (str[i] == 'B') {
            flg = true;
            break;
        }
    }
    if (!flg) {
        return true;
    }
    for (int i = x + 1; str[i] != '.' && i <= n; i++) {
        if (str[i] == 'B') {
            return false;
        }
    }
    return true;
}
int calc(int x) {
    int ans = 0;
    for (int i = x - 1; str[i] != '.' && i >= 1; i--) {
        if (str[i] == 'W') {
            ans = std::max(ans, x - i - 1);
            break;
        }
    }
    for (int i = x + 1; str[i] != '.' && i <= n; i++) {
        if (str[i] == 'W') {
            ans = std::max(ans, i - x - 1);
            break;
        }
    }
    return ans;
}
int main() {
    scanf("%d %s", &n, str + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (str[i] == '.' && check(i)) {
            ans = std::max(ans, calc(i));
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
// #define int long long

ll mod(ll i, ll j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

signed main(){
    // int a= 1;
    // cout<< a/-2<<" "<<a%-2<<endl;
    // cout<<mod(-9,2)<<endl;
    ll N ;
    cin>>N;
    vector<int>v;
    if(N == 0)v.pb(0);
    while(N !=0){
        int ret = N %-2;
        if(ret<0  ){
            N += ret;             
            ret*= -1;            
        }
        v.pb(ret);
        N /= -2;
    }
    rrep(i,v.size())cout<<v[i];
    cout<<endl;    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<string.h>
#include<cctype>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else cout<<"No";













    return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    vector<bool> c(1000001,0) ;
    int s ;
    cin >> s ;
    int ans = 1 ;
    c.at(s) = 1 ;
    while (1)
    {
        if (s % 2 == 0)
        {
            s /= 2 ;
        }else
        {
            s = 3*s + 1 ;
        }
        ans ++ ;
        if (c.at(s) == 1)
        {
            break ;
        }else
        {
            c.at(s) = 1 ;
        }
        
        
        
    }
    
    cout << ans << endl ;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LL long long

const int maxn = 3e5+7;

using namespace std;

int w[maxn],e[maxn],ans=3e5+7,n;
string s;

int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n;
    cin>>s;

    memset(w,0,sizeof(w));
    memset(e,0,sizeof(e));
    for (int i=1;i<=n;i++)
    {
        if (s[i-1]=='W') w[i]=1;
        if (s[i-1]=='E') e[i]=1;
        w[i]=w[i]+w[i-1];
        e[i]=e[i]+e[i-1];
    }

    for (int i=1;i<=n;i++)
    {
        int temp=0;
        temp+=w[i-1]-w[0];
        temp+=e[n]-e[i];
        ans=min(temp,ans);
    }

    cout<<ans;
    return 0;
}


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

int main() {
  int n, x;
  vi m(110);
  cin >> n >> x;
  int sum = 0;
  int min_m = 1001000100;
  rep(i, n) {
    cin >> m[i];
    sum += m[i];
    if (min_m > m[i]) min_m = m[i];
  }

  // 残り
  int leftovers = x - sum;
  int ans = n + leftovers / min_m;

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int K, S; cin >> K >> S;

    int res = 0;
    rep(x, K + 1){
        rep(y, K + 1){
            if(0 <= S - x - y and S - x - y <= K){
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = b - a;
    ll ans;
    if (x % 2 == 0) ans = x / 2;
    else ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++ )
    {
        cin >> A[i];
    }
    res = 0;
    for (int i = 0; i < N-1; i++)
    {
        if(A[i+1]<A[i]){
            res += A[i] - A[i + 1];
            A[i + 1] = A[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4792
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main()
{
  int N, K, s = 0;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++)
  {
    cin >> l.at(i);
  }
  sort(l.rbegin(), l.rend());
  for (int i = 0; i < K; i++)
  {
    s += l[i];
  }
  cout << s << endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int gcd(int a, int b)
{
if (a%b == 0)
{
    return(b);
}
else
{
    return(gcd(b, a%b));
}
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
int main()
{
    cin >> N;
    vi arr(N);
    for (int i = 0; i < N; i++) 
    {
        cin >> A;
        B += --A;
    }

    cout << B;
    return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String args[]) {
        StringBuilder sb = new StringBuilder();
        
        
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                System.out.println(i+"x"+j+"="+(i*j));
            }
        }
    }
}

Measured memory_bytes: 16860
#include <stdio.h>

int main()
{
  char s[120000];
  char a['z'+2];
  char ans = 'z';

  fgets(s, sizeof(s), stdin);

  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
        a[s[i]]++;
      if (s[i] < ans) {
        ans = s[i];
      }
    }
    
  }

  int flag = 1;
  for (int i = 'a'; i <= 'z'; i++) {
    if (a[i] == 0) {
      flag = 0;
      ans = i;
      break;
    }
  }

  if (flag == 0 ) {
    printf("%c\n", ans);
  } else {
    printf("None\n");
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,d,b=0,c=INT_MAX;
  cin>>a;
  rep(i,a){
    cin>>d;
    c=min(d,c);
    if(c==d)b++;
  }
  cout<<b;
}


Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
typedef struct {
  int parent;
  int leftchild;
  int rightchild;
} Node;
Node t[25];
void preParse(int);
void inParse(int);
void postParse(int);
  
int main()
{
  int n,i,id,right,left;
  scanf("%d",&n);
  for(i=0; i<n; i++) t[i].parent=NIL;
  for(i=0; i<n; i++) {
    scanf("%d%d%d",&id,&left,&right);
    t[id].leftchild=left; t[id].rightchild=right;
    if(left!=NIL) t[left].parent=id;
    if(right!=NIL) t[right].parent=id;
  }
  
  for(i=0; ; i++) {
    if(t[i].parent==NIL) {
      printf("Preorder\n");
      preParse(i);
      printf("\nInorder\n");
      inParse(i);
      printf("\nPostorder\n");
      postParse(i);
      printf("\n");
      break;
    }
  }
  return 0;
}
  
void preParse(int u)
{
  if(u==NIL)  return;
  printf(" %d",u);
  preParse(t[u].leftchild);
  preParse(t[u].rightchild);
}
  
void inParse(int u)
{
  if(u==NIL) return;
  inParse(t[u].leftchild);
  printf(" %d",u);
  inParse(t[u].rightchild);
}
  
void postParse(int u)
{
  if(u==NIL) return;
  postParse(t[u].leftchild);
  postParse(t[u].rightchild);
  printf(" %d",u);
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x;
int main()
{
cin>>x;
for(ll i=-120;i<=120;i++)

for(ll j=-120;j<=120;j++)
{
	if(i*i*i*i*i-j*j*j*j*j==x)
	{
	
	cout<<i<<" "<<j;
	return 0;
}
}

return 0;

}

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

int main(){
    int n;
    while(cin>>n && n!=0){
        string s[n];
        bool d=true;
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        int cnt=0;
        for(int i=0;i<n-1;){
            if(d){
                if(s[i][1]=='u' && s[i+1][1]=='u'){
                    d=false;
                    cnt++;
                    i+=2;
                    continue;
                }
                else{
                    i++;
                    continue;
                }
            }
            else {
                if(s[i][1]=='d' && s[i+1][1]=='d'){
                    d=true;
                    cnt++;
                    i+=2;
                    continue;
                }
                else {
                    i++;
                    continue;
                }
            }
        }
        cout<<cnt<<endl;

    }
    
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;


signed main() {
  int N; cin >> N;
  vector<int> Input(N);
  
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }

  for (int i = 1; i < N; i++) {
    Input[i] += Input[i-1];
  }

  unordered_map<int, int> freq;

  freq[0] = 1;
  for (const auto &x: Input) {
    freq[x]++;
  }

  int ans = 0;
  for (const auto &x: freq) {
    // cout << x.first << x.second << endl;
    ans += x.second * (x.second - 1) / 2;
  }

  cout << ans << endl;
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] sw = br.readLine().split(" ");
			int s = Integer.parseInt(sw[0]);
			int w = Integer.parseInt(sw[1]);
			System.out.println((w >= s) ? "unsafe" : "safe");
		}
	}
}

Measured memory_bytes: 32504
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <map>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct T
{
	T *l,*r;
	int pr,nd;
	ll vl;
	T(ll vl=0,T *l=NULL,T *r=NULL):vl(vl),l(l),r(r){pr=rand();nd=1;}
	void update()
	{
		nd=1;
		if(l!=NULL) nd+=l->nd;
		if(r!=NULL) nd+=r->nd;
	}
};//priority が小さい順にbuild
typedef pair <T*,T*> PT;
struct Treap
{
	T *root;
	
	T *merge(T *l,T *r)
	{
		if(l==NULL) return r;
		if(r==NULL) return l;
		if(l->pr<=r->pr)
		{
			l->r=merge(l->r,r);
			l->update();
			return l;
		}
		else
		{
			r->l=merge(l,r->l);
			r->update();
			return r;
		}
	}
	ll get(T *v,int k)
	{
		T *l=v->l,*r=v->r;
		int left=l==NULL?0:l->nd;
		if(k==left) return v->vl;
		if(k<left) return get(l,k);
		else return get(r,k-left-1);
	}
	PT split(T *v,ll x)
	{
		if(v==NULL) return PT(NULL,NULL);
		if(v->vl>x)
		{
			PT p=split(v->l,x);
			v->l=p.second;
			v->update();
			return PT(p.first,v);
		}
		else
		{
			PT p=split(v->r,x);
			v->r=p.first;
			v->update();
			return PT(v,p.second);
		}
	}
	void add(ll x)
	{
		PT p=split(root,x);
		root=merge(merge(p.first,new T(x)),p.second);
	}
	ll median()
	{
		int tg=root->nd/2;
		return get(root,tg);
	}
	void see(T *v)
	{
		if(v==NULL) return;
		see(v->l);
		printf("%lld ",v->vl);
		see(v->r);
	}
	void check()
	{
		printf("%d : ",root->nd);
		see(root);
		puts("");
	}
};
ll A[SIZE];
Treap dat[SIZE];
vector <ll> nd[SIZE];
ll memo[SIZE];
int start[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	for(int i=0;i<n;i++)
	{
		ll b;
		scanf("%lld",&b);
		A[i]-=b;
	}
	for(int i=1;i<n;i++) A[i]+=A[i-1];
	//for(int i=0;i<n;i++) printf("%lld ",A[i]);puts("");
	int sz=0;
	for(int i=0;i<n;i++)
	{
		nd[sz].clear();
		nd[sz].push_back(A[i]);
		dat[sz].root=new T(A[i]);
		memo[sz]=A[i];
		while(sz>0)
		{
			if(memo[sz-1]<=memo[sz]) break;
			if(nd[sz].size()>nd[sz-1].size())
			{
				swap(dat[sz],dat[sz-1]);
				swap(nd[sz],nd[sz-1]);
			}
			for(int i=0;i<nd[sz].size();i++)
			{
				ll v=nd[sz][i];
				nd[sz-1].push_back(v);
				dat[sz-1].add(v);
			}
			memo[sz-1]=dat[sz-1].median();
			sz--;
		}sz++;
	}
	ll ret=0;
	for(int i=0;i<sz;i++)
	{
		//printf("%lld : ",memo[i]);
		//for(int j=0;j<nd[i].size();j++) printf("%lld ",nd[i][j]);puts("");
		if(memo[i]<0) memo[i]=0;
		else if(memo[i]>A[n-1]) memo[i]=A[n-1];
		//dat[i].check();
		for(int j=0;j<nd[i].size();j++)
		{
			ret+=llabs(nd[i][j]-memo[i]);
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 15744
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int Max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	int X;

	int B_min = B*10;
	int B_max = B*10 + 9;
	int A_min, A_max;
	if(A%2 == 0){
		A_min = 25*A/2;
		A_max = A_min + 12;
	}
	else{
		A_min = 25*A/2 + 1;
		A_max = A_min + 11;
	}

	// printf("X_A = %d X_B = %d\n",X_A,X_B);
	int i,j;
	for(int i=A_min; i<=A_max; i++){
		for(int j=B_min; j<=B_max; j++){
			if(i == j){
				printf("%d\n",i);
				return 0;
			}
		}
	} 
	printf("-1\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define swap( x, y ) do { double tmp; tmp = x; x = y; y = tmp; } while ( 0 )

int rel_s_s( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y ) {
	double a, b, c, d;
	int rel;

	if ( x1 < x0 ) {
		swap( x0, x1 );
		swap( y0, y1 );
	}
	if ( x3 < x2 ) {
		swap( x2, x3 );
		swap( y2, y3 );
	}

	if ( x0 != x1 ) {
		a = ( y0 - y1 ) / ( x0 - x1 );
		b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
	}
	if ( x2 != x3 ) {
		c = ( y2 - y3 ) / ( x2 - x3 );
		d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
	}

	rel = 1;
	if ( x0 == x1 ) {
		*x = x0;
		if ( x2 == x3 )
			if ( x0 == x2 ) {
				if ( y1 < y0 )
					swap( y0, y1 );
				if ( y3 < y2 )
					swap( y2, y3 );

				if ( y3 < y0 || y1 < y2 )
					rel = 3;
				else if ( y3 == y0 || y1 == y2 ) {
					*y = y3 == y0 ? y0 : y1;
					rel = 4;
				} else
					rel = 5;
			} else
				rel = 2;
		else {
			*y = c * *x + d;
			if ( *x < x2 || x3 < *x || *y < ( y0 < y1 ? y0 : y1 ) || ( y0 < y1 ? y1 : y0 ) < *y )
				rel = 0;
		}
	} else {
		if ( x2 == x3 ) {
			*x = x2;
			*y = a * *x + b;
			if ( *x < x0 || x1 < *x || *y < ( y2 < y3 ? y2 : y3 ) || ( y2 < y3 ? y3 : y2 ) < *y )
				rel = 0;
		} else {
			if ( a == c )
				if ( b == d )
					if ( x3 < x0 || x1 < x2 )
						rel = 3;
					else if ( x3 == x0 || x1 == x2 ) {
						*x = x3 == x0 ? x0 : x1;
						rel = 4;
					} else
						rel = 5;
				else
					rel = 2;
			else {
				*x = ( -b + d ) / ( a - c );
				if ( *x < x0 || x1 < *x || *x < x2 || x3 < *x )
					rel = 0;
			}
			*y = a * *x + b;
		}
	}

	return rel;
}

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		int rel;
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		rel = rel_s_s( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );

		printf( "%d\n", rel == 1 || rel == 4 || rel == 5 ? 1 : 0 );
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k,d,t;
    cin >> n >> k;
    int a[n] = {0};
    for(int i = 0; i < k ; i++){
        cin >> d;
        for(int j = 0; j < d ; j++){
            cin >> t;
            a[t-1]=1;
        }
    }
    int c = 0;
    for(int i = 0; i < n ; i++){
        if(a[i] == 0 )c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3544
#素因数分解
def prime_factor(n):
        ass = []
        for i in range(2,int(n ** 0.5) + 1):
            while n % i == 0:
                ass.append(i)
                n = n // i
        if n != 1:
            ass.append(n)
        return ass

a,b=map(int,input().split())
a=list(set(prime_factor(a)))
b=list(set(prime_factor(b)))

arr=[i for i in a if i in b]
print(len(arr)+1)


Measured memory_bytes: 38512
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    MOD = 10**9 + 7
    d = defaultdict(lambda: 0)
    for a in A:
        d[a] += 1
        if d[a] >= 3:
            return 0

    if not (d[0] == 0 or d[0] == 1):
        return 0

    cnt = 0
    A = set(A)
    for a in A:
        if a == 0:
            continue

        if d[a] != 2:
            return 0
        else:
            cnt += 1

    return (2**cnt) % MOD


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


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

int main() {
    int n, k, x, y;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    int price = 0;
    if(n <= k){
        price = n * x;
    } else {
        price = (n - k)*y + k * x;
    }
    cout << price << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x, y;
  scanf("%d %d", &x, &y);
  while(y){
    if(y > x){
      int tmp = y;
      y = x;
      x = tmp;
    }
    if(y){
      int tmp = y;
      y = x % y;
      x = tmp;
    }
  }
  printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 99999999
typedef std::pair<int,int> pii;
struct point {
    char process[11];
    int time;
};
int main(){
    int N,q;
    std::cin >> N >> q;
    std::queue<point> p;
    point input;
    for (int i = 0; i < N; i++) {
        std::cin >> input.process >> input.time;
        p.push(input);

    }
    int sum = 0;
    while (!p.empty()) {
        point cur = p.front();
        p.pop();
        
        if (cur.time <= q) {
            sum += cur.time;
            std::cout << cur.process << " " << sum << std::endl;
        }
        else {
            sum += q;
            cur.time -= q;
            p.push(cur);
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

from collections import Counter 
from collections import defaultdict
import itertools
import sys
sys.setrecursionlimit(10**6)

def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans)




n=int(input())
node=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=input_list()
    w=w%2
    u-=1
    v-=1
    node[u].append([v,w])
    node[v].append([u,w])

ans=[-1 for _ in range(n)]
ans[0]=0
sol(0,0,node,ans)
for i in ans:
    print(i)

Measured memory_bytes: 83936
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< P, P > PP;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 510;

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

    int h, w;
    cin >> h >> w;
    int a[SIZE][SIZE];
    vector< PP > v;
    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) {
            cin >> a[i][j];

        }
    }

    int cnt = 0;
    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) {
            if( !i || !j ) {
                if( j ) {
                    if( a[i][j - 1] % 2 ) {
                        a[i][j]++;
                        a[i][j - 1]--;
                        v.pb( MP( MP( i + 1, j ), MP( i + 1, j + 1 ) ) );
                        ++cnt;
                    }
                } else if( i ) {
                    if( a[i - 1][j] % 2 ) {
                        a[i][j]++;
                        a[i - 1][j]--;
                        v.pb( MP( MP( i, j + 1 ), MP( i + 1, j + 1 ) ) );
                        ++cnt;

                    }
                }

            } else {
                if( a[i][j - 1] % 2 ) {
                    a[i][j]++;
                    a[i][j - 1]--;
                    v.pb( MP( MP( i + 1, j ), MP( i + 1, j + 1 ) ) );
                    ++cnt;

                }
                if( a[i - 1][j] % 2 ) {
                    a[i][j]++;
                    a[i - 1][j]--;
                    v.pb( MP( MP( i, j + 1 ), MP( i + 1, j + 1 ) ) );
                    ++cnt;
                }
            }
        }
    }

    cout << cnt << endl;
    for( int i = 0; i < v.size(); ++i ) {
        cout << v[i].F.F << " " << v[i].F.S << " " << v[i].S.F << " " << v[i].S.S << endl;

    }
    return 0;
}



Measured memory_bytes: 5232