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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll count=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        count+=a[i];
        if(i%2==0){
            if(count<=0){
                ans+=abs(count)+1;
                count=1;
            }
        }
        else{
            if(count>=0){
                ans+=count+1;
                count=-1;
            }
        }
    }

    ll count2=0;
    ll ans2=0;
    for(int i=0;i<n;i++){
        count2+=a[i];
        if(i%2==1){
            if(count2<=0){
                ans2+=abs(count2)+1;
                count2=1;
            }
        }
        else{
            if(count2>=0){
                ans2+=count2+1;
                count2=-1;
            }
        }
    }
    
    cout<<min(ans,ans2)<<endl;
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if (s.size() > k) {
    s = s.substr(0, k) + "...";
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<String> wordList = new ArrayList<String>();
		while(stdIn.hasNext()){
			wordList.add(stdIn.next());
		}
		int simmetryCount = 0;
		for(String i:wordList){
			int iDotLength = i.length();
			for(int j = 0;j < iDotLength; j++){
				if(i.charAt(j) != i.charAt(iDotLength -1 - j)){
					break;
				}else if(iDotLength == 1 || i.charAt(j) == i.charAt(iDotLength -1 - j) && j >= iDotLength - 1 - j){
					simmetryCount++;
					break;
				}
			}
		}
		System.out.println(simmetryCount);
	}
}

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

int x,y;

int main()
{
    scanf("%d%d",&x,&y);
    if(x < y)printf("%d\n",min(y - x,abs(x + y) + 1));
    else printf("%d\n",min(x - y + 2,abs(x + y) + 1));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,a,i=0,r,o=0;
  while( scanf("%d",&n) != EOF )
    {
      o=0;
      if(n>=2000) a=2000;
      else a=n;
      while((a>=0)&&(n-a<=2000))
	{
	  if(a<1001) r=a+1;
	  else r=2001-a;
	  if(n-a<1001) r*=n-a+1;
	  else r*=2001-n+a;
	  o+=r;
	  a-=1;
	}
      printf("%d\n",o);
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
4
2 2 1 3

3 2 2 1
0 3 2 2

123456

6 5 4 3 2 1
0 6 5 4 5 4

12345
5 4 3 2 1
0 5 4 4 3

5=0112
6=01122
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, ans = 0; cin >> N;
  vector<ll> A(N, 0);
  rep(i, N) cin >> A[i];
  sort(all(A));
  reverse(all(A));
  ll end = N/2;
  if(N%2)
    end++;
  rep(i, end)
    ans += A[i]*2;
  ans -= A[0];
  if (N%2)
    ans -=A[end-1];
  cout << ans << endl;
           
}


Measured memory_bytes: 4756
#include<iostream>
#include<string>
#include<map>
#include<list>

using namespace std;

int main()
{
	int N = 0, mx = -1;
	string s;
	map<string, int> mp;
	list<string> lst;
	
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> s;
		mp[s]++;
		if(mp[s] > mx)
		{
			mx = mp[s];
		}
	}

	for(auto it = mp.begin(); it != mp.end(); ++it)
	{
		if(it->second == mx)
		{
			lst.push_back(it->first);
		}
	}
	lst.sort();

	for(auto it= lst.begin(); it != lst.end();++it)
	{
		cout << *it << endl;
	}
}


Measured memory_bytes: 31488
#include<stdio.h>

int main(void)
{
  
  int score[100][5] = {0};
  int total = 0;
  int high[100];
  int low[100];
  int i;
  int j = 0;
  int testcase;
  
  while(1){
    
    scanf("%d",&testcase);
    
    if(testcase == 0)
      break;
    
    for(i=0;i<testcase;i++){
      
      scanf("%d %d %d %d %d",&score[i][0],&score[i][1],&score[i][2],&score[i][3],&score[i][4]);
      total = score[i][0]+score[i][1]+score[i][2]+score[i][3]+score[i][4];
      
      if(i == 0){
	high[j] = total;
	low[j] = total;
      }
      
      else{
	if(high[j] < total)
	  high[j] = total;
	
	if(low[j] > total)
	  low[j] = total;
      }
    }
    
    j++;
    
  }
  
  for(i=0;i<j;i++)
    printf("%d %d\n",high[i],low[i]);
  
  return 0;
  
}

Measured memory_bytes: 600
# if true

# include <iostream>
# include <vector>

