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

int main(){
  int n;
  double ans,tmp=0;
  cin >> n;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tmp = tmp + (1 / a[i]);
  }
  ans = 1 / tmp;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
cnt=0
lst=[]
for i in range(n):
  a,b=map(int,input().split())
  lst.append([a,b])
lst.sort(key=lambda x:x[0])
for j in range(n):
  cnt+=lst[j][1]
  if cnt>k-1:
    print(lst[j][0])
    break
    
  

Measured memory_bytes: 21248
// C++ implementation of the approach
#include <bits/stdc++.h>
using namespace std;

// Function to find special numbers
void divisibilityCheck(int arr[], int n)
{

	// Storing all array elements in a hash
	// and finding maximum element in the array
	unordered_set<int> s;
	int max_ele = INT_MIN;
	for (int i = 0; i < n; i++) {
		s.insert(arr[i]);

		// Update the maximum element of the array
		max_ele = max(max_ele, arr[i]);
	}

	// Traversing the array elements and storing the array
	// multiples that are present in s in res
	unordered_set<int> res;
	for (int i = 0; i < n; i++) {

		// Check for non-zero values only
		if (arr[i] != 0) {

			// Checking the factors of current element
			for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) {

				// If current factor is already part
				// of the array then store it
				if (s.find(j) != s.end())
					res.insert(j);
			}
		}
	}

	// For non-distinct elmments
	// To store the frequency of elements
	unordered_map<int, int> mp;
	for (int i = 0; i < n; i++)
		mp[arr[i]]++;

	unordered_map<int, int>::iterator it;
	vector<int> ans;
	for (it = mp.begin(); it != mp.end(); it++) {

		// If frequency is at least 2
		if (it->second >= 2) {
			if (res.find(it->first) == res.end()) {

				// If frequency is greater than 1 and
				// the number is not divisible by
				// any other number
				int val = it->second;

				// Then we push the element number of
				// times it is present in the vector
				while (val--)
					ans.push_back(it->first);
			}
		}

		// If frequency is greater than 1 and the number
		// is divisible by any other number
		if (res.find(it->first) != res.end()) {
			int val = it->second;

			// Then we push the element number of
			// times it is present in the vector
			while (val--)
				ans.push_back(it->first);
		}
	}

	// Print the elements that are divisible by
	// at least one other element from the array
	int i;
	cout<<n-ans.size()<<endl;
}

// Driver code
int main()
{
    int n;
    cin>>n;
	int arr[n+1],i;
	//int n = sizeof(arr) / sizeof(arr[0]);
     for(i=0;i<n;i++)
        cin>>arr[i];
	divisibilityCheck(arr, n);

	return 0;
}


Measured memory_bytes: 30584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,m;
	cin>>n>>m;
	vector<ll> vec(m+1,0);
	ll sum=0;
	for(ll i=1;i<=m;i++){
		cin>>vec[i];
		sum+=vec[i];
	}
	
	ll ans=n-sum;
	if(ans<0){
		cout<<-1<<endl;
	}
	else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3704
n,*a=map(int,open(0).read().split())

ans=0

for i in range(n-1):
    ans+=a[i]//2
    if a[i]%2==1 and a[i+1]>0:
        ans+=1
        a[i+1]-=1
    #print(ans)
ans+=a[n-1]//2
#print(a)
print(ans)

Measured memory_bytes: 14092
#include <stdio.h>


