akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a;
    cin>>n;
    vector<ll> A;
    for(int i=0;i<n-1;i++){
        cin>>a;
        A.push_back(a);
    }
    if(n==1){
        cout<<2*A[0];
    }
    ll ans=A[0]+A[n-2];
    for(int i=0;i<n-2;i++){
        ans+=min(A[i],A[i+1]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if(b < a){
		cout << 0 << endl;
		return 0;
	}
	if(!n)
		cout << 0 << endl;
	else if(n == 1)
		cout << (a == b ? 1 : 0) << endl;
	else
		cout << (n - 2) * (b - a) + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
# include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    int max_q = n / 7;
    int flag = 0;
    for (int i=0; i<=max_q; i++) {
        if ((n - i * 7) % 4 == 0) {
            flag = 1;
            break;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    ll N; cin>>N;
    ll cou=0,i,X,M; cin>>X>>M;
    ll K=X;
    vector<bool> a(M,false);
    ll e=0;
    rep(i,M){
        if(a[X]) break;
        cou++;
        e+=X;
        a[X]=true;
        X=X*X%M;
    }
    ll cou2=0;
    ll b=0;
    rep(i,M){
        if(!a[X]) break;
        cou2++;
        b+=X;
        a[X]=false;
        X=X*X%M;
    }
    if(N<cou){
        ll ans=0;
        rep(i,N){
            ans+=K;
            K=K*K%M;
        }
        AA(ans);
    }
    else{
        ll c,d,ans=0;
        c = (N-cou)/cou2;
        d = (N-cou)%cou2;
        ans += c*b+e;
        rep(i,d){
            ans += X;
            X=X*X%M;
        }
        AA(ans);
    }
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char B[1 << 15], *S = B, *T = B;
inline long long F()
{
	R char ch; R long long cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}

int main()
{
//	setfile();
	R long long x = F();
	if (x <= 6) puts("1");
	else printf("%lld\n", (x * 2 + 9) / 11 );
	return 0;
}


Measured memory_bytes: 128
import numpy as np
N = int(input())
a = list(map(int,input().split()))
ans=1
for i in range(N):
    ans *= a[i]
    if (ans > 1000000000000000000):
        ans = -1
        break
for i in range(N):
    if (a[i] == 0):
        ans = 0
        break
print(ans)

Measured memory_bytes: 40240
import java.util.*;
public class Main {
	// get topological order from edge-list format,
	// such as 0: <1, 2>, 1: <>, 2: <3>, 3: <>
	// (expecting vetex-number starts from 0)
	// if there is no topological order, it returns null.
	static ArrayList<Integer> getTopologicalOrder(ArrayList<ArrayList<Integer>> es) {
		int n = es.size(); // number of vertexes
		int[] deg = new int[n];
		ArrayList<Integer> ret = new ArrayList<>(n);
		Queue<Integer> q = new ArrayDeque<Integer>(n);
		for(int i=0; i<n; i++) {
			for(int to : es.get(i)) {
				deg[to]++;
			}
		}
		for(int i=0; i<n; i++) {
			if(deg[i]==0) q.add(i);
		}
		int cnt = 0;
		while(!q.isEmpty()) {
			int from = q.poll();
			ret.add(from);
			for(int to : es.get(from)) {
				deg[to]--;
				if(deg[to]==0) {
					q.add(to);
				}
			}
			cnt++;
		}
		if(cnt!=n) return null;
		return ret;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); int m = sc.nextInt();
		ArrayList<ArrayList<Integer>> es = new ArrayList<>();
		for(int i=0; i<n; i++) {
			es.add(new ArrayList<Integer>());
		}
		for(int i=0; i<m; i++) {
			int s = sc.nextInt(); int t = sc.nextInt();
			es.get(s).add(t);
		}
		ArrayList<Integer> tord = getTopologicalOrder(es);
		for(int i=0; i<n; i++) {
			System.out.println(tord.get(i));
		}
	}
}



Measured memory_bytes: 70240
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			String n = scan.next();
			if(n.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i = 0; i < n.length(); i++) {
				sum += Integer.parseInt(n.substring(i, i + 1));
			}
			System.out.println(sum);
		}
		scan.close();
	}
}


Measured memory_bytes: 26840
//
// Created by ss250251 on 2/16/2020.
//

