akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define tam 102
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef pair<double,double> pt;
ll fmin(ll n,ll m)
{
    if (n*m-ll(n/2)*m<=n*m-ll(m/2)*n)
        return ll(n/2)*m;
    else
        return ll(m/2)*n;
}
ll go(ll n,ll m)
{
    ll area1,area2,area3;
    ll ans=1e18;
    forr(i,1,m)
    {
        area1=i*n;

        area2=fmin(m-i,n);
        area3=(m-i)*n-area2;
        //cout<<area1<<" "<<area2<<" "<<area3<<" : "<<i<<endl;
        ans=min(max(max(area3,area1),area2)-min(min(area3,area1),area2),ans);
    }
    return ans;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    if (n==2&& m==2)
    {
        cout<<1<<endl;
    }
    else
    {
        if (n%3==0|| m%3==0)
            cout<<0<<endl;
        else
        {
            cout<<min(go(n,m),go(m,n))<<endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, m;
vector<int> a[MAXN];
ll res[MAXN], f[MAXN], z[MAXN];

void dfs(int u, int p) {
    f[u] = 1;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == p) continue;
        dfs(v, u);
        f[u] = f[u] * (f[v] + 1) % m;
    }
    ll e = 1;
    FORE(i,SZ(a[u])-1,0) {
        int v = a[u][i];
        if (v == p) continue;
        z[v] = e;
        e = e * (f[v] + 1) % m;
    }
}

void dfs2(int u, int p, ll x) {
    res[u] = f[u] * (x + 1) % m;
    ll l = 1, r = 1;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == p) continue;
        r = z[v];
        ll w = (x + 1) * l % m * r % m;
        dfs2(v, u, w);
        l = l * (f[v] + 1) % m;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(v);
        a[v].emplace_back(u);
    }
    dfs(1, 0);
    dfs2(1, 0, 0);
    FOR(i,1,n) cout << res[i] << "\n";
    return 0;
}


Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int l ,r;
	cin>>l>>r;
	int d;
	cin>>d;
	int ans=0;
	FOR(i,l,r+1){
		if(i%d==0){
			ans++;
		}
	}
	cout<<ans<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3636
"use strict"

