akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){int i,x,n,mn=1000,k,ans;
cin>>x>>n;
map<int,int>mp;
for(i=0;i<n;i++){
    cin>>k;
    mp[k]++;
}
    for(i=-101;i<=101;i++){
        if(mp[i])continue;
        if(abs(x-i)<mn){mn=abs(x-i);ans=i;}
    }cout<<ans;
    return 0;}

Measured memory_bytes: 3648
N=int(input())
D=list(map(int, input().split()))
M=int(input())
T=list(map(int, input().split()))
import bisect
D=sorted(D)
T=sorted(T)
idx=0
for i in range(M):
    t=T[i]
    while D[idx]<t:
        idx+=1
    if D[idx]!=t:
        print("NO")
        exit()
    idx+=1
print("YES")

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<char> s(n);
  for(int i=0;i<n;i++){
   cin >> s.at(i); 
  }
  if(s.at(k-1)=='A'){
    s.at(k-1)='a';
  }else if(s.at(k-1)=='B'){
    s.at(k-1)='b';
  }else{
   s.at(k-1)='c'; 
  }
  
  for(int i=0;i<n;i++){
   cout << s.at(i) ;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex> //exp
#include<cstdlib> //rand,exit
#include<time.h>
#include<fstream>

using namespace std;


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

  //float A_org_min, A_org_max;
  //float B_org_min, B_org_max;


  //A_org_min=A/0.08;
  //A_org_max=A/0.08+8;
  
  //B_org_min=B*10;
  //B_org_max=B*10+10;

  
  //cout<<  A_org_min<<" "<<A<<" "<<A_org_max<<endl;
  //cout<<  B_org_min<<" "<<B<<" "<<B_org_max<<endl;
  
  int start,end;
  int A_out, B_out;
  start=A/0.08-15;
  end=B/0.1+15;
  for(int i=start;i<end;i++)
    {
//cout<<i<<endl;
A_out=i*0.08;
B_out=i*0.1;
if (A_out==A && B_out==B){
result=i;
break;
}
}



cout << result <<endl;
  
  return 0;
}



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

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

    int sum = 0;
    int x = n;
    while(x > 0){
        sum += (x % 10);
        x /= 10;
    }

    if(n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n;
    string s;
    int count=0;

    cin>>n>>s;

    FOR(i,0,n-3){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            count++;
        }
    }
    cout<<count<<endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int count = 0;

    public static void main(String[] args) {
        read();
        solve();
        output();
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
    }

    public static void solve() {
        boolean flag= true;
        while(flag) {
        flag = false;
            for (int i = n-1; i > 0; i--) {
                if (a[i - 1] > a[i]) {
                    int tmp = a[i];
                    a[i] = a[i - 1];
                    a[i - 1] = tmp;
                    flag = true;
                    count++;
                }
            }
        }
    }

    public static void output() {
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
            if (i + 1 < a.length) {
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(count);
    }
}