int main()
{
  int A[1000],n,i,v,j=0,x,y;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
     if(i<n-1){
	printf(" ");
      }
  }
  printf("\n");
  for(i=1;i<n;i++){
    
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
    for(x=0;x<n;x++){
      printf("%d",A[x]);
      if(x<n-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2124
n,k=map(int,input().split())
h=[]
for _ in range(n):
    h.append(int(input()))
h=sorted(h)
min=10**10
for i in range(n-k+1):
    if h[i+k-1]-h[i]<min:
        min=h[i+k-1]-h[i]
print(min)


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

int main() {
  int n, W;
  cin >> n >> W;
  vector<P> p;
  map<int, int> id;
  vector<ll> ww(4);
  int cnt = 0;
  rep(i,n) {
    int w, v;
    cin >> w >> v;
    p.emplace_back(make_pair(w, v));
    if (!id.count(w)) {
      id[w] = cnt;
      ww[cnt] = w;
      cnt++;
    }
  }
  sort(p.begin(), p.end(), greater<P>());
  int m = id.size();
  vector<vector<ll>> v(m), cum(m);
  for (int i = 0; i < n; i++) {
    int j = id[p[i].first];
    v[j].emplace_back(p[i].second);
  }
  
  for (int i = 0; i < m; i++) {
    cum[i].resize((int)v[i].size() + 1, 0);
    for (int j = 0; j < v[i].size(); j++) cum[i][j + 1] = cum[i][j] + v[i][j];
  }
  ll res = 0;
  auto dfs = [&](auto&& f, ll value = 0, ll weight = 0, int i = 0)->void{
    if (weight > W) return ;
    res = max(res, value);
    if (i >= m) return ;
    for (int j = 0; j < cum[i].size(); j++) {
      f(f, value + cum[i][j], weight + ww[i] * j, i + 1);
    }
  };
  dfs(dfs);
  cout << res << endl;
  return 0; 
} 

Measured memory_bytes: 256
from itertools import combinations_with_replacement as C

X = int(input())
mono = [100, 101, 102, 103, 104, 105]
ans = 0
if X >= 2000:
    ans = 1
else:
    for i in range(1, 19 + 1):
        L = list(C(mono, i))
        for L in L:
            if sum(L) == X:
                ans = 1
                break

print(ans)

Measured memory_bytes: 18268
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	total := 0
	for i := 1; i <= n; i++ {
		if i%5 != 0 && i%3 != 0 {
			total += i
		}
	}
	fmt.Println(total)
}


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

int main(){
  int a,b,c,check;
  cin >> a >> b >> c;
  check = 0;
  if(a == b){
    check++;
  }
  if(b == c){
    check++;
  }
  if(a == c){
    check++;
  }
  
  if(check == 0){
    cout << "3" << endl;
  }
  else if(check == 1 || check == 2){
    cout << "2" << endl;
  }
  else{
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 
 int main(){
 int n;
 int sum=0;
  cin>>n;
 vector<int>a(n),b(n),c(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int j=0;j<n;j++)cin>>b[j];
  for(int k=0;k<n;k++)c[k]=a[k]-b[k];
  sort(c.begin(),c.end());
 for(int i=0;i<n;i++){
  	if(c[i]>0)sum=sum+c[i]; 
 }
 cout<<sum;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc143/submissions/10478260
N=gets.to_i
L=gets.split.map(&:to_i).sort.reverse

ans = 0
(0..N-2).each do |i|
  j, k = i+1, N-1
  while j < k
    if L[i] < L[j] + L[k]
      ans += k-j
      j += 1
    else
      k -= 1
    end
  end
end
puts ans

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

using namespace std;

const int MAX_N = 114514;

typedef pair<int, int> pii;

int N, A[MAX_N];
vector<pii> opers;

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
    sort(A + 1, A + N + 1);
    int split = 1;
    while (split + 1 < N && A[split + 1] < 0) split++;
    int curr = A[1];
    for (int i = N; i > split + 1; i--) {
        opers.emplace_back(curr, A[i]);
        curr -= A[i];
    }
    opers.emplace_back(A[split + 1], curr);
    curr = A[split + 1] - curr;
    for (int i = 2; i <= split; i++) {
        opers.emplace_back(curr, A[i]);
        curr -= A[i];
    }
    printf("%d\n", curr);
    for (auto i : opers) {
        printf("%d %d\n", i.first, i.second);
    }
}

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

int main(void) {
    int num;
    cin >> num;
    for(int r = 0; r < num; r++) {
        int a, b, c;
        cin >> a >> b >> c;
        if(a > b){ a ^= b; b ^= a; a ^= b;}
        if(a > c){ a ^= c; c ^= a; a ^= c;}
        if(b > c){ b ^= c; c ^= b; b ^= c;}
        if(a * a + b * b == c * c) printf("YES\n");
        else printf("NO\n");
    }
    
    return(0);
}

Measured memory_bytes: 1116
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    h,w,D = LI()
    a = LIR(h)
    d = defaultdict(int)
    for y in range(h):
        for x in range(w):
            d[a[y][x]] = y*w+x
    n = h*w
    dist = [[0 for i in range(n//D+1)] for i in range(D)]
    for i in range(1,n-D+1):
        y = d[i]//w
        x = d[i]%w
        y_ = d[i+D]//w
        x_ = d[i+D]%w
        k = i%D
        j = i//D
        dist[k][j+1] = dist[k][j]+abs(y_-y)+abs(x_-x)
    q = I()
    for i in range(q):
        l,r = LI()
        k = l%D
        print(dist[k][r//D]-dist[k][l//D])
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 76380
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int n, m, q, ans;
int a[N], b[N], c[N], d[N];
vector<int> v;

void go(int id){
	if(id == n+1){
		int cur = 0;
		for(int i = 1; i <= q; i++){
			if(v[b[i]]-v[a[i]] == c[i])
				cur += d[i];
		}
		ans = max(ans, cur);
		return;
	}
	for(int i = v[id-1]; i <= m; i++){
		v.push_back(i);
		go(id+1);
		v.pop_back();
	}
}

signed main() {
	IOS;
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	v.push_back(1);
	go(1);
	cout << ans;
	return 0;
}

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

int main()
{
    double x1, y1, x2, y2;
    cin >>x1 >> y1 >> x2 >> y2;
    double a = x2 - x1;
   	double a_2 = a * a;
    double b = y2 - y1;
  	double b_2 = b * b;
    cout << fixed << setprecision(10) << sqrt(a_2 + b_2) << endl;
}


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

void res(int);
int judge(double);

int main(void){
  int n,cnt[6]={0};
  double height;

  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    cin >> height;
    cnt[judge(height)-1]++;
  }

  for( int i = 0 ; i < 6 ; i++ ){
    cout << i+1 << ':';
    res(cnt[i]);
  }

  return 0;
}

void res(int cnt){
  while(cnt > 0 ){
    cout << '*';
    cnt--;
  } 
  cout << endl;
}

int judge(double h){

  if( h < 165.0 ) return 1;
  else if( h < 170.0 ) return 2;
  else if( h < 175.0 ) return 3;
  else if( h < 180.0 ) return 4;
  else if( h < 185.0 ) return 5;
  return 6;

}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2010, M = 2 * N;

int n;
int cnt[N], dist[N];
int h[N], e[M], ne[M], idx;
int q[N];
bool st[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void bfs(int s)
{
	memset(st, 0, sizeof st);
	memset(dist, 0, sizeof dist);
	
	dist[s] = 0;
	st[s] = true;
	int hh = 0, tt = -1;
	q[ ++ tt] = s;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (st[j]) continue;
			
			dist[j] = dist[t] + 1;
			cnt[dist[j]] ++ ;
			st[j] = true;
			
			q[ ++ tt] = j;
		}
	}
}

int main()
{
	memset(h, -1, sizeof h);
	
	cin >> n;
	for (int i = 1; i < n; i ++ )
		add(i, i + 1), add(i + 1, i);
	
	{
		int a, b;
		cin >> a >> b;
		add(a, b), add(b, a);
	}
	
	for (int i = 1; i <= n; i ++ ) bfs(i);

	
	for (int i = 1; i < n; i ++ ) cout << cnt[i] / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#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;
    vector<int> A(N), B(N), C(N);
    cin >> A >> B >> C;

    int ans = 0;
    rep(i, 0, N) {
        int idx = A[i];
        if (i < N - 1 && A[i + 1] == idx + 1) ans += C[idx - 1];
        ans += B[idx - 1];
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    set<char> set = {};
    for (auto c : S) {
        if (set.find(c) == set.end()) set.insert(c);
    }
    if (set.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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


int main(){
    int x; cin >> x;
    cout << !x << endl;
    return 0;
}

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

//int n,k;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    //input part has been done
    vector< int> dp(n,INT_MAX);
   // memset(dp,INT_MAX,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
//#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define nax (ll)1e6+2
typedef long long ll;
typedef unsigned long long ull;
class solution{
public: 
	void solve(){
		string s;
		cin>>s;
		int check = s.size()/2;
		int j = s.size()-1;
		int ans  =0;
		for(int i =0;i<check;i++){
			if(s[i] != s[j]){
				ans++;
			}
			j--;
		}
		cout<<ans;
	}
};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str = br.readLine();
        String[] split = str.split(" ");
        int x = Integer.parseInt(split[0]);
        int y = Integer.parseInt(split[1]);
        int z = Integer.parseInt(split[2]);

        System.out.println(z + " " + x + " " + y);
    }
}


Measured memory_bytes: 21332
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int A = reader.nextInt();
        int B = reader.nextInt();
        System.out.println(Math.max(A-B*2, 0));
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	rep(i,s.size()){
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstdio>
using namespace std;

#define EPS (double)1e-9
#define INF (double)1e9
#define MAX_SPEED 33

vector<vector<vector<double> > > dijk(int s_point, int s_speed, vector<vector<vector<pair<double, pair<int, int> > > > >& adj){
  int v = adj.size();
  int t = adj[0].size();
  vector<vector<vector<double> > > result(v, vector<vector<double> >(v, vector<double>(t, INF)));
  priority_queue<pair<double, pair<int, pair<int, int> > > > wait;
  wait.push(make_pair(0, make_pair(0, make_pair(s_point, s_speed))));
  for(int i = 0; i < v; i++){ result[s_point][i][s_speed] = 0; }
  
  while(!wait.empty()){
    double nowcost = -wait.top().first;
    int prevpoint = wait.top().second.first;
    int nowpoint = wait.top().second.second.first;
    int nowspeed = wait.top().second.second.second;
    wait.pop();
    if(result[nowpoint][prevpoint][nowspeed] + EPS < nowcost){ continue; }

    for(size_t i = 0; i < adj[nowpoint][nowspeed].size(); i++){
      double nextcost = adj[nowpoint][nowspeed][i].first + nowcost;
      int nextpoint = adj[nowpoint][nowspeed][i].second.first;
      int nextspeed = adj[nowpoint][nowspeed][i].second.second;
      if(nextpoint != prevpoint && result[nextpoint][nowpoint][nextspeed] - EPS > nextcost){
        wait.push(make_pair(-nextcost, make_pair(nowpoint, make_pair(nextpoint, nextspeed))));
        result[nextpoint][nowpoint][nextspeed] = nextcost;
      }
    }
  }

  return result;
}

int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    int s, g;
    cin >> s >> g;

    int x, y, d, c;
    vector<vector<vector<pair<double, pair<int, int> > > > > adjlist(n + 1,
                                                                     vector<vector<pair<double, pair<int, int> > > >(MAX_SPEED + 1));
    for(int i = 0; i < m; i++){
      cin >> x >> y >> d >> c;
      for(int j = 0; j <= MAX_SPEED; j++){
        if(1 <= j - 1 && j - 1 <= c){
          adjlist[x][j].push_back(make_pair((double)d / (j - 1), make_pair(y, j - 1)));
          adjlist[y][j].push_back(make_pair((double)d / (j - 1), make_pair(x, j - 1)));
        }
        if(1 <= j && j <= c){
          adjlist[x][j].push_back(make_pair((double)d / j, make_pair(y, j)));
          adjlist[y][j].push_back(make_pair((double)d / j, make_pair(x, j)));
        }
        if(j + 1 <= c){
          adjlist[x][j].push_back(make_pair((double)d / (j + 1), make_pair(y, j + 1)));
          adjlist[y][j].push_back(make_pair((double)d / (j + 1), make_pair(x, j + 1)));
        }
      }
    }
    
    double ans = INF;
    vector<vector<vector<double> > > result = dijk(s, 0, adjlist);
    for(int i = 0; i <= n; i++){ ans = min(ans, result[g][i][1]); }
    if(ans + EPS >= INF){ printf("unreachable\n"); }
    else{ printf("%.10f\n", ans); }
  }

  return 0;
}

Measured memory_bytes: 5236
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

map<ll, ll>mp;
int main() {
	ll n; cin >> n;
	repe(k, 1, n) {
		ll x = k;
		repe(j, 1, k) {
			if (j == 1) {
				mp[1]++;
				continue;
			}

			ll t = j;
			while (x > 1) {
				if (x % t == 0) {
					mp[t]++;
					x /= t;
				}
				else {
					break;
				}
			}
		}
	}

	ll ans = 1;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->first != 1) {
			ans = ans *(it->second + 1) %MOD;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"Yes\n";else cout<<"No\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
#define mod 1000000007
using namespace std;
ll expo(ll x, ll y)
{
  if (y == 1)
    return x;
  if (y % 2 == 1)
    return (x * (expo((x * x) % mod, (y - 1) / 2)) % mod) % mod;
  else
    return  (expo((x * x) % mod, y / 2)) % mod;
}
vector<ll> v[100000 + 1];
ll vis[100000 + 1];
void dfs(ll n)
{
  vis[n] = 1;
  for (auto x : v[n])
  {
    if (!vis[x])
      dfs(x);
  }
}
int main()
{
// #ifndef HP
//   freopen("in.txt", "r", stdin);
//   freopen("out.txt", "w", stdout);
// #endif
  fastio;
  int t = 1;
  //cin >> t;
  while (t--)
  {
    ll n, m;
    cin >> n >> m;
    ll i, p, q;
    for (i = 0; i < m; i++)
    {
      cin >> p >> q;
      v[p].pb(q);
      v[q].pb(p);
    }
    ll ans = 0;
    for (i = 1; i <= n; i++)
    {
      if (!vis[i])
      {
        dfs(i);
        ans++;
      }
    }
    cout << ans - 1 << endl;
  }
}


Measured memory_bytes: 11132
// C - Walk on Multiplication Table
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = LLONG_MAX;
	for(ll a=1; a*a<=N; ++a){
		if(N%a) continue;
		ll b = N/a;
		ans = a + b - 2;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200005
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
ll fac[maxn],inv[maxn];
ll pow_mod(ll a,ll n)
{
    ll ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
ll Cc(ll x, ll y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}
ll f[maxn];
int main(){
	
	init();
	ll n,k;
	cin>>n>>k;
	f[1] = 1;
	for(int i=2;i<maxn;i++)
		f[i] = (f[i-1]*i%mod); 
	ll sum = 0;
	for(ll i=0;i<=min(n,k);i++){
		sum+=(Cc(n,i)*Cc(n-1,(n-i-1))%mod);
		sum%=mod;
	}
	cout<<(sum+mod)%mod<<endl;
}

Measured memory_bytes: 4480
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            set.add(String.valueOf(c));
        }

        System.out.println(set.size() - s.length() == 0 ? "yes" : "no");
    }
}



Measured memory_bytes: 23124
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a+b == 15){
	cout << "+" << endl;
  }
  else if(a*b == 15){
	cout << "*" << endl;
  }
  else{
	cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
L, R = [list(i) for i in zip(*LR)]

l = 0
r = N+1

for i in range(M):
    l = max(l, L[i])
    r = min(r, R[i])

print(max(0, r-l+1))

Measured memory_bytes: 72664
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n;
    cin >> n;
    int p[n];
    inrep(n,p);
    
    rep(i,0,n){
	rep(j,0,n){
	 
	    swap(p[i],p[j]);
	    int f  = 0;
	    rep(k,0,n-1){
		if(p[k] > p[k+1]){
		    f = 1;
		    break;
		}
	    }
	    if(f == 0){
		YES;
		ret 0;
	    }
		            
	    swap(p[i],p[j]);
	}
     
    }
    
    NO;
    return  0;
}


Measured memory_bytes: 256
sw_input = True
while sw_input == True:
    n,x  = map(int, input().split())
    if n == 0 and x == 0:
        sw_input = False
    else:
        ctr = 0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range (j+1,n+1):
                    if i+j+k==x:
                        ctr +=1
        print(ctr)


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

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ull binpowmod(ull x,ull y,ull p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.second>y.second;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
vector<int> g[200001];
ll a[200001];
int ans[200001];
vector<ll> seq;
map<ll,pair<ll,ll>> m;
void dfs(int node,int parent){
    //find LIS
    if(parent==0){
        ans[node]=1;
        seq.push_back(a[node]);
    }
    else
    {
        if(a[node]>seq.back()){
            ans[node]=seq.size()+1;
            seq.push_back(a[node]);
            m[node]={-1,-1};
        }
        else
        {
            int index=lower_bound(seq.begin(),seq.end(),a[node])-seq.begin();
            m[node]={seq[index],index};
            seq[index]=a[node];
            ans[node]=seq.size();
        }
    }
    for(int to: g[node]){
        if(to == parent) continue;
        dfs(to,node);
        if(m[to].second==-1)
            seq.pop_back();
        else
            seq[m[to].second]=m[to].first;
    }
}
void solve()
{   
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 52436
AB = list(map(int,input().split()))

plus = AB[0] + AB[1]
minus = AB[0] - AB[1]
mul = AB[0] * AB[1]

if plus > minus:
    if plus > mul:
        print(plus)
    else:
        print(mul)
else:
    if minus > mul:
        print(minus)
    else:
        print(mul)


Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <cstring>
#include <vector>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
const ll maxn = 1010;
const ll mod = 1000000007;

char grid[maxn][maxn];
ll dp[maxn][maxn];

int main(){
    ll n,m;

    scanf("%lld %lld",&n,&m);

    for(ll i = 1; i <= n; i++){
        scanf(" %s",grid[i]+1);
    }

    dp[1][1] = 1;
    //cerr << dp[1][1] << endl;
    //if(grid[1][1] == '#')   dp[1][1] = 0;
    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= m; j++){
            if(i == 1 && j == 1)    continue;
            if(grid[i][j] == '#')   dp[i][j] = 0;
            else    dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= mod;
            //printf("dp[%lld][%lld]: %lld\n",i,j,dp[i][j]);
        }
    }
    printf("%lld\n",dp[n][m]);

}


Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <functional>

#define N 100000

using namespace std;

int parent(int i){return((i-1)/2);}
int lchild(int i){return(2*i+1);}
int rchild(int i){return(2*i+2);}

bool gt(int x, int y){
  return(x > y);
}

bool lt(int x, int y){
  return(x < y);
}

void push(int x, int *pq, int *q_max, function<bool(int, int)> f){
  pq[*q_max] = x;
  int idx = *q_max;
  (*q_max)++;
  while (idx > 0) {
    if (f(pq[idx], pq[parent(idx)])) {
      int tmp = pq[parent(idx)];
      pq[parent(idx)] = pq[idx];
      pq[idx] = tmp;
      idx = parent(idx);
    } else {
      return;
    }
  }
}

int pop(int *pq, int *q_max, function<bool(int, int)> f){
  if (*q_max < 0) {
    cerr << "queue is empty." << endl;
    return 0;
  }
  int result = pq[0];
  pq[0] = pq[--(*q_max)];
  int idx = 0;
  while (lchild(idx) < *q_max) {
    if (f(pq[idx], pq[lchild(idx)]) && f(pq[idx], pq[rchild(idx)])) {
      return(result);
    }
    if (f(pq[lchild(idx)], pq[rchild(idx)])) {
      int tmp = pq[lchild(idx)];
      pq[lchild(idx)] = pq[idx];
      pq[idx] = tmp;
      idx = lchild(idx);
    } else {
      int tmp = pq[rchild(idx)];
      pq[rchild(idx)] = pq[idx];
      pq[idx] = tmp;
      idx = rchild(idx);
    } 
  }
  return(result);
}


int main(){
  int n;
  int a1_pq[N+1], a2[N+1], a3_pq[N+1];
  int a1_pq_max = 0;
  int a3_pq_max = 0;
  long long a1_max[N+1], a3_min[N+1];
  cin >> n;
  a1_max[0] = 0;
  a3_min[n] = 0;
  for (int i=0;i<n;i++) {
    int a;
    cin >> a;
    push(a, a1_pq, &a1_pq_max, lt);
    a1_max[0] += a;
  }
  for (int i=0;i<n;i++) {
    int a;
    cin >> a;
    a2[i] = a;
  }
  for (int i=0;i<n;i++) {
    int a;
    cin >> a;
    push(a, a3_pq, &a3_pq_max, gt);
    a3_min[n] += a;
  }
  for (int i=0;i<n;i++) {
    if (a1_pq[0] < a2[i]) {
      a1_max[i+1] = a2[i] - a1_pq[0] + a1_max[i];
      pop(a1_pq, &a1_pq_max, lt);
      push(a2[i], a1_pq, &a1_pq_max, lt);
    } else {
      a1_max[i+1] = a1_max[i];
    }
  }
  for (int i=n;i>0;i--) {
    if (a3_pq[0] > a2[i-1]) {
      a3_min[i-1] = a2[i-1] - a3_pq[0] + a3_min[i];
      pop(a3_pq, &a3_pq_max, gt);
      push(a2[i-1], a3_pq, &a3_pq_max, gt);
    } else {
      a3_min[i-1] = a3_min[i];
    }
  }
  long long result = LLONG_MIN;
  for (int i=0;i<=n;i++) {
    if (a1_max[i] - a3_min[i] > result) {
      result = a1_max[i] - a3_min[i];
    }
  }
  cout << result << endl;  
}


Measured memory_bytes: 2944
/*
 *  author : Atul Anand   
 *  created on : Fri Apr 03 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        int B = in.nextInt();
        println(Math.max(A+B, Math.max(A-B, A*B)));
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <memory>
#include <stack>

using namespace std;

int dfs(int n, vector<vector<int>>& adjl, vector<int>& dp)
    {
        if (dp[n] != -1)
            return dp[n];
        int &ret = dp[n];
        ret = 0;
        for (int i = 0; i < adjl[n].size(); i++)
            ret = max(1 + dfs(adjl[n][i], adjl, dp),ret);
        return ret;
    }

    void LongPath()
    {
        int n, e;
        cin >> n >> e;
        vector<vector<int>> adjl(n + 1);
        vector<int> dp(n + 1,-1);
        int _max = 0;
        for (int i = 0; i < e; i++)
        {
            int a, b;
            cin >> a >> b;
            adjl[a].push_back(b);
        }
        for (int i = 1; i <= n; i++)
        {
            _max = max(_max, dfs(i, adjl, dp));
        }
        cout << _max;
    }

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


Measured memory_bytes: 8192
import sys

input = sys.stdin.readline

def main():
    ans = ''
    f = '#'
    n = '\n'
    H, W = map(int, input().split())
    ans += f*(W+2)
    for _ in range(H):
        ans += n + f + input().rstrip(n) + f
    ans += n + f*(W+2)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vvi dp(n+1,vi(m+1));
		dp[0][0]=1;
		rep(k,101){
			for(int i=n-1;i>=0;i--)rep(j,m+1){
				if(j+k<=m){
					dp[i+1][j+k]+=dp[i][j];
				}
			}
		}
		cout<<dp[n][m]<<endl;
	}
}

Measured memory_bytes: 1292
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

const int N=1e5+100 ;

int f[N] , g[N] ;
int a[N] ;
int n ;

int main ()
{
    int i ;
    scanf("%d",&n);
    for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
    f[1]=a[1],g[n]=a[n];
    for ( i=2 ; i<=n ; i++ ) f[i]=__gcd(a[i],f[i-1]);
    for ( i=n-1 ; i>=1 ; i-- ) g[i]=__gcd(g[i+1],a[i]);
    int res=0 ;
    for ( i=2 ; i<n ; i++ ) res=max(res,__gcd(f[i-1],g[i+1]));
    res=max(res,g[2]),res=max(res,f[n-1]); 
    printf("%d\n",res);
    return 0 ;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll K, X; cin >> K >> X;
    if (K*500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=list(map(int,input().split(" ")))
r=[]
for i in range(N):
    x,y=list(map(int,input().split(" ")))
    r.append((x,y))
r=sorted(r,key=lambda x:x[0])

p=0
for yen,can in r:
    if can<=M:
        M-=can
        p+=yen*can
    else:
        p+=M*yen
        break
print(p)



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int h,w,n;
int u,d,l,r;

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

	cin>>w>>h>>n;
	u=h,d=0,l=0,r=w;

	REP(i,n) {
		int x,y,a;cin>>x>>y>>a;
		if(a==1) l=max(l,x);
		else if(a==2) r=min(r,x);
		else if(a==3) d=max(d,y);
		else u=min(u,y);
	}
	if(l>=r||u<=d) cout<<0<<endl;
	else cout<<(r-l)*(u-d)<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

l = a[0][0]
r = sum(a[1])
ans = l+r

for i in range(1,n):
  l += a[0][i]
  r -= a[1][i-1]
  if l + r > ans: ans = l+r
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 1000000007;
const int cons = 100001;
const double pi = 3.141592653589793;

bool chk[100001];
int dat[100001];
int upper[100001];
int a[100001];

int main()
{
	int n;
	scanf("%d", &n);

	int cur = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);

		if (x != cur)
		{
			dat[i] = x;
			chk[i] = true;
			cur = x;
			continue;
		}
		else
		{
			upper[i] = cur;
		}
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	cur = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		if (cur != a[i])
		{
			if (dat[i + 1] && dat[i + 1] != a[i])
			{
				puts("0");
				return 0;
			}

			if (dat[i + 1] == 0 && upper[i + 1] < a[i])
			{
				puts("0");
				return 0;
			}

			chk[i + 1] = true;
			dat[i + 1] = a[i];
			cur = a[i];
		}
		else
		{
			if (dat[i + 1] && dat[i + 1] > cur)
			{
				puts("0");
				return 0;
			}

			upper[i + 1] = min(upper[i + 1], cur);
		}
	}

	ll ans = 1;

	for (int i = 1; i <= n; i++)
	{
		if (chk[i])continue;
		ans = (ans*(ll)upper[i]) % mod;
	}

	cout << ans << endl;

	return 0;
}

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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

main(){
    int N,X,b,H=0,W=0,count=0,count2=0;
    double d;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>N>>X;
    vvc c(N,vc (X));
    rep(0,N){
      REP(0,X){
        cin>>c[i][j];
        cout<<c[i][j];
      }
      cout<<endl;
      REP(0,X){
        cout<<c[i][j];
      }
      cout<<endl;
    }
}


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

int main ()
{
  int H,W;
  while(1)
    {
      cin >> H >> W;
      if(H==0&&W==0)   break;
      for(int i=0;i<H;i++)
        {
          for(int j=0;j<W;j++)
            {
              cout << "#";
            }
          cout << endl;
        }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
n = int(input())
lab = [0]*n
for i in range(n):
  a,b = map(int,input().split())
  lab[i] = [b,a]

lab.sort()
time = 0
for i in lab:
  time += i[1]
  if time > i[0]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 37348