akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	
	std::vector<int> v;
	for (int i = 0; i < 3; ++i) {
		int a; cin >> a;
		v.push_back(a);
	}
	sort(v.rbegin(), v.rend());
	int ans;
	ans = v[0]*10 + v[1] + v[2];
	cout << ans << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  c++ primer
//
//  Created by 隋洪宇 on 2017/8/25.
//  Copyright © 2017年 隋洪宇. All rights reserved.
//

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main(int argc, char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    if((a+b+c)%17==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
int a[1000000+10];

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

// Function to find gcd of array of 
// numbers
int findGCD(int arr[], int n)
{
  int result = arr[0];
  for (int i = 1; i < n; i++)
    {
      result = gcd(arr[i], result);

      if(result == 1)
        {
          return 1;
        }
    }
  return result;
}

int findMaxGCD(int arr[], int n) 
{ 
    // Calculating MAX in array 
    int high = 0; 
    for (int i = 0; i < n; i++) 
        high = max(high, arr[i]); 
  
    // Maintaining count array 
    vector<int> count(high+1, 0);
    for (int i = 0; i < n; i++) 
        count[arr[i]]++; 
  
    // Variable to store the 
    // multiples of a number 
    int counter = 0; 
  
    // Iterating from MAX to 1 
    // GCD is always between 
    // MAX and 1. The first 
    // GCD found will be the 
    // highest as we are  
    // decrementing the potential 
    // GCD 
    for (int i = high; i >= 1; i--) 
    { 
        int j = i; 
       counter = 0; 
    
        // Iterating from current 
        // potential GCD 
        // till it is less than 
        // MAX 
        while (j <= high) 
        { 
            // A multiple found 
  
            if(count[j] >=2) 
               return j; 
  
           else if (count[j] == 1)          
                counter++;          
  
            // Incrementing potential 
            // GCD by itself 
            // To check i, 2i, 3i.... 
            j += i; 
  
            // 2 multiples found, 
            // max GCD found 
            if (counter == 2)          
                return i; 
        } 
    }
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a[i] = t;
  }
  int arr_gcd = findGCD(a, n);
  int max_gcd = findMaxGCD(a, n);
  if(max_gcd == 1) {
    cout << "pairwise coprime\n";
  } else if(arr_gcd == 1) {
    cout << "setwise coprime\n";
  } else {
    cout << "not coprime\n";
  }
	return 0;
}


Measured memory_bytes: 10628
gets
l=gets.split.map{|c|[c.to_i]}
i=0
l.sort.map{|a|a<<i+=1}
l.map!{|a,b|b}
b=[s=0]*(1+r=l.size)
l.reverse_each{|n|i=n;(s+=b[i];i&=i-1)while i>0;(b[n]+=1;n+=n&-n)until n>r}
p s

Measured memory_bytes: 32616
from decimal import *
import math

def main():
    a,b = input().split()

    a_p = int(a)
    b_p = int(b.replace('.',''))
    ans = a_p * b_p // 100
    print(ans)

def main2():
    a,b = input().split()

    ans = Decimal(a) * Decimal(b)
    print(int(ans))


main2()


Measured memory_bytes: 10080
package main

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

var h, w int
var s [][]byte
var wall byte = '#'
var visited map[int]struct{}

type pos struct {
	x int
	y int
}

var direction = []pos{
	pos{-1, 0},
	pos{0, 1},
	pos{1, 0},
	pos{0, -1},
}

func bfs(i, j int) int {
	move := 0
	q := []pos{pos{i, j}}
	visited[i*w+j] = struct{}{}

	for {
		nextq := make([]pos, 0)
		for len(q) > 0 {
			p := q[0]
			q = q[1:]

			for _, d := range direction {
				nx := p.x + d.x
				ny := p.y + d.y
				if _, ok := visited[nx*w+ny]; ok {
					continue
				}
				if nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == wall {
					continue
				}
				nextq = append(nextq, pos{nx, ny})
				visited[nx*w+ny] = struct{}{}
			}
		}
		if len(nextq) == 0 {
			return move
		}
		q = nextq
		move++
	}

	return move
}

func main() {
	h, w = readInt(), readInt()
	s = make([][]byte, h)
	for i := range s {
		s[i] = readBytes()
	}

	ans := 0
	for i := range s {
		for j := range s[i] {
			if s[i][j] == wall {
				continue
			}
			visited = make(map[int]struct{})
			// fmt.Print(i, j)
			t := bfs(i, j)
			// fmt.Println("", t)
			ans = max(ans, t)
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 5504
# Problem https://atcoder.jp/contests/abc081/tasks/abc081_a
# Python 3rd Try


def solver(str):
    result = 0
    if str[0] == '1':
        result = result + 1
    if str[1] == '1':
        result = result + 1
    if str[2] == '1':
        result = result + 1

    return result


if __name__ == "__main__":
    result = 0
    result = solver(input())
    print(result)


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

int n, d, a, x, h;
long long s, ans;
vector <pair<int, int> > v;
queue <pair<int, long long> > q;

int main(){
    cin >> n >> d >> a;
    for (int i = 0; i < n; i++){
        cin >> x >> h;
        v.push_back({x, (h-1)/a+1});
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++){
        while (!q.empty() && q.front().second < v[i].first){
            s -= q.front().first;
            q.pop();
        }
        if (s < v[i].second){
            q.push({v[i].second-s, v[i].first+d*2});
            ans += v[i].second - s;
            s = v[i].second;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3440
#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>;

int64_t dp[110][110000];
int v[110], w[110000];

int main() {
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = dp[i-1][j];
            if (j-w[i] >= 0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]); 
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 87168
N = int(input())
a = []
flg = 1
for i in range(N):
    a.append(input())
for i in range(N-1):
    if(a[i][-1] != a[i+1][0]):
        flg = 0
a.sort()
for i in range(N-1):
    if(a[i] == a[i+1]):
        flg = 0
if(flg == 0):
    print("No")
else:
    print("Yes")


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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 GetDigit(int num){
    return log10(num)+1;
}

int n;

void solve() {
  cin >> n;
  int digit = 0;
  int ans=0;
  rep(i,1,n+1) {
    if(GetDigit(i)%2==1) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


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

int main() {
    string N,T;
    cin >> N >> T;

    char s1, s2;

    int p = 0;
    for (int i = 0; i < N.size(); i++) {
        s1 = N[i];
        s2 = T[i];

        if (N[i] != T[i]) {
            p = 1;
            break;
        }
    }

    if(p == 1){
        cout << "No";
    }
    else {
        cout << "Yes";
    }

}

Measured memory_bytes: 3624
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    #根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

n,m = inpl()
ab = [0] * m
for i in range(m):
    a,b = inpl()
    ab[i] = (a-1,b-1)

res = 0
for _ in range(m):
    uf = UnionFind(n)
    for i in range(m):
        if _ == i:
            continue
        uf.union(ab[i][0],ab[i][1])
    if uf.size(0) != n:
        res += 1
print(res)


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using db = double;
using ii = pair <int, int>;

#define int long long
#define FOR(a, b, c) for(int a = b, _c = c; a <= _c; ++a)
#define FORD(a, b, c) for(int a = b, _c = c; a >= _c; --a)
#define REP(a, b, c) for(int a = b, _ = c; a < _; ++a)
#define ALL(a, b) for(auto &a : b)
#define pb push_back
#define mp make_pair
#define all(a) begin(a), end(a)
#define reset(f, x) memset(f, x, sizeof(f))
#define fi first
#define se second
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll

template <class T> void Max(T &x, T y) { x = (x > y) ? x : y;}

const int N = 3005;
int n;
ll s, a[N], f[N][N];

ll F(int l, int r) {
  if(l > r) return 0;
  if(f[l][r] != -1) return f[l][r];
  ll ans;
  if((l + r) % 2 != n % 2) ans = max(F(l + 1, r) + a[l], F(l, r - 1) + a[r]);
  else ans = min(F(l + 1, r) - a[l], F(l, r - 1) - a[r]);
  return f[l][r] = ans;
}

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  FOR(i, 1, n) cin >> a[i], s += a[i];
  reset(f, -1);
  cout << F(1, n) << '\n';
}


Measured memory_bytes: 70912
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

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


const ll inf = 1LL << 50;
const int NMAX = 1010;
const int MMAX = 2020;
using edge = struct { int from; int to; ll cost; };
vector<edge> tree;



int main()
{

	int N, M;
	cin >> N >> M;

	int a, b, c;
	rep(i, M) {
		cin >> a >> b >> c;
		a--, b--;
		c = -c;
		tree.push_back({a,b,c});
	}


	//ベルマンフォード
	ll dist[NMAX];
	rep(i, N) dist[i] = inf;
	dist[0] = 0;
	bool negative = 0;

	rep(i, 3*N) {
		rep(j, M) {
			edge e = tree[j];
			if (dist[e.from] == inf)continue;
			if (dist[e.to] > dist[e.from] + e.cost) {
				dist[e.to] = dist[e.from] + e.cost;
				if (i == 3 * N - 1 && e.to == N - 1)
					negative = 1;
			}
		}
	}

	if (negative) cout << "inf" << endl;
	else cout << -dist[N-1] << endl;
	





	return 0;
}

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

int main()
{
    int N, T;
    cin >> N >> T;
    int A[N];
    cin >> A[0];
    int amin = A[0];
    int max = 0;
    int maxcnt = 1;
    for (int i = 1; i < N; i++) {
        cin >> A[i];
        amin = min(amin, A[i]);
        int diff = A[i] - amin;
        if (diff > max){
            max = diff;
            maxcnt = 1;
        } else if (diff == max) {
            maxcnt ++;
        }
    }
    cout << maxcnt << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n%2!=0){
        cout<<"No";
        exit(0);
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[i+n/2]){
            cout<<"No";
            exit(0);
        }
    }
    cout<<"Yes";
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

ll lcm(ll A, ll B){
    ll C = Euclid(A, B);
    return A*(B/C); //()がないとオーバーフローする可能性があるので注意！
}

ll f(ll X, ll C, ll D){
	ll L = lcm(C, D);
	return X - X/C - X/D + X/L;
}

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

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << f(B, C, D) - f(A-1, C, D) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    map<string, vector<pair<int, int>>> dict;
    rep(i,n){
        string s; int p;
        cin >> s >> p;
        dict[s].emplace_back(p,i+1);
    }
    for(auto v : dict){
        sort(rALL(v.second));
        for(auto p : v.second){
            cout << p.second << endl;
        }
    }
}

Measured memory_bytes: 256
// この人のコード素晴らしかった
// https://atcoder.jp/contests/abc064/submissions/10042047
#include<bits/stdc++.h>
using namespace std;

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

    int left = 0, right = 0;    // left --- 左に'('を追加する数
                                // right -- 右に')'を追加する数

    for(int i = 0; i < N; ++i) {
        if(S[i] == ')') {
            left++;
        } else {
            right++;
        }
        if (right > 0 && S[i] == ')') {
            left--;
            right--;
        }
    }

    cout << string(left,'(') + S + string(right, ')') << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	LL n; cin >> n;
	VLL a(n); REP(i, n)cin >> a[i];
	VLL b(n);
	b = a;
	SORT(b);
	reverse(ALL(b));
	for (int i = 0; i < n; i++) {
		if (b[0] == a[i]) {
			cout << b[1] << endl;
		}
		else {
			cout << b[0] << endl;
		}
	}

}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b == c || b+c == a || c+a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        String s = scanner.next();
        char k = s.charAt(scanner.nextInt() - 1);
        System.out.println(s.replaceAll("[^" + k + "]", "*"));
    }
}

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

int main() {
	int n;
	cin >> n;
	int out_d;
	out_d = n / 100;
	if (out_d * 111 < n) ++out_d;
	
	cout << out_d * 111 << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

int main() {
  string s;
  int ans = 0;
  while (getline(cin, s)) {
    transform(begin(s), end(s), begin(s), [](char c){ return isdigit(c) ? c : ' '; });
    stringstream ss(s);
    int x;
    while (ss >> x) ans += x;
  }
  cout << ans << endl;

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const ll mod = 1000000007;

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x / 500) * 1000;
  x = x % 500;
  ans += (x / 5) * 5;
  cout << ans << endl;
}


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

int main(){
	long n, x, min = LONG_MAX;
	scanf("%ld\n", &n);
	for(int i=0; i<5; i++){
		scanf("%ld\n", &x);
		if(x < min) min = x;
	}
	printf("%ld\n", (n + min - 1) / min + 4);
	return 0;
}

Measured memory_bytes: 128
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }
template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = st; i != ed; ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); }  // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