int main()
{
    int N; std::cin >> N;
    std::vector<int> numbers(N);
    for (auto& p : numbers) std::cin >> p;


    int ret{};
    for (int i{}; i < N - 2; ++i)
    {
        auto p0 = numbers[i];
        auto p1 = numbers[i + 1];
        auto p2 = numbers[i + 2];
        
        if (p0 < p1 && p1 < p2) ++ret;
        if (p2 < p1 && p1 < p0) ++ret;
    }

    std::cout << ret;

    return 0;
}

# endif

Measured memory_bytes: 256
n, m, t = int(input()), int(input()), list(map(int, input().split()))
p = [0 for _ in range(n)]
for i in t:
    k = list(map(int, input().split()))
    for j in range(n):
        if k[j] == i:
            p[j] += 1
        else:
            p[i - 1] += 1
for i in p:
    print(i)



Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define int long long
#define IOS() ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
signed main()
{
	int a;
	string s;	
	while(cin>>a>>s)
	{
		int k=s[0]-'0';
		for(int i=2;i<s.length();i++) k=k*10+s[i]-'0';
		int n=a*k/100;
		cout<<n<<"\n";
	}
} 

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


const int MOD = (int)1e9 + 7;

template<int mod>
class binary_indexed_tree_2d_by_mod {
private:
    int N;
    int M;
    std::vector<std::vector<int>> bit;

    void add(int &a, int b) {
        if (b < 0) b += mod;
        a += b;
        if (a >= mod) a -= mod;
    }

public:
    binary_indexed_tree_2d_by_mod() {}
    binary_indexed_tree_2d_by_mod(int n, int m) : N(n), M(m), bit(n, std::vector<int>(m)) {}

    void init(int n, int m) {
        N = n;
        M = m;
        bit = std::vector<std::vector<int>>(N + 1, std::vector<int>(M + 1));
    }

    void add(int x, int y, long long val) {
        val %= mod;
        for (int i = x; i <= N; i += i & (-i)) {
            for (int j = y; j <= M; j += j & (-j)) {
                this->add(this->bit[i][j], val);
            }
        }
    }

    int sum(int x, int y) {
        int res = 0;
        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                this->add(res, this->bit[i][j]);
            }
        }
        return res;
    }

    int sum(int x1, int y1, int x2, int y2) {

        int res = this->sum(x2, y2);
        add(res, -sum(x1 - 1, y2));
        add(res, -sum(x2, y1 - 1));
        add(res, sum(x1 - 1, y1 - 1));

        return res;
    }
};

const int MAX = 2e3 + 10;
int N, M;
binary_indexed_tree_2d_by_mod<MOD> bit;

int main(void) {
    std::cin >> N >> M;
    std::vector<int> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    std::vector<int> T(M);
    for (int i = 0; i < M; i++) {
        std::cin >> T[i];
    }
    bit.init(N + 1, M + 1);

    bit.add(1, 1, 1);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i] == T[j]) {
                bit.add(i + 2, j + 2, bit.sum(i + 1, j + 1));
            }
        }
    }

    std::cout << bit.sum(N + 1, M + 1) << std::endl;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 100000000

int		main(void)
{
	int n, m;
	cin >> n >> m;
	Graph g(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	Vec depth(n, INF);
	Vec sign(n, -1);
	queue<int> q;
	q.push(0);
	while (!(q.empty()))
	{
		int front;
		front = q.front();
		q.pop();
		for (auto it = g[front].begin(); it != g[front].end(); it++)
		{
			if (sign[*it] >= 0)
				continue ;
			sign[*it] = front;
			q.push(*it);
		}
	}
	bool f = false;
	for (int i = 0; i < n; i++)
	{
		if (sign[i] < 0)
			break ;
		if (i == n-1)
			f = true;
	}
	if (f)
	{
		cout << "Yes" << endl;
		for (int i = 1; i < n; i++)
			cout << sign[i] + 1 << endl;
	}
	else
		cout << "No" << endl;
}





Measured memory_bytes: 10652
#include <stdio.h>
#include <ctype.h>


int main(void)
{
  int a[26] = { 0 };       // アルファベット（'a'-'z'）は26文字
  int ch, i;

  //input
  while ((ch = getchar()) != EOF) {
    //走査
    if (islower(ch)) {
      a[ch - 'a']++;
    }
    
    if (isupper(ch)) {
      a[ch - 'A']++;
    }
  }

  //output
  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", i + 'a', a[i]); 
  }
  return 0;
}


Measured memory_bytes: 2044
n = int(input())
z = [[] for _ in range(n)]
for i in range(n):
	a = int(input())
	for j in range (a):
		z[i].append(list(map(int,input().split())))

