akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
    int n,k;
    int temp=0;
    int res=0;
    int ans=0;
    int ans_temp=0;

    vector<int> v1;
    string S;
    cin >> n >> k;
    cin >> S;

    for(int i=0;i<S.length();i++){
            if(i==0){temp++;}
            else if(S[i]==S[i-1]){temp++;}
            else if(S[i-1]=='0'){v1.push_back(-temp); temp=1;}
            else{v1.push_back(temp); temp=1;}
                        
    }
    if(S[S.length()-1]=='0'){ v1.push_back(-temp);}
    else{ v1.push_back(temp);}

    int len=v1.size();

    

    for(int i=0;i<len;i++){
        res=k;
        ans_temp=0;
        for(int j=i;j<len;j++){
            
            if(v1[j]<0&&res<=0){
                break;
            }else if(v1[j]<0){
                ans_temp+=abs(v1[j]);
                res--;
            }else{
                ans_temp+=v1[j];
            }
        }
        ans=max(ans,ans_temp);
        if(v1[i]>0)i++;


    }
    
   


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

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
ll a,b,c;
ll gcd(ll x,ll y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b);
	c=gcd(a,b);
	printf("%lld\n",a/c*b);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N= keyboard.nextInt();
		int K= keyboard.nextInt();
		int[][] da = new int[K+1][N+1];
		int[] okashi = new int[N+1];
		
		for(int k=1; k<K+1; k++) {
			da[k][0]= keyboard.nextInt();
			for(int a=1; a<da[k][0]+1; a++) {
				da[k][a] = keyboard.nextInt();
				okashi[da[k][a]]++;
			}
		}
		
		int ans =0;
		for(int i=1; i<N+1; i++) {
			if(okashi[i] == 0) {
				ans++;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
		
	}
}

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

int main() {
    int N, cnt[200003];

    scanf("%d", &N);

    memset(cnt, 0, sizeof(cnt));
    for (int i = 2; i <= N; i++) {
        int A;
        scanf("%d", &A);

        cnt[A] += 1;
    }

    for (int i = 1; i <= N; i++)
        printf("%d\n", cnt[i]);
}


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

int main()
{
    int N;
    int A[200];

    int cnt=0;

    std::cin >> N;
    for (int i=0; i<N; i++){ std::cin >> A[i]; }

    while(true){

        bool existsOdd = false;
        for (int i = 0; i < N; i++){
            if (A[i] % 2 != 0) { existsOdd = true; }
        }

        if (existsOdd == true) { break; }

        for (int i = 0; i < N; i++){
            A[i] /= 2;
        }

        cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args) {
		
		String input;
		
		Stack<Integer> stack = new Stack<Integer>();
		
		Scanner keyboard = new Scanner(System.in);
		
		input = keyboard.nextLine();
		
		Scanner expression = new Scanner(input);
		
		while(expression.hasNext()) {
			
			String nextString;
			
			if(expression.hasNextInt()) {
				nextString = expression.next();
				stack.push(Integer.parseInt(nextString));
			}
			else {
				int first = stack.pop();
				int second = stack.pop();
				String operator = expression.next();
				
				int result = calculate(first, second, operator);
				
				stack.push(result);
				
			}
			
		}
		
		System.out.println(stack.pop());
		
	}
	
	public static int calculate(int a, int b, String operator) {
		
		if(operator.equals("+")) {
			return a + b;
		}
		else if(operator.equals("-")) {
			return b - a;
		}
		else if(operator.equals("*")) {
			return a * b;
		}
		
		return 0;
	}

}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        ll A, V; cin >> A >> V;
        ll B, W; cin >> B >> W;
        ll T; cin >> T;
        if (V <= W) {
                cout << "NO" << endl;
                exit(0);
        }
        ll al = A + (T * V);
        ll bl = B + (T * W);
        if (al < bl) {
                cout << "NO" << endl;
                exit(0);
        }
        ll ap = A;
        ll bp = B;
        for (int i = 1; i <= T; ++i) {
                if (ap < bp) {
                        ap += V;
                        bp += W;
                        if (ap == bp) {
                                cout << "YES "<< endl;
                                exit(0);
                        }
                        if (ap > bp) {
                                cout << "YES" << endl;
                                exit(0);
                        }
                }
                else {
                        ap -= V;
                        bp -= W;
                        if (ap == bp) {
                                cout << "YES "<< endl;
                                exit(0);
                        }
                        if (bp > ap) {
                                cout << "YES" << endl;
                                exit(0);
                        }
                }
        }
        cout << "NO" << endl;


}