function Main(input) {
  input = input.split(" ");

  const N = parseInt(input[0], 10);
  const Y = parseInt(input[1], 10);

  let result = '-1 -1 -1';

  for (let a = 0; a <= N; a++) {
    for (let b = 0; b <= N; b++) {
      if ((a + b) > N) continue;

      let sum = (a * 10000) + (b * 5000) + ((N - a - b) * 1000);
      if (sum === Y) {
        result = `${a} ${b} ${N - a - b}`;
        break;
      }
    }
  }
  console.log(result);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>
#include <set>


using namespace std;

//二次元の外積
//回転の方向
double gaiseki(double x1, double y1, double x2, double y2){
    return x1*y2-x2*y1;
}

bool inside_outside_of_triangle(double xpa, double ypa, double xpb, double ypb, double xpc, double ypc, double x, double y){
    double vab_x = xpa-xpb;
    double vab_y = ypa-ypb;
    double vbc_x = xpb-xpc;
    double vbc_y = ypb-ypc;
    double vca_x = xpc-xpa;
    double vca_y = ypc-ypa;
    double vap_x = xpa-x;
    double vap_y = ypa-y;
    double vbp_x = xpb-x;
    double vbp_y = ypb-y;
    double vcp_x = xpc-x;
    double vcp_y = ypc-y;
    
    double direction_a = gaiseki(vca_x,vca_y,vap_x,vap_y);
    double direction_b = gaiseki(vab_x,vab_y,vbp_x,vbp_y);
    double direction_c = gaiseki(vbc_x,vbc_y,vcp_x,vcp_y);
    
    direction_a/=fabs(direction_a);
    direction_b/=fabs(direction_b);
    direction_c/=fabs(direction_c);
    
    if(direction_a==direction_b&&direction_b==direction_c)return true;
    else return false;

}



int main(){
    int n;
    while(cin>>n){
        for(int i=0; i<n; i++){
            double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
            cin>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3>>xk>>yk>>xs>>ys;
            bool in_bega = inside_outside_of_triangle(xp1, yp1, xp2, yp2, xp3, yp3, xs, ys);
            bool in_altair = inside_outside_of_triangle(xp1, yp1, xp2, yp2, xp3, yp3, xk, yk);
            if((in_bega&&!in_altair)||(!in_bega&&in_altair))cout<<"OK"<<endl;
            else cout<<"NG"<<endl;
        }
   
    }
}

Measured memory_bytes: 1224
package main

import (
	"fmt"
)

var c, d int

func main() {
	var n int

	fmt.Scan(&n)
	c, d = 4, 7

	if helper(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func helper(money int) bool {
	if money%c == 0 {
		return true
	}

	if money%d == 0 {
		return true
	}

	if money >= c {
		return helper(money - c)
	}
	if money >= d {
		return helper(money - d)
	}

	return false
}


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

#define inf INT_MAX

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

    int arr[n];

    for(int i=0; i<n; i++){
        cin >> arr[i];
    }

    int dp[n];

    dp[0] = 0;
    for(int j=1; j<n; j++){
        dp[j] = inf;
        for(int i=j-1; i>=0 && j-i<=2; i--){
            dp[j] = min(dp[j], abs(arr[j]-arr[i])+dp[i]);
        }
    }

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


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

using namespace std;


int main()
{
    int N;
    int V[100], C[100];
    cin >> N;
    for (int i = 0;i < N;i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = ans + max(0, V[i] - C[i]);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int64 ret = 0;

  {
    int64 get = min(B, C);
    ret += get * 2;
    B -= get;
    C -= get;
  }

  {
    int64 get = min(A, C);
    ret += get;
    A -= get;
    C -= get;
  }

  if(C > 0) {
    ++ret;
  }

  cout << ret + B << endl;
}



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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W;
    cin >> H >> W;

    vector<vector<char>> blocks(H, vector<char>(W, '.'));

    vector<int> dispRow;
    vector<int> dispCol;
    vector<char> tmpBlocks;

    REPinit(i, 0, H) {
        REPinit(j, 0, W) {
            cin >> blocks[i][j];
            if (blocks[i][j] == '#') {
                dispRow.push_back(i);
                dispCol.push_back(j);
            }
        }
    }
    
    REPinit(i, 0, H) {
        if(std::find(dispRow.begin(), dispRow.end(), i) == dispRow.end()) continue;
        REPinit(j, 0, W) {
            if(std::find(dispCol.begin(), dispCol.end(), j) == dispCol.end()) continue;
            cout << blocks[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String []args){
        Scanner in = new  Scanner(System.in);
        int x = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        System.out.println((x - a) - ((x - a) / b) * b);
    }
}


Measured memory_bytes: 21588
// AtCoder Beginner Contest 139 C - Lower
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] heights = new int[n];
        for(int i = 0; i < n; i++){
            heights[i] = scan.nextInt();
        }

        int downCountMax = 0;
        int downCount = 0;
        for(int i = 0; i <= n - 2; i++){
            if(heights[i] >= heights[i + 1]){
                downCount += 1;
                downCountMax = Math.max(downCount, downCountMax);
            }else{
                downCount = 0;
            }
        }

        System.out.println(downCountMax);
    }
}


Measured memory_bytes: 51528
def divisor(n):
    div = set()
    for i in range(1, n // 2 + 1):
        d, m = n // i, n % i
        if m == 0:
            div.add(i)
            div.add(d)
        if d < i:
            break
    return sorted(list(div))  

n = int(input())
if n < 105:
  print(0)
else:
  count = 0
  for n in range(105, n + 1, 2):
    if len(divisor(n)) == 8:
      count += 1
  print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void)
{
	int d, n, ans = 0;
	scanf("%d %d", &d, &n);

	int i = (int)pow(100.0, (double)d);
	for (int j = 1; j <= n; j++)
	{
		ans += i;
		if (ans % (i * 100) == 0) ans += i;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

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

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

template <class T>
inline void show(T a) {
    cout << a << endl;
}

typedef struct{
    ll x;
    ll y;
}idx;



//------------------------main function-------------------------------
void Main(){
    string a;
    cin >> a;
    if(a == "SUN"){
        cout << 7 << endl;
    }else if(a == "MON"){
        cout << 6 << endl;
    }else if(a == "TUE"){
        cout << 5 << endl;
    }else if(a == "WED"){
        cout << 4 << endl;
    }else if(a == "THU"){
        cout << 3 << endl;
    }else if(a == "FRI"){
        cout << 2 << endl;
    }else if(a == "SAT"){
        cout << 1 << endl;
    }
    
    
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}



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

int onaji(int n){
    int a;
    int b;
    int c;
    int d = 0;
    a = n % 10;
    b = (n / 10) % 10;
    c = ((n / 10) / 10) % 10;
    if(a == b && b == c)d = 1;
    return d;

}

int main(){
    int N ;
    cin >> N ;
    while(1){
    int owari = onaji(N);
    if(owari == 1)break;
    N++;
    }
    cout << N << endl;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        r: i32
    }
    println!("{}", r * r);
}

Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
  int  N,A,B;
  scanf("%d",&N);
  scanf("%d",&A);
  scanf("%d",&B);
  if(N*A>B)
  {
    printf("%d",B);
  }
  else if(N*A<B)
  {
    printf("%d",N*A);
  }
  else if(N*A==B)
  {
    printf("%d",B);
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

//最大公約数
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    ll N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    //sort(A.begin(), A.end());
    ll GCD = gcd(A[0], A[1]);
    for(int i = 2; i < N; i++) GCD = gcd(GCD, A[i]);
    cout << GCD << endl;

    
}

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

void strplus(string& s, int nn, int c)
{
	switch (nn) {
	case 0:
		break;
	case 1:
		switch (c % 5) {
		case 0:
			s += ".";
			break;
		case 1:
			s += ",";
			break;
		case 2:
			s += "!";
			break;
		case 3:
			s += "?";
			break;
		case 4:
			s += " ";
			break;
		}
		break;
	case 2:
		switch (c % 3) {
		case 0:
			s += "a";
			break;
		case 1:
			s += "b";
			break;
		case 2:
			s += "c";
			break;
		}
		break;
	case 3:
		switch (c % 3) {
		case 0:
			s += "d";
			break;
		case 1:
			s += "e";
			break;
		case 2:
			s += "f";
			break;
		}
		break;
	case 4:
		switch (c % 3) {
		case 0:
			s += "g";
			break;
		case 1:
			s += "h";
			break;
		case 2:
			s += "i";
			break;
		}
		break;
	case 5:
		switch (c % 3) {
		case 0:
			s += "j";
			break;
		case 1:
			s += "k";
			break;
		case 2:
			s += "l";
			break;
		}
		break;
	case 6:
		switch (c % 3) {
		case 0:
			s += "m";
			break;
		case 1:
			s += "n";
			break;
		case 2:
			s += "o";
			break;
		}
		break;
	case 7:
		switch (c % 4) {
		case 0:
			s += "p";
			break;
		case 1:
			s += "q";
			break;
		case 2:
			s += "r";
			break;
		case 3:
			s += "s";
			break;
		}
		break;
	case 8:
		switch (c % 3) {
		case 0:
			s += "t";
			break;
		case 1:
			s += "u";
			break;
		case 2:
			s += "v";
			break;
		}
		break;
	case 9:
		switch (c % 4) {
		case 0:
			s += "w";
			break;
		case 1:
			s += "x";
			break;
		case 2:
			s += "y";
			break;
		case 3:
			s += "z";
			break;
		}
		break;
	}
}

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

	for (int i = 0; i < n; i++) {
		string str;
		string temp;

		cin >> temp;

		int nownum = 0;
		int count = 0;

		for (unsigned int j = 0; j < temp.size(); j++) {
			if (stoi(temp.substr(j, 1)) == 0) {
				strplus(str, nownum, count);
				nownum = 0;
			}
			else {
				if (nownum == stoi(temp.substr(j, 1))) {
					count++;
				}
				else {
					nownum = stoi(temp.substr(j, 1));
					count = 0;
				}
			}
		}

		cout << str << endl;
	}

	return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	vector<int64> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
	}
	sort(aa.begin(), aa.end());
	int64 ans = 0, sum = 0;
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		sum += aa[ii];
		if(aa[ii + 1] <= 2 * sum)
		{
			ans++;
		}
		else
		{
			ans = 0;
		}
	}
	if(aa[nn - 1] > sum * 2)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> check(n + 1, 0);
    vector<int> cnt(n + 1, 0);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        check[b] = a;
    }
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        cnt[p] += x;
    }
    for(int i = 1; i < n; i++){
        int score = cnt[i], p = i;
        while(check[p]){
            p = check[p];
            score += cnt[p];
        }
        check[i] = 0;
        cnt[i] = score;
        cout << score << " ";
    }
    int score = cnt[n], p = n;
    while(check[p]){
        p = check[p];
        score += cnt[p];
    }
    cout << score << "\n";
}

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

