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

using namespace std;

ll n,a,b,c,d;

int main()
{
          //freopen("INPUT.txt","r",stdin);
          cin>>n>>a>>b>>c>>d;
          n--;
          b-=a;
          if(b<0)
                    b*=-1;

          if(d*n<b)
          {
                    cout<<"NO";
                    return 0;
          }

          ll dif=(d-c);
          if(2*c-(n-1)*dif<=0)
          {
                    cout<<"YES";
                    return 0;
          }

          if(n%2==1)
          {
                   ll p=2*c-(n-1)*dif;
                   ll seg=n*dif;
                   b-=p/2;
                   if(b<0)
                   {
                             cout<<"NO";
                             return 0;
                   }
                   if(b%(p+seg)<=seg)
                              cout<<"YES";
                   else
                              cout<<"NO";
          }
          else
          {
                    ll p=2*c-(n-1)*dif;
                    ll seg=n*dif;
                    b-=seg/2;
                    if(b<=0)
                    {
                              cout<<"YES";
                              return 0;
                    }
                    if(b%(seg+p)<p && b%(seg+p))
                              cout<<"NO";
                    else
                              cout<<"YES";
          }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int x,y;
	cin>>x>>y;
	if((y&1)==0&&x*4>=y&&x*2<=y){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, A, B, C, D = rl()
# N-1回を+の回数と-の回数ずつに区切る
bool = False
diff = B - A
for i in range(N):
    j = N-1-i
    #iが+, jが-
    if C*i-D*j <= diff <= D*i-C*j:
        bool = True
        break

print('YES' if bool else 'NO')
# 22

Measured memory_bytes: 12500
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll x,a;
  cin>>x>>a;
  if(x<a) COUT(0);
  else COUT(10);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,S,T;

	scanf("%d %d %d %d",&a,&b,&c,&d);// A???????????????
	
	scanf("%d %d %d %d",&e,&f,&g,&h);// B???????????????

	S=a+b+c+d;

	T=e+f+g+h;

	if(S>T){
	printf("%d\n",S);
	}

	else{
	printf("%d\n",T);
	}

	return 0;
}

Measured memory_bytes: 1800
# -*- coding: utf-8 -*-
import sys

def inpl(): return tuple(map(int, input().split()))

def ismale(S):
    if S == "Male":
        return 1
    elif S == "Female":
        return 0
    else:
        exit()

N = int(input())
print(0)
sys.stdout.flush()

c0 = ismale(input())
w = c0

C = [0 for _ in range(N)]

L = 0
R = N - 1
post = (R + L)//2
while True:
    print(post)
    sys.stdout.flush()
    
    if post % 2 == 1:
        c = ismale(input())
        if c != w:
            L = post + 1
        else:
            R = post - 1
    else:
        c = ismale(input())
        if c != w:
            R = post
        else:
            L = post

    if R - L == 2:
        print((R+L+1)//2)
        sys.stdout.flush()
        c = ismale(input())
        print(R)
        sys.stdout.flush()
        c = ismale(input())
        print(L)
        sys.stdout.flush()
        c = ismale(input())
    else:
        post = (R + L)//2

Measured memory_bytes: 4588
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

fl = [True]*N
for i in range(M):
    fl[a[i]] = False
dp = [0]*(N+1)
dp[0] = 1

for i in range(1,N+1):
    if i>0 and fl[i-1]:
        dp[i] += dp[i-1]%MOD
    if i>1 and fl[i-2]:
        dp[i] += dp[i-2]%MOD
print(dp[N]%MOD)

Measured memory_bytes: 9588
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{
    int A, B;
    scanf("%d %d", &A, &B);
    int add, sub, mul;
    add = A + B;
    sub = A - B;
    mul = A * B;
    int max = add;
    if (max < sub)
    {
        max = sub;
    }
    if (max < mul)
    {
        max = mul;
    }
    printf("%d", max);
    return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int X;

    cin >> X;

    for(int i = 1; i <= X; i ++){
        if((360 * i) % X == 0){
            cout << 360 * i / X << endl;

            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	cout<<(n+m-1)/m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
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;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, 3) ans += S[i] == T[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define bigint int64_t
#define mod 1000000007
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))

using namespace std;
ll dp[1000+5][1000+5],n,m;char a[1000+5][1000+5];
ll f(ll i,ll j){
if(i==n-1&&j==m-1){
    return 1;
}
if(dp[i][j]!=-1)return dp[i][j];
ll x=0,y=0;
if(j+1<m&&a[i][j+1]=='.')
    x=f(i,j+1);
if(i+1<n&&a[i+1][j]=='.')
y=f(i+1,j);
return dp[i][j]=(x+y)%mod;
}
int main(){
cin>>n>>m;
forab(i,0,n-1,1){
forab(j,0,m-1,1){
cin>>a[i][j];
}
}
forab(i,0,n-1,1)
forab(j,0,m-1,1)dp[i][j]=-1;
cout<<f(0,0);
}

Measured memory_bytes: 9088
def main():
    s=input()
    t=input()
    n=len(s)
    m=len(t)
    memo=[[n+m for _ in [0]*(m+1)] for _ in [0]*(n+1)]
    memo[0][0]=0
    
    for i in range(n+m):
        for j in range(i+1):
            k=i-j
            if 0<=j<n and 0<=k<m:
                if s[j]==t[k]:
                    memo[j+1][k+1]=min(memo[j+1][k+1],memo[j][k])
                else:
                    memo[j+1][k]=min(memo[j+1][k],memo[j][k]+1)
                    memo[j][k+1]=min(memo[j][k+1],memo[j][k]+1)
                    memo[j+1][k+1]=min(memo[j+1][k+1],memo[j][k]+1)
            elif j==n:
                memo[j][k+1]=min(memo[j][k+1],memo[j][k]+1)
            elif k==m:
                memo[j+1][k]=min(memo[j+1][k],memo[j][k]+1)
    print(memo[n][m])
                
if __name__ == '__main__':
    main()


Measured memory_bytes: 46212
s = input()
rock = 0
ans = 0
for i in s:
    if i == 'g':
        if rock:
            rock -=1
            ans += 1
        else:
            rock += 1
    else:
        if rock:
            rock-=1
        else:
            rock+= 1
            ans -= 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

signed main() {
    const int MAX = 1e5 + 5;
    auto prime = prime_table(MAX);
    set<int> ans;
    for (int i = 2; i <= MAX; i++) {
        if (prime[i] && prime[(i + 1) / 2]) ans.insert(i);
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << distance(ans.lower_bound(l), ans.upper_bound(r)) << endl;
    }
}


Measured memory_bytes: 640
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let a = get!(String);
    let b = get!(String);
    if a.len() > b.len() {
        println!("GREATER");
    } else if b.len() > a.len() {
        println!("LESS");
    } else if a > b {
        println!("GREATER");
    } else if b > a {
        println!("LESS");
    } else {
        println!("EQUAL");
    }
}

Measured memory_bytes: 4352
h,w = map(int,input().split())
tate = [[0]*w for i in range(h)]
yoko = [[0]*w for i in range(h)]
s = [str(input()) for i in range(h)]

for i in range(h):
    cnt = 0
    now = 0
    for j in range(w):
        if s[i][j] == ".":
            cnt += 1
        else:
            for k in range(now,j+1):
                yoko[i][k] = cnt
            cnt = 0
            now = j+1
    for k in range(now,j+1):
        yoko[i][k] = cnt
for i in range(w):
    cnt = 0
    now = 0
    for j in range(h):
        if s[j][i] == ".":
            cnt += 1
        else:
            for k in range(now,j):
                tate[k][i] = cnt
            cnt = 0
            now = j+1
    for k in range(now,j+1):
        tate[k][i] = cnt
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans,tate[i][j]+yoko[i][j]-1)
print(ans)

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/

using namespace std;
typedef long long int ll;
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);
#else
// online submission
#endif
	string res="ABC";
	string s;
	cin>>s;
	if(s==res){
		res="ARC";
	}
	cout<<res;


}