#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L + 7
#define MOD 1e9+7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}

int main(){
    int n, k;
    cin>>n>>k;
    vector<bool>dp(k+1,0);
    vector<int>vals(n);
    for(int i=0;i<n;i++){
        cin>>vals[i];
    }

    for(int i=1;i<=k;i++){
        for(auto x:vals){
            if(i-x>-1){
                dp[i] = !dp[i-x];
                if(dp[i])break;
            }
        }
    }
    cout<<(dp[k]?"First":"Second");
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    var a = sc.nextLong()
    var b = sc.nextLong()
    var k = sc.nextLong()

    if( k > a) {
        k -= a
        a = 0

        if(k > b) {
            k-= b
            b = 0
        }
        else {
            b-= k
        }
    }
    else {
        a-=k
    }

    println("$a $b")


}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}





Measured memory_bytes: 31136
#include <iostream>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    vector <int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    vector < pair<int, int> > store(n);
    for (int i = 0; i < n; i++) {
        store[i] = make_pair(a[i], b[i]);
    }

    sort(store.begin(), store.end());

    long long count = 0;
    long long cost = 0;

    for (int i = 0; i < n; i++) {
        if (count + store[i].second >= m) {
            cost += store[i].first * (m - count);
            break;
        }

        count += store[i].second;
        cost += store[i].first * store[i].second;
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1792
import numpy as np

a, b, x = map(int,input().split())
th = a**2 * b / 2
if x <= th:
    ans = np.arctan(a*b**2/2/x)
else:
    ans = np.arctan((2*b-2*x/a**2)/a)
print(np.degrees(ans))

Measured memory_bytes: 13132
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		String s = sc.next();

		if ( s.length()<=k ) {
			System.out.println(s);
		} else {
			System.out.println(s.substring(0,k) + "...");
		}
	}
}