char in[11];
pair<pair<string,int>,int> p[100];

int main()
{
  int n;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    int t;
    cin >> in >> t;
    string tmp = in;
    p[i] = make_pair(make_pair(tmp,-t),i);
  }
  sort(p,p+n);
  for(int i=0; i<n; i++)
  {
    cout << p[i].second+1 << endl;
  }
}


Measured memory_bytes: 256
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 takahashi=0;
		
		for(int month = 1 ; month <= a ; month ++) {
			for(int day = 1; day <= 31 ; day ++) {
				if(month==a && day>b) {
					break;
				}
				if(month == day ) {
					takahashi++;
				}
			}
		}
		System.out.println(takahashi);
	}
}


Measured memory_bytes: 21588
use proconio::{input, fastout, marker::Chars};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        r: usize, s: usize, p: usize,
        t: Chars,
    }

    let mut ans: usize = 0;
    let mut it = t.iter();
    let mut q: VecDeque<char> = VecDeque::with_capacity(k);
    for _ in 0..k {
        let c = it.next().unwrap();
        q.push_back(*c);
        ans += match c {
            'r' => p,
            's' => r,
            'p' => s,
            _ => unreachable!(),
        }
    }

    for c in it {
        let lchar = q.pop_front().unwrap();
        if c == &lchar {
            q.push_back('_');
            continue;
        }
        q.push_back(*c);
        ans += match c {
            'r' => p,
            's' => r,
            'p' => s,
            _ => unreachable!(),
        }
    }

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


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a==b&&a!=c) cout<<"Yes"<<endl;
    else if(a==c&&a!=b) cout<<"Yes"<<endl;
    else if(b==c&&a!=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

int v[1005];
int col[1006];

int main() {
    //freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

    int aux = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        if(x >= 3200) {
            aux++;
            continue;
        }
        col[x / 400]++;
    }

    int m;
    m = 0;
    for(int i = 0; i <= 100; i++) {
        if(col[i] != 0) {
            m++;
        }
    }

    cout << max(1, m) << " " << m + aux;
    cout << "\n"; return 0;
}


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