Measured memory_bytes: 3636
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val h = Array.fill(n)(sc.nextInt())
  if (calc(h.length-1)) {
    println("Yes")
  } else {
    println("No")
  }
  
  def calc(i: Int): Boolean = {
    if (i == 0) {
      true
    } else if (i == 1) {
      h(i-1) <= h(1)
    } else if (h(i-1) <= h(i)) {
      calc(i-1)      
    } else if (h(i-1) - 1 == h(i)) {
      h(i-1) = h(i-1) - 1
      calc(i-1)
    } else {
      false
    }
  }
}

Measured memory_bytes: 59480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	    // 1000の倍数の場合はお釣りは必ず0円となる
	    // 1000の倍数でない場合は、1000-（N円の1の位～百の位）がお釣りとなる
	    int answer = 0;
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    try{
	        String str = br.readLine();
	        int n = Integer.parseInt(str);

	        if (n % 1000 == 0) {
	            System.out.println(answer);
	        } else {
	            answer = 1000 - (n % 1000);
	            System.out.println(answer);
	        }

	    } catch (IOException ioe) {

	    }
	}

}

Measured memory_bytes: 32512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	vector<int> b(n);
	rep(snip_i, n) cin >> b.at(snip_i);
	vector<int> c(n);
	rep(snip_i, n) cin >> c.at(snip_i);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	rep(i, n){
		int bb = b.at(i);
		// cerr << bb << " ";
		int cc = upper_bound(c.begin(), c.end(), bb) - c.begin();
		// cerr << cc << " ";
		cc = n - cc;
		int aa = lower_bound(a.begin(), a.end(), bb) - a.begin();
		// cerr << aa << endl;
		ans += (ll)aa * (ll)cc;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	int ans = 0;

	Rep(i, 1, n - 1) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
		else if (p[i - 1] > p[i] && p[i] > p[i + 1])ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// ref: https://drken1215.hatenablog.com/entry/2018/09/23/232100


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string S; cin >> S;
    string T; cin >> T;
    uint N=S.size();
    
    unordered_map<char, char> cnv_s2t('z'-'a'+1);
    unordered_map<char, char> cnv_t2s('z'-'a'+1);
    
    bool TF=true;
    for(uint i=0; i<N; ++i){
        char s = S[i];
        char t = T[i];
        
        auto itr_s = cnv_s2t.find(s);
        auto itr_t = cnv_t2s.find(t);
        if(itr_s!=cnv_s2t.end() && cnv_s2t[s]!=t){ TF=false; break; }
        if(itr_t!=cnv_t2s.end() && cnv_t2s[t]!=s){ TF=false; break; }
        cnv_s2t[s] = t;
        cnv_t2s[t] = s;
    }
    cout << (TF ? "Yes":"No") << endl;
    
    return 0;
}


Measured memory_bytes: 916
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    long long int n,k;
    cin>>n>>k;
    long long int cnt[100050]={0};
    for(int i=0;i<n;i++)
    {
        long long int a,b;
        cin>>a>>b;
        cnt[a]+=b;
    }
    for(int i=1;i<=100005;i++)
    {
        if(k-cnt[i]<=0)
        {
            cout<<i<<endl;
            return 0;
        }
        else
            k-=cnt[i];
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int d,e;

int main(void){
	while(1){	
		scanf("%d%d",&d,&e);
		if(d+e==0)break;
		double res=1e8;
		for(int i=0;i<=d;i++){
			double x=i;
			double y=d-i;
			res=min(res,fabs(sqrt(x*x+y*y)-e));
		}
		printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n;
   cin>>n;
   int t=log2(n);
   cout<<pow(2,t);



 return 0;
}








Measured memory_bytes: 4288
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int i,j,k;
  int mat[100][100]={{}};
  int ve[100]={};
  cin >> n >> m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> mat[i][j];
    }
  }
  for(j=0;j<m;j++) cin >> ve[j];
  for(i=0;i<n;i++){
    int x=0;
    for(j=0;j<m;j++) x+=mat[i][j]*ve[j];
    cout << x << endl;		       
  }
  
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  string s;cin>>s;
  cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[100000];