const int MOD = 1000000007;

int n;
vi as;

int main(){
    R(n);
    as.assign(n, 0);
    FOR(i, n) R(as[i]);

    vi cnt{-1, -1, -1};
    int ans = 1;
    FOR(i, n){
        int j = -1, c = 0;
        for(j=0; j<3; j++){
            if(cnt[j]+1 == as[i]){
                if(c == 0) cnt[j]++;
                c++;
            }
        }
        if(c == 0){
            ans = 0;
            break;
        }else{
            ans = (long long)ans * c % MOD;
        }
    }

    W(ans);

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class  Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int A =sc.nextInt();
		int B =sc.nextInt();
		if(A>12)
			System.out.println(B);
		else if(A>5)
			System.out.println(B/2);
		else
			System.out.println("0");
	}

}


Measured memory_bytes: 21844
import java.io.*;
import java.util.regex.Pattern;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Pattern pattern=Pattern.compile("the|this|that");
		String str;
		try{
			while((str=br.readLine())!=null){
				char[] ch=str.toCharArray();
				for(int j=0;!pattern.matcher(String.valueOf(ch)).find()&j<26;j++){
					for(int i=0;i<ch.length;i++){
						if('a'<=ch[i]&&ch[i]<'z'){	//a〜zでプラスしてループ
							ch[i]++;
						}else if(ch[i]=='z'){
							ch[i]='a';	//zの次はa
						}
					}
					if(pattern.matcher(String.valueOf(ch)).find()){
						break;
					}
				}
				System.out.println(ch);
			}
		}catch(Exception e){
		}
	}
}