int main()
{
	int n,d;
	cin>>n>>d;
	int arr[n][2];
	
	for(int i=0;i<n;i++)
	{
       for(int j=0;j<2;j++)
       {
       	  scanf("%d",&arr[i][j]);
	   }
	   printf("\n");
	}
	double res;
	int count = 0;
	
	for(int p = 0;p<n;p++)
	{
		double temp = pow(arr[p][0],2) + pow(arr[p][1], 2);
		res = sqrt(temp);
		
		if( res <= d)
		{
			count++;
		}
	}
	
	cout<< count ;
	
	return 0;
}

Measured memory_bytes: 5308
from math import gcd # Python3.6以降
# --------------------------------------------------------------

# n以下の素数列挙: O-nlogn
# def primes(n):
#     prs = []
#     is_prime = [True] * (n + 1)
#     is_prime[0] = False
#     is_prime[1] = False
#     for i in range(2, int(n**0.5)+1):
#         if not is_prime[i]:
#             continue
#         for j in range(i*2, n+1, i):
#             is_prime[j] = False
#     for i in range(len(is_prime)):
#         if is_prime[i]:
#             prs.append(i)
#     return prs

n    = int(input())
lis  = list(map(int,input().split()))
A    = 10**6
nlis = [0]*A
flg_pairwise = True

