akhauriyash/Code-Regression huggingface dataset:
from typing import List


class Dice():
    def __init__(self, lst):
        self.top = lst[0]
        self.front = lst[1]
        self.right = lst[2]
        self.left = lst[3]
        self.back = lst[4]
        self.bottom = lst[5]

    def rotate(self, direction):
        if direction == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        if direction == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        if direction == "S":
            self.top, self.front, self.bottom, self.back = self.back, self.top, self.front, self.bottom
        if direction == "W":
            self.top, self.left, self.bottom, self.right = self.right, self.top, self.left, self.bottom


def main():
    dice_nums: List[int] = list(map(int, input().split()))
    directions: str = input()

    dice = Dice(dice_nums)
    for direction in directions:
        dice.rotate(direction)
    print(dice.top)


if __name__ == "__main__":
    main()



Measured memory_bytes: 7164
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 7;
int32_t main(){
    IOS;
    int t;
    cin >> t;
    if(t>=30) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
  int A[3];
  for (auto & a : A)
    cin >> a;
  sort(A, A + 3);
  int cost = 0;
  for (int i = 1; i < 3; ++i)
    cost += abs(A[i] - A[i - 1]);
  cout << cost;
  return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
if a <= b <= c:
    print(a,b,c)
elif c <= a <= b:
    print(c,a,b)
elif b <= c <= a:
    print(b,c,a)
elif c <= b <= a:
    print(c,b,a)
elif a <= c <= b:
    print(a,c,b)
elif b <= a <= c:
    print(b,a,c)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
typedef long long ll;
ll qpow(ll a,ll b)
{
    ll ans=1;
    while (b)
    {
        if (b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
    if (!b) x=1,y=0;
    else exgcd(b,a%b,y,x),y-=a/b*x;
}
int main()
{
    ll n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
    ll ans=qpow(2,n)-1;
    ll C=1;
    for (ll i=1;i<=max(a,b);++i)
    {
        ll x,y;exgcd(i,MOD,x,y);
        ll inv=(x+MOD)%MOD;
        C=C*(n-i+1)%MOD*inv%MOD;
        if (i==a||i==b) ans-=C;
    }
    printf("%lld\n",(ans+MOD+MOD)%MOD);
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int x,k,d;
    cin >> x >> k >> d;
   
   if(x < 0) x = -x; 
    
   int res = 1e18;
  
   //first reach nearest to 0 
   int mov = (x/d);
    
   if(mov <= k)
   {
      x-=(mov*d);
       
      k-=mov;
       
      if(x == 0)
      {
          if(k%2 == 0) res = min(res,(int)0);
          else res = min(res,d);
      }
      else 
      {
          int v2 = abs(x - d);
          
          if(v2 < x && k > 0) 
          {
              k--;
              if(k % 2 == 1) res = min(res,x);
              else res = min(res,v2);
          }
          else if(k % 2 == 1) res = min(res,v2);
          else res = min(res,x);
      }
   }
   else
   {
       res = min(res,x - (k*d));
   }
    
   cout << res; 
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  int aa[a],bb[b],cc[c],ax[x],ay[y];
  rep(i,0,a) cin>>aa[i];
  rep(i,0,b) cin>>bb[i];
  rep(i,0,c) cin>>cc[i];
  
  sort(bb,bb+b); reverse(bb,bb+b);
  sort(aa,aa+a); reverse(aa,aa+a);
  sort(cc,cc+c); reverse(cc,cc+c);
  
  rep(i,0,x) ax[i]=aa[i];
  rep(i,0,y) ay[i]=bb[i];
  
  int p[x+y];
  rep(i,0,x) p[i]=ax[i];
  rep(i,0,y) p[i+x]=ay[i];

  sort(p,p+x+y);
  rep(i,0,c){
    if(cc[i]>p[i]) p[i]=cc[i];
    else break;
  }
  ll ans=0;
  rep(i,0,x+y) ans+=p[i];
  co(ans);
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
        a--;
    else
        b--;
    cout<<a<<" "<<b;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict
from itertools import compress 
N = int(input())
S = input().strip()
#N = 18
#S = 'abc' * 12
S1 = S[:N]
S2 = S[N:][::-1]

Ls = defaultdict(lambda : defaultdict(int))

def int2bin(x,N): 
    res = [0]*N
    for i in range(N):
        res[N-1-i] = x % 2
        x >>= 1
    return res

for i in range(2**N):
    bs = int2bin(i,N)
    n = sum(bs)
    R = ""
    B = ""
    for s,b in zip(S1,bs):
        if b == 1:
            R += s
        else:
            B += s
    Ls[n][(R,B[::-1])] += 1

ans = 0
for i in range(2**N):
    bs = int2bin(i,N)
    n = sum(bs)
    R = ""
    B = ""
    for s,b in zip(S2,bs):
        if b == 1:
            B += s
        else:
            R += s
    R = R[::-1]
    ans += Ls[n][(B,R)]

print(ans)







Measured memory_bytes: 208516
#[allow(unused_macros)]
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)*}
    };
}