bool X[100000];
bool damn[100000];

int count(int x) {
  if (damn[x])return 0;
  int c = 0;
  for (int t : G[x]) {
    if (X[t])continue;
    if (damn[t]) return 0;
    c++;
  }
  return c;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  rep(_, 100) {
    vector<int> xs;
    rep(x, N) {
      if (damn[x]) continue;
      int c = 0;
      for (int t : G[x]) {
        if (damn[t]) {
          c = 0;
          break;
        }
        c += count(t) == 1;
      }
      if (c > 1) {
        cout << "First\n";
        return 0;
      }
      if (c == 1) {
        xs.pb(x);
        for (int t : G[x]) {
          if (damn[t]) continue;
          if (count(t) == 1) {
            damn[t] = true;
          }
        }
      }
    }
    for (int x :xs) X[x] = true;
    rep(x, N) {
      bool f = !damn[x];
      for (int t : G[x]) {
        if (!X[t] || damn[t]) f = false;
      }
      if (f) {
        cout << "First\n";
        return 0;
      }
    }
  }
  cout << "Second\n";
  return 0;
}


Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int n, s[4];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		if (c == 'P')s[0]++;
		if (c == 'W')s[1]++;
		if (c == 'G')s[2]++;
		if (c == 'Y')s[3]++;
	}

	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] > 0)ans++;
	}

	if (ans == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
(let ((a (read))
    (b (read))
    (ans 0))

    (loop for i from a to b do
        (if (= (floor (/ i 10000)) (rem i 10))
            (if (= (rem (floor (/ i 1000)) 10) (floor (/ (rem i 100) 10)))
                (incf ans)
            )
        )
    )
    (princ ans)
)

Measured memory_bytes: 31080
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int m[10];
	for (int i = 0; i < 10; i++)
		cin >> m[i];
	sort(m, m + 10);
	cout << m[9] << endl << m[8] << endl << m[7] << endl;
}


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


int main(){
    int n,k;
    cin >> n >> k;
    vector<bool> have(n,false);
    rep(i,k){
        int d; 
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            have[--a] = true;
        }
    }
  	int ans = 0;
    rep(i,n) if(have[i]==false) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int x = Integer.parseInt(sc.nextLine());
            System.out.println(x * x * x);
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
            return;
        }
    }
}