for i in range(n):
    nlis[lis[i]-1] += 1

for i in range(2,A):
    cnt = 0
    for j in range(i-1,A,i):
        cnt += nlis[j]
    if cnt > 1:
        flg_pairwise = False
        break

if flg_pairwise:
    print('pairwise coprime')
else:
    for i in range(n-1):
        if i==0:
            tmp = gcd(lis[i],lis[i+1])
        else:
            tmp = gcd(tmp,lis[i+1])

    if tmp==1:
        print('setwise coprime')
    else:
        print('not coprime')

Measured memory_bytes: 128672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  if(n%2==0){
    cout << n << endl;
  }
  else{
    cout << 2*n << endl;
  }
}
    


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, H, W;
    cin >> N >> H >> W;
    cout << max(0LL, N - H + 1) * max(0LL, N - W + 1) << endl;
    return 0;
}


Measured memory_bytes: 3620
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

int n;
struct seq
{
	LL a[233],lb;
	bool operator ==(const seq&b)const
	{
		for(int i=2;i<=n;i++)if(a[i]-a[1]!=b.a[i]-b.a[1])return false;
		return true;
	}
	bool operator <(const seq&b)const
	{
		for(int i=2;i<=n;i++)if(a[i]-a[1]!=b.a[i]-b.a[1])return a[i]-a[1]<b.a[i]-b.a[1];
		return false;
	}
};
vector<seq>all;

#define getcode(msk,i) ((msk>>i)&1)
LL a[233],c[233],m;
LL calc(LL l,LL r,int&cnt)
{
	if(l==0){cnt=0;return 0;}
	LL ret=0;cnt=0;
	for(int i=60;i>=0;i--)
	{
		if(getcode(r,i)){ret|=1ll<<i;cnt++;}
		if(getcode(l-1,i)!=getcode(r,i))break;
	}
	return ret;
}
int main()
{
	get2(n,m);for(int i=1;i<=n;i++)get1(a[i]);sort(a+1,a+n+1);
	for(int k=0;k<=60;k++)
	{
		for(int i=1;i<=n;i++)c[i]=a[i]&(1ll<<k)-1;
		sort(c+1,c+n+1);c[0]=-1;
		for(int i=1;i<=n;i++)if(c[i]!=c[i-1])
		{
			int now;LL p=calc(c[i-1]+1,c[i],now);
			now+=k;for(int j=1;j<=n;j++)if(a[j]<p)now=-1;
			if(now!=-1&&now<=m)
			{
				seq tmp;for(int j=1;j<=n;j++)tmp.a[j]=(a[j]-p)>>k;
				tmp.lb=max(0ll,tmp.a[1]-m+now);all.pb(tmp);
			}
		}
	}
	sort(all.begin(),all.end());
	LL ans=0;
	for(int i=0,nxt=0;i<(int)all.size();i=nxt)
	{
		vector<pair<LL,LL> >v;
		for(;nxt<(int)all.size()&&all[nxt]==all[i];nxt++)v.pb(mp(all[nxt].lb,all[nxt].a[1]));
		sort(v.begin(),v.end());
		LL mx=-1;
		for(auto&x:v)
		{
			if(x.ff>mx)ans=(ans+x.ss-x.ff+1)%mod;
			else if(x.ss>mx)ans=(ans+x.ss-mx)%mod;
			mx=max(mx,x.ss);
		}
	}
	printendl(ans);
	return 0;
}

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