Measured memory_bytes: 3612
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import heapq

n, m = map(int, readline().split())
ab = [[] for _ in range(10 ** 5 + 1)]
for _ in range(n):
    a, b = map(int, readline().split())
    ab[a - 1].append(-b)
ans = 0
q = []
for mm in range(m):
    while ab[mm]:
        heapq.heappush(q, ab[mm].pop())
    if q:
        ans += heapq.heappop(q)
print(-ans)


Measured memory_bytes: 17836
using System;
using System.Linq;

namespace ALDS1_4_DAllocation
{
	class Program
	{
		static void Main ( string[] args )
		{
			var result = Solve ();
			Console.WriteLine (result);
		}

		static long Solve ()
		{
			//input
			int[] inputNum = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
			
			int baggageCount = inputNum[0];
			int trackCount = inputNum[1];

			long[] baggage = new long[baggageCount];

			for (int lp = 0; lp < baggageCount; lp++)
			{
				baggage[lp] = long.Parse (Console.ReadLine ());
			}

			//process
			long left = 0;
			long right = baggageCount * 10000;
			long middle;

			while (1 < right - left)
			{
				middle = (left + right) / 2;

				int capacity = Check (middle, baggageCount, trackCount, baggage);

				if (baggageCount <= capacity)
				{
					right = middle;
				}
				else
				{
					left = middle;
				}
			}

			return right;
		}

