akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

const int MAX_N = 55;

int H, W;
char S[MAX_N][MAX_N];

int used[MAX_N][MAX_N];

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

bool isInField(int x, int y)
{
  return 0 <= x && x < W && 0 <= y && y < H;
}

struct Pos{
  int x, y;
};

int solve()
{
  memset(used, -1, sizeof(used));
  used[0][0] = 0;
  queue<Pos> que;
  que.push(Pos{0, 0});

  int ret = 0;
  for(int y = 0; y < H; y++) {
    for(int x = 0; x < W; x++) {
      if(S[y][x] == '.') {
	ret++;
      }
    }
  }
  
  while(que.size()) {
    Pos pos = que.front();
    que.pop();

    if(pos.x == W-1 && pos.y == H-1) {
      return ret - used[pos.y][pos.x] - 1;
    }

    for(int d = 0; d < 4; d++) {
      int nx = pos.x + dx[d];
      int ny = pos.y + dy[d];
      if(isInField(nx, ny)) {
	if(used[ny][nx] == -1 && S[ny][nx] != '#') {
	  que.push(Pos{nx, ny});
	  used[ny][nx] = used[pos.y][pos.x] + 1;
	}
      }
    }
  }

  return -1;
}

int main()
{
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 256
/*786*/
#include<bits/stdc++.h>
#define        ll          long long int
#define        sj          200010
#define        fast        ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        sc1(a)      scanf("%lld",&a)
#define        sc2(a,b)    scanf("%lld %lld",&a,&b)
#define        pb          push_back
#define        pn          printf("No\n")
#define        py          printf("Yes\n")
#define        op(a)       printf("%lld\n",a)

using namespace std;

/*
0  1  2  3  4  5 6  7  8  9  () & *  !  #  Z  z  %
*/

map<ll,ll>mp;

ll tani(ll x)
{
    ll i,j,s,d;
    d=0;
    ll c=0;

    for(i=1;i<=x;i++)
    {
        if(d+i<=x)
        {
            c++;
            d+=i;
        }
        else
            break;
    }

    return c;
}
ll solve(ll n)
{

    ll p,c,i,j,k,d,x;
    p=0;

    while(n%2==0)
    {
        p++;
        n/=2;
    }
    mp[2]=p;

    for(i=3;i<=sqrt(n);i++)
    {
        p=0;
        while(n%i==0)
        {
            p++;
            n/=i;
        }
        mp[i]=p;
    }

    if(n>2)mp[n]=1;


    map<ll,ll>::iterator it;

    c=0;


    for(it=mp.begin();it!=mp.end();it++)
    {
        ll b=it->second;
        if(b!=0)
        {
            c+=tani(b);
        }
    }


    return c;

}

int main()
{


     ll n;

     cin>>n;

     ll d=solve(n);

     cout<<d<<endl;

    return 0;
}





Measured memory_bytes: 66160
#include <stdio.h>

int N, K, A[100];
int dp[100001];

int main() {
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 1; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            if (i - A[j] >= 0) {
                dp[i] |= !dp[i - A[j]];
            }
        }
    }
    puts(dp[K] ? "First" : "Second");
    return 0;
}



Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (isPrime(sc.nextInt())) {
                count++;
            }
        }
        System.out.println(count);
    }
    
    static boolean isPrime(int x) {
        for (int i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}


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

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll X, K, D;
  cin >> X >> K >> D;
  
  X = abs(X);
  if (X/D >= K){
    cout << X - K * D << endl;
    return 0;
  }
  ll cnt = X/D;//最短回数
  K -= cnt;
  X %= D;
  if (K%2 == 0)
    cout << X << endl;
  else
    cout << abs(X - D) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    if(A+B > C+D) cout << "Left" << endl;
    else if(A+B ==C+D) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    for(int i=1;;i++){
        int x;
        cin>>x;
        if(x==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
//============================================================================
// Name        : abc116c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> H(N);

	cin >> H[0];
	for(int i = 1; i < N; ++i){
		int h;
		static int preH = H[0];
		cin >> h;
		H[i] = h - preH;
		preH = h;
	}

	int h = 0;
	int maxh = 0;
	int minh = 101;
	int count = 0;
	for(int i = 0; i < N; ++i){
		if(0 < H[i])count += H[i];
	}
	cout << count << endl;

	return 0;
}


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

int main() {
    int N,i;
    cin >> N;
    cout << fixed << setprecision(7);
    vector<double> vec(N);
    for (i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    double sum = 0;
    for (i = 0; i < N; i++){
        sum = sum + 1/vec.at(i);
    }
    double ans = 1/sum;
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,j,k) for(ll i=j;i<k;i++)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

vi prime,faktor;
int n,sz;
bool vis[2000];

ll power(ll x,ll y)
{
	ll ans = 1LL;
	rep(i,0,y) {ans*=x;}
	return ans;
}

int main()
{
	for(int i=2;i<1010;i++) vis[i] = true;
	for(int i=2;i<1010;i++)
		for(int j=2;j<=1010/i;j++)
			vis[i*j] = false;
	for(int i=2;i<1010;i++)
		if(vis[i]) prime.pb(i);
	int sz = prime.size();
	cin >> n;
	ll ans = 1;
	for(int i=0;i<sz;i++)
	{
		int hit = 0, pembagi = prime[i];
		while(pembagi<=n) {hit+=n/pembagi; pembagi*=prime[i];}
		ans*=(hit+1);
		ans%=1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    bool frag1=false,frag2=false;
    string S; cin >> S;
    rep(i,SZ(S)){
        if(S[i]=='C') frag1=true;
        if(S[i]=='F' && frag1) frag2=true; 
    }
    if(frag1&&frag2) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 256
n=gets.to_i
values=gets.chomp.split.map(&:to_i)
costs=gets.chomp.split.map(&:to_i)
maxs = []
values.each_with_index do |val, idx|
  profit=val-costs[idx]
  maxs<<profit if profit>=1
end

ans = maxs.inject(:+)
if ans.nil?
  puts 0
else
  puts ans
end

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

 using namespace std;
 int main() {
   int D, i;
   cin >> D;
   cout << "Christmas";
   if (D == 25) cout << endl;
   else {
     for (i = 1; i <= 25 - D; i++) {
       cout << " Eve";
     }
   }
   cout << endl;
 }


Measured memory_bytes: 256
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math
#from math import gcd

N = int(input())
ans = 0
for i in range(1,N+1):
    if(i % 3 != 0 and i % 5 != 0):
        ans += i

print(ans)

Measured memory_bytes: 9928
/*input
3 4
1 3 100
1 1 -10
2 2 -20
3 3 -30
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
 ll MOD=1e9+7;
const ld PI=2*acos(0);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
int add(int a,int b){
    return (a+b)%MOD;
}
int mult(int a,int b){
    return (ll)a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}

// default code end
const int N = 2e5 + 9;
const ll oo = 1e18;
ll t[N<<2];
ll pushing[N<<2];
struct SegmentTree {

    SegmentTree() {
        fill(t, t + (N << 2), 0);
        fill(pushing, pushing + (N << 2), 0);
    }

    void push(int v) {
        pushing[v << 1] += pushing[v];
        t[v << 1] += pushing[v];
        pushing[v << 1 | 1] += pushing[v];
        t[v << 1 | 1] += pushing[v];
        pushing[v] = 0;
    }

    void upd(int v, int tl, int tr, int l, int r, ll inc) {
        if (l > r) return;
        if (tl == l && tr == r) {
            t[v] += inc;
            pushing[v] += inc;
            return;
        }
        push(v);
        int tm = tl + tr >> 1;
        upd(v << 1, tl, tm, l, min(tm, r), inc);
        upd(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r, inc);
        t[v] = max(t[v << 1], t[v << 1 | 1]);
    }

    ll get(int v, int tl, int tr, int l, int r) {
        if (l > r) return -oo;
        if (tl == l && tr == r) {
            return t[v];
        }
        push(v);
        int tm = tl + tr >> 1;

        return max(
                get(v << 1, tl, tm, l, min(tm, r)),
             get(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r)
        );
    }
};

int n, m;

int lf[N], rf[N];
ll a[N];
ll dp[N];

vector<int> st[N], fin[N];

int main(){
    cin >> n >> m;
    REP (i, m) {
        cin >> lf[i] >> rf[i] >> a[i];
        st[lf[i]].push_back(i);
        fin[rf[i]].push_back(i);
    }
    SegmentTree tree;
    for (int i = 1; i <= n; ++i) {
        for (auto ind : st[i]) {
            tree.upd(1, 0, n, 0, i - 1, a[ind]);
        }
        dp[i] = tree.get(1, 0, n, 0, i - 1);
        tree.upd(1, 0, n, i, i, dp[i]);
        for (auto ind : fin[i]) {
            tree.upd(1, 0, n, 0, lf[ind] - 1, -a[ind]);
        }
    }
    cout << *max_element(dp,dp+n+1);
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	map<string, int> m;
	int maior = 0;
	while(n--){
		cin>>s;
		m[s]++;
		if(m[s] > maior)
			maior = m[s];
	}
	set<string> s1;
	for(auto it: m){
		if(it.second == maior){
			s1.insert(it.first);
		}
	}
	for(auto it: s1){
		cout<<it<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 34888
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
const ll MOD = 1e9 + 7;
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define vll vector<vector<ll> >
#define ins insert
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main(){
	speed
	ll ar[3][3];
	bool fou[3][3]={0};
	for( ll i = 0; i < 3; i++ ){
		for( ll j = 0; j < 3; j++ ){cin >> ar[i][j]; }
	}
	ll n;
	cin >> n;
	ll a[10];
	for( ll i = 0; i < n; i++ ){
	cin >> a[i];	
	}
	for( ll i=0;i<n;i++){
	for( ll j = 0; j < n; j++ ){
		for( ll k = 0; k < n; k++){
			if(ar[i][j]==a[k])fou[i][j]=true;
			}
		}
	}
	s ans="No";
	for( ll i = 0; i < 3; i++ ){
	if(fou[i][0]&&fou[i][1]&&fou[i][2])ans="Yes";	
	}
	for( ll i = 0; i < 3; i++ ){
	if(fou[0][i]&&fou[1][i]&&fou[2][i])ans="Yes";	
	}
	if(fou[0][0]&&fou[1][1]&&fou[2][2])ans="Yes";	
	
	if(fou[0][2]&&fou[1][1]&&fou[2][0])ans="Yes";	
	
	cout << ans << endl;
	
	
	
	
	
	
	
	
	






return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
    Arrays.sort(a);
    int[] b = {5,5,7};
    if(Arrays.toString(a).equals(Arrays.toString(b))){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	long long int a,b,n;
	cin>>a>>b>>n;

	int ans = 0;
	int i;

	if(n >= b){
		ans = (a*(b-1))/b;
	}

	else{
		ans = (a*n)/b;
		ans -= a * (n/b);
	}

	// for(i=1;i<=n;i++){
	// 	long long int temp = (a*i)/b;
	// 	temp -= a * (i/b);
	// 	if(temp>ans){
	// 		ans = temp;
	// 	}
	// 	if(temp < ans)
	// 	break;
	// }
	// cout<<i<<endl;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  int h, w;
  cin >> h >> w;

  vector<bool> rows(h, false), cols(w, false);

  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char s;
      cin >> s;

      if (s == '#') {
        rows.at(i) = true;
        cols.at(j) = true;
      }

      a.at(i).at(j) = s;
    }
  }

  for (int i = 0; i < h; i++) {
    if (!rows.at(i)) continue;

    for (int j = 0; j < w; j++) {
      if (!cols.at(j)) continue;

      cout << a.at(i).at(j);
    }

    cout << endl;
  }

  return 0;
}

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

bool num[15];

bool check(int x)
{
	while (x)
	{
		int t = x % 10;
		if (num[t]) return 0;
		x /= 10;
	}
	return 1;
}

int main()
{
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 1, t; i <= k; i++)
	{
		cin >> t;
		num[t] = 1;
	}
	for (int i = n; ; i++)
	{
		if (check(i))
		{
			cout << i << endl;
			break; 
		} 
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 
import bisect as bs

def resolve():
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    ans = 0
    for t in T:
        i = bs.bisect_left(S, t)
        if i<len(S) and t==S[i]:
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 16736
unittest
{
	assert( [ "12 4" ].parse.expand.solve == 4 );
	assert( [ "20 15" ].parse.expand.solve == 0 );
	assert( [ "20 30" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return max( 0, a - b * 2 );
}


Measured memory_bytes: 256
N, K = map(int, input().split())
if N == K:
    print(0)
else:
    N = N % K
    a, b, c = N, abs(N - K), abs(abs(N - K) - K)
    while not (a == b or a == c or b == c):
        a, b, c = b, c, abs(c - K)
    print(min(a, b, c))

Measured memory_bytes: 3060
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int ret = 0;
	
	string S;

	while (cin >> S)
	{
		int sum = 0;

		for (int i = 0; i < S.size(); i++)
		{
			if (!isdigit(S[i]))
			{
				ret += sum; sum = 0;
			}
			else
			{
				sum *= 10; sum += S[i] - 48;
			}
		}

		ret += sum;
	}

	cout << ret << endl;

	return 0;
}

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

using namespace std;

int main(void){
   
   int s;
   cin >> s;
   
   set<int> st;
   
   int count = 1;
   
   while(true){
       
       if (st.count(s)){
           cout << count << endl;
           return 0;
       }
       
       st.insert(s);
       
       if (s % 2 == 0){
           s /= 2;
       }else{
           s = 3*s + 1;
       }
       
       count ++;
   }
}


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

int main(){

	char a,b;

	cin >> a >> b;

	if (a > b)
	{
		cout << ">";
	}
	else if (a == b)
	{
		cout << "=";
	}
	else{
		cout << "<";
	}

	return 0;
}

Measured memory_bytes: 256
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			std::cout << *p << ' ';
		}
		std::cout << std::endl;
	}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;


int alist[100005];

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i,n){
		int tmp;
		cin >> tmp;
		alist[tmp]++;
		ans+=tmp;
	}
	vll anslist;
	int q;
	cin >> q;
	rep(i,q){
		int b,c;
		cin >> b >> c;
		alist[c] += alist[b];
		ans+=alist[b]*(c-b);
		alist[b] = 0;
		anslist.push_back(ans);
	}

	for(ll x : anslist){
		prints(x);
	}




	return 0;
}




Measured memory_bytes: 4704
s = [_ for _ in input()]
n = len(s)

s0 = s[0:round((n-1)/2)]
s1 = s[round((n+3)/2-1):n]


def kaibun(ss):
    if ss[::-1] == ss:
        return True
    return False

if kaibun(s) and kaibun(s0) and kaibun(s1):
    print('Yes')
    exit(0)
print('No')



Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
#define M -1
using namespace std;
int dp[101][10001];
int value[101],weight[101];
int main(void)
{
	int n,w,i,j;
	cin>>n>>w;
	for(i=0;i<n;i++) cin>>value[i]>>weight[i];
	for(i=0;i<n;i++) {
		for(j=0;j<=w;j++) dp[i][j]=M;
	}
	dp[0][0]=0;
	for(i=0;i<n;i++) {
		for(j=0;j<=w;j++) {
			if(dp[i][j]!=M) {
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(j+weight[i]<=w) {
					dp[i+1][j+weight[i]]=max(dp[i][j]+value[i],dp[i+1][j+weight[i]]);
				}
			}
		}
	}
	int mx=-1;
	for(i=0;i<=w;i++) if(mx<dp[n][i]) mx=dp[n][i];
	cout << mx << endl;
	exit(0);
}

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

const int mod = 1000000007;

int main(){
    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        a--;
    }else{
        b--;
    }
    cout<<a<<endl;
    cout<<b<<endl;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[n];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(line[0]) - 1;
            var d = int.Parse(line[1]) - 1;
            a[c]++;
            a[d]--;
        }
        var z = 0;
        if (a[0] == 0) z = 1;
        for (int i = 1; i < n; i++)
        {
            a[i] += a[i - 1];
            if (a[i] == 0) z++;
        }
        var res = z + (n - z) * 3 + 1;
        Console.WriteLine(res);
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) { return a.first < b.first; }

void sort2vectors(
	vector<ll> &av,
	vector<ll> &bv) { // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
  ll n = av.size();
  vector<pair_t> p(n);
  vector<ll> av2(n), bv2(n);
  for (ll i = 0; i < n; i++)
	p[i] = make_pair(av[i], bv[i]);
  sort(p.begin(), p.end(), comp);
  for (ll i = 0; i < n; i++) {
	av2[i] = p[i].first;
	bv2[i] = p[i].second;
  }
  av = av2;
  bv = bv2;
}
/****** define variable start ******/
ll n, m;
vl a, b;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	a.resize(n);
	b.resize(n);
	REP(i, n){
		cin >> a[i] >> b[i];
	}
	sort2vectors(a, b);
	ll ans = 0;
	priority_queue<ll> queue;
	ll ite = 0;
	for(ll i = 1; i <= m; i++){
		for(ll j = ite; j < n; j++){
			if(a[j] <= i){
				ite = j+1;
				queue.push(b[j]);
			}else{
				ite = j;
				break;
			}
		}
		if(!queue.empty()){
			ans += queue.top();
			queue.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll D,T,S;
    cin>>D>>T>>S;
    YN(D <= S*T);
    return 0;
}

Measured memory_bytes: 3620
import heapq
N = int(input())
A = [int(_) for _ in input().split()]

X = A[0:N]
B = A[N:2*N]
Y = [-_ for _ in A[2*N:3*N]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(N):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(N):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[-1 - _] for _ in range(N+1)]))

Measured memory_bytes: 37212
#!ruby -pl
l=$_.split(?,).map &:to_i
v=l.zip(l.rotate 2).map{|a,b|b-a}.each_slice(2).to_a
z=v.zip(v.rotate).map{|(a,b),(c,d)|a*d-b*c}
$_=z.all?{|i|i>0}|z.all?{|i|i<0}?:YES: :NO

Measured memory_bytes: 6116
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X = int(read())

for a in range(-118, 120):
    for b in range(-119, 119):
        if pow(a, 5) - pow(b, 5) == X:
            print(a, b)
            sys.exit()


Measured memory_bytes: 27148
#include <stdio.h>
int main(void)
{
  int s,m,h; //area:面積 circumference:周囲
  scanf("%d",&s); //キーボード入力
  if(0<=s&&s<=86400)
  {
    m=s/60; //除算 (割算)
    s=s%60; //剰余 (余り)
    h=m/60;
    m=m%60;
    printf("%d:%d:%d\n", h,m,s);
  }
  else
  {
    printf("再度、条件を満たす入力をしてください。\n");
  }
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    string a,b,c;
    cin >> a >> b >> c;
    a[0]-=32;
    b[0]-=32;
    c[0]-=32;
    cout << a[0] << b[0] << c[0] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
string S = "753";

bool isOk(string s)
{
  return s.find("7") != string::npos && s.find("5") != string::npos && s.find("3") != string::npos;
}

int dfs(int depth, int cnt, string s, string N)
{
  if (depth == 0)
  {
    if (stoi(s) > stoi(N))
      return cnt;
    if (isOk(s))
    {
      // cout << s << endl;
      cnt++;
    }
    return cnt;
  }

  rep(i, 3)
  {
    string tmp = s + S[i];
    cnt = dfs(depth - 1, cnt, tmp, N);
  }

  return cnt;
}

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

  int ans = 0;
  string s = "";

  repd(i, 3, N.size() + 1)
  {
    ans += dfs(i, 0, s, N);
  }

  cout << ans;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,a[10000007];
int main()
{
    sfl(n);
    ll  z = n + n*n + n*n*n;
    pf("%lld\n",z);
}


Measured memory_bytes: 3816
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;


#define MAXN 200500

ll  t[MAXN*4];
int a[MAXN];
ll  f[MAXN];
int h[MAXN];
vi  hh;
map<int, int> m;
int n;

void add(int v, int l, int r, int x, ll value) {
    if (x < l || r < x) return;
    t[v] = max(t[v], value);
    if (l == r) return;

    int m = (l + r) / 2;
    add(v*2, l, m, x, value);
    add(v*2 + 1, m + 1, r, x, value);
}

ll  get(int v, int l, int r, int L, int R) {
    if (R < l || r < L) return 0;
    if (L <= l && r <= R) return t[v];

    int m = (l + r) / 2;
    return max(get(v*2, l, m, L, R), get(v*2 + 1, m + 1, r, L, R));
}

int main() {
    scanf("%i", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%i", &h[i]);
        hh.pb(h[i]);
    }
    sort(hh.begin(), hh.end());
    for(int i = 0; i < hh.size(); ++i) m[ hh[i] ] = i;

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

    for(int i = 0; i < n; ++i) {
        f[i] = a[i];
        if (h[i]) f[i] += get(1, 0, n, 0, h[i] - 1);
        add(1, 0, n, h[i], f[i]);

        //printf("%i:  h=%i a=%i  f=%lld\n", i, h[i], a[i], f[i]);
    }

    printf("%lld\n", get(1, 0, n, 0, n));
    return 0;
}

Measured memory_bytes: 18548
S = list(input())
i = 0
while True:
    if i >= len(S):
        break
    if S[i] != "C" and S[i] != "F":
        del S[i]
        i -= 1
    i += 1
    
ans = -1
for i in range(1, len(S)):
    if S[i - 1] == "C" and S[i] == "F":
        print("Yes")
        ans = 1
        break
if ans == -1:
    print("No")


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

using namespace std;

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

    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    
    if (a + b + c + d == 7) {
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    } else if (a + b + c - d == 7) {
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    } else if (a + b - c + d == 7) {
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    } else if (a + b - c - d == 7) {
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    } else if (a - b + c + d == 7) {
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    } else if (a - b + c - d == 7) {
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    } else if (a - b - c + d == 7) {
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    } else if (a - b - c - d == 7) {
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  double a, b, x;
  cin >> a >> b >> x;

  double s = x / a;
  if(s == a*b){
    cout << 0 << endl;
    return 0;
  }

  double c = 0, ans = 0;
  if(s > a*b/2){
    double u = 2*s/a - b;
    s -= a*u;
    b -= u;
    c = 2*s/b;
  }else{
    c = 2*s/b;
  }

  double r = atan(b/c);
  ans = r * (180/PI);

  printf("%.16f\n", ans);
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int h,n,i,o=0,temp;
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> temp;
    o=o+temp;
  }
  if(o>=h){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

using pil = pair<int, ll>;
using pli = pair<ll, int>;
const int maxn = 300005;
int n = maxn;
vector<vector<pil> > G(maxn); // 行き先と cost

vector<ll> dijkstra(int s) {
  vector<ll> d(maxn, INF);
  //頂点、最短距離、小さい順に
  priority_queue<pli, vector<pli>, greater<pli> > q;

  d[s] = 0;
  q.push(pli(0, s));

  while (!q.empty()) {
    pli p = q.top();
    q.pop();
    int v = p.S;
    if (d[v] < p.F) continue;
    for (pil np : G[v]) {
      int nv = np.F;
      ll cost = np.S;
      if (chmin(d[nv], d[v] + cost)) {
        q.push(pli(d[nv], nv));
      }
    }
  }

  return d;
}

void solve() {
  int m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[3 * a].eb(3 * b + 1, 1);
    G[3 * a + 1].eb(3 * b + 2, 1);
    G[3 * a + 2].eb(3 * b, 1);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;

  auto d = dijkstra(3 * s);
  cout << (d[3 * t] == INF ? -1 : d[3 * t] / 3) << endl;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a, b, c, i, j;
    cin >> a >> b >> c;
    if(a==b)
    {
        cout << c;
    }
    else if(b==c)
    {
        cout << a;
    }
    else
    {
        cout << b;
    }
    return 0;
}


Measured memory_bytes: 256
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

a,b=input2()
count=1
if b<=1:
	print(0)
else:
	for i in range(1,21):
		count=count-1+a
		if count>=b:
			print(i)
			break

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int MOD = 1e9 + 7; 
const int N = 1e5+10;
int main(void) 
{
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif


	int h, a; 
	scanf("%d %d", &h, &a); 
	int sum =0; 
	for (int i=1; i<=a; i++) 
	{
		int x; 
		scanf("%d", &x); 
		sum += x; 
	}
	if (sum >= h) printf("Yes\n");  
	else printf("No\n");  


	return false;   


}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, dp[N];
vector < int > g[N];

inline bool cmp(int i, int j) {
	return dp[i] < dp[j];
}

void dfs(int v, int pr = -1) {
	vector < int > gn;
	for (auto to : g[v]) {
		if (to != pr) {
			dfs(to, v);
			gn.pb(to);
		}
	}
	sort(all(gn), &cmp);
	int prv = -1;
	for (auto to : gn) {
		dp[to] = max(dp[to], prv + 1);
		prv = dp[to];
	}
	dp[v] = prv + 1;
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 2; i <= n; i++) {
		int x;
		cin >> x;
		g[i].pb(x);
		g[x].pb(i);
	}

	dfs(1);

	cout << dp[1];
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

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

int main() {
  int K;
  cin >> K;
  int sum = 0;
  int l[201][201];
  for(int b = 1; b <= K; b++) {
      for(int c = 1; c <= K; c++) {
        l[b][c] = gcd(b, c);
      }
  }
  for(int a = 1; a <= K; a++) {
    int g;
    for(int b = 1; b <= K; b++) {
      for(int c = 1; c <= K; c++) {
        sum += l[a][l[b][c]];
      }
    }
  }
  cout << sum << endl;
  return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n;
  cin >> n;
  vector<int> A(n + 1);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << A[i] << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    string S;
    cin >> S;
    ll res=0;
    char cur = '<';char nex = '>';
    ll temp_c = 0;ll temp_n=0;
    rep(i,0,S.size()){
        if(S[i]==cur){
            if(temp_n>0){
                ll maxi = max(temp_n,temp_c);
                ll mini = min(temp_n,temp_c);
                res+=(maxi+1)*maxi/2+(mini-1)*mini/2;
                temp_n=0;temp_c=0;
            }
            temp_c++;
            continue;
        }else{
            temp_n++;
            continue;
        }
    }
    if(temp_n>0 || temp_c>0){
        ll maxi = max(temp_n,temp_c);
        ll mini = min(temp_n,temp_c);
        res+=(maxi+1)*maxi/2+(mini-1)*mini/2;
    }
    COUT(res);
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll d1[300][300];
ll d2[300][300];

int main(){
	int n,m,l;cin>>n>>m>>l;
	memset(d1,0x3f,sizeof(d1));
	rep(i,n)d1[i][i]=0;
	rep(i,m){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		d1[a][b]=d1[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)d1[i][j]=min(d1[i][j],d1[i][k]+d1[k][j]);
	memset(d2,0x3f,sizeof(d2));
	rep(i,n)d2[i][i]=0;
	rep(i,n)rep(j,n){
		if(d1[i][j]<=l)d2[i][j]=1;
	}
	rep(k,n)rep(i,n)rep(j,n)d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
	int q;cin>>q;
	rep(i,q){
		int s,t;scanf("%d%d",&s,&t);s--;t--;
		if(d2[s][t]==INFL)puts("-1");
		else printf("%lld\n",d2[s][t]-1);
	}
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
long long mod=1000000007;
long long func(long long x,long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=func(x,n/2);
    return (t*t)%mod;
  }
  else{
    long long y=func(x,n-1);
    return (x*y)%mod;
  }
}

int main() {
  long long n,a,b;
  cin>>n>>a>>b;
  long long ans=func(2,n)-1;
  long long xa=1;
  long long ya=1;
  long long n1=n;
  long long a1=1;
  for(int i=0;i<a;i++){
    xa*=n1;
    ya*=a1;
    xa%=mod;
    ya%=mod;
    n1--;
    a1++;
  }
  long long xb=1;
  long long yb=1;
  long long n2=n;
  long long a2=1;
  for(int i=0;i<b;i++){
    xb*=n2;
    yb*=a2;
    xb%=mod;
    yb%=mod;
    n2--;
    a2++;
  }
  long long aaa=func(ya,mod-2);
  long long bbb=func(yb,mod-2);
  aaa*=xa;
  aaa%=mod;
  bbb*=xb;
  bbb%=mod;
  ans-=aaa;
  ans-=bbb;
  if(ans>=0) ans%=mod;
  else{
    ans=mod-abs(ans)%mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3488