def is_valid(nn,p):
	if not (nn>>p)&1:
		return True
	for talk in z[p]:
		if not (nn>>(talk[0]-1))&1 == talk[1]:
			return False
	return True	

def num_true(nn):
	sum = 0
	while nn:
		sum += nn%2
		nn //=2
	return sum
ans = 0
for nn in range(1<<n):
	for p in range(n):
		if not is_valid(nn,p):
			break
		if p == n-1:
			ans = max(ans,num_true(nn))
print(ans)	 


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,c;cin >> n >> c;
  vector<ll> x(n),v(n),sl(n+1),sr(n+1),ml(n+1),mr(n+1);
  sl[0]=0;
  sr[n]=0;
  for(int i=0;i<n;i++){
    cin >> x[i] >> v[i];
    sl[i+1]=sl[i]+v[i];
  }
  for(int i=n;i>0;i--){
    sr[i-1]=sr[i]+v[i-1];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ml[i+1]=max(ml[i],sl[i+1]-x[i]);
    ans=max(ans,ml[i+1]);
  }
  for(int i=n;i>0;i--){
    mr[i-1]=max(mr[i],sr[i-1]-(c-x[i-1]));
    ans=max(ans,mr[i-1]);
  }
  for(int i=0;i<n;i++){
    ans=max(ans,mr[i+1]+sl[i+1]-2*x[i]);
  }
  for(int i=n;i>0;i--){
    ans=max(ans,ml[i-1]+sr[i-1]-2*(c-x[i-1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    #define Would
    #define you
    #define please
    #define mp make_pair
    #define pb push_back
    #define INF 1000000000000
    #define modulo 1000000007
    #define ii pair<int,int>
    #define int long long int
    using namespace std;
    map<int,int> performans;
    int32_t main(){
    	ios_base::sync_with_stdio(0);
    	cin.tie(0);
    	int a,b,c;
    	cin >> a >> b;
    	for(int i=0;i<b;i++){
    		cin >> c;
    		a-=c;
    	}
    	if(a<=0) cout << "Yes";
    	else cout << "No";
    	Would you please return 0;
    }

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 1
    n = int(input())
    a = [int(input()) for _ in range(n)]
    c = [False]*n
    now = a[0]
    c[0] = True
    while now != 2:
        now = a[now-1]
        if c[now-1] == True:
            ans = -1
            break
        ans += 1
        c[now-1] = True
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 13836
package main

import (
        "fmt"
)

func main() {
        var n int
        fmt.Scanf("%d", &n)
        fmt.Println(fact(n))
}

func fact(n int) (f uint64) {
        if n < 2 {
                return uint64(1)
        } else {
                return fact(n-1) * uint64(n)
        }
}



Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;

ll cnt[N];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin >> n;vector<ll> a(n);
    ll ans = 0;
    for(auto &i: a)
    {
        cin >> i;
        cnt[i]++;
        ans += i;
    }

    int q;cin >> q;
    while(q--)
    {
        ll a,b;cin >> a >> b;
        ans -= cnt[a] * a;
        ans += cnt[a] * b;
        cnt[b] += cnt[a];
        cnt[a] = 0;
        cout << ans <<"\n";
    }


    return 0;
}

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

using namespace std;

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

    int n; string s;
    cin >> n >> s;

    string ans;
    for (int i = 0; i < s.size(); ++i) {
        ans += ((s[i] - 'A' + n) % 26) + 'A';
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		int sum = 0, min = Integer.MAX_VALUE;
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 5; i++) {
			int n = scan.nextInt();
			sum += Math.ceil((double) n / 10) * 10;
			if (n % 10 != 0)
				min = Math.min(min, n % 10);
		}
		if (min == Integer.MAX_VALUE)
			System.out.println(sum);
		else
			System.out.println(sum - 10 + min);
	}
    public static void main(String[] args) {
    	new Main().run();
    }
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  int nA, nB, nC; cin >> nA >> nB >> nC;
  vec<int, 1> a(nA), b(nB);
  for (auto& i : a) {
    cin >> i;
  }
  for (auto& i : b) {
    cin >> i;
  }
  int ans = *min_element(all(a)) + *min_element(all(b));
  while (nC--) {
    int x, y, c; cin >> x >> y >> c; --x; --y;
    asMn(ans, a[x] + b[y] - c);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;


int main() {

    int N, M, sum = 0;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; }
    //vector<vector<int>> A(N,vector<int>(M));
    //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
    sort(A.begin(), A.end(), greater<int>());
    double aa = M * 4;
    //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
    //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
    if (A[M - 1] >= ceil(double(((sum / aa))))) {

        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b[100],B[100],c,d=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b[i];
        B[i]=b[i];
    }
    sort(B,B+a);
    for(int i=0;i<a;i++){
        for(int j=i;j<a;j++){
            if(b[j]==B[i]){
                if(i==j){
                    break;
                }else{
                c=b[j];
                b[j]=b[i];
                b[i]=c;
                d++;

                break;
            }
            }
        }
    }
    for(int i=0;i<a-1;i++){
        cout<<b[i]<<" ";
    }
    cout<<b[a-1]<<"\n"<<d<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include<stdio.h>

int main(){
    int H,W,i,j;
    while(true){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        else{
            for(i=0;i<H;i++){
                for(j=0;j<W;j++)printf("#");
                printf("\n");
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  int h,w;
  cin>>h>>w;
  string dot="";
  rep(i,w) dot+='.';
  vector<string> A;
  rep(i,h){
    string s;
    cin>>s;
    if(s!=dot){
      A.push_back(s);
      //cout<<i<<s<<endl;
    }
  }
  vector<int> num;
  rep(i,w){
    bool exist=true;
    rep(j,A.size()){
      if(A[j][i]!='.'){
        exist=false;
        //cout<<j<<i;
        break;
      }
    }
    if(exist) num.push_back(i);
  }
  
  rep(i,A.size()){
    rep(j,w){
      if(count(num.begin(),num.end(),j)==0)
        cout<<A[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std; 
int main(){ int n,x; 
scanf("%d",&n); 
for(int i = 1; i<= n; i++) {
    if(i%3 == 0){ printf(" %d",i);
    }
    
    else{ x = i; do{ if(x%10 == 3){ printf(" %d",i); 
    break;
    } x /=10; }while(x); 
    
    }
    } printf("\n"); 
    
} 


Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a) distance((v).begin(),upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a) distance((v).begin(),lower_bound((v).begin(),(v).end(),(a)))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

struct D21{
  int is,js;
  D21(int isize,int jsize){
    is = isize;
    js = jsize;
  }
  int operator()(int i,int j){
    return i*js+j;
  }
};


void Main(){
  int n;
  cin>>n;
  int w;
  cin>>w;
  v(pll) a(n);
  cin>>a;

  vv(ll) dp(n+1,vl(w+1,0));

  rep(i,n) rep(j,w+1){
    if(j>=a[i].fi){
      dp[i+1][j] = max(dp[i][j], dp[i][j-a[i].first] + a[i].se); 
    } else{
      dp[i+1][j] = dp[i][j];
    }   
  }

  cout<<dp[n][w]<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 80256
#include<stdio.h>

int main()
{
	double a, b;
	
	scanf("%lf %lf", &a ,&b);
	
	int x = a, y = b;
		
	printf("%d %d %.5lf\n", x/y, x%y,a/b);
	
	
	return 0;
}


Measured memory_bytes: 2728
s = input().strip()

bs = int(s[:2])
cs = int(s[2:])


if bs <=12 and cs <= 12 and 0<bs and 0<cs:
    print("AMBIGUOUS")
elif (bs==0 or bs > 12) and (cs > 12 or cs ==0):
    print("NA")
elif bs <= 12 and 0 < bs:
    print("MMYY")
elif cs <= 12 and 0 < cs:
    print("YYMM")


Measured memory_bytes: 38256
#include <iostream>
#include <vector>


class SegmentTree {
	std::vector<std::vector<int>> _array;
	std::vector<int> _size;
	static constexpr int undefined = -1;
	void make_upper_undefined(int pos, int depth = 1) {
		if (depth == _array.size()) return;
		make_upper_undefined(pos / 2, depth + 1);
		switch (_array[depth][pos]) {
		case undefined: return;
		default:
			_array[depth - 1][pos * 2] = _array[depth][pos];
			if (pos * 2 + 1 < _array[depth - 1].size()) _array[depth - 1][pos * 2 + 1] = _array[depth][pos];
			_array[depth][pos] = undefined;
		}
	}
public:
	SegmentTree(int size) :_array{}, _size{} {
		for (auto i = size; i > 1; i = (i + 1) / 2) {
			_size.push_back(i);
		}
		_size.push_back(1);
		_array = std::vector<std::vector<int>>(_size.size());
		for (auto i = 0; i < _array.size(); ++i) {
			_array[i] = std::vector<int>(_size[i], undefined);
		}
		_array[_array.size() - 1][0] = 2147483647;
	}
	void update(int from, int to, int new_value) {
		auto depth = 0;
		while (from < to) {
			if (from % 2 == 1) {
				make_upper_undefined(from / 2, depth + 1);
				_array[depth][from] = new_value;
				++from;
			}
			if (to % 2 == 0) {
				make_upper_undefined(to / 2, depth + 1);
				_array[depth][to] = new_value;
				--to;
			}
			from >>= 1; to >>= 1; ++depth;
		}
		if (from == to) {
			make_upper_undefined(from / 2, depth + 1);
			_array[depth][from] = new_value;
		}
	}
	int find(int pos) const {
		for (auto i = _array.size() - 1; i >= 0; --i) {
			switch (_array[i][pos >> i]) {
			case undefined: continue;
			default: return _array[i][pos >> i];
			}
		}
	}
};
int main() {
	int n, q;
	std::cin >> n >> q;
	auto stree = SegmentTree(n);
	int query, s, t, x, i;
	for (auto count = 0; count < q; ++count) {
		std::cin >> query;
		switch (query) {
		case 0:
			std::cin >> s >> t >> x;
			stree.update(s, t, x);
			break;
		default:
			std::cin >> i;
			std::cout << stree.find(i) << std::endl;
		}
	}
}


Measured memory_bytes: 3644
#include<stdio.h>
#define MAX 20000000

int L[MAX/2+1],R[MAX/2+1],count=0;

void mergeSort(int a[],int left,int right)
{
	void merge(int a[],int,int,int);
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergeSort(a,left,mid);
		mergeSort(a,mid,right);
		merge(a,left,mid,right);
	}
}

void merge(int a[],int left,int mid,int right)
{
	int i,j,cnt;
	int n1=mid-left;
	int n2=right-mid;
	for(i=0;i<n1;i++)
		L[i]=a[left+i];
	for(i=0;i<n2;i++)
		R[i]=a[mid+i];
	for(i=0,j=0,cnt=0;cnt<n1+n2;cnt++)
	{
		if(i>=n1)
		{
			a[left+cnt]=R[j];
			count++;
			j++;
		}
		else if(j>=n2)
		{
			a[left+cnt]=L[i];
			count++;
			i++;
		}
		else if(R[j]<=L[i])
		{
			a[left+cnt]=R[j];
			j++;
			count++;
		}
		else
		{
			a[left+cnt]=L[i];
			i++;
			count++;
		}
	}
}

int main()
{
	int n,s[500002];
	scanf("%d",&n);
	int i,ju=0;
	for(i=0;i<n;i++)
		scanf("%d",&s[i]);
	mergeSort(s,0,n);
	for(i=0;i<n;i++)
	{
		if(ju++>0) printf(" ");
		printf("%d",s[i]);
	}
	printf("\n%d\n",count);
	return 0;
}


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

long long  INF=1000000000000000000;
using namespace std;


int main(){


int N;
cin>>N;

long long A[N+1];
long long s[N+1];
map<long long,int>sum;
s[0]=0;
A[0]=0;
for(int i=1;i<=N;i++){
    cin>>A[i];
    s[i]=s[i-1]+A[i];
}

for(int i=0;i<=N;i++){
    auto iter=sum.find(s[i]);
    if(iter==sum.end()){
        sum.insert(make_pair(s[i],1));
    }
    else{
        iter->second++;
    }
}
auto it=sum.begin();
long long ans=0;
while(it!=sum.end()){
long long i=it->second;
if(i>=2){
    ans+=i*(i-1)/2;
}
it++;
}
cout<<ans<<endl;
 return 0;
}

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

using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};
//const int INF = (1 << 29);


int main(){

  int x;
  cin >> x;
  ll res = 0;
  for(int i = x;!res;i++){
    bool flag = true;
    for(int j = 2;j*j <= i;j++){
      if(!(i % j))flag = false;
    }
    if(flag)res = i;
  }
  cout << res;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v[1234567];
  for(int i=1;i<N;i++){
    int a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int k;
  for(int i=0;i<N;i++)if(v[i].size()==1)k=i;
  int ans=1;
  queue<int> que;
  que.push(k);
  std::vector<int> res1(1234567,0),res2(1234567,0),used(1234567,0);used[k]++;
  while(que.size()){
    int q=que.front();que.pop();//cout<<q<<" "<<ans<<endl;
    int t=0;for(int a:v[q])t+=res1[a];
    ans*=K-res1[q]-t;ans%=MOD;
    for(int p:v[q]){
      res1[p]++;res2[p]+=res1[q];
      if(used[p])continue;used[p]++;

      que.push(p);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 62836
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    s.insert(s.begin()+4,' ');
    std::cout<<s<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>

using namespace std;

int main(void)
{
  int i;
  char str[100];
  scanf("%s",str);

  for(i=0;str[i];i++)
    {
      if(str[i]==',')
	putchar(' ');
      else
	putchar(str[i]);
    }
  puts("");
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(readline())
s = [readline().rstrip() for _ in range(n)]

import collections

c = collections.Counter(s)
c = c.most_common()

ans = [c[0][0]]
v_max = c[0][1]
for k,v in c[1:]:
    if v == v_max:
        ans.append(k)
ans.sort()

for a in ans:
    print(a)

Measured memory_bytes: 45072
import java.util.Scanner;

public class Main {

	static int[] b = {0,1,2,3,5,7,8,9};
	
	static void enc(int n){
		if(n>=8){
			enc(n/8);
		}
		System.out.print(b[n%8]);
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			enc(n);
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	_, m := r.nextInt(), r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	sumInt := func(src []int) (vs int) {
		vs = 0
		for i := range src {
			vs += src[i]
		}
		return
	}
	pt := float64(sumInt(a)) / float64(4*m)

	cnt := 0
	for _, ai := range a {
		if float64(ai) >= pt {
			cnt++
		}
	}
	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(cnt >= m)])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int seq[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int k;
	cin>>k;
	cout<<seq[k-1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 200005;
const int MM = 1000000007;

ll merge_vi(int a, int b){
	ll ch = 0, c = 0;
	for(int i = 0; i < 30; i++){
		if( a&1<<i ) ch++;
		if( b&1<<i ) ch++;
		if( ch ) c |= 1<<i, ch--;
	}
	return c;
}

void reduce_vc(vector<int> &L){
	map<int, int> S;
	for(int c : L){
		int t = __builtin_popcount(c);
		if( S.find(t) == S.end() ) S[t] = c;
		else S[t] = min(S[t], c);
	} L.clear();
	for(auto e : S) L.push_back(e.second);
}

void merge_vc(vector<int> X, vector<int> Y, vector<int> &Z){
	Z.clear();
	for(int x : X){
		for(int y : Y){
			ll z = merge_vi(x, y);
			Z.push_back(z);
		}
	}
	reduce_vc(Z);
}

struct UF{
	int t[MX];
	vector<int> L[MX];
	int find(int x){ return t[x]? t[x] = find(t[x]) : x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		if( a == b ) return 0;
		t[a] = b; merge_vc(L[a], L[b], L[b]);
		return 1;
	}
} uf;
int N, V;
int D[MX], vst[MX];
vector<int> pre[MX], suf[MX];

int main()
{
	vector<int> P;
	scanf("%d%d", &N, &V);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	while(V){
		P.push_back(V);
		V /= 2;
	}
	reverse(P.begin(), P.end());
	for(int i = 1; i <= N; i++) uf.L[i].push_back(1);
	for(int t = 1; t <= P.size(); t++){
		for(int i = 1; i+1 <= N; i++){
			if( D[i+1] - D[i] <= P[t-1] && D[i+1] - D[i] > P[t-1]/2){
				uf.merge(i+1, i);
			}
		}
		for(int i = 1; i <= N; i++){
			if( uf.find(i) == i ){
				uf.L[i].push_back(1<<t);
				reduce_vc(uf.L[i]);
			}
		}
		/*
		printf("%d %d\n", t, P[t-1]);
		for(int i = 1; i <= N; i++){
			if( uf.find(i) == i ){
				printf("%d : ", i);
				for(int c : uf.L[i]) printf("%d ", c);
				printf("\n");
			}
		} // */
	}
	pre[0].push_back(0);
	suf[N+1].push_back(0);
	for(int i = 1; i <= N; i++){
		pre[i] = pre[i-1];
		if( uf.find(i) == i ) merge_vc(pre[i], uf.L[i], pre[i]);
	}
	for(int i = N; i >= 1; i--){
		suf[i] = suf[i+1];
		if( uf.find(i) == i ) merge_vc(suf[i], uf.L[i], suf[i]);
	}
	for(int i = 1; i <= N; i++){
		vector<int> L;
		merge_vc(pre[i-1], suf[i+1], L);
		for(int c : L) if( c < 1 << P.size()) vst[i] = 1;
	}
	for(int i = 1; i <= N; i++){
		if( vst[uf.find(i)] ) printf("Possible\n");
		else printf("Impossible\n");
	}
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  vector<ll> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  ll sum=0;
  sum=v[2]-v[1]+v[2]-v[0];
  if(sum%2==1) sum+=3;

  cout<<sum/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int a[4];
  cin >> a[1] >> a[2] >> a[3];
  cin >> a[1] >> a[2] >> a[3];
  sort(a + 1, a + 1 + 3);
  if ((a[1] == a[2] && a[2] != a[3]) || (a[2] == a[3] && a[1] != a[2])) 
  	cout << "Yes" << endl;
  else 
  	cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h  = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = sc.nextInt();
        }
        if (sc != null) {
            sc.close();
        }
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            if (h[i] >= k) c++;
        }
        System.out.println(c);
    }

}

Measured memory_bytes: 49660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int cnt=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%10==i/10000&&(i/10)%10==(i/1000)%10)
      cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    long double A;
    long double B;
    cin >> A >> B;
    LD c = A*B;
    


    int ans = c;
    pa;

    

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_c && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_c && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_c && sh submit.sh
*/


Measured memory_bytes: 3812
#include <stdio.h>
int main(void)
{
	char s1[101], s2[101];
	int n;
	if (~scanf("%d", &n))
	{
		scanf("%s %s", s1, s2);
		for (int i = 0; i < n; i++)
		{
			printf("%c", s1[i]);
			printf("%c", s2[i]);
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[501][501];
int n; 
int x[3][3];

int hsh()
{
	int cur = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j=0;j<n;j++)
		{
			cur<<=1;
			cur+=(x[i][j]=='#');
		}
	}
	return cur;
}

char b[3][3];

void unhash(int x)
{
	for(int i = n - 1; i >= 0; i--)
	{
		for(int j = n - 1; j >= 0; j--)
		{
			if(x&1) b[i][j]='#';
			else b[i][j]='.';
			x>>=1;
		}
	}
}

int apply(int bit, int i, int j)
{
	unhash(bit);
	int z[3];
	for(int k=0;k<n;k++)
	{
		z[k]=b[i][k];
	}
	for(int k=0;k<n;k++)
	{
		b[k][j]=z[k];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			x[i][j]=b[i][j];
		}
	}
	return hsh();
}

vector<int> adj[1051];
int dist[1051];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	bool allempty = 1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#') allempty=0;
			//x[i][j]=a[i][j];
		}
	}
	/*
	int s = hsh();
	for(int i = 0; i < (1<<(n*n)); i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				int dest = apply(i,j,k);
				adj[i].pb(dest);
			}
		}
	}
	queue<int> q;
	q.push(s);
	int e = (1<<(n*n)) - 1;
	for(int i=0;i<1050;i++)
	{
		dist[i]=100000;
	}
	dist[s]=0;
	while(!q.empty())
	{
		int u = q.front(); q.pop();
		for(int i = 0; i < adj[u].size(); i++)
		{
			int v = adj[u][i];
			if(dist[u]+1<dist[v])
			{
				dist[v]=dist[u]+1;
				q.push(v);
			}
		}
	}
	if(dist[e]>=100000) cout<<-1<<'\n';
	else cout<<dist[e]<<'\n';
	*/
	
	if(allempty)
	{
		cout<<-1<<'\n';
		return 0;
	}
	int fullcol = 0;
	for(int j = 0; j < n; j++)
	{
		bool full=1;
		for(int i=0;i<n;i++)
		{
			if(a[i][j]=='.')
			{
				full=0;
				break;
			}
		}
		if(full) fullcol++;
	}
	if(fullcol==n)
	{
		cout<<0<<'\n'; return 0;
	}
	int minans = 1000000;
	for(int i = 0; i < n; i++)
	{
		//find min steps to make row i full
		int cntemp = 0;
		for(int j = 0; j < n; j++)
		{
			if(a[i][j]=='.') cntemp++;
		}
		if(cntemp==0)
		{
			minans=0; break;
		}
		bool pos=0;
		for(int j = 0; j < n; j++)
		{
			if(a[j][i]=='#')
			{
				pos=1;
			}
		}	
		if(!pos)
		{
			cntemp++;
			pos=1;
		}
		if(pos)
		{
			minans=min(minans,cntemp);
		}
	}
	minans+=n-fullcol;
	cout<<minans<<'\n';
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> x;
    ll ans = x / 11 * 2;
    if (x % 11 > 6) ans += 2;
    else if (x % 11) ans++; 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(a: int, b: int):
    return str(sorted([a, b])[0]) * sorted([a, b])[1]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    print(f'{solve(a, b)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75072
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
double r=ir.nextDouble();
out.printf("%.10f %.10f\n",Math.PI*Math.pow(r,2),2*Math.PI*r);
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 25004
using System;
//全部が？の時、10^10^5通りなので、全列挙はむり
//独立性桁ごとに考える
//動的計画法
namespace D
{
    class Program
    {
        static public int Mod = 1000000007;
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            const int N=13;
            //dp[k]=>13で割った時のあまりがkのパターン数
            long[] dp = new long[N];
            dp[0] = 1;
            //後ろから解くアルゴリズム
            //1?2?3  0->3->?3->2?3->....
            int mul = 1;//桁の把握
            for(int i = s.Length - 1; i >= 0; i--)
            {
                long[] nextDP = new long[N];
                char c = s[i];
                if (c == '?')
                {
                    for(int k = 0; k < 10; k++)
                    {
                        for(int j = 0; j < N; j++)
                        {
                            nextDP[(k * mul + j) % N] += dp[j];
                            nextDP[(k * mul + j) % N] %= Mod;
                        }
                    }
                }
                else
                {
                    int k = (int)(s[i]-'0');
                    for (int j = 0; j < N; j++)
                    {
                        nextDP[(k * mul + j) % N] += dp[j];
                        nextDP[(k * mul + j) % N] %= Mod;
                    }
                }
                mul *= 10;
                mul %= N;
                dp = nextDP;
            }
            Console.WriteLine(dp[5]);
        }
    }
}
//namespace D
//{
//    class Program
//    {
//        static public int n;
//        static public int[] S;
//        static public long ans;
//        static public int Mod = 1000000007;
//        static void Main(string[] args)
//        {
//            string s = Console.ReadLine();
//            n = s.Length;
//            S = new int[n];
//            for(int i=0; i < n; i++)
//            {
//                if (s[i] == '?') S[i] = -1;
//                else S[i] = int.Parse(s[i].ToString());
//            }
//            DFS();
//            Console.WriteLine(ans);
//        }
//        static public void DFS(int value = 0, int index=0)
//        {
//            if (index >= n) { RenewAns(value);Console.WriteLine(value); return;}
//            else if (S[index] != -1) DFS(value += (S[index] * (int)Math.Pow(10, n - index - 1)), ++index);
//            else if (S[index] == -1)
//            {
//                for (int i = 0; i <= 9; i++)
//                {
//                    DFS(value += (i * (int)Math.Pow(10, n - index - 1)),++index);
//                }
//            }
//        }
//        static public bool canDivide(int x)
//        {
//            if (x % 13 == 5) return true;
//            else return false;
//        }
//        static public void RenewAns(int x)
//        {
//            if (canDivide(x)) ans++;
//            if (ans >= Mod) ans -= Mod;
//        }
//    }
//}


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

int check(int m, vector<int>& A) {
  map<int, int> S;
  for (int i = 1; i < A.size(); i++) {
    if (A[i-1] < A[i]) continue;
    if (m == 1) return 0;
    int a = A[i];
    S.erase(S.upper_bound(a), S.end());
    while (S[a] == m-1) {
      a--;
      if (a == 0) return 0;
    }
    S[a]++;
    S.erase(S.upper_bound(a), S.end());
  }
  return 1;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int& a : A) cin >> a;

  int l = 0, r = N;
  while (1 < r - l) {
    int m = (l + r) / 2;
    if (check(m, A)) r = m;
    else l = m;
  }
  cout << r << endl;
}

Measured memory_bytes: 1024
//gcd ユーグリッドの互除法
#include <stdio.h>
int main(void){
   int x,y;
   int tmp;
   int r;
   
   scanf("%d %d",&x,&y);
   if(y>x){
       tmp = x;
       x = y;
       y = tmp;
   }
   while(y!=0){
       r = x%y;
       x = y;
       y = r;
   }
   printf("%d\n",x);
}



Measured memory_bytes: 2104
import sys
a,b,c,d=map(int,input().split())
l=[0 for i in range(4)]
l[0]=max(a,b)*max(c,d)
l[1]=max(a,b)*min(c,d)
l[2]=min(a,b)*max(c,d)
l[3]=min(a,b)*min(c,d)
print(max(l))

Measured memory_bytes: 9192