		static int Check ( long capacity, int maxCapacity, int trackCount, long[] baggage )
		{
			int count = 0;

			for (int lp = 0; lp < trackCount; lp++)
			{
				long s = 0;

				while (s + baggage[count] <= capacity)
				{
					s += baggage[count];
					count++;

					if (count == maxCapacity)
					{
						return maxCapacity;
					}
				}
			}

			return count;
		}
	}
}

Measured memory_bytes: 11300
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long n,k, ans=0;

	cin >> n >> k;

	vector<long long> h(n);

	for (long long i = 0; i < n; i++)
		cin >> h[i];

	if (k >= h.size())
	{
		ans = 0;
	}
	else
	{
		sort(h.begin(), h.end());

		for (long long i = 0; i < k; i++)
			h.pop_back();

		for (long long i = 0; i < h.size(); i++)
		{
			ans += h[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		boolean[][] adj = new boolean[n][n];
		
		for(int i = 0; i < n; i++){
			final int u = sc.nextInt() - 1;
			final int k = sc.nextInt();
			
			for(int j = 0; j < k; j++){
				final int v = sc.nextInt() - 1;
				
				adj[u][v] = true;
			}
		}
		
		LinkedList<Integer> node_queue = new LinkedList<Integer>();
		node_queue.add(0);
		int[] times = new int[n];
		Arrays.fill(times, Integer.MAX_VALUE);
		times[0] = 0;
		
		while(!node_queue.isEmpty()){
			final int node = node_queue.poll();
			
			for(int next = 0; next < n; next++){
				if(!adj[node][next]){
					continue;
				}else if(times[next] <= times[node] + 1){
					continue;
				}
				
				times[next] = times[node] + 1;
				node_queue.add(next);
			}
		}
		
		
		
		for(int i = 0; i < n; i++){
			System.out.println((i + 1) + " " + (times[i] == Integer.MAX_VALUE ? "-1" : times[i]));
		}
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}

}

Measured memory_bytes: 16932
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  int n,a[100000];
  vector<int> v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    if(i==0||a[i]==a[i-1]) v.push_back(i);
  }
  v.push_back(n);
  int ans = 0;
  for(int i=0;i+1<v.size();i++){
    ans = max(ans,v[i+1]-v[i]);
    if(i+2<v.size()) ans = max(ans,v[i+2]-v[i]);
    if(i+3<v.size()) ans = max(ans,v[i+3]-v[i]);
  }
  printf("%d\n",ans);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, n) for (int i = 1; i <= (int)n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back

const int INF = 1e9;

int main() {
	string t;
	cin >> t;
	int n = t.size();
	rep(i, n) if(t[i]=='?') t[i]='D';
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int p = x / 500 * 1000;
        x = x % 500;
        p += x / 5 * 5;
        System.out.println(p);
    }
}