Measured memory_bytes: 38656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[82][82][25610];
ll c[82][82];
int main() {
	ll h,w;
	cin>>h>>w;
	ll a[82][82];
	ll b[82][82];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>b[i][j];
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			c[i][j]=abs(a[i][j]-b[i][j]);
		}
	}
	ll K=12805;
	ch[0][0][K+c[0][0]]=ch[0][0][K-c[0][0]]=true;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(i!=0){
				for(ll k=0;k<25610;k++){
					if(ch[i-1][j][k]){
						ch[i][j][k+c[i][j]]=ch[i][j][k-c[i][j]]=true;
					}
				}
			}
			if(j!=0){
				for(ll k=0;k<25610;k++){
					if(ch[i][j-1][k]){
						ch[i][j][k+c[i][j]]=ch[i][j][k-c[i][j]]=true;
					}
				}				
			}
		}
	}
	ll ans=INF;
	for(ll i=h-1;i<h;i++){
		for(ll j=w-1;j<w;j++){
			for(ll k=0;k<25610;k++){
				if(ch[i][j][k]){
					ans=min(ans,abs(K-k));
				}
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 108920
#include <string>
#include <vector>
#include <string.h>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <random>
using namespace std;
typedef long long ll;
const int INF = 987654321;
const int MAX_N = 3e5 + 2, MAX_X = 1e6 + 2;

int main()
{
	int N,cnt = 0;
	cin >> N;
	for (int i = 1; i < N; i++) {
		cnt += N / i - (N%i == 0 ? 1 : 0);
	}
	cout << cnt;
}

Measured memory_bytes: 3572
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let I = {
        let mut I = (0..N).collect::<Vec<_>>();
        I.sort_by_key(|&i| A[i] + B[i]);
        I.reverse();
        I
    };

    let ans = (0..N).map(|i| if i % 2 == 0 { A[I[i]] } else { -B[I[i]] }).sum::<i64>();

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

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

using namespace std;

int abs(int a,int b)
{
	int c=a-b;
	return c > 0 ? c : -c;
}
int main()
{
	std:ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	int height[n],dp[n];
	for(int i=0;i<n;i++)
		cin>>height[i];
	for(int i=0;i<n;i++)
		dp[i]=0;
	dp[0]=0;
	dp[1]=abs(height[0]-height[1]);
	for(int i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(height[i],height[i-1]),dp[i-2]+abs(height[i],height[i-2]));
	cout<<dp[n-1]<<endl;
  	return 0;
}

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

int n, k, a, cnt[200010], sol;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cnt[a]++;
	}
	sort(cnt, cnt + 200010);
	for (int i = 200010 - k - 1; i >= 0; i--) sol += cnt[i];
	cout << sol;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    string alph = "abcdefghijklmnopqrstuvwxyz";
    if(s.size() == 26){
        if(s == "zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 << endl;
            return 0;
        }
        int i;
        for(i = 25; (int)s[i-1] > (int)s[i]; i--){}
        int key = i;
        while(s[i-1] < s[key]){
            key ++;
        }
        s[i-1] = s[key-1];
        s.erase(i, 26);
        cout << s << endl;
        return 0;
    }
    int l = 0;
    for(int j = 0; j < 26; j++){
        l = 0;
        int i;
        for(i = 0; i < s.size(); i++){
            if(alph[j] == s[i]) l = 1;
        }
        if(l == 0){
            s = s + alph[j];
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class ElementCounter<T>
{
    public Dictionary<T, long> Dic;

    public ElementCounter()
    {
        Dic = new Dictionary<T, long>();
    }
    public long this[T key]
    {
        get
        {
            if (Dic.ContainsKey(key))
            {
                return Dic[key];
            }
            else
            {
                return 0;
            }
        }
        set
        {
            if (Dic.ContainsKey(key))
            {
                Dic[key] = value;
            }
            else
            {
                Dic.Add(key, value);
            }
        }
    }
    public void Add(T item)
    {
        if (Dic.ContainsKey(item))
        {
            Dic[item] += 1;
        }
        else
        {
            Dic.Add(item, 1);
        }
    }
    public void Remove(T item)
    {
        if (Dic.ContainsKey(item))
        {
            Dic[item] = Dic[item] != 0 ? Dic[item] - 1 : 0;
        }
    }
}

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            var dic = new ElementCounter<long>();
            foreach (long n in A) dic.Add(n);
            long result = 0;
            foreach (long i in dic.Dic.Values) result += i * (i - 1) / 2;
            foreach (long i in A) Console.WriteLine(result - dic[i] + 1);
        }
    }
}


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

using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( i = 0; i < (int)n; ++i )
typedef long long ll;

int H, W, k;

int main()
{
    //IOS
    
    int i, j, ans = 0;
    cin >> H >> W >> k;
    vector<vector<char>> grid(H, vector<char>(W));

    forin(i, H)
    {
        forin(j, W)
        {
            cin >> grid[i][j];
        }
    }

    for( int mask_row = 0; mask_row < ( 1 << H ); ++mask_row )
    {
        for( int mask_col = 0; mask_col < ( 1 << W ); ++mask_col )
        {
            int michis = 0;
            forin(i, H)
            {
                forin(j, W)
                {
                    if ( ( (mask_row >> i) & 1 ) && ( (mask_col >> j) & 1 ) &&
                            grid[i][j] == '#' ) ++michis;
                }
            }

            if ( michis == k ) ++ans;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

ll modpow(ll k, ll n, int mod) {
  ll ret = 1;
  while (n > 0) {
    if (n % 2 == 1) ret = k * ret % mod;
    k = k * k % mod;
    n /= 2;
  }

  return ret;
}

int main() {
  int n, k;
  cin >> n >> k;

  k = min(k, n - 1);

  int mod = 1000000007;

  ll f[n + 1];
  f[0] = f[1] = 1;
  for (int i = 1; i < n; ++i) {
    f[i + 1] = f[i] * (i + 1) % mod;
  }

  ll fi[n + 1];
  rep(i, n + 1) { fi[i] = modpow(f[i], mod - 2, mod); }

  auto ch = [&](int a, int b) {
    return (f[a] * fi[b] % mod) * fi[a - b] % mod;
  };

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans += ch(n, i) * ch(n - 1, i) % mod;
    ans %= mod;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "TASK"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

int n;
int a[100010];

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    n=in;
    forinc(i,1,n) a[i]=in;
    int i=1,j,t,ret=0;
    while(i<=n){
        j=t=i+1;
        while(j<=n && a[j]>=a[j-1]) j++;
        while(t<=n && a[t]<=a[t-1]) t++;
        ret++;
        i=max(j,t);
    }
    cout<<ret;
}


Measured memory_bytes: 640
fun main() {
    val inLine = readLine()!!.split(" ").map(String::toInt)

    val h1 = inLine[0]
    val m1 = inLine[1]
    val h2 = inLine[2]
    val m2 = inLine[3]
    val k = inLine[4]

    val wake = h1 * 60 + m1
    val sleep = h2 *60 + m2

    val result = sleep - wake - k

    println(result)
}

Measured memory_bytes: 36336
N = int(input())
fouls = 0
for i in range(N):
    W = input()
    if i == 0:
        words = ['0' + W[:1]]
    if W in words:
        fouls += 1
    if W[:1] != words[i][-1:]:
        fouls += 1
    words.append(W)
if fouls >= 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
var
    n,i,x,y: Integer;
    a: array[1..100] of Integer;
type
    datatype=Integer;
    datatype_p=PInteger;

procedure qsort(l,r:Longint;data:datatype_p);
var
    i,j,mid,t: datatype;
begin
    if l>=r then
    begin
        exit;
    end;
    i:=l;
    j:=r;
    mid:=data[(l+r) div 2];
    repeat
        while data[i]<mid do
        begin
            inc(i);
        end;
        while data[j]>mid do
        begin
            dec(j);
        end;
        if i<=j then
        begin
            t:=data[i];
            data[i]:=data[j];
            data[j]:=t;
            inc(i);
            dec(j);
        end;
    until i>j;
    qsort(l,j,data);
    qsort(i,r,data);
end;
begin
    readln(n);
    for i := 1 to n do
    begin
        read(a[i]);
    end;
    qsort(1,n,@a[0]);
    i:=n;
    while i>0 do
    begin
        inc(x,a[i]);
        dec(i,2);
    end;
    i:=n-1;
    while i>0 do
    begin
        inc(y,a[i]);
        dec(i,2);
    end;
    writeln(x-y);
    readln;
    readln;
end.


Measured memory_bytes: 128
class DFSdata
  def initialize(id, next_id)
    @id = id
    @next_id = next_id
    @first = 0
    @finish = 0
  end

  attr_accessor  :id, :next_id, :first, :finish
end

def depth_first_search(start)
  return if start.first != 0
  
  start.first = @count
  @count += 1
  stack = [start]

  until stack.empty? do
    now = stack.pop
    child = now.next_id.map{|x|x}
    child.each do |x|
      if @array[x].first == 0
        @array[x].first = @count
        @count += 1
        stack << now
        stack << @array[x]
        break
      else
        now.next_id.delete(x)
      end
    end

    if now.next_id.empty?
      now.finish = @count
      @count += 1
    end

  end

end


@array = [nil]
@count = 1

n = gets.to_i.times do
  input = gets.split(" ").map{|x| x.to_i}
  u = input.shift
  k = input.shift
  @array << DFSdata.new(u, input)
end
1.upto n do|i|
  depth_first_search(@array[i])
end

1.upto n do |i|
  printf "%d %d %d\n" ,@array[i].id ,@array[i].first ,@array[i].finish
end



Measured memory_bytes: 6896
n, m = gets.split.map(&:to_i)
sol = 10**12
if n <= m then
    #puts "a"
    sol = [sol, m-n].min
end
if -n <= m then
    #puts "b"
    sol = [sol, 1 + m-(-n)].min
end
if -n <= -m then
    #puts "c"
    sol = [sol, 2 + -m-(-n)].min
end
if n * m < 0 && n <= -m then
    #puts "d"
    sol = [sol, 1 + -m - n].min
end
if n == 0 then
    #puts "f"
    sol = [sol, m.abs + ((m<0)?1:0)].min
end
if m == 0 then
    #puts "g"
    sol = [sol, n.abs + ((n>0)?1:0)].min
end
puts sol

Measured memory_bytes: 1788
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    n,*a=map(int,open(0).read().split())
    print(*reversed(a))
if __name__ == '__main__':
    main()


Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc045_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string A, B, C;
  cin >> A >> B >> C;

  int a = 0, b = -1, c = -1;
  char next = 'a';
  while (true) {
    if (next == 'a') {
      a++;
      if (a == A.size()) {
        cout << "A" << endl;
        return 0;
      }
      next = A[a];
    } else if (next == 'b') {
      b++;
      if (b == B.size()) {
        cout << "B" << endl;
        return 0;
      }
      next = B[b];
    } else {
      c++;
      if (c == C.size()) {
        cout << "C" << endl;
        return 0;
      }
      next = C[c];
    }
  }
}

Measured memory_bytes: 3640
//Solution by NurlashKO
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <list>
#include <map>

using namespace std;

int n, k, a[555], ans;
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);

    for (int i = 1; i < n; i++) {
        if (a[i] <= k) {
            ans++;
            k -= a[i];
        }
    }
    ans += a[n] == k;
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 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;
}

 typedef long long ll;
 const long long INF = 1LL << 60;



 int main()
 {
   int n,k;
   cin >> n >> k;
   
   vector<int> h(n);
   for(int i = 0; i < n; i++) cin >> h.at(i);

   vector<long long> dp(n, INF);
   
   dp.at(0) = 0;
   for(int i = 1; i < n; i++)
   {
       chmin(dp.at(i), dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
        for(int j = 1; j < k; j++)
        {
            if(i > j) chmin(dp.at(i), dp.at(i-j-1) + abs(h.at(i) - h.at(i-j-1)));
        }
   }

   cout << dp.at(n-1) << endl;
    

    return 0;
 }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 998244353;

//AのN乗(mod M)を高速に計算する(O(logN))
//Aの逆元を取る場合、modpow(A, MOD-2, MOD)で求まる
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main() {
  COMinit();

  int N, M, K;
  cin >> N >> M >> K;
  int all = modpow(M, N, MOD);
  for( int i = K+1; i < N; i++ ){
    int hiku = COM(N-1, i);
    hiku *= (M * modpow(M - 1, N - i - 1, MOD)) % MOD;
    hiku %= MOD;
    all = (all-hiku)%MOD;
    if( all < 0 ) all += MOD;
  }
  cout << all%MOD << endl;
}


Measured memory_bytes: 15592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(b,n*a) << endl;
    return 0;
}

Measured memory_bytes: 3632
import math
a, b, h, m = map(int, input().split())
h_rad = math.radians((-h*30)+90-m*0.5)
m_rad = math.radians((-m*6)+90)
hx = math.cos(h_rad) * a
hy = math.sin(h_rad) * a
mx = math.cos(m_rad) * b
my = math.sin(m_rad) * b
ans = math.sqrt((mx-hx)**2+(my-hy)**2)
print(ans)


Measured memory_bytes: 9576
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[10],p[10],q[10];
int main()
{
	int l,r,n;
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		a[i]=i;
	}
	for(int i=1;i<=n;i++) cin>>p[i];
	for(int i=1;i<=n;i++) cin>>q[i];
	do{
		ans++;
		int flag=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=p[i]) flag=1;
		}
		if(!flag) l=ans;
		flag=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=q[i]) flag=1;
		}
		if(!flag) r=ans;
	}while(next_permutation(a+1,a+1+n));
	cout<<abs(r-l)<<"\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}