Measured memory_bytes: 26056
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    var ans = 1900 * M + 100 * (N - M)
    var m =  M
    while (m > 0) {
        ans *= 2
        m -= 1
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { Integer.parseInt(it) + d }
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 37872
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

B = []
for h in range(H):
    for w in range(W):
        if A[h][w] % 2 == 1:
            if w == W-1:
                if h != H-1:
                    B.append((h, w, h+1, w))
                    A[h+1][w] += 1
            else:
                B.append((h, w, h, w+1))
                A[h][w+1] += 1
print(len(B))
for b in B:
    print(' '.join([str(q+1) for q in b]))

Measured memory_bytes: 22640
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio
    ll t, i, j, n, x, sum=0;
    string s;
    cin>>s;
    for(i=0; i<s.size(); i++)
    {
        sum+=s[i]-48;
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}





Measured memory_bytes: 3764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

	REP(i,n+1) REP(j,m+1){
		int p = i * (m - j) + (n - i) * j;
		if (p == k){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;



    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int T,X;
    cin >> T >> X;
    cout << fixed << setprecision(14);
    cout << (double)T/X << endl;



}


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

int K,S;
int cnt = 0;

int main()
{
    scanf("%d%d",&K,&S);
    for(int i = 0; i <= K; i++)
    {
        for(int j = 0; j <= K; j++)
        {
            if(0 <= S - i - j && S - i - j <= K)cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
    rep(i, n){
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    rep(i, n){
        if((x[i + 1] + y[i + 1]) % 2 != t[i + 1] % 2){
            cout << "No" << endl;
            return 0;
        }
        if(t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define reps(i,a,b) for(long long int i=a;i<b;i++)
#define rep(i,a) for(long long int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;

long long int dp[55][55][3000];
int N,A;
long long int x[50];
const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

//再帰関数、下の方を先に計算させる感覚

ll dpp(int basho,int maisu,int gouke){
    if(basho>=N){
        if(gouke==maisu*A && maisu!=0){
        return 1;//一番下では１（？）
        }
        else{
            return 0;
        }
    }
    if (dp[basho][maisu][gouke] != -1){
        return dp[basho][maisu][gouke];
    }


    long long int yes = dpp(basho+1,maisu+1,gouke+x[basho]);
    long long int no = dpp(basho+1,maisu,gouke);

    dp[basho][maisu][gouke]= yes+no;
    
    return dp[basho][maisu][gouke];
}



int main(){
    cin>>N>>A;
    rep(i,N){
        cin>>x[i];
    }
    memset(dp, -1, sizeof(dp));//初期化

    cout<<dpp(0,0,0)<<endl;



    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

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

int32_t main() {
IOS;
int n,start=10000,end=0;
cin>>n;
    for (int i = 0; i < n; ++i) {
       int a;
       cin>>a;
        start=min(start,a);
        end=max(end,a);
    }
    cout<<end-start<<endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Problem Code
//
//  Created by Algo张伯威 on 2020/4/24.
//  Copyright © 2020 Algo张伯威. All rights reserved.
//

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <set>
using namespace std;

int nxt[200010][62];

int main() {
    int n;
    long long k;
    scanf("%d%lld", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &nxt[i][0]);
    }
    for(int i = 1; (1LL<<i) <= k; i++) {
        for(int j = 1; j <= n; j++) {
            nxt[j][i] = nxt[ nxt[j][i - 1] ][i - 1];
        }
    }
    int now = 0, ans = 1;
    while(k) {
        if((k & (1LL<<now)) > 0) {
            ans = nxt[ans][now];
            k ^= (1LL<<now);
        }
        now++;
    }
    printf("%d\n", ans);
    
    return 0;
}






















Measured memory_bytes: 52276
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x[101],y[101];
int main()
{
	scanf("%d%d%d%d",&n,&m,&x[0],&y[0]);
	for(int i=1;i<=n;++i) scanf("%d",&x[i]);
	for(int i=1;i<=m;++i) scanf("%d",&y[i]);
	sort(x,x+1+n);sort(y,y+1+m);
	if(x[n]<y[0]) printf("No War\n");
	else printf("War\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  int d = b - a;
  int l = 0;
  REP(i, d) l += i+1;
  cout << l-b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod=998244353;
const int N=2e5+10;
int a[N];
int f[N];
struct node{
    int s[2];
}T[N];
bool cmp(node t1,node t2){
    return t1.s[0]<t2.s[0];
}
int main()
{
    f[1]=1;
    f[2]=-1;
    a[1]=1;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;++i)cin>>T[i].s[0]>>T[i].s[1];
    // for(int i=1;i<=k;++i){
    //     cout<<T[i].s[0]<<' '<<T[i].s[1]<<endl;
    // }
    sort(T+1,T+k+1,cmp);
    for(int i=1;i<=n;++i){
        if(i>2)f[i]=(f[i-1]+a[i])%mod;
        else if(i==2)f[i]=a[i];
        // else if(i==2)f[2]=f[i-1]+f[i];
        for(int j=1;j<=k;++j){
            if(i+T[j].s[0]<=n)(a[i+T[j].s[0]]+=f[i])%=mod;
            if(i+T[j].s[1]+1<=n)(((a[i+T[j].s[1]+1]-=f[i])%=mod)+=mod)%=mod;
        }
    }
    // for(int i=1;i<=n;++i){
    //     cout<<f[i]<<' ';
    // }
    // cout<<endl;
    cout<<f[n]<<endl;
    // int sum=0;
    // for(int i=1;i<=n;i++)sum+=f[i];
    // cout<<sum<<endl;
}

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,n,b,ans=0;
    cin>>a>>n;
    while(n--)
    {
        cin>>b;
        ans+=b;
    }
    if(ans>a) cout<<"-1"<<endl;
    else cout<<a-ans<<endl;
}



Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int p[100005];
  int n; cin >> n;
  for(int i = 0; i < n; i++)cin >> p[i];
  sort(p, p+n);
  cout << p[n/2] - p[n/2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
#include<queue>
#define INF 999999

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100050];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int k = 1;
	int i = 0;
	int ope = 0;
	while (k <= n) {
		i = a[i]-1;
		if (i == 1) {
			ope++;
			break;
		}
		k++;
	}
	if (ope == 0)cout << -1 << endl;
	else cout << k << endl;
	return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] height = new int[n];
		for (int i = 0; i < n; i++) {
			height[i] = sc.nextInt();
		}

		int temp = 0;
		long totalStandHeight = 0;
		for (int i = 0; i < n; i++) {

			if (temp > height[i]) {
				totalStandHeight += temp - height[i];
			} else if (temp < height[i]) {
				temp = height[i];
			}

		}

		System.out.println(totalStandHeight);

		sc.close();

	}

}


Measured memory_bytes: 59472
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(long long i=0; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using namespace std;

int main(){
  int d,n;  cin >> d >> n;
  if(n == 100){
      cout << (int)pow(100,d)*(n+1);
  }else{
    cout << (int)pow(100,d)*(n);
  }
  
}


Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    int H, W;
    cin >> H >> W;
    vs S(H + 2);
    rep(i, H) {
        cin >> S[i + 1];
        S[i + 1] += '.';
        S[i + 1] = '.' + S[i + 1];
    }
    rep(i, W + 2) {
        S[0] += '.';
        S[H + 1] += '.';
    }

    vs ans(H);
    repp(i, H) {
        repp(j, W) {
            if (S[i][j] == '#') ans[i - 1] += '#';
            else {
                int count = 0;
                if (S[i - 1][j - 1] == '#') count++;
                if (S[i - 1][j] == '#') count++;
                if (S[i - 1][j + 1] == '#') count++;
                if (S[i][j - 1] == '#') count++;
                if (S[i][j + 1] == '#') count++;
                if (S[i + 1][j - 1] == '#') count++;
                if (S[i + 1][j] == '#') count++;
                if (S[i + 1][j + 1] == '#') count++;
                string c = to_string(count);
                ans[i - 1] += c;
            }
        }
    }
    for (string s : ans) cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    
    set<char> C;
    rep(i, S.size()) C.insert(S[i]);
    for (char x = 'a'; x <= 'z'; ++x) {
        if (!C.count(x)) {
            cout << x << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int num = stoi(a);
    bool flag = false;
    for(int i = 1; i * i <= num; i++) if(i * i == num) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
def resolve():
    from collections import deque
    n, Q = [int(i) for i in input().split()]
    ans = [deque() for _ in range(n)]
    for _ in range(Q):
        q = [int(i) for i in input().split()]
        if q[0] == 0:
            ans[q[1]].append(q[2])
        elif q[0] == 1:
            if len(ans[q[1]]) > 0:
                print(ans[q[1]][-1])
        else:
            if len(ans[q[1]]) > 0:
                ans[q[1]].pop()


resolve()



Measured memory_bytes: 14540
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 200005;
template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, par[N], x[N], fa[N];
long long ans = 0ll;
struct node {
	int rt;
	int one, total;
	bool operator < (node rhs) const {
		if (1ll * one * rhs.total < 1ll * total * rhs.one) return true;
		else if (1ll * one * rhs.total > 1ll * total * rhs.one) return false;
		else return rt < rhs.rt;
	}
} vec[N];
multiset<node> s;

int findroot (int x) {
	return fa[x] == x ? x : fa[x] = findroot(fa[x]);
}

int main () {
	read(n), par[1] = 0;
	for (int i = 2; i <= n; i++) read(par[i]);
	for (int i = 1; i <= n; i++) {
		read(x[i]), fa[i] = i;
		vec[i].rt = i, vec[i].one = x[i];
		vec[i].total = 1, s.insert(vec[i]);
	}

	while (!s.empty()) {
		node u = *s.begin();
		s.erase(u);
		if (par[u.rt]) {
			node v = vec[findroot(par[u.rt])];
			fa[u.rt] = par[u.rt];
			ans += 1ll * v.one * (u.total - u.one);
			node w = {v.rt, u.one + v.one, u.total + v.total};
			s.erase(v), s.insert(vec[v.rt] = w);
		}
	}

	write(ans), putchar('\n');
	return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<4;i++)
  {
    if(s[i]=='-')
      ans--;
    else
      ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3640
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  int C[N-1],S[N-1],F[N-1];
  for(int i = 0; i < N-1; i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  int Ans;
  for(int i = 0; i < N-1; i++){
    Ans = S[i];
    for(int j = i; j < N-2; j++){
      Ans += C[j];
      if(Ans>=S[j+1]){
        if(Ans%F[j+1]!=0) Ans += F[j+1]-Ans%F[j+1];
      }else Ans = S[j+1];
    }
    Ans += C[N-2];
    printf("%d\n",Ans);
  }
  printf("0\n");
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int m = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static int[] arr;
    static string s = "";
    static string[] ss;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static long Max(long a, long b)
    {
        return Math.Max(a, b);
    }
    static long Min(long a, long b)
    {
        return Math.Min(a, b);
    }
    static long Abs(long a)
    {
        return Math.Abs(a);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        ss = rls();
        string s1 = ss[0];
        string s2 = ss[1];

        for (int i = 0; i < n; i++)
        {
            s += s1[i].ToString() + s2[i].ToString();
        }

        wl(s);
    }


}



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

typedef long long ll;

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{
	int a= 0,b= 0;
	
	scanf("%d %d",&a,&b);
	
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	
	return(0);

}

Measured memory_bytes: 580
from collections import defaultdict
N, M = map(int, input().split())
wa = defaultdict(int)
ac = {}
for i in range(M):
    p, S = input().split()
    if S == 'AC':        
        ac[p] = True
    else:
        if p not in ac:
            wa[p] += 1
print(len(ac), sum([wa[x] for x in ac.keys()]))

Measured memory_bytes: 30544
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  map<char, ll> dic{{'M', 1}, {'A', 2}, {'R', 3}, {'C', 4}, {'H', 5}};
  ll cnt[6]={};
  for(i=0; i<N; i++) {
    string s;
    cin >> s;
    cnt[dic[s[0]]]++;
  }
  
  ll ans=0;
  for(i=1; i<=5; i++) {
    for(j=i+1; j<=5; j++) {
      for(k=j+1; k<=5; k++) {
        ans+=cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  
  pt(ans);
  
}
 
 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long int N,A,B;
  cin >> N >> A >> B;
  long int NR = N/(A+B);
  long int NE = N%(A+B);
  long int ans = A*NR;
  if(A > NE) ans += NE;
  else ans += A;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n; cin >> n;
	map<int, int> mp1;
	map<int, int> mp2;
	REP(i,n) {
		int v; cin >> v;
		if (i % 2 == 0) mp1[v] += 1;
		else mp2[v] += 1;
	}
	priority_queue<pair<int, int>> pq1;
	priority_queue<pair<int, int>> pq2;
	for (auto p : mp1) {
		pq1.push(make_pair(p.second, p.first));
	}
	for (auto p : mp2) {
		pq2.push(make_pair(p.second, p.first));
	}
	auto _max1 = pq1.top(); pq1.pop();
	auto _max2 = pq2.top(); pq2.pop();
	int _max1_2 = pq1.size() == 0 ? 0 : pq1.top().first;
	int _max2_2 = pq2.size() == 0 ? 0 : pq2.top().first;
	if (_max1.second == _max2.second) {
		int tmp = n - _max1.first - _max2_2;
		tmp = min(tmp, n - _max1_2 - _max2.first);
		cout << tmp << endl;
	} else {
		cout << n - _max1.first - _max2.first << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 6140
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)

using namespace std;

typedef long long LL;
const int N = 100010;

int t[N * 8];
int num = 0;
void build(int x, int l, int r)
{
	t[x] = 2e9;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r);
}
void modify(int x, int l, int r, int a, int b, int c)
{
	if (a > b) return;
	if (a <= l && r <= b){ t[x] = c; return;}
	int mid = (l + r) >> 1;
	if (a <= mid) modify(x << 1, l, mid, a, b, c);
	if (b > mid) modify(x << 1 | 1, mid + 1, r, a, b, c);
}
int query(int x, int l, int r, int a)
{
	int ret = t[x];
	if (l == r) return ret;
	int mid = (l + r) >> 1;
	if (a <= mid) ret = min(ret, query(x << 1, l, mid, a));
	else ret = min(ret, query(x << 1 | 1, mid + 1, r, a));
	return ret;
}

int b[N], cnt;
LL L[N], R[N], s[N], f[N], a[N], h[N];
int main()
{
	
	int n, k;
	scanf("%d%d", &n, &k);
	Rep(i, n) scanf("%lld%d", &a[i], &b[i]);
	Rep(i, n){
		if (b[i] == 1 && a[i] * 2 > k) { printf("-1\n"); return 0;}
		a[i] += a[i - 1], s[i] = a[i] % k;
		if (b[i] == 1){
			L[i] = ((-s[i - 1] * 2) % k + k) % k, h[++ cnt] = L[i];
			R[i] = ((-s[i] * 2) % k + k) % k, h[++ cnt] = R[i];
		}
	}
	h[++ cnt] = 0, h[++ cnt] = k - 1;
	sort(h + 1, h + 1 + cnt);
	cnt = unique(h + 1, h + 1 + cnt) - h - 1;
	Rep(i, n) if (b[i] == 1) {
		L[i] = lower_bound(h + 1, h + 1 + cnt, L[i]) - h;
		R[i] = lower_bound(h + 1, h + 1 + cnt, R[i]) - h;
	}
	build(1, 1, cnt);//printf("%d\n", cnt);
	for (int i = n; i; i --) if (b[i] == 1) {
		int tmp = query(1, 1, cnt, L[i]);
		if (tmp != 2e9) f[i] = f[tmp] + (h[L[tmp]] - h[L[i]] + k) % k;
		else f[i] = 0;
		if (L[i] <= R[i]){
			modify(1, 1, cnt, 1, L[i] - 1, i);
			modify(1, 1, cnt, R[i] + 1, cnt, i);
		}
		else modify(1, 1, cnt, R[i] + 1, L[i] - 1, i);
	}
	LL ans = 1e18;
	Rep(i, n) if (b[i] == 1){
		int tmp = query(1, 1, cnt, L[i]);
		if (tmp != 2e9) ans = min(ans, f[tmp] + (h[L[tmp]] - h[L[i]] + k) % k); 
		else ans = 0;
		tmp = query(1, 1, cnt, R[i]);
		if (tmp != 2e9) ans = min(ans, f[tmp] + (h[L[tmp]] - h[R[i]] + k) % k);
		else ans = 0;
	}
	
	printf("%lld\n", ans + a[n] * 2);
	
	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

vector<long> dp(10000);

int main () {
    int n;
    cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i++ ) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    printf("%ld\n", dp[n]);
}



Measured memory_bytes: 3296
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S; cin >> S;
    int N = S.size();
    int subN = N - 7;
    if(subN < 0){
        cout << "NO" << endl;
        return 0;
    }
    for(int i = 0; i < N-subN+1; i++){
        string first = S.substr(0, i);
        string middle = S.substr(i, subN);
        string last = S.substr(i+subN);
        string ans = first + last;
        //cout << ans << endl;
        if(ans == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL l;
    LL r;
    LL d;
    LL ans=0;
    cin >> l >> r >> d;
    for(LL i=l; i<=r; i++){
        if(i%d==0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
function main(input) {
  const inputs = input.trim().split('\n')
  const [N, M] = inputs[0].split(' ')
  const H = [0, ...inputs[1].split(' ')].map(Number)
  const path = []
  inputs.slice(2).forEach(e => {
    // console.log('e', e)
    const [A, B] = e.split(' ')
    if (!path[A]) {
      path[A] = []
    }
    path[A].push(B)
    if (!path[B]) {
      path[B] = []
    }
    path[B].push(A)
  })
  // console.log(path)

  let good = 0
  for(let i = 1; i <= N; i++) {
    let isGood = true
    if (!path[i]) {
      good++
      continue
    }
    for(const e of path[i]) {
      // console.log(i, H[i], e, H[e])
      if (H[e] >= H[i]) {
        isGood = false
        // console.log('not good')
        break
      }
    }
    if (isGood) good++
  }
  console.log(good)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 97864
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;


public class Main {

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

		int n = 9;
		char[] s = new char[n];
		for (int i = 0; i < n; i++) {
			s[i] = (char)('0' + sc.nextInt());
		}
		
		String ans = "123456780";
		int[] d = {-3, 3, -1, 1};
		
		HashMap<String, Integer> hm = new HashMap<String, Integer>();
		
		Queue<String> q = new ArrayDeque<String>();
		q.add(toString(s));
		hm.put(toString(s), 0);

		while (!q.isEmpty()) {
			String u = q.remove();
			if (u.equals(ans)) {
				System.out.println(hm.get(u));
				break;
			}
			
			StringBuffer str = new StringBuffer(u);
			int zero = str.indexOf("0");
			assert (zero != -1);
			for (int i = 0; i < d.length; i++) {
				if (zero + d[i] >= 0 && zero + d[i] < n && !(d[i] == -1 && (zero + d[i]) % 3 == 2) && !(d[i] == 1 && (zero + d[i]) % 3 == 0)) {
					str.setCharAt(zero, str.charAt(zero + d[i]));
					str.setCharAt(zero + d[i], '0');
					if (!hm.containsKey(str.toString())) {
						q.add(str.toString());
						hm.put(str.toString(), hm.get(u) + 1);
					}
					str.setCharAt(zero + d[i], str.charAt(zero));
					str.setCharAt(zero, '0');
				}
			}
		}

        sc.close();
	}
	
	private static String toString(char[] s) {
		String ret = "";
		for (int i = 0; i < s.length; i++) {
			ret += s[i];
		}
		
		return ret;
	}
}

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

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

    int n = s.size();

    int a;
    rep(i, n) {
        if(s[i] == 'A') {
          a = i;
          break;
        }
    }

    int b;
    for(int i = n-1; i >= 0; i--) {
        if(s[i] == 'Z') {
          b = i;
          break;
        }
    }
  
    cout << b-a+1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main()
{
  int T, C;
  vector<pair<int, int> > v;
  while (scanf("%d,%d ", &T, &C) == 2) {
    if (T == 0 && C == 0) {break;}
    v.push_back(make_pair(C, T - 1));
  }
  sort(v.begin(), v.end(), greater<pair<int, int> >());
  map<int, int> lank;
  
  lank[v[0].second] = 1;
  int l = 1;
  for (int i = 1; i < v.size(); i++) {
    //printf("%d,%d\n", v[i].second, v[i].first);
    for (;v[i].first == v[i - 1].first && i < v.size() ;i++) {
      lank[v[i].second] = l;
    }
    if (i < v.size()) {
      lank[v[i].second] = ++l;
    }
  }

  int N;
  while (scanf("%d ", &N) == 1) {
    printf("%d\n", lank[N - 1]);
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
plus,minus=[],[]
n=int(input())
m=10**9
for i in input().split():
    a = int(i)
    m=min(m,abs(a))
    if a>0:
        plus.append(a)
    else:
        minus.append(a)
if len(minus)%2==0:
    print(sum(plus)-sum(minus))
else:
    print(sum(plus)-sum(minus)-2*m)

Measured memory_bytes: 14956