akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }
    static long GCD(long x,long y)
    {
        if (y == 0) return x;
        return GCD(y, x % y);
    }

    static long LCM(long x,long y)
    {
        return x * y / GCD(x, y);
    }

    static int keta(int x)
    {
        string s = x.ToString();
        return s[s.Length - 1]-'0';
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        long N = sc.longarr[0];

        long[] x=new long[5];
         x[0] = sc.longarr[0];
         x[1] = sc.longarr[0];
         x[2] = sc.longarr[0];
         x[3] = sc.longarr[0];
         x[4] = sc.longarr[0];

        long ans = 0;
        long mi = x.Min();
        int mii=0;
        for(int i = 0; i < 5; ++i)
        {
            if (mi == x[i])
            {
                mii = i;
                break;
            }
        }

        ans = (N+mi-1) / mi + 4;
        wr.wri(ans);
    }


}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int A,X;
  cin >> X >> A ;
  
  if(X < A){
    cout << 0 << endl;
  }
  else{
  	cout << 10 << endl;
  }
  return 0;
}



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

using namespace std;
using namespace atcoder;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(n), b(m);
    for (auto &x : a) {
        scanf("%d", &x);
    }
    for (int &x : b) {
        scanf("%d", &x);
    }
    vector<int> c = convolution(a, b);
    for (int x : c) {
        printf("%d ", x);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 19076
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  map<long, long> foo;
  rep(i, 4) {
    long tmp;
    cin >> tmp;
    foo[tmp]++;
  }
  cout << ((foo[1] and foo[9] and foo[7] and foo[4]) ? "YES" : "NO") << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


ll f(ll n) {
	if (n % 2 == 0) return n / 2;
	else return 3 * n + 1;
}

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

	ll tmp = s;
	map<ll, ll> bak;
	bak[tmp] = 1;
	rep(i, 10000000) {
		if (bak[f(tmp)] == 1) {
			cout << i + 2 << endl;
			break;
		}
		else {
			tmp = f(tmp);
			bak[tmp] = 1;
		}
	}

}


Measured memory_bytes: 256
fn check_garden(h: &mut Vec<u32>, begin: usize, end: usize) -> u32 {
    if begin == end {
        return 0;
    }

    let grow = *h[begin..end].iter().min().unwrap();
    for i in h[begin..end].iter_mut() {
        *i -= grow;
    }
    let mut ans = grow;
    let mut i = begin;
    while i < end {
        if h[i] != 0 {
            for j in (i + 1)..end {
                if h[j] == 0 {
                    ans += check_garden(h, i, j);
                    i = j;
                    break;
                }
            }
            return ans + check_garden(h, i, end);
        }
        i += 1;
    }
    ans
}

fn c_grand_garden() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("input error");
    let n = input.trim_right().parse::<usize>().expect("parse error");
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("input error");
    let mut h : Vec<u32> = input.split_whitespace()
        .filter_map(|s| s.parse::<u32>().ok())
        .collect();

    println!("{}", check_garden(&mut h, 0, n));
}