Measured memory_bytes: 35676
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') c++;
  }
  int c2 = 0;
  for (int i = 0; i < c; i++) {
    if (s[i] == 'R') c2++;
  }
  int ans = min(c - c2, n - c);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N,M,K;
int X[110],L[110],F[110],D[110],UD[110];
double m1[110],m2[110];
double V[110];
double T[110],nxtT[110];

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

  while(1){
    cin>>N>>M>>K;
    if(N==0)break;
    repl(i,1,N+1){
      cin>>X[i]>>L[i]>>F[i]>>D[i]>>UD[i];
      if(UD[i]==0){
        m1[i]=(double)L[i]/(double)D[i];
        m2[i]=(double)L[i]/(double)F[i];
      }else{
        m1[i]=(double)L[i]/(double)F[i];
        m2[i]=(double)L[i]/(double)D[i];
      }
    }
    X[N+1]=K; F[N+1]=D[N+1]=1; L[N+1]=0; UD[N+1]=0;
    m1[N+1]=m2[N+1]=0;

    rep(i,M)cin>>V[i];
    rep(i,M){
      T[i]=(double)i/V[i];
      rep(j,i)maxch(T[i],(double)i/V[j]);
    }

    rep(i,N+1){
      double d=X[i+1]-X[i];
      if(UD[i+1]==0){
        nxtT[0]=T[0]+d/V[0]+m2[i+1];
      }else{
        nxtT[0]=max(T[0]+d/V[0],m1[i+1])+m2[i+1];
      }
      repl(j,1,M){
        double tmp=0;
        rep(k,j)maxch(tmp,nxtT[k]+(double)(j-k)/V[k]);
        nxtT[j]=max({T[j]+d/V[j],nxtT[j-1]+m1[i+1],tmp})+m2[i+1];
      }
      memcpy(T,nxtT,sizeof(T));
    }
    printf("%.10f\n", T[M-1]);
  }
  return 0;
}



Measured memory_bytes: 3152
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long now = 100;
        int ans = 0;

        while(x > now){
            now += now/100L;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35776
N,L=map(int,input().split())
ls=[]
total=0
for i in range(1,N+1):
    total+=L+i-1
    v=abs(L+i-1)
    ls.append(v)
    x=min(ls)
    if L+i-1>=0:
        x=x
    else:x=-x
total=total-x
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll either = 0;
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    if (i > 1) {
      either ^= A.at(i);
    }
    else {
      sum += A.at(i);
    }
  }
  ll both = sum - either;
  if (both % 2 == 1 || both >= A.at(0) * 2 + 1) {
    cout << -1 << "\n";
    return 0;
  }
  both /= 2;
  if (either & both) {
    cout << -1 << "\n";
    return 0;
  }
  bitset<40> bs1(either);
  ll ans_small = 0;
  for (ll i = 40; i >= 0; --i) {
    if (bs1[i] == 1) {
      if (ans_small + pow(2, i) + both <= A.at(0)) {
        ans_small += pow(2, i);
      }
    }
  }
  if (both + ans_small == 0) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = A.at(0) - (both + ans_small);
  cout << ans << "\n";
}


Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int min=999;
    int temp=0;
    int fav=753;
    for(int i=0;i<s.length()-2;i++){
        int a=100*(s[i]-48)+10*(s[i+1]-48)+(s[i+2]-48);
        int def=abs(a-fav);
        if(min>def){
            min=def;
            temp=a;
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const num inf = 0x7f7f7f7f7f7f;

int n;
num a[200005], dp[200005][5], ans = inf;

int main() {
    memset(dp, inf, sizeof(dp));
    cin >> n;
    cont (i, n) {
        cin >> a[i];
    }
    dp[0][0] = 0;
    cont (i, n) {
        circ (j, 0, 4) {
            circ (k, 0, j) {
                if (j == 0 || j == 4) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][k] + a[i]);
                } else if (j == 1 || j == 3) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][k] + (a[i] > 0 ? a[i] % 2 : 2));
                } else {
                    dp[i][j] = min(dp[i][j], dp[i - 1][k] + (a[i] + 1) % 2);
                }
            }
        }
    }
    ans = min(ans, dp[n][0]);
    ans = min(ans, dp[n][1]);
    ans = min(ans, dp[n][2]);
    ans = min(ans, dp[n][3]);
    ans = min(ans, dp[n][4]);
    cout << ans << endl;
}