#[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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    let mut alice = 0;
    let mut bob = 0;
    for i in 1..n+1 {
        let mi =  a.iter().enumerate().max_by_key(|&(_, v)| v).unwrap().0;
        if i % 2 == 1 {
            alice += a[mi];
        } else {
            bob += a[mi];
        }
        a[mi] = 0;
    }
    println!("{}", alice - bob);
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int cnt=0;
		for(int i=a;i<=b; i++) {
			if(c%i==0) {
				cnt++;
			}
		}

		System.out.println(cnt);

	}

}



Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int q,flip = 0;
	string s,a,b;
	cin >> s >> q;
	for(int i = 0;i < q;i++){
		int t;
		cin >> t;
		if(t == 1){
			flip++;
		}else{
			int f;
			char c;
			cin >> f >> c; f--;
			if(f ^ (flip % 2)) b.push_back(c);
			else a.push_back(c);
		}
	}
	reverse(all(a));
	s = a + s + b;
	if(flip % 2) reverse(all(s));
	cout << s << endl;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll a, b; cin >> a >> b;
    a = pow(100, a);
    if(b == 100) ++b;
    ll ans = a * b;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
package main

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

// N: [1, 2e5]
// len(S) = N
// P: [2, 10000], prime
func main() {
	sc := newInputScanner(true, 256)
	N, P, S := sc.nextInt(), sc.nextInt(), sc.nextStr()
	answer := checkSubNumbers(N, P, S)
	fmt.Println(answer)
}

func checkSubNumbers(N int, P int, S string) int {
	switch P {
	case 2, 5:
		return checkTwoOrFive(N, P, S)
	default:
		return checkNotTwoNorFive(N, P, S)
	}
}

func checkTwoOrFive(N int, P int, S string) int {
	answer := 0
	var n int
	for i := N - 1; i >= 0; i-- {
		n, _ = strconv.Atoi(S[i : i+1])
		if n%P == 0 {
			answer += i + 1
		}
	}
	return answer
}

func checkNotTwoNorFive(N int, P int, S string) int {
	multiplier := 1 // 10^i % P
	answer := 0
	remainderLookup := make([]int, P)
	prevRemaider := -1
	var digit, remainder, count int
	for i := N - 1; i >= 0; i-- {
		digit = int(S[i] - '0')
		if prevRemaider == -1 { // first digit
			remainder = digit % P
		} else {
			remainder = (((multiplier * digit) % P) + prevRemaider) % P
		}
		if remainder == 0 {
			answer++
		}
		count = remainderLookup[remainder]
		answer += count
		count++
		remainderLookup[remainder] = count
		prevRemaider = remainder
		multiplier = (multiplier * 10) % P
	}
	return answer
}

type inputScanner struct {
	*bufio.Scanner
}

func newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {
	scanner := bufio.NewScanner(os.Stdin)
	if enabledScanWords {
		scanner.Split(bufio.ScanWords)
	}
	capacity := sizeInKB * 1024
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)
	return &inputScanner{
		Scanner: scanner,
	}
}