fn main() {
    c_grand_garden();
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<cctype>
#include<algorithm>
#define REP(i,a,b) for(int i(a);i<=(b);++i)
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define gc getchar()
inline int read(){char c,p=0;int w;
	while(isspace(c=gc));if(c=='-')p=1,c=gc;w=c&15;
	while(isdigit(c=gc))w=w*10+(c&15);return p?-w:w;
}
template<typename T,typename U>inline bool smin(T&x,const U&y){return x>y?x=y,1:0;}
template<typename T,typename U>inline bool smax(T&x,const U&y){return x<y?x=y,1:0;}
const int N=2e5+5;
int n,k,a[N],b[N],c[N],d[N];
int main(){
	n=read();
	REP(i,1,n)smax(k,std::__lg(a[i]=read()));
	REP(i,1,n)smax(k,std::__lg(b[i]=read()));
	int ans=0;
	for(int i=k+1;~i;--i){
		int t=1<<i+1;
		REP(j,1,n)c[j]=a[j]&t-1,d[j]=b[j]&t-1;
		std::sort(d+1,d+1+n);
		int s=0;
		REP(j,1,n){
			#define F(x,y) (std::lower_bound(d+1,d+1+n,y)-std::lower_bound(d+1,d+1+n,x))
			s+=F(t/2-c[j],t-c[j])+F(t+t/2-c[j],t*2-c[j]);
		}
		ans<<=1;ans|=s&1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3328
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val a = get[Int]
    val b = get[Int]
    val c = get[Int]
    val d = get[Int]
    val e = get[Int]
    val k = get[Int]

    out.println(
      if({
        for {
          i <- List(a, b, c, d, e)
          j <- List(a, b, c, d, e)
        } yield (i, j)
        }.forall {
        case (i, j) => Math.abs(i - j) <= k
      }) {
        "Yay!"
      } else {
        ":("
      }
    )

    out.flush()
  }
}

Measured memory_bytes: 25412
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

bool check(int y){
  rep(i, 1, 200){
    if (i*i == y){
      return true;
    }
  }
  return false;
}

int solve(){
  int N,D;cin>>N>>D;
  vvi x(N, vi(D));
  rep(n,N){
    rep(d,D){
      cin>>x[n][d];
    }
  }

  int res=0;
  rep(i, N){
    rep(j, i+1, N){
      int d2 = 0;
      rep(d, D){
        d2 += (x[i][d]-x[j][d]) * (x[i][d]-x[j][d]);
      }
      dump(d2);
      if (check(d2)){
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
package main;

import (
    "fmt"
)

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

    fmt.Println(solver(n, s))
}

func solver(n int, s []string) string {
    var tmp int;
    var ans string;
    var arare map[string]int = map[string]int{"P": 0, "W": 0, "G": 0, "Y": 0}
    for i := 0; i < len(s)-1; i++ {
        arare[s[i]] = 1
    }
    tmp = arare["P"] + arare["W"] + arare["G"] + arare["Y"]
    if tmp == 3 {
        ans = "Three"
    } else if tmp == 4 {
        ans = "Four"
    } else if tmp == 1 {
        ans = "One"
    } else if tmp == 2 {
        ans = "Two"
    } else {
        ans = "Zero"
    }
    return ans
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll H, W, K;
    cin >> H >> W >> K;
    ll sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;
    vvc grid(H, vc(W));
    rep(i, H) rep(j, W) cin >> grid[i][j];

    vvll dist(H, vll(W, INF));
    queue<pll> q;
    q.emplace(sx, sy);
    dist[sx][sy] = 0;
    while(!q.empty()) {
        ll x = q.front().first, y = q.front().second;
        q.pop();
        rep(i, 4) for(ll k = 1; k <= K; k++) {
            ll nx = x + k * dx[i], ny = y + k * dy[i];
            if(nx < 0 || H <= nx || ny < 0 || W <= ny) break;
            if(grid[nx][ny] == '@') break;
            if(dist[nx][ny] <= dist[x][y]) break;

            if(dist[nx][ny] == INF) {
                dist[nx][ny] = dist[x][y] + 1;
                q.emplace(nx, ny);
            }
        }
    }

    ll ans = dist[gx][gy];
    if(ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 19848
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int ans = 0;
        for (int i = 0; i < 3; i++) {
        	ans += sc.nextInt();
        }
        
        System.out.println(ans == 17? "YES": "NO");
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int n, a;
public:
	A()
	{
		cin >> n >> a;
	}
	void solve()
	{
		cout << n * n - a << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s[2000];
long long dp[2000][2000];
long long m = 1000000007;
long long num_ways(long long i, long long j)
{
	if(i<0 || j<0)
		return 0;
	if(s[i][j]=='#')
		return 0;
	if(dp[i][j]==-1)
	{
		dp[i][j] = (num_ways(i-1,j) + num_ways(i,j-1))%m;
	}
	return dp[i][j]%m;
}
int main()
{
	long long n,m;
	cin>>n>>m;
	for (long long i = 0; i < n; ++i)
	{
		cin>>s[i];
	}
	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m;j++)
		{
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 1;
	cout<<num_ways(n-1,m-1)<<endl;

	
	return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  bool h=true;
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  if(k>=100){
    for(int i=0;i<n;i++){
        cout<<n;
        if(i!=n-1){
            cout<<' ';
        }
    }
    cout<<endl;
    return 0;
  }
  for(int i=0;i<k;i++){
    int b[n];
    for(int j=0;j<n;j++){
        b[j]=0;
    }
    for(int j=0;j<n;j++){
        int m=max(0,j-a[j]);
        int M=min(n-1,j+a[j]);
        b[m]++;
        if(M<n-1) b[M+1]--;
    }
    for(int j=1;j<n;j++) b[j]+=b[j-1];
    for(int j=0;j<n;j++) a[j]=b[j];
  }
  for(int i=0;i<n;i++){
        cout<<a[i];
        if(i!=n-1){
            cout<<' ';
        }
    }
  cout<<endl;
  return 0;
}


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

const int INF = 1e9 + 5;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bitset<10> > nlist(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      nlist[a- 1].set(i);
    }
  }
  bitset<10> bset;
  for (int i = 0; i < m; i++) {
    int b;
    cin >> b;
    if (b) {
      bset.set(i);
    }
  }

  int cnt = 0;
  for (int i = 0; i < (1<<n); i++) {
    bitset<10> bset2;
    for (int j = 0; j < n; j++) {
      if (i>>j&1) {
        bset2 ^= nlist[j];
      }
    }
    if (bset == bset2) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] defargs) {
        Scanner scanner = new Scanner(System.in);
        int sec = scanner.nextInt();
        int hour = sec / 3600;
        int min = (sec % 3600) / 60;
         sec = sec % 60;
        System.out.println(hour + ":" + min + ":" + sec);
    }
}



Measured memory_bytes: 26272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define bitcount __builtin_popcount
#define pw(x) (1LL<<(x))
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define endl '\n'
#define next ____next
#define prev ____prev
#define hash ____hash
#define left ____left
#define to ____to
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << endl;})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<endl;})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<endl;})
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3fll;
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE {cout << -1 << endl; exit(0);}
//------------------------------------------------------------------------------------------------------

