akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
ans = 0

if N == 1:
    ans = A1[0] + A2[0]
else:
    for i in range(N-1):
        if i == N:
            ans = max(ans, sum(A1)+A2[-1])
        else:
            ans = max(ans, sum(A1[:i+1])+sum(A2[i:]))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int x, n;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return;
  }
  map<int, bool> mp;
  REP(i, n) {
    int p;
    cin >> p;
    mp[p] = true;
  }
  int idx = 1;
  if (!mp.count(x)) {
    cout << x << endl;
    return;
  }
  while (1) {
    bool right = mp[x + idx];
    bool left = mp[x - idx];
    if (right && left) {
      idx++;
      continue;
    } else if (!right && !left) {
      cout << x - idx << endl;
      return;
    } else if (!right) {
      cout << x + idx << endl;
      return;
    } else {
      cout << x - idx << endl;
      return;
    }
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  ld N,M;in(N,M);
  vector<ll>A(N);ins(A);
  ll sum=accumulate(all(A),0);
  ll cnt=0;
  rep(i,N)if(A[i]>=sum/(4*M))cnt++;
  out(cnt>=M?"Yes":"No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
def main():
  N = int(input())
  count = 0
  a = [int(x) for x in input().split()]
  while all([x % 2 == 0 for x in a]):
    a = list(map(lambda x: x // 2, a))
    count += 1
  print(count)


if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
X = int(input())

ts = [False for x in range(X+1)]
ts[1] = True

for i in range(2,int(X ** 0.5) + 1):
    k = 2
    while i ** k <= X:
        ts[i**k] = True
        k += 1

for i in range(X,-1,-1):
    if ts[i]:
        print(i)
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int n,x,y;cin>>n>>x>>y;
 
  vector<int> ve(n-1,0);
  rep(i,n){
    Rep(j,i+1,n){
      int k=j-i;
      int a=0,b=0;
      if(i>x-1){
        a=i-x+1;
      }
      if(i<=x-1){
        a=x-1-i;
      }
      if(j>y-1){
        b=j-y+1;
      }
      if(j<=y-1){
        b=y-1-j;
      }
      k=min(a+b+1,k);
      ve[k-1]++;
    }
  }
  
  rep(i,n-1){
    cout<<ve[i]<<endl;
  }
      
    
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int, readline().split())
A = np.int32(read().split())

A -= 1

def mult(A,B):
    return B[A]

def power(A,n):
    if not n:
        return np.arange(N)
    B = power(A,n//2)
    B = mult(B,B)
    return mult(A,B) if n & 1 else B

print(power(A, K)[0] + 1)

Measured memory_bytes: 39460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
ll a[maxn];
int main() {
	int n;
	cin >> n;
	ll sum1 = 0, sum2 = 0, p = 0;
	long long x = 0;
	srand(time(0));
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		p += a[i];
		x += p / n;
		p %= n;
		sum1 += a[i]; sum2 += a[i] * a[i];
	}
	if (2 * p < n) {
		cout << sum2 - 2 * sum1 * x + n * x * x << endl;
	} else {
		x++;
		cout << sum2 - 2 * sum1 * x + n * x * x << endl;
	}
	return 0;
}

//2 * n * x1 + n  2 * (n * x + tmp)
// 2 * n * x + n  2 * (n * x + tmp)
//n   2 * p


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int K, N;
    cin >> K >> N;
    vi a(N);
    REP(i, N) cin >> a[i];

    sort(ALL(a));

    int max_d = K-a[N-1] + a[0];
    REP(i, N-1) {
        max_d = max(max_d, a[i+1]-a[i]);
    }

    cout << K-max_d << endl;

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for( int i=0; i<H+2; i++ ){
    cout << "#";
    for( int j=0; j<W; j++ ){
      if( (i == 0) || (i == (H + 1)) ){
        cout << "#";
      }
      else{
        char a;
        cin >> a;
        cout << a;
      }
    }
    cout << "#" << endl;
  }
}

Measured memory_bytes: 3568
#include <iostream>

int main(void) {
    int N, K;
    char *S;
    std::cin >> N;
    S = new char[N+1];

    std::cin >> S >> K;

    for(int i=0; i<N; i++) {
        if(S[i] != S[K-1]) S[i] = '*';
    }

    std::cout << S << "\n";
    return 0;
}


Measured memory_bytes: 256
import itertools

n,m = map(int, input().split())

s= []
#s.append([0])

for i in range(m):
	ss = list(map(int, input().split()))
	temp_ss = []
	for i in range(1, len(ss)):
		temp_ss.append(ss[i]-1)
	s.append(temp_ss)
p = list(map(int, input().split()))

ans = 0

#print(s)
#print(p)
#print(list(combi))

for c in itertools.product([0,1], repeat=n):
	#print(c)
	is_ans = True
	for i in range(len(s)):
		if(sum([c[a] for a in s[i]])) % 2 != p[i]:
			is_ans = False
			break

	if(is_ans):
		ans += 1
print(ans)

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

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//c

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";
	
	int ans=0;


	int n;
	cin >> n;
	
	vector<int> a(n);
	
	rep(i,n) cin >> a[i];
	
	int memo=0;
	
	rep(i,n-1){
		if(a[i]>=a[i+1]) {
			memo++;
		}
		
		else {
			ans=max(ans,memo);
			memo=0;
		}
		if(i==n-2) ans=max(memo,ans);
	}
	
	
	
	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 640
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

// PfsMap : 素因数分解し、マップを作成
func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

func initPrime() {

}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	T := make([]int, N)
	for i := 0; i < N; i++ {
		T[i] = getInt()
	}

	l := T[0]
	for i := 1; i < N; i++ {
		l = LCM(l, T[i])
	}
	out(l)
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
	}
	sort.Ints(ps)

	ans := 0
	for i := 0; i < k; i++ {
		ans += ps[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for(int i=0; i<s.size(); i++){
    cnt++;
    if(s[i]==s[i-1]){
      cnt--;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		long ans = 0;
		for(int i = 0 ; i < n - 1 ; i++) {
			if(a[i + 1] - a[i] <= t) ans += a[i + 1] - a[i];
			else ans += t;
		}
		ans += t;
		System.out.println(ans);
	}
}

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

int main(){
  int W,a,b;
  cin >> W >> a >> b;
  
  if(a>b){
    if(b+W<a){
      cout<<a-b-W<<endl;
      return 0;
    }
    cout<<0<<endl;
    return 0;
  }
  if(b>a){
    if(a+W<b){
      cout<<b-a-W<<endl;
      return 0;
    }
    cout<<0<<endl;
    return 0;
  }
  cout<<0<<endl;
  return 0;
}

    
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	bool first = true;
	while (true)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
			break;

		if (first)
			first = false;
		else
			printf("\n");

		bool notFound = true;
		for (int i = a; i <= b; ++i)
		{
			if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0))
			{
				printf("%d\n", i);
				notFound = false;
			}
		}
		if (notFound)
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	int N, K;
	double sumipe = 0;
	int i;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		int tomatu = i;
		double ainama = 1;
		while (tomatu < K) {
			tomatu *= 2;
			ainama /= 2;
		}
		sumipe += ainama;
	}
	printf("%.30f\n", sumipe / N);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    string S; cin >> S;
    ll count = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    
    unsigned long n=0;
    int ac=0,wa=0,tle=0,re=0;
    char s[3];

    scanf("%lu",&n);

    for(int i=0;i<n;i++){
        scanf("%s",s);
        if(s[0]=='A' && s[1]=='C'){
            ac++;
        }
        if(s[0]=='W' && s[1]=='A'){
            wa++;
        }
        if(s[0]=='T' && s[1]=='L' && s[2]=='E'){
            tle++;
        }
        if(s[0]=='R' && s[1]=='E'){
            re++;
        }
        for(int i=0;i<3;i++){
            s[i]='\0';
        }
    }

    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);

    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

