akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n=INF,aa[110000],ab[110000],k=0,cnt=0,a,b,ac[110000][10];
pair<int,int> p[220000];
string s,ss[220000],sf,se;
char c;
signed main(){
    cin>>a>>b>>m;
    rep(i,a){
        cin>>aa[i];
        n=min(n,aa[i]);
    }
    cnt+=n;
    n=INF;
    rep(i,b){
        cin>>ab[i];
        n=min(n,ab[i]);
    }
    cnt+=n;
    rep(i,m){
        cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
        cnt=min(cnt,aa[ac[i][0]-1]+ab[ac[i][1]-1]-ac[i][2]);
    }
    cout<<cnt;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define int long long
using namespace std;

int constexpr N = 100009;
int n, k;
vector<int> d[N];

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i = 0, t, x; i < n; ++i) {
        cin >> t >> x;
        d[t].push_back(x);
    }

    vector<int> mx, rest;
    for(auto& v : d) {
        if(v.empty()) continue;
        sort(v.begin(), v.end());
        mx.push_back(v.back());
        for(int j = (int)v.size() - 2; j >= 0; --j) rest.push_back(v[j]);
    }
    sort(mx.rbegin(), mx.rend());
    sort(rest.rbegin(), rest.rend());

    int tot = 0;
    int j;
    for(j = 0; j < min(k, (int)rest.size()); ++j) tot += rest[j];
    int needed = k - j;
    j -= 1;


    int i = 0;
    for(; i < needed; ++i) tot += mx[i];

    int ans = i * i + tot;
    
    int lp = min(k, (int)mx.size());
    for(; i < lp; ++i) {
        tot += mx[i] - rest.at(j--);
        ans = max(ans, (i + 1) * (i + 1) + tot);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6904
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
#define endl '\n'
#define all(v) v.begin(), v.end()

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    for (auto& x : a) cin >> x;
    ll ans = 0;
    ll mod = 1e9+7;
    ll sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];
    for (int i = 0; i < n; i++) {
        sum -= a[i];
        ans += ((a[i] % mod) * (sum%mod)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> G[114514];
int c[114514];
int n,flg;
int calc(vector<int> v,int s){
  sort(v.rbegin(),v.rend());
  if(2*v[0]<=s) return s-(s%2);
  return s-v[0];
}
int dfs(int v,int p){
  if((int)G[v].size()==1) return c[v];
  vector<int> a;
  int s=0;
  for(int u:G[v]){
    if(u==p) continue;
    int k=dfs(u,v);
    s+=k;
    a.push_back(k);
  }
  int q=calc(a,s);
  int x=2*c[v]-s,y=s-c[v];
  flg&=0<=y&&y<=q;
  flg&=0<=x;
  return x;
}
signed main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>c[i];
  if(n==2){
    if(c[0]==c[1]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
  }
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<n;i++){
    if(G[i].size()<2) continue;
    flg=1;
    int x=dfs(i,0);
    if(flg&&x==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 16128
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    string S,T;
    cin >> S;
    cin >> T;
    int c = 0;
    rep(i,3){
        if(S[i]==T[i]) ++c;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int v_max = 1005;
const int n_max = 105;

signed main(){
    int n,w;
    cin >> n >> w;
    int weight[n],value[n];
    REP(i,n) cin >> weight[i] >> value[i];

    int dp[2][v_max * n_max + 1];
    REP(i,2) REP(j,v_max * n_max + 1) dp[i][j] = INF;
    dp[0][0] = 0;
    REP(i,n){
        REP(j,v_max * n_max + 1){
            dp[(i+1) %2][j] = dp[i%2][j];
            if(j - value[i] < 0) continue;
            chmin(dp[(i+1) %2][j], dp[i%2][j-value[i]] + weight[i]);
        }
    }
    int ans = 0;
    REP(i,v_max * n_max + 1) if( dp[n%2][i] <= w) ans = i;
    cout << ans << endl;

}

Measured memory_bytes: 1920
N=int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
num = 0
for i in range(N):
    num += min(A[i],B[i])
    B[i] = max(0, B[i]-A[i])
    num += min(A[i+1], B[i])
    A[i+1] = max(0, A[i+1]-B[i])
print(num)

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

int main(){
	int nums[3];
	cin >> nums[0] >> nums[1] >> nums[2];
	sort(nums, nums + 3);
	if(nums[0] == nums[1]){
		cout << nums[2] << endl;
	}else{
		cout << nums[0] << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a = 0;
        int wk = 0;
        for(int i =0 ; i < m;i++){
            wk = sc.nextInt();
            a =a + wk;
        }
        String ret = null ;
        if(n - a > 0){
            ret = "No";
        }else{
            ret = "Yes";
        }

            System.out.println(ret);
        }
    }

Measured memory_bytes: 48800
N,K = gets.split.map &:to_i
Xs = (0...N).map{ |i| gets.split.map &:to_i }.sort.map.with_index{ |r,i| [i,*r] }
Ys = Xs.sort_by{ |i,x,y| y }
ans = 10**24
(0...N).each{ |i1|
  usable = 0
  (i1...N).each{ |i2|
    usable += (1 << i2)
    (0...N).each{ |j1|
      d = Ys[j1]
      used = 0
      used_count = 0
      yu = -10**10
      yd = +10**10
      xr = -10**10
      xl = +10**10
      (j1...N).each{ |j2|
        u = Ys[j2]
        b2 = (1 << u[0])
        if (usable & b2) != 0
          used += b2
          used_count += 1
          xr = [xr, u[1]].max
          xl = [xl, u[1]].min
          yu = [yu, u[2]].max
          yd = [yd, u[2]].min
          if used_count >= K
            w = xr - xl
            h = yu - yd
            ans = [ans, w*h].min
            #p [usable.to_s(2), used.to_s(2), used_count, w*h, ans, [xr,xl,yu,yd]]
            break
          end
        end
      }
    }
  }
}
p ans




Measured memory_bytes: 1788
N=int(input())
A=[int(input()) for i in range(N)]
if A[0]!=0:
  print(-1)
  exit()
ans=0
for i in range(N-1):
  if A[i+1]-A[i]>1:
    print(-1)
    exit()
  elif A[i+1]-A[i]==1:
    ans+=1
  else:
    ans+=A[i+1]
print(ans)

Measured memory_bytes: 11048
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

#### START
n = int(input())
a = list(map(int,input().split()))

f_cnt = 0
t_cnt = 0
o_cnt = 0

for ai in a:
    if ai%4 == 0:
        f_cnt += 1
    elif ai%2 == 0:
        t_cnt += 1
    else:
        o_cnt += 1

if t_cnt == 0:
    if f_cnt+1>=o_cnt:
        print("Yes")
    else:
        print("No")
else:
    if f_cnt>=o_cnt:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 23056
#include <stdio.h>

int gcd(int m,int n){
	if(!n)return m;
	gcd(n,m%n);
}

int main(void){
	int ans=0,a=2,b;
	scanf("%d",&b);
	ans=gcd(a,b);
	ans=a*b/ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
<?php
/*
    Problem URL : http://abc060.contest.atcoder.jp/tasks/abc060_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

list($A, $B, $C) = explode(" ", trim(fgets(STDIN)));

$t = $C;
while($t < 10000) {
    if ($t % $A == 0) {
        echo "YES\n";
        exit;
    }
    $t += $B;
}
echo "NO\n";


Measured memory_bytes: 4728
#include <stdio.h>
int main(void){
  
  int r;

scanf("%d",&r);
  if(r<1200){
    printf("ABC\n");
  }
  else  if(r<2800){
      printf("ARC\n");
  }
else {
  printf("AGC\n");
}

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
  int n;
  cin >> n;
  vector<vector<string>> ans(n, vector<string>(0));
  ans.at(0).push_back("a");
  for(int i=0; i<n-1; i++){
    rep(j, ans.at(i).size()){
      int ia = 0;
      int ib = 0;
      int ic = 0;
      int id = 0;
      int ie = 0;
      int iff = 0;
      int ig = 0;
      int ih = 0;
      int ii = 0;
      int ij = 0;
      rep(l, ans.at(i).at(j).size()){
        if(ans.at(i).at(j).at(l) == 'a') ia = 1;
        if(ans.at(i).at(j).at(l) == 'b') ib = 1;
        if(ans.at(i).at(j).at(l) == 'c') ic = 1;
        if(ans.at(i).at(j).at(l) == 'd') id = 1;
        if(ans.at(i).at(j).at(l) == 'e') ie = 1;
        if(ans.at(i).at(j).at(l) == 'f') iff = 1;
        if(ans.at(i).at(j).at(l) == 'g') ig = 1;
        if(ans.at(i).at(j).at(l) == 'h') ih = 1;
        if(ans.at(i).at(j).at(l) == 'i') ii = 1;
        if(ans.at(i).at(j).at(l) == 'j') ij = 1;
      }
      int k = ia + ib + ic + id + ie + iff + ig + ih + ii + ij;
      rep(m, k+1){
        if(m == 0) ans.at(i+1).push_back(ans.at(i).at(j)+'a');
        if(m == 1) ans.at(i+1).push_back(ans.at(i).at(j)+'b');
        if(m == 2) ans.at(i+1).push_back(ans.at(i).at(j)+'c');
        if(m == 3) ans.at(i+1).push_back(ans.at(i).at(j)+'d');
        if(m == 4) ans.at(i+1).push_back(ans.at(i).at(j)+'e');
        if(m == 5) ans.at(i+1).push_back(ans.at(i).at(j)+'f');
        if(m == 6) ans.at(i+1).push_back(ans.at(i).at(j)+'g');
        if(m == 7) ans.at(i+1).push_back(ans.at(i).at(j)+'h');
        if(m == 8) ans.at(i+1).push_back(ans.at(i).at(j)+'i');
        if(m == 9) ans.at(i+1).push_back(ans.at(i).at(j)+'j');
      }
    }
  }
  rep(i, ans.at(n-1).size()) cout << ans.at(n-1).at(i) << endl;
  return 0;
}

Measured memory_bytes: 11380
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n = in_int()

print(6.28*n)

Measured memory_bytes: 9200
package main

import "fmt"

func main() {
	var a, b, c, d, e, k int
	fmt.Scan(&a, &b, &c, &d, &e, &k)

	if (b-a) <= k && (c-a) <= k && (d-a) <= k &&
		(e-a) <= k && (c-b) <= k && (d-b) <= k &&
		(e-b) <= k && (d-c) <= k && (e-c) <= k && (e-d) <= k {
		fmt.Println("Yay!")
		return
	}

	fmt.Println(":(")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
	dcl(n);
	ll a=1,b=1;
	rep(i,n){
	    dcl(p,q);
	    //cout<<(double)a/p<<","<<(double)b/q<<endl;
	    ll x=max(a/p+(a%p?1:0),b/q+(b%q?1:0));
	    //cout<<x<<endl;
	    x=x?x:1;
	    a=p*x,b=q*x;
	    //cout<<a<<","<<b<<endl;
	}
	cout<<a+b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>


using namespace std;


using ll = long long;


static const ll INF = (1LL << 32);


ll V, E;
vector< vector<ll> > adj(100, vector<ll>(100, INF));


int main()
{
    cin >> V >> E;

    for (ll i = 0; i < E; i++) {
        ll x, y, c;
        cin >> x >> y >> c;
        adj[x][y] = c;
    }

    for (ll i = 0; i < V; i++) {
        adj[i][i] = 0;
    }


    for (ll k = 0; k < V; k++) {
        for (ll i = 0; i < V; i++) {
            for (ll j = 0; j < V; j++) {
                if (adj[i][k] == INF || adj[k][j] == INF)
                    continue;

                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }

    for (ll i = 0; i < V; i++) {
        if (adj[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < V; j++) {
            if (adj[i][j] == INF)
                cout << "INF";
            else
                cout << adj[i][j];
            if (j != V - 1)
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3196
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
        m:usize,
        ab:[(usize,usize);m],
    }

    let mut uf = UnionFindTree::new(n);
    let mut vec = vec![0; n + 1];

    for (ai, bi) in ab {
        uf.unite(ai - 1, bi - 1);
    }

    for i in 0..n {
        vec[uf.root(i)] += 1;
    }

    println!("{}", vec.into_iter().max().unwrap());
}

struct UnionFindTree {
    parents: Vec<usize>,
    sizes: Vec<usize>,
    weights: Vec<isize>,
    has_loops: Vec<bool>,
}

impl UnionFindTree {
    fn new(n: usize) -> Self {
        let parents = (0..n).collect();
        let sizes = vec![1; n];
        let weights = vec![0; n];
        let has_loops = vec![false; n];
        UnionFindTree {
            parents,
            sizes,
            weights,
            has_loops,
        }
    }

    fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            x
        } else {
            let tmp = self.root(self.parents[x]);
            self.weights[x] += self.weights[self.parents[x]];
            self.parents[x] = tmp;
            tmp
        }
    }

    fn size(&self, x: usize) -> usize {
        self.sizes[x]
    }

    fn has_loop(&self, x: usize) -> bool {
        self.has_loops[x]
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite_with_weight(&mut self, x: usize, y: usize, w: isize) {
        let root_x = self.root(x);
        let root_y = self.root(y);

        if self.same(x, y) {
            self.has_loops[root_x] = true;
            self.has_loops[root_y] = true;
        } else {
            if self.sizes[root_x] >= self.sizes[root_y] {
                self.parents[root_y] = root_x;
                self.sizes[root_x] += self.sizes[root_y];
                self.weights[root_y] = -w - self.weights[y] + self.weights[x];
            } else {
                self.parents[root_x] = root_y;
                self.sizes[root_y] += self.sizes[root_x];
                self.weights[root_x] = w + self.weights[y] - self.weights[x];
            }
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        self.unite_with_weight(x, y, 0);
    }

    fn diff(&mut self, x: usize, y: usize) -> Option<isize> {
        if self.same(x, y) {
            Some(self.weights[x] - self.weights[y])
        } else {
            None
        }
    }

    fn is_parent(&self, x: usize) -> bool {
        self.parents[x] == x
    }
}


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

int main() {
  int H, W, N;
  int count = 0;

  cin >> H;
  cin >> W;
  cin >> N;

  while (N > 0) {
    N -= max(H, W);
    count ++;
  }

  cout << count;

  return 0;

}

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

const ll INF = pow(10, 9) + 7;

int main() {
	string s;
	cin >> s;
	rep(i, s.size())cout << "x";
}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    unsigned int n;
    scanf("%d", &n);
    for (; n != 0; n /= 10) {
        if (n % 10 == 7) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

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

int main(){
	int a,b,c,t;
	cin >> a >> b >> c;
	if ( a > b ) { t = a; a = b; b = t; }
	if ( b > c ) { t = b; b = c; c = t; }
	if ( a > b ) { t = a; a = b; b = t; }

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 
 int h,w,in,iin,m;cin>>h>>w>>m;
 map<int,int>row,col;
set<pair<int,int>>jp;

 while(m--)
 {
    cin>>in>>iin;
    row[in]++;
    col[iin]++;
    jp.insert({in,iin});
 }
 int mr=0,ir,mc=mr,ic;
 for(auto p:row)
 {
     if(p.second>mr)
     {
         mr=p.second;ir=p.first;
     }
 }
  for(auto p:col)
 {
     if(p.second>mc)
     {
         mc=p.second;ic=p.first;
     }
 }
// mr ir mc ic done
vector<int>r,c;
 for(auto p:row)
 {
     if(p.second==mr)
     {
        r.push_back(p.first);
     }
 }
for(auto p: col)
{
      if(p.second==mc)
     {
         c.push_back(p.first);
     }
}
for(auto u:r)
{
    for(auto v:c)
    {
        if(jp.find({u,v})==jp.end())
        {
            cout<<mr+mc<<endl;return 0;
        }
    }
}
 cout<<mr+mc-1<<endl;
 
return 0;
   
}

Measured memory_bytes: 49632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		List<Integer>[] adj;
		int[] p;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for (int i = 0; i < n - 1; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			p = new int[n];
			p[0] = -1;
			dfs1(0);
			List<Integer> path = new ArrayList<>();
			for (int v = n - 1; v >= 0; v = p[v]) {
				path.add(v);
			}
			Collections.reverse(path);
			int bad = path.get((path.size() + 1) / 2);
			int a = dfs2(0, bad, -1);
			int b = n - a;
			out.println(a > b ? "Fennec" : "Snuke");
		}

		private void dfs1(int v) {
			for (int u : adj[v]) {
				if (u != p[v]) {
					p[u] = v;
					dfs1(u);
				}
			}
		}

		private int dfs2(int v, int bad, int pr) {
			int res = 1;
			for (int u : adj[v]) {
				if (u == pr || u == bad) {
					continue;
				}
				res += dfs2(u, bad, v);
			}
			return res;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 64124
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,d = imap()
ans = 0
for i in range(n):
    x,y = imap()
    dist = ma.sqrt(x**2 + y**2)
    if dist <= d: ans += 1
print(ans)


Measured memory_bytes: 37680
require 'matrix'

until $stdin.eof?
  a, b, c, d, e, f = gets.split.map(&:to_i)
  mat  = Matrix[ [a, b], [d, e] ]
  pair = Matrix[ [c],    [f] ]
  result = mat.inv * pair

  x, y = result[0, 0].to_f, result[1, 0].to_f
  puts "%.3f %.3f" % [x, y]
end

Measured memory_bytes: 6424
#include <stdio.h>
#define N 100000
 
typedef struct{
  int par;
  int left;
  int right;
}node;
 
node T[N];
int dep(int);
int hei(int);
 
int main(){
  int i,j,n,a;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++) T[i].par = T[i].left = T[i].right =-1;
 
  for(i=0; i<n; i++){
    scanf("%d",&a);
    scanf("%d %d", &T[a].right, &T[a].left);
    if(T[a].left != -1) T[T[a].left].par = a;
    if(T[a].right != -1) T[T[a].right].par = a;
  }
  
 for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = ", i ,T[i].par);
    if(T[i].par == -1){
      printf("-1, ");
    }
    else{
      if(T[T[i].par].left == i){
        printf("%d, ",T[T[i].par].right);
      }
      else{
        printf("%d, ",T[T[i].par].left);
      }
    }
 
    printf("degree = ");
    if(T[i].left == -1 && T[i].right == -1){
      printf("0, ");
    }  
 else{
      if(T[i].left != -1 && T[i].right != -1){
        printf("2, ");
      }
      else{
        printf("1, ");
      }
    }
    printf("depth = %d, height = %d, ", dep(i), hei(i));
 
    if(T[i].par == -1){
      printf("root");
    }
    else{
      if(T[i].left ==-1 && T[i].right == -1){
        printf("leaf");
      }
      else{
        printf("internal node");
      }
    }
    printf("\n");
  }
 
  return 0;
}
 
int dep(int n){
  if(T[n].par == -1) return 0;
  return dep(T[n].par)+1;
}
 
int hei(int n){
  int right=0,left=0;
 
  if(T[n].right == -1 && T[n].left == -1) return 0;
 
  if(T[n].right != -1) right = hei(T[n].right)+1;
  if(T[n].left != -1) left = hei(T[n].left)+1;
 
  if(left > right) return left;
  else return right;
}

Measured memory_bytes: 2756
from collections import defaultdict
import sys
input = sys.stdin.readline


count = defaultdict(int)
n, m = map(int, input().split())
for _ in range(m):
    a, b = map(int, input().split())
    count[a] += 1
    count[b] += 1

for cnt in count.values():
    if cnt % 2 != 0:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    string ans = "NG";
    int base = a / k;
    int end = b / k;
    for (int i = base; i < end + 1; i++)
    {
        int num = k * i;
        if (num >= a && num <= b)
        {
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int m;
	int h,w;cin >>h >>  w >> m;
	vector<int> ws(w);
	vector<int>   h_cnt[h];
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		h_cnt[a].push_back(b);
		ws[b]++;
	}
	multiset<int> st;
	auto upd = [&](int pos,int delta){
		st.erase(st.find(ws[pos]));
		ws[pos] += delta;
		st.insert(ws[pos]);
	};
	rep(i,w)st.insert(ws[i]);
	int ret =0 ;
	rep(i,h){
		int cur = h_cnt[i].size();
		for(auto x:h_cnt[i])upd(x,-1);
		if(st.size()){
			cur += *st.rbegin();
			
		}
		ret = max(ret,cur);
		for(auto x:h_cnt[i])upd(x,1);
	}
	cout <<ret << endl;

	return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for (ll i = 0; i < n; i++) cin >> t[i];
    ll ans = 1;
    ll cnt = 0;
    sort(t.begin(), t.end());
    for (ll i = 0; i < n;i++){
        if(cnt<c and t[i]<=t[i-cnt]+k){
            cnt++;
        }
        else{
            ans++;
            cnt = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3992
import java.util.*;
public class Main {
    static double[][] nums;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        Arrays.sort(nums);
        int ans=1;
        for(int i=0;i<n-1;i++){
            if(nums[i]!=nums[i+1])ans++;
        }
        System.out.println(ans);
    }


    
}


Measured memory_bytes: 68876
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

string s,t;
string ans;
vector<vector<ll>>dp(3005,vector<ll>(3005,-1));
ll func(ll i,ll j){
	//cout<<i<<" "<<j<<endl;
	if(dp[i][j]!=-1)return dp[i][j];
	
	if(i==0 || j==0)dp[i][j]=0;
	else if(s[i-1]==t[j-1]){
		dp[i][j]=func(i-1,j-1)+1;
	}else dp[i][j]=max(func(i,j-1),func(i-1,j));
	return dp[i][j];
}
void serch(ll i,ll j,ll num){
	//cout<<i<<" "<<j<<" "<<num<<endl;
	//cout<<s[i]<<t[j]
	if(num==0)return;
	if(s[i-1]==t[j-1]){
		//cout<<ans<<endl;
		ans.push_back(s[i-1]);
		return serch(i-1, j-1, num-1);
	}else if(dp[i-1][j]>dp[i][j-1]){
		serch(i-1,j,num);
		return;
	}else serch(i,j-1,num);
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>s>>t;
	serch(s.length(),t.length(),func(s.length(),t.length()));
	//cout<<func(s.length(),t.length())<<endl;
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}


Measured memory_bytes: 71296
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
N = ii()
nums = tuple(li())
cnt = 0
bar = -1
for n in nums:
    cnt += 1 if n >= bar else 0
    bar = max(bar, n)
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;
//typedef long long ll;
int main()
{
//    OJ;
  int n;
  cin>>n;
  int a[n],dp[n];
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
      
      if(i>=2)
      {
          dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
      }
  }
    dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] data = str.split(" ");
		int num[] = new int[data.length];
		for(int i = 0; i < data.length; i++){
			num[i] = Integer.parseInt(data[i]);
		}
	
		int a = num[0];
		int b = num[1];
		int c = num[2];


		ArrayList<Integer> yaku = new ArrayList<Integer>();
		for(int i = a; i <= b; i++){
			if(c % i == 0){
				yaku.add(i);
			}
		}
		int x = yaku.size();
		System.out.println(x);
	}
}


Measured memory_bytes: 26308
"""
愚直に考えると、
・aを0 ~ Lの範囲まで見る
・各aについてbを0 ~ Lまで動かして、a xor b = a + b　であれば答えに＋１する。
a,b が 2**(100001)までなので、正確なオーダーは知らんが非常に大きく、O(?^2)で到底間に合わない。

無駄な部分として、(a,b)の組で成立するなら(b,a)も可能、みたいなものもあるが、
xor の特徴として
・加算と異なり桁上がりがない
という点を考えてみると、
・a,bの互いの各bitについて両方では1が立っていない（一方のみ１が立ってる or 両方0）
のものを探せばいいことが分かる。
で、a + b <= L みたいな条件（XXX以下の数字について条件を満たす～のような縛り）があるときは桁DPがつかえることがままある

dp[i+1][j] 
→　Lの左からi桁目まで見たときに、問題文の条件を満たすa,bの組の数。
　 jは a xor b (a+b でもある) のi桁目までが、Lのi桁目までより厳密に小さい（j = 1）か否か(j = 0)

遷移

dp[i][1] -> dp[i+1][1] : i-1桁まででa+bがLより小さいことが確定していれば、i桁目は何にしてもよいので、L[i]と ai+biが同じになるように遷移
dp[i][0] -> dp[i+1][1] : i-1桁まででa+bがLより小さいことが確定しておらず、i桁目で小さくなる。L[i] = 1 の場合のみOK
dp[i][0] -> dp[i+1][0] : i-1桁まででa+bがLより小さいことが確定しておらず、i桁目も同じ


"""


L = input()
N = len(str(L))
dp = [[0 for _ in range(2)] for _ in range(N+1)]
dp[0][0] = 1
MOD = 10**9 + 7

for i in range(N):
    if L[i] == "1":
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0), (1,0), (0,1)
        dp[i+1][1] += dp[i][0] # (a,b) = (0,0)
        dp[i+1][0] += dp[i][0] * 2 # i桁目も一致。L[i]=1なので、(1,0)か(0,1)
    else:
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0), (1,0), (0,1)
        # dp[i+1][1] += dp[i][0] # L[i] = 0 の場合、ai+biが0未満にならないのでこの遷移はない
        dp[i+1][0] += dp[i][0] # i桁目も一致。L[i]=0なので、(0,0)のみ

    dp[i+1][1] %= MOD
    dp[i+1][0] %= MOD

# 最後に和をとった時もちゃんとMODとる
print(sum(dp[-1]) % MOD)


Measured memory_bytes: 54236
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
now=-2
for a in A:
    ans+=B[a-1]
    if a==now+1:
        ans+=C[now-1]
    now=a
print(ans)

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

int main()
{
    int n; cin >> n;
    int amin = INT_MAX, amax = INT_MIN;
    long sum = 0;
    
    while(n--) {
        int x; cin >> x;
        amin = (x<amin) ? x : amin;
        amax = (x>amax) ? x : amax;
        sum += x;
    }
    
    cout << amin << ' ' << amax << ' ' << sum << endl;
    
    return 0;
}


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

int main(){
  int N ; 
  cin >> N ;
  vector<int> a(N) ,b(N); 
  
  for(int i = 0 ; i < N ; i++){
    cin >> a.at(i) ; 
    b.at(i) = 0 ; 
  }
  int i = 0 ; 
  int cnt = 0 ; 
  
  while(b.at(i) != 2){
    
    b.at(i)++ ; 
    i = a.at(i)-1 ; 

    if(b.at(1)==1){
      cout << cnt << endl ;
      return 0 ; 
    }
        cnt++ ; 
  }
  

  cout << "-1" << endl ; 
  
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#define isset(mask,bit) ((mask&(1LL<<bit))!=0)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e5+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
int main()
{
  lld i,j;
  ts(n,b,c);
  pp((n-b+1)*(n-c+1));
  return 0;
}

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


Measured memory_bytes: 2032
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn itob(i: u32) -> Vec<bool> {
    let mut n = i;
    let mut ret: Vec<bool> = vec![];
    for _ in 0..9 {
        if n % 2 == 1 {
            ret.push(true);
        } else {
            ret.push(false);
        }
        n /= 2;
    }
    ret
}

fn pow(u: u32) -> u32 {
    let mut ret: u32 = 1;
    for _ in 0..u {
        ret *= 2;
    }
    ret
}

fn main() {
    let mut ans: u64 = 0;
    let s: String = read();
    let cv: Vec<char> = s.chars().collect();

    if cv.len() == 1 {
        println!("{}", cv[0]);
        return;
    }

    for i in 0..pow(s.len() as u32 - 1) {
        let bv = itob(i);
        let mut tmp: Vec<char> = vec![cv[0]];
        for j in 1..cv.len() {
            if bv[j - 1] {
                let stmp: String = tmp.clone().into_iter().collect();
                let utmp: u64 = stmp.parse().unwrap();
                ans += utmp;
                tmp = vec![cv[j]];
            } else {
                tmp.push(cv[j]);
            }
        }
        let stmp: String = tmp.clone().into_iter().collect();
        let utmp: u64 = stmp.parse().unwrap();
        ans += utmp;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <math.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

//最大公約数
ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

//最小公倍数
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

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

    vector<double> a(n);
    cin >> a;

    double average, total;
    total = accumulate(a.begin(), a.end(), 0);
    average = total / n;

    double res=0, diff=1000000;
    int ans=0;
    REP(i,n){
        res = fabs(a[i]-average);
        if(res < diff){
            diff = res;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li x[55];

li dp[55][2555] = {{0}};

int main() {
	li n, a;
	cin >> n >> a;
	rin{
		cin >> x[i];
	}
	sort(x, x + n);

	dp[0][0] = 1;
	rep(i, n) {
		for (li j = n; j > 0; --j) {
			for (li k = 2500; k >= 0; --k) {
				dp[j][k + x[i]] += dp[j - 1][k];
			}
		}
		//dump2d(dp, 40, n);
		//puts("");
	}
	li res = 0;
	repp(i, 1, n + 1) {
		res += dp[i][a * i];
	}
	cout << res << endl;


	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char , char> pcc;
#define pb push_back
#define mp make_pair
#define ft first
#define se second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define I_MAX 1000000

int main()
{
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	//set <pair<ll,ll> > st;
  	ll n,k;
  	cin >> n >> k;
  	ll h[n+5];
  	ll dp[n+5];
  	for(ll i=1;i<=n;i++)
  	{
  		cin >> h[i];
      dp[i]=1e18;
  	}
  	ll l=max(0LL,n-k);
 //  	dp[n]=0;
	// st.insert(mp(h[n],n));
	// for(ll i=n-1;i>0;i--)
	// {
	// 	set<pair<ll,ll> >::iterator it=st.lower_bound(mp(h[i],I_MAX));
		
		//st.upper_bound(h[i]);
		//while()
	//}
    dp[n]=0;
    for(ll i=n-1;i>l;i--)
    {
      for(ll j=i+1;j<=n;j++)
      {
         dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
      }
    }
    for(ll i=l;i>0;i--)
    {
      for(ll j=i+1;j<=i+k;j++)
      {
        dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
      }
    }
    cout << dp[1] << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }

  bool flag=true;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==0){
      if(!(A.at(i)%3==0||A.at(i)%5==0)){
        flag=false;
      }
    }
    if(!flag){
      break;
    }
  }

  if(flag){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
}


Measured memory_bytes: 256
N, W = map(int, input().split())
MAX_N = 100


def main():
    w, v = [], []
    for i in range(N):
        wi, vi = map(int, input().split())
        w.append(wi)
        v.append(vi)

    dp = [[[0 for k in range(3*MAX_N+1)] for j in range(N+1)] for i in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, i+1):
            for k in range(3*j+1):
                if k - (w[i-1]-w[0]) >= 0:
                    if j * w[0] + k <= W and j > 0:
                        dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-(w[i-1]-w[0])]+v[i-1])
                    else:
                        dp[i][j][k] = 0
                else:
                    dp[i][j][k] = dp[i-1][j][k]

    ans = 0
    for i in range(N+1):
        for j in range(3*i+1):
            ans = max(ans, dp[N][i][j])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37468
local n = io.read("*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
end
for i = 2, n do
  a[i] = a[i] + a[i - 1]
end
for i = n - 1, 1, -1 do
  b[i] = b[i] + b[i + 1]
end
local ans = 0
for i = 1, n do
  ans = math.max(ans, a[i] + b[i])
end
print(ans)


Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
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) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) 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> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> se;
    int n = SZ(s);
    REP(i, n) {
        REP(j, k + 1) {
            string t = s.substr(i, j);
            if (t != "") se.insert(t);
        }
    }
    auto itr = begin(se);
    REP(i, k-1) itr++;
    cout << *itr << endl;
    return 0;
}



Measured memory_bytes: 1664
//
// ABC178 A - Not
//

#include <bits/stdc++.h>

using namespace std;

int main()
{
    // 標準入力から値を受け取る
    int x;
    cin >> x;

    // 値(0,1)を反転させる
    if (x == 0)
    {
        cout << "1" << endl;
    }
    else if (x == 1)
    {
        cout << "0" << endl;
    }

    // 戻り値
    return (0);
}

Measured memory_bytes: 3588