const int N = 1e5 + 10;
int a[N];
int n;

int main() {
    cin >> n;
    REP(i, n) cin >> a[i];
    int e = 0, o = 0;
    REP(i, n) {
        if(a[i] % 2 == 0) e++;
        else o++;
    }

    if(o == 1 and e == 0) cout << "YES\n";
    else if(o % 2 == 0) cout << "YES\n";
    else cout << "NO\n";


































    return 0;
}


Measured memory_bytes: 640
mark = [0,0]
n = int(input())
for i in range(n):
    a,b = input().split()
    if a<b:
        mark[1] += 3
    elif a>b:
        mark[0] += 3
    else:
        mark[0] += 1
        mark[1] += 1
print(f"{mark[0]} {mark[1]}")


Measured memory_bytes: 5608
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int a = Integer.parseInt(sc.next());
      	int b = Integer.parseInt(sc.next());
      	int x = Integer.parseInt(sc.next());
      	
      	if (a <= x && (x - a) <= b) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }
}


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

using namespace std;

int main() {
  int N;
  int max = 0;
  int min = 0x7fffffff;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    max = max < in ? in : max;
    min = min > in ? in : min;
  }
  
  cout << max - min << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXW = 1e5+2;
int N, W;
ll dp[MAXW];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> W;
	for(int i = 1;i<=N;i++){
		ll w, v;
		cin >> w >> v;
		for(int j = W;j>=w;j--){
			dp[j] = max(dp[j], dp[j-w]+v);
		}
	}
	cout << dp[W] << '\n'; 
	return 0;
}

Measured memory_bytes: 1024
def main():
    A = list(map(int, input().split()))

    diff = 0
    for i in range(len(A)):
        diff += max(A)-A[i]
    if diff%2 == 0:
        print(diff//2)
    else:
        print(diff//2+2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	string s;
	int K;
	cin >> s;
	scanf("%d", &K);

	vector<string> ST;

	REP(i, s.length()){
		FOR(j, 1, K + 1){
			string c = s.substr(i, j);
			ST.push_back(c);
		}
	}

	sort(ST.begin(), ST.end());
	ST.erase(unique(ST.begin(), ST.end()), ST.end());

	auto itr = ST.begin() + K - 1;
	cout << *itr << endl;

	return 0;
}

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

using namespace std;

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

	int x;
	cin >> x;
	x %= 7;
	if( x == 1 )cout << "fri" << endl;
	else if( x == 2 )cout << "sat" << endl;
	else if( x == 3 )cout << "sun" << endl;
	else if( x == 4 )cout << "mon" << endl;
	else if( x == 5 )cout << "tue" << endl;
	else if( x == 6 )cout << "wed" << endl;
	else if( x == 0 )cout << "thu" << endl;

	return 0;
}