Measured memory_bytes: 17868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int powint(int a, int x){
	int res = 1;
	REP(i,x){
		res = res *a; 
	}
	return res;
}

using namespace std;

int main(){
	int K;
	cin>>K;
	vector<int> A(K);
	REP(i,K){
		cin>>A[i];
	}
	//解の範囲の左端と右端
	long long int l=2;
	long long int r=2;
	bool dame=false;
	for(int i=K-1; i>=0; i--){
		//cout<<l<<" "<<r<<endl;
		long long int nl = -1;//新しい左端(のもと)
		long long int nr = -1;//新しい右端(のもと)
		nl = ((l+A[i]-1)/A[i])*A[i];
		nr = (r/A[i])*A[i];
		//存在しなかった場合
		if(nl>r){
			dame=true;
		}
		if(dame) break;
		l=nl;
		r=nr+A[i]-1;
	}
	if(dame){
		cout<<-1<<endl;
	} else {
		cout<<l<<" "<<r<<endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;
int perfect_number[5] = {6, 28, 496, 8128, 33550336};

void solve()
{
	int N;
	while(cin >> N, N)
	{
		bool perfect_flag = false;
		for(int i = 0; i < 5; ++i)
		{
			if(perfect_number[i] == N)
			{
				cout << "perfect number" << endl;
				perfect_flag = true;
				break;
			}
		}
		if(perfect_flag)
		{
			continue;
		}
		int sum = -N;
		for(int i = 1; i * i <= N; ++i)
		{
			if(N % i == 0)
			{
				sum += i + N / i;
				if(i == N / i)
				{
					sum -= i;
				}
			}
		}
		if(sum < N)
		{
			cout << "deficient number" << endl;
		}
		else
		{
			cout << "abundant number" << endl;
		}
	}
}

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

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

int main(){
    int n;
    long long sum=0;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(), a.end());
    cout<<a[0]<<" "<<a[n-1]<<" "<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3240
#include <cstdio>
#include <deque>
#include <algorithm>

using namespace std;

int n;
int a[222222];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a+i);
  deque<int> b;
  for (int i = 0; i < n; i++) {
    if (i%2 == 0) {
      b.push_back(a[i]);
    } else {
      b.push_front(a[i]);
    }
  }
  if (n%2 != 0) reverse(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    printf("%d%c", b[i], i == n-1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353



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

    // solution comes here

    ll N, ex=0, ans=0;
    cin >> N;
    vb rate(8, false);
    rep(i, N) {
        ll a;
        cin >> a;
        if(a<400)      rate[0] = true;
        else if(a<800) rate[1] = true;
        else if(a<1200)rate[2] = true;
        else if(a<1600)rate[3] = true;
        else if(a<2000)rate[4] = true;
        else if(a<2400)rate[5] = true;
        else if(a<2800)rate[6] = true;
        else if(a<3200)rate[7] = true;
        else ex++;
    }

    for(bool x:rate) ans += x;

    if(ans) cout << ans << " " << ans+ex << nl;
    else    cout << "1 " << ex << nl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;

LL n,mi=1e17,sa[300100],sum[300100];


int main(void)
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&sa[i]);
	if(n==2){
		cout<<abs(sa[2]-sa[1])<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+sa[i];
	for(int i=2;i<n;i++){
		if(abs(sum[n]-sum[i]-sum[i])<mi)
			mi=abs(sum[n]-sum[i]-sum[i]);
	}
	cout<<mi<<endl;
    return 0;
}




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

#define MAX 312

int n;
int m;

#define MOD 1000000007

long long int dp[MAX][MAX][MAX];  // pos, used_kind, sep_kind

int main(){
	cin>>n>>m;
	swap(n,m);
	dp[0][1][1]=1;
	for(int i=0;i<n;i++){
		for(int j=1;j<=m;j++){
			for(int k=1;k<=j;k++){
				if(dp[i][j][k]==0)continue;
				//connect
				dp[i+1][j][j]+=dp[i][j][k]*k;
				//disconnect
				dp[i+1][j][k]+=dp[i][j][k]*(j-k);
				//new
				dp[i+1][j+1][k]+=dp[i][j][k]*(m-j);
				dp[i+1][j][j]%=MOD;
				dp[i+1][j][k]%=MOD;
				dp[i+1][j+1][k]%=MOD;
			}
		}
	}
	printf("%lld\n",dp[n][m][m]);
	return 0;
}


Measured memory_bytes: 227584
def resolve():
    import bisect
    N = int(input())
    L = list(map(int,input().split()))
    L = sorted(L)
    ans = 0
    for i in range(N-1,-1,-1):
        for j in range(i-1,-1,-1):
            p = j - bisect.bisect_left(L,L[i]-L[j]+1)
            if p < 1:
                break
            ans += p
    print(ans)
resolve()

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

ll N, W;
vector<ll> w(110);
vector<ll> v(110);
vector<vector<ll>> dp(110, vector<ll>(100100, INF));


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

    cin >> N >> W;
    REP(i, N) cin >> w.at(i) >> v.at(i);

    dp.at(0).at(0) = 0;

    for (int i = 0; i < N; i++) {
        for (int sum_v = 0; sum_v < 100100; sum_v++) {
            if (v.at(i) <= sum_v) {
                chmin(dp.at(i + 1).at(sum_v), dp.at(i).at(sum_v - v.at(i)) + w.at(i));
            }
            chmin(dp.at(i + 1).at(sum_v), dp.at(i).at(sum_v));
        }
    }

    ll ans = 0;
    for (int sum_v = 0; sum_v < 100100; sum_v++) {
        if (dp.at(N).at(sum_v) <= W) ans = sum_v;
    }

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

LL x;
LL minOperations()
{
	LL ret = x / 11;
	ret *= 2;
	LL rem = x % 11;
	if(rem != 0 && rem <= 6)
		++ret;
	else if(rem != 0)
		ret += 2;
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> x;

	cout << minOperations() << endl;

	return 0;
}

Measured memory_bytes: 256
//
// Created by tac on 2016/10/12.
//

//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <iostream>

int main() {
    int h, w;
    while (true) {
        std::cin >> h >> w;
        if (h <= 0 && w <= 0) {
            break;
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (i <= 0 || h - 1 <= i || j <= 0 || w - 1 <= j ) {
                    std::cout << "#";
                } else {
                    std::cout << ".";
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return EXIT_SUCCESS;
}

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

int main()
{
  int N,A,B ;
  cin>>N>>A>>B ;
  int SUM=0 ;
  for(int i=1;i<=N;i++){
    string S=to_string(i) ;
    int sum=0 ;
    for(int i=0;i<S.size();i++) sum+=(S.at(i)-'0') ;
    if(A<=sum&&sum<=B) SUM+=i ;
  }
  cout<<SUM<<endl ;
  
  return 0 ;
}

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

int main() {
  int n;
  while(cin >> n, n) {
    vector<pair<int, int> > ps;
    for(int i = 0; i < n; ++i) {
      int m, a, b;
      cin >> m >> a >> b;
      ps.push_back(make_pair(a, m));
      ps.push_back(make_pair(b, -m));
    }
    sort(begin(ps), end(ps));
    int cweight = 0;
    bool result = true;
    for(int i = 0; i < ps.size(); ++i) {
      cweight += ps[i].second;
      if(i < ps.size() - 1 && ps[i + 1].first == ps[i].first) continue;
      if(cweight > 150) {
        result = false;
        break;
      }
    }
    cout << (result ? "OK" : "NG") << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    N=[]
    n = int(input())
    N=np.array(list(map(int,input().split())))
    Ncum=N.cumsum()
    L=Ncum[:-1]
    R=Ncum[-1]-L
    ans=np.abs(L-R).min()
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 49572
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
double a[105];
int main()
{
   double n,sum=1,sum0=0;
     cin>>n;
     for(int i=0;i<n;i++)
		cin>>a[i],sum*=a[i];
	 for(int i=0;i<n;i++)
		sum0+=sum/a[i];
		//printf("%.5lf\n",(double)sum/(double)sum0);
	 cout<<(double)sum/sum0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int T;
    cin >> T;
    rep(_,T){
        int n;
        cin >> n;
        ll ans = 0;
        priority_queue<P> que1, que2;
        rep(i,n){
            ll k, l, r;
            cin >> k >> l >> r;
            if(l >= r){
                ans += r;
                que1.push(P(k,l-r));
            }else{
                ans += l;
                que2.push(P(n-k,r-l));
            }
        }
        int m = que1.size();
        int w = que2.size();

        priority_queue<ll> que;

        drep(i,m){
            while(que1.size() > 0 && que1.top().first >= i+1){
                que.push(que1.top().second);
                que1.pop();
            }
            if(que.size()){
                ans += que.top();
                que.pop();
            }
        }

        while(!que.empty())que.pop();

        drep(i,w){
            while(que2.size() > 0 && que2.top().first >= i+1){
                que.push(que2.top().second);
                que2.pop();
            }
            if(que.size()){
                ans += que.top();
                que.pop();
            }
        }

        cout << ans << endl;
    }
    return 0;
}




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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
    {
        cin >> a[i];
        // dump(a[i]);
    }
    sort(ALL(a), greater<ll>());
    ll alice = 0, bob = 0;
    REP(i, n)
    {
        // dump(a[i]);
        if (i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
        // dump(alice);
        // dump(bob);
    }
    cout << alice - bob << endl;
    return 0;
}


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

int main() {
 int N;
cin >> N;
vector<int> vec(N);
for(int i=0; i<N; i++){
cin >> vec.at(i);
}
int sz=0;
sort(vec.begin(), vec.end(), greater<int>());
for(int i=0; i<N; i++){
if(i%2==0){
sz += vec.at(i);
}else{
sz -= vec.at(i);
}
}
cout << sz << endl;
}

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

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R - i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i, z[i]));
    return mx;
}

int main() {
    string s;
    string t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans;
    return 0;
}

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

int bfs(int H, int W, vector<vector<char>> maze) {
    int INF = 1000000;
    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, -1, 0, 1};
    
    vector<vector<int>> distance(H, vector<int>(W));
    queue <pair<int, int>> que;
    
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            distance.at(i).at(j) = INF;
        }
    }
    
    que.push(pair<int, int> (0, 0));
    distance.at(0).at(0) = 0;
    
    while (que.size() != 0) {
        pair<int, int> now = que.front();
        que.pop();
        
        if(now.first==H-1 && now.second==W-1) break;
        
        for(int i = 0; i < 4; i++) {
            int ny = now.first + dy.at(i);
            int nx = now.second + dx.at(i);
            
            if(0<=ny && ny<H && 0<=nx && nx<W && maze.at(ny).at(nx)!='#' && distance.at(ny).at(nx)==INF) {
                que.push(pair<int, int> (ny, nx));
                distance.at(ny).at(nx) = distance.at(now.first).at(now.second) + 1;
            }
        }
    }
    
    return distance.at(H-1).at(W-1);
}

int kabe_count (int H, int W, vector<vector<char>> maze) {
    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(maze.at(i).at(j)=='#') ans++;
        }
    }
    return ans;
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> maze(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        for(int j= 0; j < W; j++) {
            cin >> maze.at(i).at(j);
        }
    }
    
    if (bfs(H, W, maze) == 1000000) cout << -1 << endl;
    else cout << H*W - (bfs(H, W, maze)+1) - kabe_count(H, W, maze) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=998244353;