func (inputSc *inputScanner) nextInt() int {
	i, e := strconv.Atoi(inputSc.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextUInt64() uint64 {
	i, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextStr() string {
	inputSc.Scan()
	return inputSc.Text()
}


Measured memory_bytes: 1024
a,b,c=map(int,input().split())
mini = 0
m = a % c
if m == 0:
  mini = a/c
else:
  mini = (c-m + a)/c
maxi = 0
M = b % c
if M == 0:
  maxi = b//c
else:
  maxi = (b-M)//c
res = int(maxi) - int(mini) + 1
print(res)

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
template <typename T> T gcd(T m, T n) {
  T temp = 0;
  while(m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

int main() {
  int N;
  cin >> N;
  vector<ll> as(N);
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
  }
  ll ans = as[0];
  for(int i = 0; i < N; ++i) {
    ans = gcd(ans, as[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, d = 0, har[10] = {0};
  
  cin >> N;
  har[0] = N;
  
  for (int i = 1; i < 11; i++) {
    if (N / 10 >= 0 && i == 1) {
      d += N % 10;
    }
    else if (N / 10 >= 0 && i > 1) {
    har[i] = N / 10;
    N = har[i];
    d += har[i] % 10;
    }
    else  break;
  }
    
    if (har[0] % d == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 2000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e9;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}


void solve() {
	int X,Y;cin>>X>>Y;
	if((2*X-Y)%3!=0){
		print(0);return;
	}
	else if(2*X-Y<0||2*Y-X<0){
		print(0);
		return;
	}
	int n=(2*X-Y)/3;
	int m=(2*Y-X)/3;
	COMinit();
	ll ans=fac[m+n]*finv[n]%MOD;
	ans=ans*finv[m]%MOD;
	print(ans%MOD);
}
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N){
    LL memo[100];
    memo[0] = 2;
    memo[1] = 1;
    REP2(i, 2, N+1) {
        memo[i] = memo[i-1] + memo[i-2];
    }

    cout << memo[N] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}



Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn water(h: &mut [usize]) -> usize {
    let min = *h.iter().min().unwrap();
    for h in h.iter_mut() {
        *h -= min;
    }
    return min;
}

fn main () {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut h: Vec<usize> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 0;
    while let Some(l) = h.iter().position(|&x| x > 0) {
        let r = h[l..].iter().position(|&x| x == 0).map(|x| x + l).unwrap_or(n);
        ans += water(&mut h[l..r]);
    }
    println!("{}", ans);
    return;
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, SC):

    for i in range(1000):
        i = str(i)
        if len(i) != N:
            continue

        for s, c in SC:
            if int(i[s-1]) != c:
                break
        else:
            return i


    return -1


def main():
    N, M = read_int_n()
    SC = [read_int_n() for _ in range(M)]
    print(slv(N, M, SC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6468
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    if(a+b+c+d==7){
      cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
      return 0;
    }
    else if(a+b+c-d==7){
      cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;  
      return 0;
    }
    else if(a+b-c+d==7){
      cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
      return 0;
    }
    else if(a+b-c-d==7){
      cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
      return 0;  
    }
    else if(a-b+c+d==7){
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
      return 0;
    }
    else if(a-b+c-d==7){
      cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
      return 0;  
    }
    else if(a-b-c+d==7){
      cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
      return 0;  
    }
    else if(a-b-c-d==7){
      cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
      return 0;  
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, k;
    cin >> n >> k;
    vi v(n);
    rep(i, n) cin >> v[i];
    int ans = 2e9;
    sort(all(v));
    REP(i, k-1, n) {
        ans = min(ans, v[i] - v[i-(k-1)]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
int max_index=-1;
int ans=0;

void solve()
{
fastio
ll x,y;
cin>>x>>y;
if(x>max_index)
{
	max_index=x;
	ans=y;
}
}
int main()
{
//code
	
fastio	
int t;
cin>>t;
while(t--)
{
	solve();
	//cout<<endl;
}
cout<<ans+max_index;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[100100];
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    rep(i,100100) dp[i] = INF;
    dp[0]=0;
    rep(i,n){
        for(int j = 1;j<=k;++j){

                dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));

        }
    }
    cout << dp[n-1] <<endl;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int main() {
	int n, x;
	cin >> n >> x;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	int cnt = 0;
	int i = 0;
	while (x >= a[i]) {
		x -= a[i];
		cnt++;
		i++;
      	if(i==n){break;}
	}
  	if(x>0&&i==n)cnt--;
  	if(cnt<0)cnt=0;
	cout << cnt << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PA pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e16+7;
const ll MOD=1e9+7;

int main(){
	ll n,m;
	cin >> n >> m;
	ll ans = 1;
	if(max(n,m)-min(n,m) >= 2)ans = 0;
	FOR(i,1,m+1)(ans*=i)%=MOD;
	FOR(i,1,n+1)(ans*=i)%=MOD;
	if(n==m)(ans*=2)%=MOD;
	cout << ans << endl;
}

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

using namespace std;

typedef vector<int> v;
typedef vector<vector<int>> vv;

int main() {
  int W, H;
  cin >> H >> W;
  vector<int> h(H, 0);
  vector<int> w(W, 0);
  vector<vector<char>> t(H, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> t[i][j];
      if (t[i][j] == '#') h[i] = w[j] = 1;
    }
  }
  for (int i = 0; i < H; ++i) {
    if (h[i] == 0) continue;
    for (int j = 0; j < W; ++j) {
      if (w[j] == 0) continue;
      cout << t[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
static const int Maxn = 10010;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int BLACK = 1;
vector <P> a[Maxn];
int n, d[Maxn], p[Maxn], color[Maxn];
struct cmp{
	bool operator()(P x, P y){
		return x.first > y.first;
	}
		
};
void dijkstra();
int main()
{
	int u, k, c, v;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> u >> k;
		while(k--){
			cin >> v >> c;
			a[u].push_back(make_pair(v, c));
		}
	}
	dijkstra();
	return 0;
}
void dijkstra(){
	priority_queue <P, vector<P>, cmp> q;
	for(int i = 0; i < n; i++){
		d[i] = INFTY;
		color[i] = WHITE;
	} 
	d[0] = 0;
	q.push(make_pair(0,0));
	while(!q.empty()){
		P f = q.top(); q.pop();
		//printf("%d %d\n", f.first, f.second);
		int u = f.second;
		color[u] = BLACK;
		if(d[u] > f.first) continue;
		for(int i = 0; i < a[u].size(); i++){
			int v = a[u][i].first;
			if(color[v] == BLACK) continue;
			if(d[v] > d[u] + a[u][i].second){//
				d[v] = d[u] + a[u][i].second;
				q.push(P(d[v], v));
			} 
		}
	}
	for(int i = 0; i < n; i++) cout << i << ' ' << d[i] << endl;
}

 


Measured memory_bytes: 8044
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

s = ns()
for i in range(26):
    if chr(i + ord('a')) not in s:
        print(chr(i + ord('a')))
        exit()
print('None')


Measured memory_bytes: 3188
from copy import deepcopy
s=list(map(int,input()))
t=deepcopy(s)
if t[0]==1:
    t[0]=0
else:
    t[0]=1

cnt=0
rev_cnt=1

for i in range(1,len(s)):
    if s[i-1]==s[i]:
        if s[i]==0:
            s[i]=1
        else:
            s[i]=0
        cnt+=1

for i in range(1,len(t)):
    if t[i-1]==t[i]:
        if t[i]==0:
            t[i]=1
        else:
            t[i]=0
        rev_cnt+=1

print(min(cnt, rev_cnt))

Measured memory_bytes: 10940
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

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

	char tmp=' ';
	int count=N;
	for(int i=0; i<N; i++){
		if(tmp==S[i]) count--;
		tmp=S[i];
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;
double D(P a, P b){return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));}

int main() {
  int n,tt=1;
  while(cin >> n && n) {
    P a[n][2];
    for(int i=0; i<n; i++) {
      for(int j=0; j<2; j++) cin >> a[i][j].F >> a[i][j].S;
    }
    double dp[1<<n][n][2];
    for(int t=0;t<(1<<n);t++)for(int i=0;i<n;i++)for(int j=0;j<2;j++)dp[t][i][j]=1<<29;
    for(int i=0; i<n; i++) {
      for(int j=0; j<2; j++) dp[1<<i][i][j]=D(a[i][0],a[i][1]);
    }
    for(int t=0; t<(1<<n); t++) {
      for(int i=0; i<n; i++) {
        if(!(t&(1<<i))) continue;
        for(int j=0; j<2; j++) {
          for(int k=0; k<n; k++) {
            if(t&(1<<k)) continue;
            for(int l=0; l<2; l++) {
              dp[t|(1<<k)][k][l^1]=min(dp[t|(1<<k)][k][l^1],dp[t][i][j]+D(a[i][j],a[k][l])+D(a[k][0],a[k][1]));
            }
          }
        }
      }
    }
    double ans=1<<29;
    for(int i=0; i<n; i++)for(int j=0; j<2; j++) ans=min(ans,dp[(1<<n)-1][i][j]);
    cout << "Case " << tt++ << ": ";
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 6764
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var AArray = retreiveLongArray();

			var Rains = Enumerable.Repeat((long)0, (int)N).ToArray();

			long first = 0;
			for (int i = 0; i < N; i++) {
				if (i%2==0) {
					first += AArray[i];
				}
				else {
					first -= AArray[i];
				}
			}

			Rains[0] = first / 2;

			for (int i = 1; i < N; i++) {
				Rains[i] = AArray[i - 1] - Rains[i - 1];
			}

			var ans = string.Join(" ", Rains.Select(x => x * 2));

			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 46212
#encoding:utf-8
numbers = []

while gets
 number = $_.to_i
 if $_ == ''
  break
 end
 numbers.push number.to_i
end

def count_pattern integer
 count = 0
 a = 0
 while a < 10
  b = 0
  while b < 10
   c = 0
   while c < 10
    d = 0
    while d < 10
     if a + b + c + d == integer
      count += 1
     end
     d += 1
    end
    c += 1
   end
   b += 1
  end
  a += 1
 end
 puts count
end

i = 0
while i < numbers.length
 count_pattern numbers[i]
 i += 1
end

Measured memory_bytes: 6088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int sum=0;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='2')
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n, m;
	int input;
	vector <vector<int>> A;
	vector<int> b;

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		vector<int> tmpVect;
		for (int j = 0; j < m; j++) {
			cin >> input;
			tmpVect.push_back(input);
		}
		A.push_back(tmpVect);
	}
	for (int i = 0; i < m; i++) {
		cin >> input;
		b.push_back(input);
	}

	for (int i = 0; i < n; i++) {
		int tmpInt = 0;
		for (int j = 0; j < m; j++) {
			tmpInt += A[i][j] * b[j];
		}
		printf("%d\n", tmpInt);
	}
	
	return 0;
}

Measured memory_bytes: 3272
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    // 建立羊肉串
    vector<int> array(n);
    for (int i = 0; i< n; i++) {
        scanf("%d", &array[i]);
    }

    // 开始枚举
    int maxl = 0;
    for (int a = 0; a <= k; a++) {
        for (int b = 0; b <= k; b++) {
            for (int c = 0; c <= k; c++) {
                if (a+b+c <= k && a+b >= c && a + b <= n) {
                    // 操作合理
                    priority_queue<int> qu;
                    for (int i = 0; i < a; i++) {
                        qu.push(array[i]);
                    }
                    for (int i = 0; i < b; i++) {
                        qu.push(array[n - i - 1]);
                    }
                    int sum = 0;
                    for (int i = 0; i < a + b - c; i++) {
                        sum += qu.top();
                        qu.pop();
                    }
                    maxl = max(maxl, sum);
                }
            }
        }

    }
    printf("%d\n", maxl);
    return EXIT_SUCCESS;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#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 P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

// dp[i][j][k]:x_1,x_2…x_iからj枚選んでx_tの合計をkにするような選び方の総数
int dp[55][55][2510];


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, a; cin >> n >> a;
	VE x(n); rep(i, n)cin >> x[i];
	int X = a;
	rep(i, n)chmax(X, x[i]);
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n * X; k++) {
				// 初期状態
				if (i == 0 && j == 0 && k == 0) {
					dp[i][j][k] = 1;
				}
				// k < x[j-1]なのでそもそもkを作れない
				else if (i >= 1 && k < x[i - 1]) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
				// 今度はsを作ることが可能。
				else if (i >= 1 && j >= 1 && k >= x[i - 1]) {
					dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
				}
				else {
					dp[i][j][k] = 0;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[n][i][i*a];
	}
	cout << ans << endl;
	return 0;
}


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



int main(){
    ll N, K;cin >> N >> K;
    vector<int> v;
    for(int i = 0;i < N;i++){
        int a;cin >> a;
        a--;
        v.push_back(a);
    }
    vector<int> zzz;
    zzz.push_back(0);
    map<int, int> mp;
    mp[0] = 0;
    int now = 0;
    for(int i = 0;;i++){
        if(i == K - 1){
          //  cout<<"AAA"<<endl;
            cout<<v[now] + 1<<endl;
            return 0;
        }
        if(mp.find(v[now]) == mp.end()){
            mp[v[now]] = i + 1;
            now = v[now];
        }else{
            int sz = i - mp[v[now]];
            //cout<<sz<<endl;
            sz += 1;
            K -= i + 1;
            for(auto a : mp){
                //cout<<a.first<<" "<<a.second<<endl;
             //   cout<<K<<" "<<sz<<endl;
             //   cout<<a.second<<" "<<mp[v[now]]<<" "<<K%sz<<endl;
                if(a.second - mp[v[now]] == (K % sz)){
                    cout<<a.first + 1<<endl;
                    return 0;
                }
            }
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 11636
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int N[maxn],M[maxn];
int main()
{
	int n;cin>>n;string s;cin>>s;
	reverse(s.begin(),s.end());
	for(int i=0;i<n;i++)
	{
		if(s[i]=='.') 
		{
			if(i>=1)
			N[i]=N[i-1]+1;
			else N[i]=1;
		}
		else
		{
			if(i>=1) N[i]=N[i-1];
			else N[i]=0;
		}
		//cout<<N[i]<<endl;
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='#') 
		{
			if(i<=n-2)
			M[i]=M[i+1]+1;
			else M[i]=1;
		}
		else
		{
			if(i<=n-2) M[i]=M[i+1];
			else M[i]=0;
		}
		//cout<<M[i]<<endl;
	}
	int ans=2e6+10;
	for(int i=0;i<n;i++)
	{
		if(i==0) ans=min(ans,M[1]);
		else if(i==n-1) ans=min(N[n-2],ans);
		else ans=(ans>(N[i-1]+M[i+1]))?(N[i-1]+M[i+1]):ans;
		//cout<<i<<" "<<ans<<endl; 
	}
	cout<<ans<<endl;
 } 

Measured memory_bytes: 2180
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = 102, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

ll dp[2][(int) 1e5 + 2];

class DKnapsack1 {
public:
    void init() {
        clr(dp,0);
    }

    void solve(istream &cin, ostream &cout) {
        init();
        int n, totW;
        cin >> n >> totW;
        bool first = true;
        for (int j = 0; j < n; j++) {
            int w, v;
            cin >> w >> v;
            first = true;
            for (int curW = 0; curW <= totW; curW++) {
                int i = j%2;
                if (first) {
                    first = false;
                    dp[i % 2][curW] = (curW - w >= 0) ? v : 0;
                    continue;
                }
                if (curW - w >= 0)
                    dp[i][curW] = max(dp[(((i - 1) % 2 + 2) % 2)][curW], dp[(((i - 1) % 2 + 2) % 2)][curW - w] + v);
                else
                    dp[i][curW] = dp[(((i - 1) % 2 + 2) % 2)][curW];
            }
        }

        cout << dp[(((n - 1) % 2 + 2) % 2)][totW] << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	DKnapsack1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;

int main(void)
{
	int a,b,c,i,cnt;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;
	for(i=a;i<=b;i++)	{
		if(c%i==0)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

double kaizyou(double n) {
    double ans = 1;
    while(n) {
        ans *= n;
        n--;
    }
    return ans;
}

int main() {
    double n;
    double ans = 0;
    cin >> n;
    vector<double> x(n), y(n), order(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        order[i] = i;
    }
    do {
        double tmp = 0;
        rep(i, n - 1) {
            tmp += sqrt((x[order[i]] - x[order[i + 1]]) *
                            (x[order[i]] - x[order[i + 1]]) +
                        (y[order[i]] - y[order[i + 1]]) *
                            (y[order[i]] - y[order[i + 1]]));
        }
        ans += tmp;
    } while(next_permutation(order.begin(), order.end()));
    ans /= kaizyou(n);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3824
import sys
input=sys.stdin.readline

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a
s = input().strip()
a = runLength(s)
print(len(a)-1)


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> v(n + 1);
    long long mod = 1e9 + 7;
    for(int i = 1; i <= n; i++)
        v[i] = v[i - 1] + i;
    long long ans = 0;
    for(int i = k; i <= n + 1; i++)
    {
        long long minsum = v[i - 1];
        long long maxsum = v[n] - (i < n + 1 ? v[n - i] : 0);
        long long r = maxsum - minsum + 1;
        ans = (ans + r) % mod;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int k;
typedef pair<int,int> p;
vector<p> g[100001];
int cost[100001];
const int INF = 1e9;
int main() {
  cin >> k;
  for(int i = 0; i < k; i++) {
    g[i].push_back(p(i * 10 % k,0));
    g[i].push_back(p((i + 1) % k, 1));
    // cout << i * 10 % k<<"   cost = "<<'0'<<endl;
    // cout << (i + 1) % k <<"   cost = "<<'1'<<endl;
  }
  fill(cost,cost+k,INF);
  deque<p> d;
  d.push_back(p(1,0));
  cost[1] = 0;

  while(!d.empty()) {
    int u = d.front().first;
    d.pop_front();
    for(int i = 0; i < g[u].size(); i++) {
      p P = g[u][i];
      if(cost[P.first] > cost[u] + P.second) {
	cost[P.first] = cost[u] + P.second;
	if(P.second == 0) d.push_front(P);
	else d.push_back(P);
      }
    }
  }

  /* for(int i = 0; i < k; i++) {
    cout << cost[i] << endl;
    }*/

  cout << cost[0] + 1 << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <map>
#include <set>
#include <string>
#include<string.h>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
    string s,t;
    cin>>s;
    t=s;
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='x'){
            t.erase(t.begin()+i);
        }
    }
    //cout<<t<<endl;
    bool p=true;
    int len=t.length();
    for(int i=0;i<=(len/2);i++){
        if(t[i]!=t[len-1-i]){
            p=false;
            break;
        }
    }
    if(!p) printf("-1\n");
    else{
        int ans=0;
        int head=0,tail=s.length()-1;
        for(int i=0;i<s.length();i++){
                if(tail<=head) break;
            if(s[head]!=s[tail]){
                if(s[head]=='x'){
                    head++;
                    ans++;
                }else if(s[tail]=='x'){
                    tail--;
                    ans++;
                }
            }else if(s[head]==s[tail]){
                tail--;
                head++;
            }
        }
        printf("%d\n",ans);
    }

	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N=int(input())
A=list(map(int, input().split()))

ans = 1
state = "normal"

for i in range(1,N):
    if state == "normal":
        if A[i-1] == A[i]:
            continue
        elif A[i-1] < A[i]:
            state = "up"
        else:
            state = "down"
    elif state == "up":
        if A[i-1] > A[i]:
            state = "normal"
            ans += 1
    elif state == "down":
        if A[i-1] < A[i]:
            state = "normal"
            ans += 1 


print(ans)

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

long f(long x) {
  long ret = 1;
  for (long i = 0; i < x; i++) ret *= 2;
  return ret;
}

int main() {
  long N, P;
  cin >> N >> P;
  long a, ne = 0, no = 0;
  for (long i = 0; i < N; i++) {
    cin >> a;
    if (a % 2) no++;
    else ne++;
  }
  if (no == 0) cout << (P ? 0 : f(N)) << endl;
  else cout << f(N-1) << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> top(n);
    vector<ll> mid(n);
    vector<ll> midn(n);
    vector<ll> bas(n);
    vector<ll> basn(n);
    rep(i, n) cin >> top.at(i);
    rep(i, n) cin >> mid.at(i);
    rep(i, n) cin >> bas.at(i);
    sort(top.begin(), top.end());
    sort(mid.begin(), mid.end());
    sort(bas.begin(), bas.end());
    rep(i, n){
        midn.at(i) = lower_bound(top.begin(), top.end(), mid.at(i)) - top.begin();
    }
    ll sum = 0;
    rep(i, n){
        sum += midn.at(i);
        midn.at(i) = sum;
    }
    ll ans = 0;
    rep(i, n){
        int l = lower_bound(mid.begin(), mid.end(), bas.at(i)) - mid.begin() -1;
        if(l >= 0) ans += midn.at(l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224