Measured memory_bytes: 3220
#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>    
using namespace std;
#define LL long long
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
LL T[MAXN+5],A[MAXN+5];
int main(){
	LL n=read(),t1,t2,tmp,g;
	for(int i=1;i<=n;i++){
		T[i]=read(),A[i]=read();
		if(i==1){
			t1=T[i],t2=A[i];
			continue;
		}
		g=max((t2+A[i]-1)/A[i],(t1+T[i]-1)/T[i]);
		t2=g*A[i],t1=g*T[i];
	}
	printf("%lld\n",t1+t2);
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int mmul(int p,int q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;}

int mpow(int x,int n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}}return ans;}

int mdiv(int p,int q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);}

#define mkprm(n) int *prime=(int *)malloc((n+1)*sizeof(int)); bool *isp=(bool *)malloc((n+1)*sizeof(bool)); seive(n,isp,prime);

int seive(int n,bool *isp,int *prime){
    fill(isp,isp+n+1,true);int p=0;isp[0]=isp[1]=false;
    for(int i=2;i<=n;++i){if(isp[i]){prime[p++]=i;for(int j=2*i;j<=n;j+=i)isp[j]=false;}}
    prime[p]=-1;return p;
}

int main(){
    bool flag=false;
    ll ans=1,sum=0;

    int n;
    cin >>n;

    mkprm(n);
    for(int i=0;prime[i]!=-1;++i){
        int tmp=n;
        int fcts=0;

        while (tmp>1){
            fcts += tmp/prime[i];
            tmp/=prime[i];
        }
        //db2(prime[i],fcts);ln;
        ans = mmul(ans,fcts+1,MOD);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
D=[int(i) for i in input().split()]
T=[0 for i in range(10)]
for i in D:
    T[i]=1
S=[]
for i in range(10):
    if T[i]==0:
        S.append(i)
import itertools
L=[]
R=[]
if N>=1000:
    L=list(itertools.product(S,S,S,S))
    R=sorted([int(str(i[0])+str(i[1])+str(i[2])+str(i[3])) for i in L])
elif N>=100:
    L=list(itertools.product(S,S,S))
    R=sorted([int(str(i[0])+str(i[1])+str(i[2])) for i in L])
elif N>=10:
    L=list(itertools.product(S,S))
    R=sorted([int(str(i[0])+str(i[1])) for i in L])
else:
    L=list(itertools.product(S))
    R=sorted([int(str(i[0])) for i in L])
P=len(str(N))
for i in R:
    if int(i)>=N:
        print(i)
        exit()
if S[0]!=0:
    print(str(S[0])*(P+1))
else:
    print(str(S[1])+"0"*P)


Measured memory_bytes: 3940
#include <stdio.h>

int main() {
	int a, b,ans;

	scanf("%d %d %d %d", &a, &b);

	ans = a + b;

	if (a - b > ans) {
		ans = a - b;
	}

	if (a*b > ans) {
		ans = a*b;
	}

	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#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(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << "\n";
    }else{
        cout << "ABC" << "\n";
    }
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int N, M;
int  **inTube;
//int  **outTube;
int  *lTube;
int  *rTube;

bool dfs(int n, int i, int l, int r)
{
	if (i==M) return true;

	if (l==-1 || inTube[n][i]>lTube[l]) {
		lTube[l+1] = inTube[n][i];
		if (dfs(n, i+1, l+1, r)) return true;
	}

	if (r==-1 || inTube[n][i]>rTube[r]) {
		rTube[r+1] = inTube[n][i];
		if (dfs(n, i+1, l, r+1)) return true;
	}

	return false;
}

int main()
{
	int i, j;
	int n;
	int res = 0;

	scanf("%d ", &N);
	M = 10;
	
	inTube = (int **)calloc(N, sizeof(int *));
//	outTube = (int **)calloc(2, sizeof(int *));
	lTube = (int *)calloc(M, sizeof(int));
	rTube = (int *)calloc(M, sizeof(int));

	for (i=0; i<N; i++) {
		inTube[i] = (int *)calloc(M, sizeof(int));	
//		outTube[i] = (int *)calloc(M, sizeof(int));	

		for (j=0; j<M; j++)
			scanf("%d ", &(inTube[i][j]));
	}

	n = 0;
	while (n<N) {

		for (i=0; i<M; i++) {
			lTube[i] = 0;
			rTube[i] = 0;
		}

//		printf("Sample %d:", n);
		if (dfs(n, 0, -1, -1))
			printf("YES\n");
		else
			printf("NO\n");
/*
		for (i=0; i<M; i++) 
			printf("%d ", lTube[i]);
		puts("");

		for (i=0; i<M; i++)
			printf("%d ", rTube[i]);
		puts("");
*/
		n++;
	}

	for (i=0; i<N; i++)
		free(inTube[i]);
	free(inTube);

	free(lTube);
	free(rTube);

	return 0;
}

Measured memory_bytes: 596
n = int(input())
l = list(map(int, input().split()))

arrive_l = {}
cnt = 1
for i in range(n):
    arrive_l[l[i]] = cnt
    cnt+=1

arrival_order = sorted(arrive_l.items())
ans = ""
for i in range(n):
    ans += str(arrival_order[i][1]) + " "
    
print(ans.strip())

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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


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

    int n, x, t;cin>>n>>x>>t;
    cout << ((n-1)/x+1)*t << endl;


    return 0;
}


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

namespace AtCoder.Abc
{
    class A_171_αlphabet
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string a = Console.ReadLine();

            // 整数の入力
            // long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            // string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            // var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            // コンソール内に入力された文字が英大文字か英小文字かを判定する
            if (System.Text.RegularExpressions.Regex.IsMatch(a, "[a-z]"))
            {
                Console.WriteLine("a");
            }
            else
            {
                Console.WriteLine("A");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26828
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

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

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	var C [41]int
	for bit := 0; bit < 41; bit++ {
		count := 0
		d := 1 << uint(bit)
		for i := 0; i < N; i++ {
			if A[i]&d > 0 {
				count++
			}
		}
		C[bit] = count
	}
	var dp [42][2]int
	for i := 0; i < 41; i++ {
		ii := 40 - i
		nd := 1 << uint(ii)
		for k := 0; k < 2; k++ {
			if K < nd {
				if k == 0 {
					dp[i+1][k] = dp[i][k] + nd*C[ii]
				}
				continue
			}
			if k == 0 {
				if nd&K > 0 {
					dp[i+1][1] = max(dp[i+1][1], dp[i][k]+nd*C[ii])
					dp[i+1][0] = dp[i][k] + nd*(N-C[ii])
				} else {
					dp[i+1][0] = dp[i][k] + nd*C[ii]
				}
			} else {
				if dp[i][k] > 0 {
					dp[i+1][k] = max(dp[i+1][k], dp[i][k]+nd*max(C[ii], N-C[ii]))
				}
			}
		}
	}

	fmt.Fprintln(wtr, max(dp[41][0], dp[41][1]))
}


Measured memory_bytes: 3072
n=int(input())
q=[j**k for j in range(1,32) for k in range(2,11)]
for i in range(len(q)):
  if q[i]>1000:
    q[i]=0
q.sort(reverse=True)
x=0
while q[x]>n:
  x+=1
print(q[x])  

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 1e5+ 2, mod = 1e9 + 7;

void solve() {
	string s;
	cin >> s;
	int rem = 0;
	for (char c : s) {
		rem = (rem + (c-'0'))%9;
	}
	cout << (rem ? "No" : "Yes");
}

int main() {
	// reopen("input.txt", "r", stdin); 
 //    freopen("output.txt", "w", stdout); 
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

int main() {
  int a,b;
  string op;
  while(1){
    cin >> a >> op >> b;
    if(op == "?"){
      break;
    }

    if(op == "+"){
      cout << a+b << endl;
    }
    if(op == "-"){
      cout << a-b << endl;
    }
    if(op == "*"){
      cout << a*b << endl;
    }
    if(op == "/"){
      cout << a/b << endl;
    }


  }
}



Measured memory_bytes: 3156
import sys
s = list(input())
t = list(input())
if s == t:
    print('Yes')
    sys.exit()
for si in range(len(s)+1):
    before = s[:si+1]
    after = s[si+1:]
    if after + before == t:
        print('Yes')
        sys.exit()
print('No')

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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003

long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;

    if (x == 1) return 1;

    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }

    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  string s;
  cin>>s;
  int countm=0;
  for(int i=0;i<(int)s.length();i++)
  {
    if(s[i]=='1')
    {
        countm++;
    }
  }
  cout<<countm;
    return 0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

struct edge
{
    int to;
    bool ok;
};

vector<edge> G[MAX_N];
bool white[MAX_N];
bool visit[MAX_N];
int deg[MAX_N];

bool dfs(int u,int p)
{
    bool res = white[u];
    deg[u] = len(G[u]);
    each(e,G[u]){
        if(e.to != p){
            if(dfs(e.to,u)){
                res = true;
            }else{
                deg[u]--;
                e.ok = false;
            }
        }
    }
    return res;
}

void dfs(int u,int p,int d,int& mx,int& mxid)
{
    visit[u] = true;
    if(p != -1){
        d += white[u]^(deg[u]%2);
        if(d >= mx){
            mx = d;
            mxid = u;
        }
    }
    each(e,G[u]){
        if(e.ok && e.to != p){
            dfs(e.to,u,d,mx,mxid);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb((edge){b-1,true}),G[b-1].pb((edge){a-1,true});
    }
    string s;
    cin >> s;
    int cnt = 0;
    int st = -1;
    rep(i,n){
        if(s[i] == 'W'){
            st = i;
            cnt++;
            white[i] = true;
        }
    }
    if(cnt == 0){
        cout << "0\n";
        return 0;
    }
    dfs(st,-1);
    int d = 0,mx = 0, mxid = -1;
    dfs(st,-1,d,mx,mxid);
    int start = mxid;
    d = 0, mx = 0, mxid = -1;
    dfs(start,-1,d,mx,mxid);
    int al = 0;
    rep(i,n){
        if(visit[i]){
            al += (white[i]^(deg[i]%2))+2;
        }
    }
    cout << al - 2*(mx+1) << "\n";
    return 0;
}


Measured memory_bytes: 14288
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const ll N = 1e5 + 7;
const ll mod = 1e18 + 7;

int n, ans;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGn
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    vector < int > vc(n + 1);
    for ( int i = 1; i <= n; i++ ) {
        cin >> vc[i];
    }
    for ( int i = 1; i <= n; i++ ) {
        if ( vc[i] == i ) {
            swap(vc[i], vc[i + 1]);
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   return ceil((N-1) /(K - 1))

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

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

const int maxn = int(1e5)+5;

int A[maxn];

int main(void)
{
	int n, res = 0;
	scanf("%d", &n);
	for(int i = 1;i <= n;i++) scanf("%d", &A[i]);
	A[0] = 0, A[n+1] = 0;

	for(int i = 0;i <= n;i++) res += abs(A[i]-A[i+1]);

	for(int i = 1;i <= n;i++)
	{
		printf("%d\n", res-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i-1]-A[i+1]));
	}
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC094-D.in", "r", stdin);
	int q; 
	scanf("%d", &q);
	while (q--)
	{
		ll a, b; 
		scanf("%lld%lld", &a, &b); 
		if (a > b)
			std::swap(a, b); 
		ll l = 0, r = 1e9, c; 
		while (l <= r)
		{
			ll m = l + r >> 1; 
			if (m * m <= a * b - 1)
			{
				c = m; 
				l = m + 1; 
			}
			else
				r = m - 1; 
		}
		if (a == b || a + 1 == b)
			printf("%lld\n", a + a - 2);
		else if (c * (c + 1) >= a * b)
			printf("%lld\n", c + c - 2);
		else
			printf("%lld\n", c + c - 1);
	}
	return 0; 
}


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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        var w = b - a + 1;
        if (w % 2 == 0) w /= 2;
        else w = (w + 1) / 2;
        if (k >= w) Console.WriteLine(string.Join(" ", Enumerable.Range(a, b - a + 1)));
        else
        {
            var ans = new List<int>();
            for (int i = a; i <= a + k - 1; i++) ans.Add(i);
            for (int i = b; i >= b - k + 1; i--) ans.Add(i);
            Console.WriteLine(string.Join(" ", ans.OrderBy(x => x)));
        }
    }
}

Measured memory_bytes: 13396
// https://atcoder.jp/contests/abc104/tasks/abc104_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
//問題数、コンプリートボーナス、合計点
typedef tuple<int, int, int> mytuple;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, g, ans = INF;
    vector<mytuple> v;
    cin >> d >> g;

    for (int i = 1; i <= d; i++) {
        int p, c;
        cin >> p >> c;
        v.push_back(make_tuple(p, c, i * p * 100 + c));
    }
    //ビット探索で完答する組み合わせを求めてから難易度の高い問題から解く
    for (uint32_t i = 0; i < (1UL << d); i++) {
        int sumAns = 0, sumScore = 0;
        for (int j = 0; j < d; j++) {
            //ビットマスクして合計点と回答数を計算
            if (i & (1UL << j)) {
                sumAns += get<0>(v[j]);
                sumScore += get<2>(v[j]);
                //目標をクリアしたら、回答数が少ない方に更新
                if (sumScore >= g) {
                    ans = min(ans, sumAns);
                    break;
                }
            }
        }
        // 指定した難易度の問題を全て解いても目標点未満なら
        // 残った問題の難易度の高いもの1つのみを目標点を超えるまで解く
        bool endF = true;
        for (int j = d - 1; j >= 0 && endF; j--) {
            // 残った問題なら1問を残して解いて目標点を超えるか判定
            if (!(i & (1UL << j))) {
                endF = false;
                for (int k = 0; k < get<0>(v[j]) - 1; k++) {
                    sumAns++;
                    sumScore += (j + 1) * 100;
                    //目標をクリアしたら、回答数が少ない方に更新
                    if (sumScore >= g) {
                        ans = min(ans, sumAns);
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	ll n,a[100010];
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	ll cnt=0;
	for(ll i=1;i<n;i++){
		if(a[i-1]>=a[i]){
			cnt++;
		}
		else{
			ans=max(cnt,ans);
			cnt=0;
		}
	}
	cout << max(ans,cnt);
	// your code goes here
	return 0;
}

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

int main()
{
	string s[500];
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
	cin >> a;
	cin >> b;


	if (a<=b)
	{
		cout << a << endl;

	}
	else
	{
	cout << a-1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
bool check(string s, int n) {
	if(n%15==0) {
		if(s=="FizzBuzz") return true;
		else return false;
	} else if(n%5==0) {
		if(s=="Buzz") return true;
		else return false;
	} else if(n%3==0) {
		if(s=="Fizz") return true;
		else return false;
	} else {
		if(atoi(s.c_str()) == n) return true;
		else return false;
	}
}
int main(){
	int m,n;
	string s;
	while(cin >> m >> n, (m || n)) {
		bool f[1010] = {};
		string s[10010];
		int cur = 0;
		rep(i,n) {
			cin >> s[i];
		}
		int p = m;
		rep(i,n) {
			if(!check(s[i], i+1)) {
				f[cur%m] = true;
				p--;
			}
			if(p<=1) break;
			while(f[++cur%m]) {}
		}
		bool b = 1;
		rep(i,m) {
			if(!b && !f[i]) {
				cout << " " << i+1;
			}
			if(b && !f[i]) {
				cout << i+1;
				b = 0;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1828
N=gets.to_i

queue357 = [3, 5, 7]
queue35 = [3, 5]
queue37 = [3, 7]
queue57 = [5, 7]
queue3 = [3]
queue5 = [5]
queue7 = [7]

count357 = 0
while !queue357.empty? do
    n = queue357.shift
    if n <= N
        count357 += 1
        queue357.push(n*10+3)
        queue357.push(n*10+5)
        queue357.push(n*10+7)
    end
end

count35 = 0
while !queue35.empty? do
    n = queue35.shift
    if n <= N
        count35 += 1
        queue35.push(n*10+3)
        queue35.push(n*10+5)
    end
end

count37 = 0
while !queue37.empty? do
    n = queue37.shift
    if n <= N
        count37 += 1
        queue37.push(n*10+3)
        queue37.push(n*10+7)
    end
end

count57 = 0
while !queue57.empty? do
    n = queue57.shift
    if n <= N
        count57 += 1
        queue57.push(n*10+5)
        queue57.push(n*10+7)
    end
end

count3 = 0
while !queue3.empty? do
    n = queue3.shift
    if n <= N
        count3 += 1
        queue3.push(n*10+3)
    end
end

count5 = 0
while !queue5.empty? do
    n = queue5.shift
    if n <= N
        count5 += 1
        queue5.push(n*10+5)
    end
end

count7 = 0
while !queue7.empty? do
    n = queue7.shift
    if n <= N
        count7 += 1
        queue7.push(n*10+7)
    end
end

puts count357 - count35 - count37 - count57 + count3 + count5 + count7


Measured memory_bytes: 15264