//a,b x
int main(){
    ll N,M; cin>>N>>M;
	vector<ll>A(N);
	vector<ll>s(N+1,0);
	rep(i,N) cin>>A[i];
	//A:  0  [0] [1] [2]
	//s: [0] [1] [2] [3]
	map<ll,ll> m;
	rep1(i,N){
		s[i]=s[i-1]+A[i-1];
		s[i]%=M;
	}
	rep(i,N+1) m[s[i]]++;
	ll ans=0;
	for(auto itr=m.bg;itr!=m.ed;itr++){
		ll D=(itr->b);
		ans+=D*(D-1)/2;
	}
	cout<<ans;
}

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

typedef long long int ll;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	ll i,j,t,k,l,m,n,x,y,z,c,a,d;

	cin >> x >> k >> d;

	l = abs(x);

	

	m = l/d;

	// cout << m << '\n';

	if(k >= m)
	{
		if((k-m)%2 == 0)
		{
			cout << l%d << '\n';
		}
		else
		{
			cout << d-l%d << '\n';
		}
	}
	else
	{
		cout << min({(ll)abs(x-k*d),(ll)abs(x+k*d)}) << '\n';
	}

	
	
 
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	long long x, money=100;
	cin >> x;

	int cnt = 0;
	while (1) {
		money += (money / 100);
		cnt++;
		if (x <= money){
			cout << cnt  << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> x(n);
	int ans=0;
	rep(i,n){
		cin>>x[i];
		ans+=min(2*x[i],2*abs(k-x[i]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int D;
	scanf("%d", &D);
	switch (D)
	{
	case 25:printf("Christmas");
		break;
	case 24:printf("Christmas Eve");
		break;
	case 23:printf("Christmas Eve Eve");
		break;
	case 22:printf("Christmas Eve Eve Eve");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 128
N,X=map(int,input().split())
x=list(map(int,input().split()))
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
X=abs(X-x[0])
for i in range(N-1):
  X=gcd(max(X,abs(x[i+1]-x[i])),min(X,abs(x[i+1]-x[i])))
print(X)

Measured memory_bytes: 19792
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    vll v(5);
    rep(i,5) cin >> v[i];
    rep(i,5) if(v[i] == 0) cout << i+1 << endl;
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1) 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
#define MOD 1e9+7
#define inf 1e9+9
#define int long long
#define ld long double
#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
typedef vector<int> vi;
typedef pair<int,int> pii; 

int max(int a, int b){return a>b? a:b;}
int min(int a, int b){return a<b? a:b;}

void solve(){
	string a,b; cin>>a>>b;
	int m=a.length();
	int n=b.length();

	int dp[m+1][n+1];
	for(int i=0;i<=n;i++)
		dp[0][i]=0;
	for(int i=0;i<=m;i++)
		dp[i][0]=0;
	FOR(i,1,m){
		FOR(j,1,n){
			if(a[m-i] == b[n-j]){
				dp[i][j]=1+dp[i-1][j-1];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	} 
	int i=m,j=n;
	string s="";
	while(i>0 && j>0){
		if(a[m-i]==b[n-j]){
			s=s+a[m-i];
			i--;
			j--;
		}else{
			if(dp[i-1][j]>dp[i][j-1]){
				i--;
			}else{
				j--;
			}
		}
	}
	cout << s << endl;
}


int32_t main(){
	fast
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 73900
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i =0; i<n; i++){
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    stack<double> s;
    for(int i=0; i<n; i++) s.push(v[i]);
    for(int i=1; i<n; i++){
        double a = s.top();
        s.pop();
        double b = s.top();
        s.pop();
        s.push((a+b)/2);
    }
    
    cout << fixed << setprecision(10) << s.top() << endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;

  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> h[i];
  }
  
  int ansh = 0, ansx = 0, ansy = 0;
  for (int cx = 0; cx <= 100; ++cx) {
    for (int cy = 0; cy <= 100; ++cy) {
      for (int i = 0; i < N; ++i) {
        if (h[i] == 0) {
          continue;
        }

        bool ok = true;
        int hh = h[i] + abs(x[i] - cx) + abs(y[i] - cy);

        for (int j = 0; j < N; ++j) {
          int tmp = max(hh - abs(x[j] - cx) - abs(y[j] - cy), 0);
          if (h[j] != tmp) {
            ok = false;
            break;
          }
        }

        if (!ok) {
          continue;
        }

        if (ansh <= hh) {
          ansh = hh;
          ansx = cx;
          ansy = cy;
        }
      }
    }
  }

  cout << ansx << " " << ansy << " " << ansh << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
  class Program
  {
    public static void Main(string[] args)
    {
      int i = int.Parse(Console.ReadLine());
      if (i >= 3200)
      {
        Console.WriteLine(Console.ReadLine());
      }
      else
      {
        Console.WriteLine("red");
      }
    }
  }
}

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

char str[120];
size_t size;

int dfs(int *i) {
  //printf("called %d\n", *i);
  int j, k;
  for (;*i < size; ++*i) {
    if (str[*i] == '(' || str[*i] == '[') {
      break;
    }
    if (str[*i] == ')' || str[*i] == ']') {
      // printf("fail");
      return 0;
    }
  }
  // printf("a %d", *i);

  if (*i == size) {
    return 1;
  }

  char end = ')', fail = ']';
  if (str[*i] == '[') end = ']', fail = ')';

  for (++*i; *i < size; ++*i) {
    if (str[*i] == end) {
      return 1;
    } else if (str[*i] == fail) {
      return 0;
    }else if(str[*i] == '(' || str[*i] == '[') {
      if(dfs(i) == 0) {
        return 0;
      }
    }
  }
  return 0;
}

int main(void) {
  while (1) {
    fgets(str, 110, stdin);
    size = strlen(str);
    while(str[size-1] == '\n')--size;
    
    if (size == 1 && str[0] == '.') return 0;

    int i = 0;

    int flag = 1;
    while(i < size) {
      if(!dfs(&i)) {
        flag = 0;
        break;
      }
      ++i;
    }
    if(flag) {
      puts("yes");
    }else {
      puts("no");
    }
  }

}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>di(N);
  for (int i = 0; i < N; i ++) cin >> di[i];
  sort(di.begin(), di.end());
  N /= 2;
  cout << di[N] - di[N - 1] << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct UF{
    vector<int> par,sz,c;
    vector<ll> w;
    explicit UF(int n):par(n),sz(n,1),w(n),c(n){
        iota(par.begin(),par.end(),0);
        for(auto&i:w) cin>>i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool unit(int x, int y, int W){
        x=find(x);
        y=find(y);
        if(x==y){
            if(w[x]<W) ++c[x];
            return false;
        }
        if(sz[x]<sz[y]) swap(x,y);
        if((w[x]+=w[y])<W) c[x]+=c[y]+1;
        else c[x]=0;
        par[y]=x;
        sz[x]+=sz[y];
        return true;
    }
    bool same(int x, int y){return find(x)==find(y);}
};

struct edge{
    int a,b,w;
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    UF uf(n);
    vector<edge> e(m);
    for(auto&E:e) cin>>E.a>>E.b>>E.w,--E.a,--E.b;
    sort(e.begin(),e.end(),[](const edge&a, const edge&b){
        return a.w<b.w;
    });
    for(auto&E:e) uf.unit(E.a,E.b,E.w);
    cout<<uf.c[uf.find(0)]<<endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  ll N,K; cin>>N>>K;

  if(N%K==0){cout<<0<<endl; return 0;}

  while(N*2>K && N>K) {
    ll k = K;
    while(N>k)k*=10;
    k/=10;
    N = abs(N-k);
  }

  while(N*2>K) {
    N = abs(N-K);
  }

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A, B, C, D = map(int, input().split())

if A < C:
    start = C
else:
    start = A

if B < D:
    end = B
else:
    end = D

answer = end - start
if answer > 0:
    print(answer)
else:
    print(0)


Measured memory_bytes: 2940
n = int(input())
s = input().split()
ans = 0

for i in range(n - 2):
    if int(s[i]) < int(s[i + 1]) and int(s[i + 1]) < int(s[i + 2]):
        ans += 1
    elif int(s[i]) > int(s[i + 1]) and int(s[i + 1]) > int(s[i + 2]):
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if ((i % 3 != 0) && (i % 5 != 0)) {
      sum += i;
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3256
t=1
while t:
	t-=1
	n=int(input())
	# n,m=(map(int,input().split()))
	l=list(map(int,input().split()))
	c=[0 for i in range(100001)]
	sumi=sum(l)
	for i in range(n):
		c[l[i]]+=1
	q=int(input())
	while(q):
		q-=1
		a,b=map(int,input().split())
		sumi+=(c[a]*(b-a))
		c[b]+=c[a]
		c[a]=0
		print(sumi)


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  string s,t; cin >>s >>t;
  vector<int> A(26, -1);
  vector<int> B(26, -1);
  // 各々のアルファベットに対応するアルファベットの数字を格納
  rep(i, s.size()){
    int a = s[i] - 'a';
    int b = t[i] - 'a';
    if (A[a] == -1) A[a] = b;
    if (B[b] == -1) B[b] = a;
    if (A[a] != b || B[b] != a){
      cout <<"No" <<endl; return 0;
    }
  }
  cout <<"Yes" <<endl;
}

Measured memory_bytes: 776
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_N = 100;
static const int MAX_K = 100000;

int N, K;
int a[MAX_N];
bool memo[MAX_K + 1];

int main(){
	scanf("%d %d", &N, &K);
	for(int i = 0; i < N; i++) scanf("%d", &a[i]);
	sort(a, a + N);
	fill(memo, memo + K + 1, false);
	for(int i = 0; i <= K; i++){
		for(int j = 0; j < N; j++){
			if(i - a[j] < 0) continue;
			memo[i] |= !memo[i - a[j]];
		}
	}
	if(memo[K]) printf("First\n");
	else printf("Second\n");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned uint;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
void dfs(int u,vector<vector<int> >&E,vector<int>&p,vector<int>&sz){
	sz[u]=1;
	for(int i=0;i<(int)E[u].size();i++){
		int to=E[u][i];
		if(p[u]!=to){
			p[to]=u;
			dfs(to,E,p,sz);
			sz[u]+=sz[to];
		}
	}
}
int main(){
    n=in();
	vector<vector<int> >E(n);
	for(int i=0;i<n-1;i++){
		int a,b;
		a=in();b=in();
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	vector<int> p(n,-1),sz(n,0);
	dfs(0,E,p,sz);
	vector<int>path;
	int c=n-1,psz=0;
	while(c>=0){
		path.push_back(sz[c]-psz);
		psz=sz[c];
		c=p[c];
	}
	reverse(path.begin(),path.end());
	int ls=0;
	for(int i=0;i<((int)path.size()+1)/2;i++){
		ls+=path[i];
	}
	if(2*ls>n)printf("Fennec");
	else printf("Snuke");
	return 0;
}

Measured memory_bytes: 14972
N,K = map(int, input().split())
sunuke_list = [str(i+1) for i in range(N)]
d_list = []
A_list = []
t_list = []

for j in range(K):
  d_list.append(input())
  A_list.append(input().split())
  
t_list = list(set(sunuke_list) - set(A_list[0]))
for j in range(K-1):
  t_list = list(set(t_list) - set(A_list[j+1]))
  
print(len(t_list))
  

Measured memory_bytes: 9532
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    # pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * (1 - p[i0-1])

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 180980
A = list(map(int, input().split())) 
r = A[0]
D = A[1]
f = A[2]
 
 
count = 0
ans = 0
 
for i in range(10):
    f = (r*f) - D 
    count = count + 1
    print(f)
    if(count == 10):
        break

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

int n,ans;

int change(char ch){
  if('0'<=ch&&ch<='9')return ch-'0';
  if('A'<=ch&&ch<='Z')return 10+ch-'A';
  return 36+ch-'a';
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int p,num=0;
    string m;
    cin>>p>>m;
    for(int i=0;i<(int)m.size();i++)
      num=num*p+change(m[i]);
    ans^=num;                        
  }
  if(ans)cout<<"win"<<endl;
  else cout<<"lose"<<endl;
  return 0;
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static void Main(string[] args)
        {
            //var vals = Console.ReadLine().Split(' ')
            //   .Select(x => int.Parse(x)).ToList();
            var N = Console.ReadLine();
            var K = Console.ReadLine();
            var Ans = (N + K[K.Length - 1] == K) ? "Yes" : "No";
            Console.WriteLine(Ans);


        }



    }
    class PriorityQueue<T> where T : IComparable<T>
    {
        private List<T> heap = new List<T>();
        private int lastindex = -1;
        private void swap(int n, int m)
        {
            T wait = heap[n];
            heap[n] = heap[m];
            heap[m] = wait;
        }
        public int Count()
        {
            return lastindex + 1;
        }
        public void Enqueue(T data)
        {
            int p;
            if (lastindex + 1 < heap.Count())
            {
                heap[lastindex + 1] = data;
            }
            else
            {
                heap.Add(data);
            }
            lastindex++;
            p = lastindex;

            while (true)
            {
                if (p > 0 && heap[p].CompareTo(heap[(p - 1) / 2]) <= -1)
                {
                    swap(p, (p - 1) / 2);
                    p = (p - 1) / 2;
                }
                else
                {
                    break;
                }
            }
        }
        public T Peek()
        {
            return heap[0];
        }
        public T Dequeue()
        {
            T result = Peek();
            heap[0] = default(T);
            swap(0, lastindex);
            lastindex--;
            int p = 0;
            while (true)
            {
                int np;
                if (2 * p + 1 > lastindex)
                {
                    break;
                }
                else
                {
                    np = ((2 * p + 1 == lastindex) || heap[2 * p + 1].CompareTo(heap[2 * p + 2]) <= -1)
                        ? (2 * p + 1) : (2 * p + 2);
                }
                if (heap[p].CompareTo(heap[np]) >= 1)
                {
                    swap(p, np);
                    p = np;
                }
                else
                {
                    break;
                }
            }

            return result;
        }





    }
}


Measured memory_bytes: 25800