Measured memory_bytes: 9728
def main():
    n=int(input())
    ga,sa,ba=map(int,input().split())
    gb,sb,bb=map(int,input().split())
    
    def calc_1(dg,a0,a1):
        return (dg//a0)*a1+dg%a0

    def calc_2(dg,a0,a1,b0,b1):
        x=dg//a0
        visit=set()
        temp=0
        for i in range(x,-1,-1):
            amari=(dg-i*a0)%b0
            if amari in visit:
                break
            temp=max(i*a1+((dg-i*a0)//b0)*b1+amari,temp)
            visit.add(amari)
        return temp

    def calc_3(dg,a0,a1,b0,b1,c0,c1):
        return max([a1*i+calc_2(dg-a0*i,b0,b1,c0,c1) for i in range(dg//a0,-1,-1)])

    gsb=[[ga,gb],[sa,sb],[ba,bb]]
    gsb.sort(key=lambda x:x[1]/x[0],reverse=True)
    temp=[[i,j] for i,j in gsb if i<j]
    if len(temp)==1:
        n=calc_1(n,temp[0][0],temp[0][1])
    elif len(temp)==2:
        n=calc_2(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1])
    elif len(temp)==3:
        n=calc_3(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1],temp[2][0],temp[2][1])

    gsb=reversed(gsb)
    temp=[[j,i] for i,j in gsb if i>j]
    if len(temp)==1:
        n=calc_1(n,temp[0][0],temp[0][1])
    elif len(temp)==2:
        n=calc_2(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1])
    elif len(temp)==3:
        n=calc_3(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1],temp[2][0],temp[2][1])
    print(n)
main()

Measured memory_bytes: 39920
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,K = LI()
    A = LI()

    c = 0
    d = collections.Counter()
    d[0] = 1
    ans = 0
    r = [0] * (N+1)
    for i,x in enumerate(A):
        if i >= K-1:
            d[r[i-(K-1)]] -= 1
        c = (c + x - 1) % K
        ans += d[c]
        d[c] += 1
        r[i+1] = c

    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<pair<ll,ll>> x(n);
    for(ll i=0; i<n; i++)
        cin >> x[i].first, x[i].first--, x[i].second = i+1;
    sort(x.begin(), x.end());

    vector<ll> res(n*n);
    for(ll i=0; i<n; i++)
        res[x[i].first] = x[i].second;

    queue<ll> www;
    queue<ll> q;

    vector<ll> rem(n+1);
    for(ll i=0; i<n; i++)
        rem[i+1] = i;
    for(ll i=0; i<n; i++)
        for(ll k=0; k<x[i].second-1; k++)
            q.push(x[i].second);

    for(ll i=0; i<n*n; i++) {
        if(res[i] > 0) {
            if(rem[res[i]]) {
                cout << "No" << endl;
                return 0;
            }
            for(ll k=0; k<n-res[i]; k++)
                www.push(res[i]);
        } else {
            if(!q.empty()) {
                res[i] = q.front(); q.pop();
                rem[res[i]]--;
            } else if (!www.empty()) {
                res[i] = www.front(); www.pop();
            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    for(auto &e: res) cout << e << ' ';
    cout << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int k, x;
	cin >> k >> x;
	rep(i, 2 * k - 1) {
		cout << x - k + 1 + i;
		if (i != 2 * k - 1)cout << " ";
	}

	cout << endl;

}

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

using namespace std;
int main() {
	int N;
	cin >> N;
	int d1[N];
	int d2[N];
	int r = 0;
	for (int i = 0; i < N; i++) {
		cin >> d1[i];
		cin >> d2[i];
		if (d1[i] == d2[i]) {
			r++;
			if (r == 3) {
				cout << "Yes" << endl;
				break;
			}
		} else {
			r = 0;
		}
	}
	if (r != 3) {
		cout << "No" << endl;
	}
}


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

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

using namespace std;

int main(void)
{
    const int N_MAX = 2000;
    const int A_MAX = 2000;
    int N;
    int S_all = 0;
    bitset<N_MAX * A_MAX + 1> b(1);
    cin >> N;
    REP(i, N) {
        int A;
        cin >> A;
        S_all += A;
        b |= b << A;
    }
    FOR(i, (S_all + 1) / 2, S_all + 1) {
        if (b[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
using System;

namespace Getting_Started
{
    class Rectangle
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] token = line.Split(' ');
            int a = int.Parse(token[0]);
            int b = int.Parse(token[1]);
            Console.WriteLine(a*b+" "+(2*a+2*b));
        }
    }
}

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;

ll T, n, a[205], res;
string s;
vector<ll> vt;
int main() {
	ll i, t;
	cin >> T;
	while(T--) {
		cin >> n;
		for(i=0; i<n; i++) cin >> a[i];
		cin >> s;
		res = 0;
		vt.clear();
		for(i=n-1; i>=0; i--) {
			if(s[i]=='0') {
				t = a[i];
				for(auto x:vt) t = min(t, t^x);
				if(t) vt.push_back(t);
			} else {
				t = a[i];
				for(auto x:vt) t = min(t, t^x);
				if(t) {res=1; break;}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, m: usize,
    }

    let mut ans = 0;
    if n > 0 {
        ans += n * (n - 1) / 2;
    }
    if m > 0 {
        ans += m * (m - 1) / 2;
    }
    println!("{}", ans);
}


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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define pll std::pair<ll, ll> 
#define ppll std::pair<ll, pll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::map<ll, ll> 
#define mpll std::map<pll, ll>
#define mppll std::map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1e9+7
#define maxlong 1e18+5


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/


int main()
{

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

	#ifdef PARTH_LATHIYA_HOME

		freopen("C_in.txt","r",stdin);
	
		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

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

	// std::vector<int> v[100];
	// std::vector<int> temp(100,4);
	// rep(i,0,100)
	// 	v[i] = temp;

	s(n);
	s(m);
	mpll mm;
	ll a,b;
	re(i,m)
	{
		cin>>a>>b;
		mm[{a,b}]=1;
	}
	int f=0;
	rep(i,2,n)
	{
		if(mm[{1,i}] && mm[{i,n}]){f=1;break;}
	}
	if(f)
		cout<<"POSSIBLE";
	// /poss
	else
		cout<<"IMPOSSIBLE";
		// imposs


//--------------------------------------------------------------------------------------
	
	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

Measured memory_bytes: 25216
import bisect

n = int(input())
aa = list(map(int,input().split()))

aa.sort()

a = [aa[0]]
b = [1]

for i in range(1,n):
    if a[-1]==aa[i]:
        b[-1]+=1
    else:
        a.append(aa[i])
        b.append(1)

ans = 0

for i in range(len(a)):
    while b[-i-1]!=0:
        c = 2**(len(bin(a[-i-1]))-2)-a[-i-1]
        d = bisect.bisect_left(a,c)
        if a[d]==c:
            if b[d]>1:
                ans += 1
                b[-i-1] -= 1
                b[d] -= 1
            elif b[d]==1 and a[d]!=a[-i-1]:
                ans += 1
                b[-i-1] -= 1
                b[d] -= 1
            else:
                break
        else:
            break

print(ans)


Measured memory_bytes: 112980
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

S = input()

if len(S) == 1:
	print(0)
	exit()

S1 = []
S2 = []

cnt1 = 0
cnt2 = 0

for i in range(len(S)):
	if i%2 == 0:
		S1.append("0")
		S2.append("1") 
	else:
		S1.append("1")
		S2.append("0") 

	if S[i] == S1[i]:
		cnt1 += 1

	if S[i] == S2[i]:
		cnt2 += 1

print(min(cnt1, cnt2))

Measured memory_bytes: 16100
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

// Range Minumum Query
class SegmentTree{
public:
    int N;
    vector<ll> node;

    SegmentTree(vector<ll> v){
        int sz = v.size();
        N = 1; while(N < sz) N *= 2;
        node.resize(2*N-1, INF);
        for(int i=0; i<sz; i++) node[i+N-1] = v[i];
        for(int i=N-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(int x, ll val){
        x += (N - 1);
        node[x] = val;
        while(0 < x){
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    ll getmin(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = N;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        
        return min(vl, vr);
    }
};

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

    int n, m; cin>>n>>m;
    SegmentTree seg(vector<ll>(n, INF));
    seg.update(0, 0);

    vector<T> v;
    for(int i=0; i<m; i++){
        int l, r, c; cin>>l>>r>>c;
        v.emplace_back(l, r, c);
    }
    sort(v.begin(), v.end());

    for(int i=0; i<m; i++){
        int l, r, c;
        tie(l, r, c) = v[i];
        l--, r--;
        ll val = seg.getmin(l, r);
        val += c;
        if(val < seg.node[seg.N-1+r]){
            seg.update(r, val);
        }
    }

    cout << (seg.node[(seg.N-1)+(n-1)] == INF ? -1 : seg.node[(seg.N-1)+(n-1)]) << endl;

    return 0;
}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll N, A;
    cin >> N >> A;

    ll eat_max = 1;
    while((1LL<<eat_max) < N) eat_max++;

    ll ans = N;
    for(ll eat=1;eat<eat_max;eat++){
        ll max_term = 2;
        while(1){
            ll score = eat * A + max_term + eat * (max_term - 1);

            // prod <- max_term * (max_term-1)^eat
            ll prod = max_term;
            for(ll i=0;i<eat;i++){
                prod *= max_term - 1;
            }

            for(ll i=0;i<eat && prod<N;i++){
                prod /= max_term - 1;
                prod *= max_term;
                score++;
            }

            if(N <= prod){
                ans = min(ans, score);
                break;
            }
            max_term++;
        }
    }

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


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        ab: [[i64; 2]; n]
    }
    let mut c: Vec<(i64,usize)> = ab.iter().map(|x| x[0] + x[1]).zip(0..n).collect();
    c.sort_by(|x, y| y.0.cmp(&x.0));
    let mut ans = 0;
    for i in 0..n {
        let j = c[i].1;
        if i % 2 == 0 {
            ans += ab[j][0];
        } else {
            ans -= ab[j][1];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0;
  char a,b,c;
  cin>>a>>b>>c;
  if(a=='1')
    cnt++;
  if(b=='1')
    cnt++;
  if(c=='1')
    cnt++;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, raw_input().split())
arr = map(int, raw_input().split())

sum = 10 ** 8 * 3 + 1
for i in range(n - k + 1):
    cur = arr[i + k - 1] - arr[i] + min(abs(arr[i + k - 1]), abs(arr[i]))
    if sum > cur:
        sum = cur
print sum


Measured memory_bytes: 11344
#include<bits/stdc++.h>
#define ve vector<int>
using namespace std;


int main(){
  int n,k,A=0;
  cin>>n>>k;
  ve h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
    if(h[i]>=k) A++;
  }
  cout<<A<<endl;
}


Measured memory_bytes: 640
N, S = map(int, input().split())
As = list(map(int, input().split()))

P = 998244353

memo = [[0 for _ in range(N+1)] for _ in range(S+1)]

for i in range(N+1):
  memo[0][i] = (2**i) % P

for i, a in enumerate(As):
  for j in range(S+1):
    if j - a < 0:
      memo[j][i+1] = memo[j][i]*2 % P
    else:
      memo[j][i+1] = (memo[j][i]*2 + memo[j-a][i]) % P

print(memo[S][N])

Measured memory_bytes: 148348
#include <iostream>
#include <vector>
#include <cstdlib>
#include <math.h>

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

const long long INF = 1LL << 60;

#define MOD 1000000007



int N;

long long dp[100010][3];

long long abc[100010][3];

int main(){

    int N;
    cin >> N;

    for(int i = 0; i < N; ++i){
        // cin >> abc[i][0];
        // cin >> abc[i][1];
        // cin >> abc[i][2];
        for(int j = 0; j < 3; ++j)
            cin >> abc[i][j];
    }

    //  i == prev choice 0:(1,2) 1:(0,2) 2:(0,1)
    //  j == recent choice
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                if(j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }

    long long res = 0;
    for(int i = 0; i < 3; ++i){
        chmax(res, dp[N][i]);
    }

    cout << res << endl;
}

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

using namespace std;

const int maxN = 2e5 + 100;
const int module = 1e9 + 9;

void enter()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}
void solve()
{
    string S, T;
    cin >> S >> T;
    int Res = 0;
    for (int i = 0; i < 3; i++) Res += S[i] == T[i];
    cout << Res << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //enter();
    solve();
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = []
    remove = n
    if n % 2 != 0:
        remove -= 1

    for i in range(n):
        for j in range(i + 1, n):
            if j + 1 == remove:
                continue
            res.append([i + 1, j + 1])
        remove -= 1

    print(len(res))
    for i in res:
        print(*i)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9704
import math
 
n = int(input())
 
 
 
def koch(n,x_0,y_0,x_1,y_1):
    if n == 0:
        return   
    x_m1 = x_0 + (x_1- x_0)/3
    y_m1 = y_0 + (y_1 -y_0)/3
    x_m2 = x_0 + (x_1- x_0)* 2/3
    y_m2 = y_0 + (y_1 -y_0) *2/3
    x_m =  (x_m2 - x_m1) * math.cos(math.pi/3) - (y_m2 - y_m1) * math.sin(math.pi/3) + x_m1
    y_m =  (x_m2 - x_m1) * math.sin(math.pi/3) + (y_m2 - y_m1) * math.cos(math.pi/3) + y_m1
 
    koch(n-1,x_0,y_0,x_m1,y_m1)
    print(x_m1,y_m1)
    koch(n-1,x_m1,y_m1,x_m,y_m)
    print(x_m,y_m)
    koch(n-1,x_m,y_m,x_m2,y_m2)
    print(x_m2,y_m2)
    koch(n-1,x_m2,y_m2,x_1,y_1)
     
print(0,0)
koch(n,0,0,100,0)
print(100,0)


Measured memory_bytes: 5780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 1;i < 10;i++)
            {
                for(int j = 1;j < 10;j++)
                {
                    Console.Write("{0}x{1}={2}\n", i, j,i*j);
                }
            }
        }
    }
}

Measured memory_bytes: 5592