string s, t, u;
llint dp[55][3];

int main(void)
{
	while(1){
		cin >> s;
		if(s == "0") break;
		cin >> t >> u;
		llint n = s.size();
		
		reverse(s.begin(), s.end());
		reverse(t.begin(), t.end());
		reverse(u.begin(), u.end());
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j < 3; j++){
				dp[i][j] = 0;
			}
		}
		dp[0][0] = 1;
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 10; j++){
				if(s[i] != '?' && s[i]-'0' != j) continue;
				if(i == n-1 && j == 0) continue;
				for(int k = 0; k < 10; k++){
					if(t[i] != '?' && t[i]-'0' != k) continue;
					if(i == n-1 && k == 0) continue;
					for(int l = 0; l < 10; l++){
						if(u[i] != '?' && u[i]-'0' != l) continue;
						if(i == n-1 && l == 0) continue;
						for(int m = 0; m < 3; m++){
							llint c = (j+k+m)/10, d = (j+k+m)%10;
							if(d != l) continue;
							(dp[i+1][c] += dp[i][m]) %= mod;
						}
					}
				}
			}
		}
		
		/*for(int i = 0; i <= n; i++){
			for(int j = 0; j < 3; j++){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		cout << dp[n][0] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3040
let is_d x i = x mod i = 0;;

let rec f c i mx ans =
	if i > mx then
			ans
	else
			if is_d c i then f c (i+1) mx (ans+1) else f c (i+1) mx ans;;

Scanf.sscanf(read_line()) "%d %d %d" (fun a b c -> Printf.printf "%d\n" (f c a b 0));;




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

 int x[10000];
 int i,n;

 i=0;
 while(1){
  scanf("%d", &x[i]);
  if(x[i] == 0){
   break;
  }

  i++;
 }

 n=i;
 
 for(i=0;i<n;i++){
  printf("Case %d: %d\n",i+1,x[i]);
 }

 return 0;
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    int a,b,c,d,f;
    cin>>a>>b>>c>>d>>f;
    int ar[10];
    ar[a]=1;
    ar[b]=2;
    ar[c]=3;
    ar[d]=4;
    ar[f]=5;
    cout<<ar[0]<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}



int main(){
  ll n, m, x;
  cin>>n>>m>>x;
  vector<ll> c(n);
  vector<vector<ll>> a(n, vector<ll>(m));
  rep(i,n) {
    cin>>c[i];
    rep(j,m) {
      cin>>a[i][j];
    }
  }
  ll ans = 1001001001;
  for(ll i=0; i<(1<<n); i++) {
    ll tmp = 0;
    vector<ll> v(m,0);
    rep(j,n) {
      if(i&(1<<j)) {
	tmp+=c[j];
	rep(k,m) {
	  v[k] += a[j][k];
	}
      }
    }

    bool f = true;
    rep(k,m) {
      f = f and (v[k] >= x);
    }
    if(f) {
      ans = min(ans, tmp);
    }
  }
  if(ans == 1001001001)
    std::cout << -1 << std::endl;
  else
    std::cout << ans << std::endl;
  
  return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX 10000
#define INFTY (1 << 29)

class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; i++) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

class Edge {
public:
  int source, target, cost;
  Edge(int source = 0, int target = 0, int cost = 0):
  source(source), target(target), cost(cost) {}
  bool operator < (const Edge &e) const {
    return cost < e.cost;
  }
};

int kruskal(int N, vector<Edge> edges){
  int totalCost = 0;
  sort(edges.begin(), edges.end());

  DisjointSet dset = DisjointSet(N + 1);

  for (int i = 0; i < N; i++) dset.makeSet(i);

  int source, target;
  for (int i = 0; i < edges.size(); i++) {
    Edge e = edges[i];
    if (!dset.same(e.source, e.target)) {
      // MST.push_back(e);
      totalCost += e.cost;
      dset.unite(e.source, e.target);
    }
  }
  return totalCost;
}


int main(int argc, char const *argv[]) {
  int N, M, cost;
  int source, target;

  cin >> N >> M;

  vector<Edge> edges;
  for (int i = 0; i < M; i++) {
    cin >> source >> target >> cost;
    edges.push_back(Edge(source, target, cost));
  }

  cout << kruskal(N, edges) << endl;
  return 0;
}



Measured memory_bytes: 5408
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

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

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, a;
  cin >> n >> a;
  if (n % 500 <= a) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i=0; i<k; i++){
        if(a+i>b){
            break;
        }
        v.push_back(a+i);
    }
    for(int i=0; i<k; i++){
        if(b-i<a){
            break;
        }
        v.push_back(b-i);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++){
        if(v[i] == v[i+1]) continue;
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  ll K,A,B; cin >>K >>A >>B;

  K++;
  if (B<=A || K<A) {
    cout <<K <<'\n';
  } else {
    K-=A;
    ll ans=A+K/2*(B-A)+K%2;
    cout <<(ans<=K+A ? K+A:ans) <<'\n';
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using namespace std;
int cost[100][100];
const int INF = 1000000;
int prim(int n,int s){
	typedef pair<int,int> P;
	bool ischeck[n];
	int mincost = 0;
	priority_queue<P,vector<P>,greater<P> > pq;
	P p,tp;
	for(int i = 0;i < n;++i){
		ischeck[i] = false;
		if(cost[s][i] != INF){
			p.first = cost[s][i];
			p.second = i;
			pq.push(p);
		}
	}
	ischeck[s] = true;
	while(!pq.empty()){
		p = pq.top();
		pq.pop();
		if(ischeck[p.second]) continue;
		else{
			ischeck[p.second] = true;
			mincost += p.first;
			for(int i = 0;i < n;++i){
				if(cost[p.second][i] != INF){
					tp.first = cost[p.second][i];
					tp.second = i;
					pq.push(tp);
				}
			}
		}
	}
	return mincost;
}
int main(){
	int n,m,a,b,c;
	while(cin >> n,n){
		for(int i = 0;i < 100;++i){
			for(int j = 0;j < 100;++j){
				cost[i][j] = INF;
			}
		}
		cin >> m;
		for(int i = 0;i < m;++i){
			scanf("%d,%d,%d",&a,&b,&c);
			cost[a][b] = cost[b][a] = c / 100 - 1;
		}
		cout << prim(n,0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1416
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for(int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while( !q.empty() ) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if( M[u][v] == 0 || d[v]!= INFTY ) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << (d[i] == INFTY ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

int m, k;
vector<int> r;
int main() {
	scanf("%d %d", &m, &k);
	if (k == 0) {
		for (int i = 0; i < (1 << m); i++) {
			r.emplace_back(i);
			r.emplace_back(i);
		}
	}
	else {
		if (m == 1 || (1 << m) <= k) {
			printf("-1\n");
			return 0;
		}
		for (int i = 0; i < (1 << m); i++)
			if (i != k)
				r.emplace_back(i);
		r.emplace_back(k);
		for (int i = (1 << m) - 1; 0 <= i; i--)
			if (i != k)
				r.emplace_back(i);
		r.emplace_back(k);
	}
	printf("%d", r[0]);
	for (int i = 1; i < (1 << (m + 1)); i++)
		printf(" %d", r[i]);
	printf("\n");
}

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

#define int long long

int lcm(int a, int b) 
{
  return (a * (b / __gcd(a, b)));
}

signed main()
{
  int n;
  int t[105];

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }

  int res = t[0];
  for (int i = 1; i < n; i++) {
    res = lcm(res, t[i]);
  }

  cout << res << endl;
}


Measured memory_bytes: 256
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/07/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

n = ii1()
p = list(map(float, input().split()))
dp = [[0 for i in range(n + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(i + 1):
        if j:
            dp[i][j] += dp[i - 1][j - 1] * p[i - 1]
        dp[i][j] += dp[i - 1][j] * (1 - p[i - 1])

tot = 0
for i in range(n + 1):
    if i > n - i:
        tot += dp[-1][i]
print(tot)
        
        

Measured memory_bytes: 223908
import java.util.*;

public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] a = new double[N];
        double av = 0;
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            av += a[i];
        }
        av = av / (double) N;
        for (int i = 0; i < N; i++) {
            a[i] = Math.abs(a[i] - av);
        }
        double min = 1000;
        int minf = -1;
        for (int i = 0; i < N; i++) {
            if (a[i] < min) {
                min = a[i];
                minf = i;
            }
        }
        System.out.println(minf);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<string.h>
int min(int a,int b){
  if(a>b) return b;
  return a;
}

int main(void){
  char s[100001];
  int a=0,b=0,tmp,i;
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    //printf("%c ",s[i]);
    if(s[i]=='1') a++;
    else if(s[i]=='0') b++;
  }
  tmp=min(a,b);
  printf("%d\n",2*tmp);
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) s.begin (), s.end ()

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 5;
const int mod = (int) 1e9 + 7;

ll ans, x;
int n, q[N];
pair<int, int> a[N], m, f, b[N + N];

inline void solve () {
        scanf ("%d", &n);
        m = f = mp (0, mod);
        for (int i = 1; i <= n; i++) {
                scanf ("%d%d", &a[i].f, &a[i].s);
                if (a[i].f > a[i].s) {
                        swap (a[i].f, a[i].s);
                }
                m.f = max (m.f, a[i].s);
                m.s = min (m.s, a[i].f);
                f.f = max (f.f, a[i].f);
                f.s = min (f.s, a[i].s);
                b[i] = mp (a[i].f, i);
                b[n + i] = mp (a[i].s, i);
        }
        ans = (f.f - m.s) * 1LL * (m.f - f.s);
        x = max (f.f, m.f) - min (f.s, m.s);
        sort (b + 1, b + n + n + 1);
        for (int i = 1, r = 0, cr = 0; i <= n + n; i++) {
                while (r < n + n && cr < n) {
                        q[b[++r].s]++;
                        if (q[b[r].s] == 1) {
                                cr++;
                        }
                }
                if (cr < n) {
                        break;
                }
                ans = min (ans, x * (b[r].f - b[i].f));
                q[b[i].s]--;
                if (q[b[i].s] == 0) {
                        cr--;
                }
        }
        printf ("%lld\n", ans);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static double[][]	tb;
	static double		total	= 0;
	static int			n		= 0;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		Town[] towns = new Town[n];
		for ( int i = 0; i < n; i++ ) {
			towns[i] = new Town();
			towns[i].x = in.nextInt();
			towns[i].y = in.nextInt();
		}
		in.close();

		tb = new double[n][n];

		// f:from t:to
		for ( int f = 0; f < n; f++ ) {
			for ( int t = 0; t < n; t++ ) {
				tb[f][t] = Math.sqrt(Math.pow(towns[f].x - towns[t].x, 2) + Math.pow(towns[f].y - towns[t].y, 2));
			}
		}

		// s:start
		for ( int s = 0; s < n; s++ ) {
			ArrayList<Integer> passed = new ArrayList<>();
			passed.add(s);
			total += calc(0.0, passed);
		}

		while ( n > 0 ) {
			total /= n;
			n--;
		}
		System.out.println(total);

	}

	public static double calc(double subtotal, ArrayList<Integer> passed) {
		if ( passed.size() >= n ) {
//			for ( Integer i : passed ) {
//				System.out.print((i + 1) + " ");
//			}
//			System.out.println("subtotal " + subtotal);
//			System.out.println();			
			return subtotal;
		}
		
		int pre = passed.get(passed.size() - 1);
		double toreturn = 0.0;

		// 未訪問の町を見つける
		for ( int now = 0; now < n; now++ ) {
			if ( passed.contains((Integer) now) ) continue;

			// 見つかったら
			ArrayList<Integer> newpassed = new ArrayList<>(passed);			
			newpassed.add((Integer) now);
			toreturn += calc(subtotal + tb[pre][now], newpassed);
		}	
		
		return toreturn;
	}
}

class Town {

	int	x	= 0;
	int	y	= 0;
}

Measured memory_bytes: 36772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   cin>>N;
   double x;
   string u;
   double sum=0.0;
   
   rep(i,N){
       cin>>x>>u;
       if(u=="JPY"){
           sum+=x;
       }
       else{
           sum+=x*380000.0;
       }
   }
  
   cout<<sum<<endl;
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		for (int i = 0; i < 5; i++) {
			if (sc.nextInt() == 0) {
				System.out.println(i+1);
				break;
			}
		}

		sc.close();
	}
}


Measured memory_bytes: 27020
#include <stdio.h>
    int main(){
    int i,n,tmp;
    long min,max,sum;
        min=1000000000;
    max=-1000000000;
    sum=0;
        scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<min){
            min=tmp;
        }
        if(tmp>max){
            max=tmp;
        }
        sum+=tmp;
    }
        printf("%ld %ld %ld\n",min,max,sum);
        return 0;
}


Measured memory_bytes: 2076
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  int n;
  cin >> n;
  rep1(i,50000){
    int aa = i*1.08;
    if(aa==n){
      pri(i);
      return 0;
    }
  }
  pri(":(");
  return 0;
}


Measured memory_bytes: 256
N = int(input())

t = [0 for i in range(100002)]

for i in range(N):
    a,b = [int(i) for i in input().split(' ')]
    t[a-1] +=1
    t[b] -= 1

ans = 0
#print(t)
for i in range(1,100002):
    t[i] += t[i-1]
    if (t[i] >= i):
        ans = i
#print(t)
print(ans)



Measured memory_bytes: 9636
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string s,t;

string ans = "";

void solve(){
	int S = s.size();
	int T = t.size();
	//sのi文字目まで確認済み、かつtのj文字目まで確認済みの時、
	//sの部分列かつtの部分列で最長のものをdp[i][j]とおく
	vector<vector<LL>> dp(S+1,vector<LL>(T+1,0));
	//ばらまくイメージ
	for(int i=0;i<=S;i++){
		for(int j=0;j<=T;j++){
			if(i+1<=S) dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(j+1<=T) dp[i][j+1] = max(dp[i][j+1],dp[i][j]);
			if(i<S && j<T){
				if(s[i]==t[j]) dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
			}
		}
	}
	// for(int j=0;j<=T;j++){
	// 	for(int i=0;i<=S;i++){
	// 		cout << dp[i][j]<< " ";
	// 	}
	// 	cout << endl;
	// }
	if(dp[S][T]==0) return;

	int i=S,j=T;
	while(1){
		if(j==0 || i==0) break;
		if(s[i-1]==t[j-1]){
			ans = s[i-1] + ans;
			i--;j--;
			continue;
		}
		if(dp[i][j]==dp[i-1][j]){
			i--;
			continue;
		}
		if(dp[i][j]==dp[i][j-1]){
			j--;
			continue;
		}
	}
}

int main(){
    cin >> s;
    cin >> t;
 
    solve();

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

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

#define PI 3.14159265358979323846;

void solve(istream& cin, ostream& cout) {
  int r;
  cin >> r;
  double ans = r * 2 * PI;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

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

int main() {
    int a,b; cin >> a >> b;
    int ans = a*b;
    
    cout << ans << "\n";
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	for (long long i = sqrtl(n); i >= 0; i --){
		if (n % i == 0){
			cout << i + n / i - 2;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;
constexpr int M = 13;

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

    string s;
    cin >> s;

    int n = (int)s.size();

    ll p[M] = { 1 }, q[M];
    int t = 1;

    for (int i = 0; i < n; i++) {
        int c = s[n - 1 - i];
        int d0, d1;

        if (c == '?') {
            d0 = 0;
            d1 = 10;
        } else {
            c -= '0';
            d0 = c;
            d1 = d0 + 1;
        }

        for (int j = 0; j < M; j++) {
            q[j] = 0;
        }
        for (int d = d0; d < d1; d++) {
            int e = d * t % M;
            for (int j = 0; j < M; j++) {
                q[(j + e) % M] += p[j];
            }
        }
        for (int j = 0; j < M; j++) {
            p[j] = q[j] % P;
        }

        t = t * 10 % M;

        //for (int j = 0; j < M; j++) {
        //    cout << p[j] << ' ';
        //}
        //cout << endl;
    }

    cout << p[5] << endl;

    return 0;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: String = read();
    let mut ans = 0;
    let mut tmp = 0;
    for c in S.chars() {
        if c == 'R' {
            tmp += 1;
            ans = std::cmp::max(ans, tmp);
        } else {
            ans = std::cmp::max(ans, tmp);
            tmp = 0;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2128
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;

int h, w;
int cnt1 = 0,cnt2=0;
vector<string>v;
bool dfs1(int x, int y) {

	if (x == h - 1 && y == w - 1)return true;

	if (y == w)return false;
	if (x == h)return false;
	bool f, g;
	if (v[x][y] == '#') {
		cnt1++;
		//cout << "x = " << x << "  y = " << y << "  cnt = " << cnt << endl;
		return dfs1(x + 1, y) | dfs1(x, y + 1);



	}

	else return false;


}

bool dfs2(int x, int y) {

	if (x == 0 && y == 0)return true;

	if (y == -1)return false;
	if (x == -1)return false;
	
	if (v[x][y] == '#') {
		cnt2++;
		//cout << "x = " << x << "  y = " << y << "  cnt = " << cnt << endl;
		return dfs2(x - 1, y) | dfs2(x, y - 1);



	}

	else return false;


}

int main() {
	cin >> h >> w;
	int value = h + w - 1-1;
	v = vector<string>(h);
	for (int i = 0; i < h; i++) {
		cin >> v[i];
	}
	bool f, g;
	int x = 0, y = 0;
	f = dfs1(x, y);
	x = h - 1; y = w - 1;
	g = dfs2(x, y);

	if (f&&g&&value == cnt1&&value == cnt2) {

		cout << "Possible" << endl;

	}
	else cout << "Impossible" << endl;

//	cout << cnt << endl;

	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

ll modpow(ll b, ll e) {
  ll ans = 1;
  while (e) {
    if (e&1) ans *= b;
    b *= b;
    ans %= 2019;
    b %= 2019;
    e >>= 1;
  }
  return ans;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s;
  cin >> s;
  int n = sz(s);

  reverse(all(s));
  ll c = 0;
  vi cnt(2020);
  cnt[0] = 1;
  ll ans = 0;
  rep(i,0,n) {
    c += modpow(10, i)*(s[i]-'0');
    c %= 2019;
    ans += cnt[c];
    ++cnt[c];
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3716