const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int n;
int num[N];
int q[N];
int head[N];
int cnt,tmp;
bool f;
int ans;

struct Edge{
	int to,nxt;
}ed[N];

void add_edge(int a,int b){
	ed[++cnt].to=b;
	ed[cnt].nxt=head[a];
	head[a]=cnt;
}

void dfs(int u,int p){
//	printf("%d ",u);
	if(!f) q[tmp++]=u;
	if(u==n) f=true;
	for(int i=head[u];i!=-1;i=ed[i].nxt){
		int v=ed[i].to;
		if(v!=p){
			dfs(v,u);
			num[u]+=num[v]+1;
		}
	}
	if(!f) --tmp;
	return ;
}

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	memset(head,-1,sizeof(head));
	n=read();
	for(int i=1;i<n;i++){
		int fr,to;
		fr=read();
		to=read();
		add_edge(fr,to);
		add_edge(to,fr);
	}
	tmp=1;
	dfs(1,-1);
//	for(int i=1;i<tmp;i++) printf("%d ",q[i]);
	for(int i=1;i<=tmp/2;i++) ans+=num[q[i]]-num[q[i+1]];
	if(ans>n-ans) puts("Fennec");
	else puts("Snuke");
	return 0;
}
/*
7
3 6
1 2
3 1
7 4
5 7
1 4

4
1 4
4 2
2 3
*/