/*
int MCM(int i, int j, int p[]) {
  int min = MAX;
  if (i == j) return 0;
  if (i < j) {
    int temp;
    for (int k = i; k < j; k++) {
      temp = MCM(i, k, p)+MCM(k+1, j, p)+p[i-1]*p[k]*p[j];
      if (min > temp) min = temp;
    }
  }
  return min;
}
*/

int main(void) {
  int n; cin >> n;
  int r[n]; int c[n];
  for (int i = 0; i < n; i++) {
    cin >> r[i] >> c[i];
  }

  long long m[n+1][n+1]; int p[n+1];
  for (int i = 0; i < n; i++) p[i] = r[i]; p[n] = c[n-1];
  for (int i = 1; i <= n; i++) m[i][i] = 0;
  //int ans = MCM(1, n, p);
  //cout << ans << endl;  
  for (int k = 1; k < n; k++) { //kはm[i][j]におけるj-iの値
    for (int i = 1; i+k <= n; i++) { //iはm[i][j]におけるi
    long long temp; m[i][i+k] = MAX; //tempmin_はm[i][i+k]の値
      for (int l = i; l < i+k; l++) { //lはm[i][i+k]を分割する地点
        temp = m[i][l]+m[l+1][i+k]+p[i-1]*p[l]*p[i+k];
        if (m[i][i+k] > temp) m[i][i+k] = temp;
      }
    }
  }
  cout << m[1][n] << endl;
}


Measured memory_bytes: 3128
#CGL_4-A Convex Polygon - Convex Hull
def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    return True
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = []
for i in n:
    P.append([int(x) for x in input().split()])
      
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33540
import sys

def gcd (x,y):
  if y :
    return gcd(y, x%y)
  else:
    return x
  
# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A,B=map(int,sys.stdin.readline().split())
ansList=factorization(gcd(A,B))
if ansList[0][0] == 1:
  print(len(ansList))
else:
  print(len(ansList)+1)

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

namespace AtCoder.Contests.NOMURA2020
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var h1 = NextInt();
            var m1 = NextInt();
            var h2 = NextInt();
            var m2 = NextInt();
            var k = NextInt();

            var oki = h1 * 60 + m1;
            var neru = h2 * 60 + m2;

            Console.WriteLine(Math.Max(0, neru - oki - k));

        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27340
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main(){
  int a, b ,c, d;
  int n,m;
  string s,t;

  cin >> a>>b>>c>>d;

  cout << (a-c)*(b-d) << endl;;
}


Measured memory_bytes: 256
S = input()

mod = 1000000007

dp = [[0, 0, 0] for _ in range(len(S))]

mul = 1

if S[0] == "A":
    dp[0][0] = 1
elif S[0] == "?":
    dp[0][0] = 1
    mul *= 3

for i in range(1, len(S)):
    if S[i] == "A":
        dp[i][0] = dp[i - 1][0] + mul
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = dp[i - 1][2]
    elif S[i] == "B":
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][0] + dp[i - 1][1]
        dp[i][2] = dp[i - 1][2]
    elif S[i] == "C":
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = dp[i - 1][1] + dp[i - 1][2]
    elif S[i] == "?":
        dp[i][0] = ((dp[i - 1][0] * 3) % mod + mul) % mod
        dp[i][1] = ((dp[i - 1][1] * 3) % mod + dp[i - 1][0]) % mod
        dp[i][2] = ((dp[i - 1][2] * 3) % mod + dp[i - 1][1]) % mod
        mul = (mul * 3) % mod