Measured memory_bytes: 26208
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int min = 2000000000;
    int p = -min;

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        if (k - min > p) {
            p = k - min;
        }
        if (k < min) {
            min = k;
        }
    }

    cout << p << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,x,y;
    x=a+b;
    y=c+d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d)
    cout << "Balanced "<< ' ';
    else if(a+b>c+d)
    cout <<"Left" <<' ';
    else if(a+b<c+d)
    cout << "Right "<<' ';
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> graph[n + 1], result[n + 1], depth(n + 1, -1);
    for (int a, b; cin >> a >> b; ) {
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    if (m % 2 == 1) {
        cout << -1;
    } else {
        function<void(int, int)> dfs = [&](int current, int parent) {
            for (int next : graph[current]) {
                if (depth[next] == -1) {
                    depth[next] = depth[current] + 1;
                    dfs(next, current);
                } else if (depth[next] > depth[current]) {
                    result[current].emplace_back(next);
                }
            }
            if (result[current].size() % 2 == 0) {
                if (parent != -1) {
                    result[parent].emplace_back(current);
                }
            } else {
                result[current].emplace_back(parent);
            }
        };
        depth[1] = 0;
        dfs(1, -1);
        for (int i = 1; i <= n; i++) {
            for (int j : result[i]) {
                cout << i << ' ' << j << '\n';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17408
#include<stdio.h>
int main()
{
    int x,y;
   while(scanf("%d %d",&x,&y)!=EOF)

{

 if(x==0 && y==0)
    {
        break;
    }

    if(x>y)
    {
        printf("%d %d\n",y,x);
    }
    else{
         printf("%d %d\n",x,y);
    }
   
}

    return 0;
}



Measured memory_bytes: 1972
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll l=in(),r=in();
    vector<bool>lrmod(2019,false);
    for(ll i=l;i<=r;++i){
        if(lrmod[i%2019])break;
        lrmod[i%2019]=true;
    }
    ll ans=2019;
    REP(i,2019){
        if(lrmod[i]){
            for(ll j=i+1;j<2019;++j){
                if(lrmod[j])ans=min(ans,i*j%2019);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

string rev(string s) {
	reverse(s.begin(), s.end());
	return s;
}

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

	for (int data_i = 0; data_i < m; ++data_i) {
		string s;
		cin >> s;

		set<string> t;

		for (int i = 0; i < s.size() - 1; ++i) {
			string s1 = s.substr(0, i + 1);
			string s2 = s.substr(i + 1, s.size() - i);
			string temp;

			t.emplace(s1 + s2);
			t.emplace(rev(s1) + s2);
			t.emplace(s1 + rev(s2));
			t.emplace(rev(s1) + rev(s2));

			t.emplace(s2 + s1);
			t.emplace(rev(s2) + s1);
			t.emplace(s2 + rev(s1));
			t.emplace(rev(s2) + rev(s1));
		}

		cout << t.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<functional>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

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

int main(){
  int n,m; cin >> n >> m;
  
  vector<int> x(m); rep(i,m) cin >> x[i];
  
  if(n >= m){cout << 0 << endl; return 0;}
  
  sort(x.begin(),x.end());
  
  vector<int> d(m-1);
  rep(i,m-1) d[i] = x[i+1] - x[i];
  
  sort(d.begin(),d.end(),greater<int>());
  
  ll ans = 0;
  for(int i = n-1; i < m-1; ++i) ans += d[i];
  cout << ans << endl;  
}

Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
using namespace std;
int ti[100000];
int n;
int tot[100000];int k=0;
int kasita(int a,int b){
	int num=0;
	for(int i=1;i<=n;i++){
		if(i!=a)
		num+=ti[i];
		else
		num+=b;
	}
	tot[++k]=num;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ti[i];
	} 
	int m;
	cin>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		kasita(a,b);
	}
	for(int l=1;l<=k;l++){
		cout<<tot[l]<<endl;
	}
	
} 

Measured memory_bytes: 256
n = int(input())
nums = []


for v in range(n):
    num = int(input())
    nums.append(num)

ma = -1000000000
mi = nums[0]
for p in range(1,len(nums)):
    a = nums[p]
    if a-mi > ma:
        ma = a-mi
    if a < mi:
        mi = a
    
        

    
        
print(ma)


Measured memory_bytes: 13592
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    C = 1000
    kabu = 0

    for i in range(1, n):
        if A[i - 1] <= A[i]:
            kabu = C // A[i - 1]
            C += kabu * (A[i] - A[i - 1])

    print(C)

resolve()

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vi B(N - 1);
    cin >> B;
    vi A(N);
    rep(i, 1, N - 1) {
        A[i] = min(B[i - 1], B[i]);
    }
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    int sum = accumulate(all(A), 0LL);
    cout << sum << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
class Module
  def tco(name)
    continue = []
    called = false
    arguments = nil

    private_name = "private_" + name.to_s
    alias_method private_name, name
    private private_name

    define_method(name) do |*args|
      unless called
        called = true
        while true
          result = send(private_name, *args)
          if result.equal? continue
            args = arguments
          else
            called = false
            return result
          end
        end
      else
        arguments = args
        continue
      end
    end
  end
end


class Solve
  def parent(x)
    return x if $mark[x] >= 1
    parent($arr[x])
  end
  tco :parent
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  $arr = Array.new(n+1)
  (2..n).each{ |i| $arr[i] = gets.to_i }
  $mark = Array.new(n+1, 0)
  $mark[1] = 1
  sum = 0
  s = Solve.new
  qs = []
  q.times do
    qs << gets.split
  end
  qs.each do |cmd, n|
    if cmd == 'M'
      $mark[n.to_i] += 1
    end
  end
  qs.reverse.each do |cmd, n|
    if cmd == 'M'
      $mark[n.to_i] -= 1
    else
      sum += s.parent(n.to_i)
    end
  end
  p sum
end

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> x(5);
    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < 5; ++i) {
        if (x[i] == 0) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> t(n + 1), x(n + 1), y(n + 1);
    x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; i++)
    {
        if ((x[i] + y[i] - t[i]) % 2 != 0 or x[i] + y[i] > t[i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
char s[1000006];
bool isPalindrome(int l, int r)
{
    int i,flag = 0;
    for(i=l;i<=r;i++)
    {
        //cout<<s[i]<<" "<<s[r+l-i]<<endl;
        if(s[i] == s[r+l-i])
        flag++;
    }
    //cout<<flag<<endl;
    if(flag == r-l+1)
    return true;
    else
    {
        return false;
    }
}
int main(void)
{
    scanf("%s",s);
    int n = strlen(s);
    //cout<<isPalindrome(0,n-1)<<" "<<isPalindrome(0,((n-1)/2)-1)<<" "<<isPalindrome((n+3)/2-1,n-1)<<endl;
    if(isPalindrome(0,n-1) && isPalindrome(0,((n-1)/2)-1) && isPalindrome(((n+3)/2)-1,n-1))
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


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

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef queue<int> qu;
typedef map<int, map<int, int> > miii;

vi bfsMinSum(vvi &ns, vi &v, int &s) {
	vi vns(ns.size(), -1), vis(ns.size());
	miii edges;
	int e = 1, k = 0, i;
	qu q;
	q.push(e);
	vis[e] = 1;
	vns[e] = v[k++];
	while (!q.empty()) {
		e = q.front(); q.pop();
		for (i = 0; i < ns[e].size(); i++) {
			if (vis[ns[e][i]] == 0) {
				vis[ns[e][i]] = 1;
				vns[ns[e][i]] = v[k++];
				edges[e][ns[e][i]] = min(vns[e], vns[ns[e][i]]);
				edges[ns[e][i]][e] = min(vns[e], vns[ns[e][i]]);
				q.push(ns[e][i]);
			}
		}
	}
	for (auto it = edges.begin(); it != edges.end(); it++) {
		for (auto jt = it->second.begin(); jt != it->second.end(); jt++)
			s += jt->second;
	}
	s /= 2;
	return vns;
}

int main()
{
	int n, a, b, c, i, s = 0;
	scanf("%d", &n);
	vi vals, vis(n + 1), vns;
	vvi ns(n + 1);
	for (i = 0; i < n - 1; i++) {
		scanf("%d %d", &a, &b);
		ns[a].push_back(b);
		ns[b].push_back(a);
	}
	for (i = 0; i < n; i++) {
		scanf("%d ", &c);
		vals.push_back(c);
	}
	sort(vals.rbegin(), vals.rend());
	vns = bfsMinSum(ns, vals, s);
	printf("%d\n", s);
	for (i = 1; i <= n; i++) {
		printf("%d", vns[i]);
		if (i < n)
			printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Traveling Alone: One-way Ticket of Youth
 * 
 */
public class Main {

	static Main main = new Main();

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			Graph g = main.new Graph(m);

			for (int i = 0; i < n; ++i) {
				g.addEdge(br.readLine());
			}

			int k = Integer.parseInt(br.readLine());
			for (int i = 0; i < k; ++i) {
				System.out.println(g.getMinCost(br.readLine()));
			}
		}
	}

	class Graph {

		// 設問上、十分な値
		final int INFINITY = Integer.MAX_VALUE;
		final int NOT_REACHABLE = -1;

		int length;
		Edge[][] matrix;

		Graph(int m) {
			length = m + 1;
			matrix = new Edge[length][length];
		}

		void addEdge(String info) {

			int a, b, c, t;
			StringTokenizer st = new StringTokenizer(info);

			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			c = Integer.parseInt(st.nextToken());
			t = Integer.parseInt(st.nextToken());

			addEdge(a, b, c, t);
		}

		void addEdge(int a, int b, int cost, int time) {
			Edge e = new Edge(cost, time);
			matrix[a][b] = e;
			matrix[b][a] = e;
		}

		int getMinCost(String info) {
			int p, q, r;
			StringTokenizer st = new StringTokenizer(info);

			p = Integer.parseInt(st.nextToken());
			q = Integer.parseInt(st.nextToken());
			r = Integer.parseInt(st.nextToken());

			return getMinCost(p, q, r);
		}

		int getMinCost(int p, int q, int r) {

			boolean[] checked = new boolean[length];
			int[] total = new int[length];

			for (int i = 1; i < length; ++i) {
				total[i] = INFINITY;
			}
			total[p] = 0;

			//
			int next = p;
			while (next != NOT_REACHABLE) {

				int s = next;
				checked[s] = true;

				for (int g = 1; g < length; ++g) {
					if (matrix[s][g] != null && !checked[g]) {
						if (total[g] > total[s] + matrix[s][g].weight[r]) {
							total[g] = total[s] + matrix[s][g].weight[r];
						}
					}
				}
				int min = INFINITY;
				next = NOT_REACHABLE;
				for (int g = 1; g < length; ++g) {
					if (total[g] < min && !checked[g]) {
						min = total[g];
						next = g;
					}
				}
			}

			return total[q];
		}
	}

	class Edge {
		int[] weight;

		Edge(int cost, int time) {
			weight = new int[] { cost, time };
		}
	}
}

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

#define all(cont)           begin(cont), end(cont)
using ll = long long;
using vi = vector<ll>;


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

	ll r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}


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

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x < r) {
		cout << "No" << endl;
	}
	else if(x + r > W) {
		cout << "No" << endl;
	}
	else if(y < r) {
		cout << "No" << endl;
	}
	else if(y + r > H) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
if __name__=="__main__":
    l = list(map(int,input().split(" ")))
    N = l[0]
    A = l[1]
    B = l[2]
    temp = 0
    for i in range(1,N+1):
        if A<=sum(map(int,list(str(i))))<=B:
            temp+=i
    print(temp)

Measured memory_bytes: 3064
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()


Measured memory_bytes: 19196
#include<stdio.h>
#define N 10000
int isPrime(int x);

int main(){
  int n,i,x;
  int cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isPrime(x)==1) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

int isPrime(int x){
  int i;
  if(x<2) return 0;
  else if(x==2) return 1;

  if(x%2==0) return 0;
  for(i=3;i*i<=x;i+=2){
    if(x%i==0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2144
n = gets.to_i

K = (3*n/4).ceil

MAX = 3500

MAX.downto(K) do |c|
  K.downto(1) do |a|
    b_bunbo = 4*c*a - a*n -c*n
    b_bunshi = n*c*a
    next if b_bunbo <= 0 || b_bunshi%b_bunbo != 0
    b = b_bunshi/b_bunbo
    puts "#{a} #{b} #{c}"
    exit
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>

using namespace std;

int main(){

	double p0x,p0y,p1x,p1y,p2x,p2y,tx,ty;
	int q;
	double a01,a2t,b01,b2t;

	cin>>p0x>>p0y>>p1x>>p1y;

	cin>>q;

	for(int i=0;i<q;i++){
		cin>>p2x>>p2y;
		if(p0x-p1x!=0) a01=(p0y-p1y)/(p0x-p1x);
		else a01=0;
		if(a01!=0) a2t=-1/a01;
		else a2t=0;
		b2t=p2y-a2t*p2x;
		b01=p0y-a01*p0x;
		if(a01-a2t!=0) tx=(b2t-b01)/(a01-a2t);
		else tx=0;
		ty=a01*tx+b01;
		if(p0x==p1x) ty=p2y;
		if(p0y==p1y) tx=p2x;
		printf("%.10f %.10f\n",tx,ty);
	}

	return 0;
}

Measured memory_bytes: 1252
//Range Product

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
struct edge{int to;ll cost;};
const int inf = 2147483647;

int main (){
    ll a,b;cin>>a>>b;
    if(a*b<=0){cout<<"Zero"<<endl;return 0;}
    if(a>0&&b>0){cout<<"Positive"<<endl;return 0;}
    if((b-a)%2==0){cout<<"Negative"<<endl;return 0;}
    else {cout<<"Positive"<<endl;return 0;}
    return 0;
}

Measured memory_bytes: 256
s = input()
a = int(len(s)/2)
b = []
if len(s)%2 == 0 :
    for i in range(0,a) :
        b += s[2*i]
    li = ''.join(b)
    print(li)
else :
    for i in range(0,a+1) :
        b += s[2*i]
    li = ''.join(b)
    print(li)

Measured memory_bytes: 3700
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        long i = sc.nextLong();
        long o = sc.nextLong();
        long t = sc.nextLong();
        long j = sc.nextLong();
        long l = sc.nextLong();
        long s = sc.nextLong();
        long z = sc.nextLong();
        long ret = 0;
        ret += o;
        long temp = 0;
        if (i>0&&j>0&&l>0) {
            temp = Math.max(temp, (i-1)/2*2+(j-1)/2*2+(l-1)/2*2+3);
        }
        temp = Math.max(temp, i/2*2+j/2*2+l/2*2);
        ret += temp;
        
        System.out.println(ret);
    }
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005
// テンプレ終了
//====================================================================//




int main(){
	int N;cin>>N;
	vector<int> A(N),B(N);
	REP(i,N)cin>>A[i]>>B[i];
	vector<int> ord(N);
	iota(ord.begin(),ord.end(),0);

	sort(ord.begin(),ord.end(),[&](int x,int y){
		if(B[x]==B[y]) return A[x] < A[y];
		return B[x] < B[y];
	});

	//for(auto i:ord)cout << A[i] << " " << B[i] << endl;

	ll suml = 0;
	int flag = 1;
	for(auto i:ord){
		suml += A[i];
		if(suml > B[i])flag = 0;
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int i,j,a[10],n;
	n=0;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	/*for(i=0;i<10;i++){
		printf("i=%d\n",a[i]);
	}*/
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				n=a[i];
				a[i]=a[j];
				a[j]=n;
			}
			//printf("i=%d j=%d\n\n",a[i],a[j]);
		}
		
	}
	for(i=0;i<3;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)




int main(void)
{
    int n;
    cin>>n;
    int ya =0; 
    for(int i=1;i<=n;i+=2)
    {   
        int y=0;
        for(int j=1;j<=i;j++)
        {
            if(i%j==0) y++;
        }
        if(y==8) ya++;
    }
    cout<<ya<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>M;
    ll sum = 0, keta = 0;
    rep(i,M){
        cin>>A>>B;
        sum += A*B;
        keta += B;
    }
    cout<<(sum - 1)/9 + (keta - 1)<<endl;
}

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

int par[100000];
int ran[100000];

void init(int n){
  rep(i,0,n){
    par[i]=i;
    ran[i]=0;
  }
}

int find(int x){
  if(par[x]==x) return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ran[x]<ran[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}

int main(){
  int n;
  cin>>n;
  P a[n];
  P b[n];
  rep(i,0,n){
    ll x,y;
    cin>>x>>y;
    a[i].first=x;
    a[i].second=i;
    b[i].first=y;
    b[i].second=i;
  }
  sort(a,a+n);
  sort(b,b+n);
  vector<ll> es[2*(n-1)];
  rep(i,0,n-1){
    es[i].push_back(a[i+1].first-a[i].first);
    es[i].push_back(a[i].second);
    es[i].push_back(a[i+1].second);
  }
  rep(i,0,n-1){
    es[n-1+i].push_back(b[i+1].first-b[i].first);
    es[n-1+i].push_back(b[i].second);
    es[n-1+i].push_back(b[i+1].second);
  }
  sort(es,es+2*(n-1));
  init(n);
  ll ans=0;
  rep(i,0,2*(n-1)){
    if(!same(es[i][1],es[i][2])){
      unite(es[i][1],es[i][2]);
      ans+=es[i][0];
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int aa;
    vector <int> a(n+1);
    rep(i,n){
        cin >> aa ;
        if(aa==0){
            a[i+1]=-1;
        }
        else{
            a[i+1]=1;
        }
    }

    vector <vector <int>> memo(n+1);

    int k,k2;
    rep(i,n){
        k=2;
        while((i+1)*k<=n){
            memo[(i+1)*k].push_back(i+1);
            ++k;
        }
    }

    int ka;
    ka=0;
    int l;
    vector <int> ans(n+1,0);
    for (int i=n; i>0;--i){
        if(a[i]==1){
            ++ka;
            ans[i]=1;
            if(memo[i].size()!=0){
                    l=memo[i].size();
                    rep(j,l){ 
                        a[memo[i][j]]*=-1;
                    }
        }
        }
    }

    cout << ka <<endl;
    rep(i,n){
        if(a[i+1]==1){
            cout << i+1 << endl;
        }
    }

    

    return 0;
}

Measured memory_bytes: 23808
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
long long mod = 1e9 + 7;
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int n;
	cin >> n;
	int w[103];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}
	int ans = INT_MAX;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		sum2 += w[i];
		ans = min(ans, abs(sum2 - (sum - sum2)));
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
typedef pair< ll , ll > P;
 
#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll A,B,C,D,E,F;
P w[4000];
P s[4000];
int main(){
 
	cin >> A >> B >> C >> D >> E >> F;
 
	REP(i,F + 1) {
		w[i] = P(-1,-1);
		s[i] = P(-1,-1);
	}
	w[0] = P(0,0);
	s[0] = P(0,0);
 
	REP(a,F + 1) {
		REP(b,F + 1) {
			if(100 * A * a + 100 * B * b <= F) {
				w[100 * A * a + 100 * B * b] = P(a,b);
			}
		}
	}
 
	REP(c,F + 1) {
		REP(d,F + 1) {
			if(C * c + D * d <= F) {
				s[C * c + D * d] = P(c,d);
			}
		}
	}
 
	double ccc = 0;
	ll m = 0,ms = 0;
	REP(i,F + 1) {
		REP(j,F + 1) {
			if(w[i] == P(-1,-1) || s[j] == P(-1,-1) || i + j > F)
				continue;
 
			ll a = w[i].fi;
			ll b = w[i].sc;
			ll c = s[j].fi;
			ll d = s[j].sc;
 
			if((100 + E) * j <= E * (i + j)) {
				if(i + j > 0 && ccc <= (double)(j) / (i + j)) {
					ccc = (double)(j) / (i + j);
					m = 100 * A * a + 100 * B * b + C * c + D * d;
					ms = C * c + D * d;
				}
			}
		}
	}
	cout << m << " " << ms << endl;
	return 0;
}



Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String readLine = null;

		Map<String, BookIndex> books = new HashMap<String, BookIndex>();

		while ((readLine = br.readLine()) != null) {

			String[] split = readLine.split(" ");
			String name = split[0];
			int page = Integer.parseInt(split[1]);

			if (books.containsKey(split[0])) {
				BookIndex idx = books.get(name);
				idx.pageList.add(page);
			} else {
				BookIndex idx = new Main().new BookIndex(name);
				idx.pageList.add(page);
				books.put(name, idx);
			}
		}
		Object[] keys = books.keySet().toArray();
		Arrays.sort(keys);
		for (Object key : keys) {
			System.out.println(key);
			BookIndex idx = books.get(key);
			idx.pageList.sort(new Comparator<Integer>() {

				@Override
				public int compare(Integer o1, Integer o2) {
					return o1 - o2;
				}
			});
			for (int pageIdx = 0; pageIdx < idx.pageList.size(); pageIdx ++) {
				if (pageIdx != 0) {
					System.out.print(" ");
				}
				System.out.print(idx.pageList.get(pageIdx));
			}
			System.out.println("");
		}
	}

	public class BookIndex {
		public String name = null;
		public ArrayList<Integer> pageList = new ArrayList<Integer>();
		public BookIndex(String name) {
			this.name = name;
		}
	}
}

Measured memory_bytes: 24364
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK"
                 << "\n";
            return 0;
        }
    }
    cout << "NG"
         << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    ll ans=1;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end(),greater<int>());
    int cnt=0;
    for(int i=0; i<N; i++){
        if(A[i]==A[i+1]){
            ans *= A[i];
            i++;
            cnt++;
        }
        if(cnt==2){
            break;
        }
    }
    if(cnt<2){
        ans=0;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n >>s;
	int mx =0;
	rep2(len, 1 , n){
		VI ca(26,0), cb(26,0);
		rep(i, len) ca[s[i]-'a']++;
		rep2(i, len,n) cb[s[i]-'a']++;
		//for(auto x :ca) printf("%d, ",x); puts("");
		int ct=0;
		rep(i,26) if(ca[i]>0 && cb[i]>0) ct++;
		mx = max(mx, ct);
	}
	
	cout << mx <<"\n";
	return 0;
}


Measured memory_bytes: 256
s = input()
n1 = int(s[:2])
n2 = int(s[2:])
if n1 == 0:
    n1 = 100
if n2 == 0:
    n2 = 100
if n1 > 12 and n2 > 12:
    ans = 'NA'
elif n1 > 12 and n2 <= 12:
    ans = 'YYMM'
elif n1 <= 12 and n2 > 12:
    ans = 'MMYY'
else:
    ans = "AMBIGUOUS"
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	ll n, m, v, p, i, a[100003];

	scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	sort(a, a + n);

	ll l, r, mid, vs, base, ak, al, rp;
	l = -1;
	r = n - 1;
	while (r - l > 1) {
		mid = (l + r + 1) / 2;
		base = a[mid] + m;
		ak = lower_bound(a, a + n, base) - a;
		al = lower_bound(a, a + n, base + 1) - a;
		if (n - al >= p) {
			l = mid;
			continue;
		}
		rp = p - (n - al) - 1;
		vs = m + m * (n - al);
		for (i = al - 1; i >= 0; i--) {
			if (i == mid) {
				continue;
			}
			if (rp > 0) {
				vs += m;
				rp--;
			}
			else {
				vs += min(m, base - a[i]);
			}
		}
		if (vs >= m * v) {
			r = mid;
		}
		else {
			l = mid;
		}
	}

	printf("%lld\n", n - r);

	return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int a[101]={0},max=0,tmp=0;
   VI ans;
   
   while(cin>>tmp){
      a[tmp]++;
      if(max==a[tmp]) ans.PB(tmp);
      if(max<a[tmp]){
         ans.clear();
         ans.PB(tmp);
         max=a[tmp];
      }
   }
   sort(ALL(ans));
   REP(i,ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 1212
import heapq

N = int(input())
V = list(map(int, input().split()))
hq = []
for v in V:
    heapq.heappush(hq, v)

while len(hq) > 1:
    a = heapq.heappop(hq)
    b = heapq.heappop(hq)
    heapq.heappush(hq, (a+b)/2)
print(heapq.heappop(hq))

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n, T int
	fmt.Scan(&n, &T)

	cost := 1001
	for i := 0; i < n; i++ {
		var c, t int
		fmt.Scan(&c, &t)
		if T < t {
			continue
		}
		if cost > c {
			cost = c
		}
	}
	if cost == 1001 {
		fmt.Println("TLE")
		return
	}
	fmt.Println(cost)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define ifr(a, value) insert(a.begin(), value)
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define str string
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(a, it) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)        // use fill() for value other than 0 //
#define rtn return 
#define clk fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define inf 1LL<<61
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }   // no need to swap a, b, it auto. happens after first call //
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b});
    return 0;
}

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

using ll=long long;

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

int N;
ll h[100010][3];
ll dp[100010][3];

int main(){
  cin >> N;
  for (int i=0;i<N;i++){
    for (int j=0;j<3;j++){
      cin >> h[i][j];
    }
  }
  for (int i=0;i<N;i++){
    for (int j=0;j<3;j++){
      dp[i][j]=h[i][j];
    }
  }
  for (int i=0;i<N;i++){
    for (int j=0;j<3;j++){
      for (int k=0;k<3;k++){
        if (j != k)
          chmax(dp[i+1][j],h[i+1][j]+dp[i][k]);
      }
    }
  }
  int ans=max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
  cout << ans << endl;
  
}

Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


print('Yes' if int(input()) >= 30 else 'No')


Measured memory_bytes: 68104
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
using ll = long long;


int main() {
	int n;
	cin >> n;
	int A[n+2];
	A[0] = 0;
	A[n+1] = 0;
	for (int i=1; i<=n; i++) cin >> A[i];
	int sum = 0;
	rep(i, n+1) {
		int diff = abs(A[i+1] - A[i]);
		sum += diff;
	}
	for (int i=1; i<=n; i++) {
		int diff_m = abs(A[i+1] - A[i]) + abs(A[i-1] - A[i]);
		int diff_p = abs(A[i+1] - A[i-1]);
		int res = sum - diff_m + diff_p;
		cout << res << endl;
	}
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    ll N,A,B; cin >> N >> A >> B;
    ll ans=0;
    ll shou=N/(A+B);
    ll ama=N%(A+B);
    
    ans+=shou*A;
    
    if (ama<=A) ans+=ama;
    else ans+=A;
    
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  int tmp=1;
  int MAX=1;
  for(int i=2;i<=x;i++){
    int j=2;
    while(true){
      if(pow(i,j)<=x){
        //cout<<pow(i,j)<<endl;
        MAX=max(MAX,(int)pow(i,j));
        j++;
      }else{
        break;
      }
    }
  }
  cout<<MAX<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  
  cin >> n;
  
  vector<ll> p(n);  rep(i, 0, n) cin >> p[i];
  vector<ll> q(n);  rep(i, 0, n) cin >> q[i];
  vector<ll> a(n);  rep(i, 0, n) a[i] = i+1;
  
  ll P, Q;
  ll cnt = 0;
  
  do {
    cnt++;
    if(a == p)
      P = cnt;
    if(a == q)
      Q = cnt;
  } while(next_permutation(all(a)));
        
  cout << abs(P-Q) << "\n";

}


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

int uf_table[100];

void uf_init(void) {
	int i;
	for(i=0;i<100;i++)uf_table[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	if(a!=b)uf_table[a]=b+1;
}

int uf_issame(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	return a==b;
}

typedef struct {
	int a,b;
	int length;
} pipe_t;

pipe_t pipe[50*50*2];

int qsort_comp(const void* x,const void* y) {
	const pipe_t* a=(const pipe_t*)x;
	const pipe_t* b=(const pipe_t*)y;
	if((a->length)>(b->length))return 1;
	if((a->length)<(b->length))return -1;
	if((a->a)>(b->a))return 1;
	if((a->a)<(b->a))return -1;
	if((a->b)>(b->b))return 1;
	if((a->b)<(b->b))return -1;
	return 0;
}

int main(void) {
	int hs_num,ds_num;
	int now;
	int i,j;
	int pos;
	int result;
	while(1) {
		scanf("%d%d",&hs_num,&ds_num);
		if(hs_num==0 && ds_num==0)break;
		pos=0;
		for(i=0;i<hs_num;i++) {
			for(j=0;j<ds_num;j++) {
				scanf("%d",&now);
				if(now>0) {
					pipe[pos].a=i;
					pipe[pos].b=hs_num+j;
					pipe[pos].length=now;
					pos++;
				}
			}
		}
		for(i=0;i<ds_num;i++) {
			for(j=i+1;j<ds_num;j++) {
				scanf("%d",&now);
				if(now>0) {
					pipe[pos].a=hs_num+i;
					pipe[pos].b=hs_num+j;
					pipe[pos].length=now;
					pos++;
				}
			}
		}
		qsort(pipe,pos,sizeof(pipe_t),qsort_comp);
		uf_init();
		for(i=1;i<hs_num;i++)uf_merge(i-1,i);
		result=0;
		for(i=0,now=0;i<pos && now<ds_num;i++) {
			if(!uf_issame(pipe[i].a,pipe[i].b)) {
				uf_merge(pipe[i].a,pipe[i].b);
				result+=pipe[i].length;
				now++;
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 0