Measured memory_bytes: 8064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ans = new int[N];
		for(int i = 1; i <= 100; i++)
			for(int j = 1; j <= 100; j++)
				for(int k = 1; k <= 100; k++)
					if(i*i+j*j+k*k+i*j+j*k+k*i <= N)
						ans[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
		for(int i = 0; i < N; i++)
			System.out.println(ans[i]);
	}

}


Measured memory_bytes: 39056
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<i<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
//#define P pair<int,int>
using namespace std;
const int INF=1e17+5;
const int maxn=2e5+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
multiset<int>T;
int32_t main()
{
    IOS
    cin>>n;
    fun(i)
    {
        cin>>a[i];
        T.insert(a[i]);
    }
    auto  q=(prev(T.end()));
    auto  w=(prev(q));
    int qq=*q,ww=*w;
    fun(i)
    {
        if(a[i]==qq)
        {
            out(ww)
        }else out(qq)
    }
    return 0;
}


Measured memory_bytes: 12544
#include <stdio.h>

int main(){ //1種類のみを未対処
  char c[4];
  char bin;
  scanf("AtCoder %c",&bin);
  c[0] = 'A';
  c[2] = 'C';
  c[3] = '\0';
  c[1] = bin;
  printf("%s\n",c);
  return 0;
}