print(dp[-1][2] % mod)

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool sortbysecdesc(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}



void solve()
{
    int n;cin>>n;
    ll a[n];fo(i,n)cin>>a[i];
    dsort(a,n);
    queue<ll>q;
    q.push(a[1]);
    q.push(a[1]);
    ll ans=a[0];
    for(int i=2;i<n;i++)
    {
       // dbg(ans)
        ll tmp=q.front();
        ans+=tmp;
        q.pop();
        q.push(a[i]);
        q.push(a[i]);
    }
    print(ans)
}


int main()
{
  //  fastio();
   // test
    solve();
}


Measured memory_bytes: 6540
import sys
sys.setrecursionlimit(20000000)

N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')

Measured memory_bytes: 87196
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  int ans=0;
  for (int i=a; i<b+1; i++) {
    if (i/10000 != i%10) continue;
    if ((i/1000)%10 != (i/10)%10) continue;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll N,A,B;
vector<ll>h(100005);
bool isOK(ll mid){
	ll ret=0;
	for(int i=0;i<N;i++){
		if(h[i]-mid*B>0){
			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);
		}
	}
	return ret<=mid;
}


int main(){
	init();
	ll N;cin>>N;
	vector<ll>A(N);
	set<ll>set;
	ll num=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(A[i]>=3200)num++;
		else set.insert(A[i]/400);
	}
	cout<<max((int)set.size(),1)<<endl;
	cout<<set.size()+num<<endl;
}


Measured memory_bytes: 1024
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        s: String
    };
    let s: Vec<char> = s.chars().collect();
    if s[2] == s[3] && s[4] == s[5]  {
        println!("Yes");
    } else {
        println!("No");
    };
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[100005][5] = {};
signed main() {
    int N;
    cin >> N;
    int a,b,c;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i = 1; i < N; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1]+a,dp[i-1][2]+a);
        dp[i][1] = max(dp[i-1][0]+b,dp[i-1][2]+b);
        dp[i][2] = max(dp[i-1][0]+c,dp[i-1][1]+c);
    }
    cout << max({dp[N-1][0],dp[N-1][1],dp[N-1][2]}) << endl;
}