Measured memory_bytes: 128
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    vec =list(map(int, input().split())) 
    vec.sort()
    if(vec[0] == 1 and vec[1] == 4 and vec[2] == 7 and vec[3] == 9):
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3944
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int t = N;
		while(t>0) {
			sum += t%10;
			t=t/10;
		}
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  cin >> N >> M;
  int X;
  X=M/N;
  int answer;
  for (int i=X;i>0;i--){
    if (M%i==0){
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		List<Integer> n=new ArrayList<Integer>();
		Scanner scan = new Scanner(System.in);
		while(true){
			int s = scan.nextInt();
			if(s==0){
				break;
			}
			else{
				n.add(s);
			}
		}
		for(int i=0;i<n.size();i++){
			System.out.println("Case " + (i+1) +": "+n.get(i));
		}
	}
		
}




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

int dp[3001][3001];

int main()
{
    string a,b;
    cin>>a>>b;
    
    memset(dp,0,sizeof(dp));
    
    for(int i=1;i<=a.size();i++)
    {
        for(int j=1;j<=b.size();j++)
        {
            if(a[i-1]==b[j-1])
            {   
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    int cnt=dp[a.size()][b.size()];
    //cout<<cnt<<endl;
    
    
    string str;
    int x=a.size();
    int y=b.size();
    
    while(x!=0 && y!=0)
    {
        if(dp[x][y-1]==cnt)
        {
            y=y-1;
        }
        else if(dp[x-1][y]==cnt)
        {
            x=x-1;
        }
        else
        {
            str.push_back(a[x-1]);
            x=x-1;
            y=y-1;
            cnt--;
        }
    }
    
    reverse(str.begin(),str.end());
    
    cout<<str<<endl;
    
    return 0;
}

Measured memory_bytes: 35456