Measured memory_bytes: 7528
/*
[abc129] E - Sum Equals Xor
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100001;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf inv() { return gf(mod_inv(n, MOD)); }
    gf pow(int n) {
        gf a = *this;
        gf x = 1;
        for (; n > 0; n >>= 1) {
            if (n & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

bitset<MAX_N> L;
gf dp[MAX_N + 1][2];

ll solve() {
    dp[MAX_N][0] = 1;
    for (int i = MAX_N; i > 0; i--) {
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j <= (smaller ? 1 : L[i - 1]); j++) {
                dp[i - 1][smaller || j < L[i - 1]] += dp[i][smaller] * (j + 1);
            }
        }
    }
    gf ans = dp[0][0] + dp[0][1];
    return ans.n;
}

int main() {
    cin >> L;

    cout << solve() << endl;

    return 0;
}


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

int main() {
  int A,B;
  int S,s1,s2,s3,s4,s5;
  int count = 0;
  cin >> A >> B;
  for(int i=A; i<=B; i++){
    S = i;
    s1 = S % 10;
    S /= 10;
    s2 = S % 10;
    S /= 10;
    s3 = S % 10;
    S /= 10;
    s4 = S % 10;
    s5 = S / 10;
    if(s1 == s5 && s2 == s4)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
ll my_gcd( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X;
    ll x[100010];
    cin >> N >> X;
    rep(i,0,N){
        cin >> x[i];
    }
    ll d[100010] = {};
    rep(i,0,N){
        d[i] = abs(X - x[i]);
    }
    ll ans = d[0];
    ll d_tmp[100010] = {};
    if(N % 2 == 0){
        rep(j,0,N/2){
            d_tmp[j] = my_gcd(d[2*j],d[2*j+1]);
        }
        rep(j,0,N/2){
            ans = my_gcd(ans, d_tmp[j]);
        }
    }else{
        rep(j,0,(N-1)/2){
            d_tmp[j] = my_gcd(d[2*j],d[2*j+1]);
        }
        rep(j,0,(N-1)/2){
            ans = my_gcd(ans, d_tmp[j]);
        }
        ans = my_gcd(ans, d[N-1]);

    }
    print(ans);



}


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

def dfs(h,w,c):
  if h == H - 1 and w == W - 1:
    return c + 1

  if H - 1 < h or W -1 < w:
    return 0
  
  if GRID[h][w] != "#":
    return 0
  
  
  right = dfs(h+1,w,c+1)
  down = dfs(h,w+1,c+1)

  return max(right,down)

NUM = sum([GRID[x].count("#") for x in range(H)])

n = dfs(0,0,0)

if n == NUM:
  print("Possible")
else:
  print("Impossible")





Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int N, M;
    cin >> N >> M;
    if (N == 0) return false;

    vector<int> ma(M, 0);
    for (int i = 0; i < N; ++i) {
        int d, v;
        cin >> d >> v;
        --d;
        ma[d] = max(ma[d], v);
    }
    cout << accumulate(ma.begin(), ma.end(), 0) << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3084
n, m = map(int, input().split())
ps = [list(map(str, input().split())) for i in range(m)]

AC =[0]*n
WA = [0]*n
WA_ans = [0]*n

for i in range(m):
    if AC[int(ps[i][0])-1] == 0:
        if ps[i][1] == 'AC':
            AC[int(ps[i][0])-1] = 1
            WA_ans[int(ps[i][0])-1] = WA[int(ps[i][0])-1]

        elif ps[i][1] == 'WA':
            WA[int(ps[i][0])-1] += 1

print(sum(AC), sum(WA_ans))

Measured memory_bytes: 35700
#include <algorithm>
#include <iostream>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = LONG_LONG_MAX / 2;

vector<ll> A;

int main(void) {
    int N;
    cin >> N;

    int zero_count = 0;
    int minus_count = 0;
    ll small_abs_value = INF;
    A.resize(N);
    for (int i = 0; i < N; i++) {
        ll x;
        cin >> x;
        A[i] = x;
        if (x == 0) {
            zero_count++;
        } else if (x < 0) {
            minus_count++;
        }
        chmin(small_abs_value, abs(x));
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(A[i]);
    }

    if (zero_count > 0 || (minus_count % 2 == 0)) {
        cout << ans << endl;
    } else {
        ans -= small_abs_value * 2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

#include <bits/stdc++.h>
using namespace std;

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;

        ll i,j,k,x,y,z,m,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
	string s1,str;
	map<ll,ll>MAP;
	vector<ll>v;
	set<ll>s;

	cin>>n;



    for(i=1;i<n;i++)
	{

            a=n/i;
            c1=c1+a;

            if(n%i==0)
                c1--;

	}


	cout<<c1;
	nl;

}


Measured memory_bytes: 3652
N, K = map(int, input().split())
r = [False for _ in range(N+1)]
b = [1 for _ in range(N+1)]
r[1] = True
r_cnt = 1
for _ in range(K):
  x, y = map(int, input().split())
  b[x] -= 1
  b[y] += 1
  if r[x]:
    if b[x] == 0:
      r[x] = False
      r_cnt -= 1
    if not r[y]:
      r[y] = True
      r_cnt += 1
print(r_cnt)

Measured memory_bytes: 84792