akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n;
        static long k;
        static int[] As;
        public static void Main(string[] args)
        {
            input();
            int cur = 0, t = 1, s = 1;
            int[] memo = new int[n];
            memo[0] = 1;

            while(true && k > 0)
            {
                cur = As[cur];
                t++;
                k--;
                if (memo[cur] > 0)
                {
                    s = t - memo[cur];
                    break;
                }
                memo[cur] = t;
            }
            k %= s;
            while(k > 0)
            {
                cur = As[cur];
                k--;
            }
            //Console.WriteLine(s);
            //Console.WriteLine(t);
            Console.WriteLine(cur + 1);
        }
        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            n = int.Parse(buf[0]);
            k = long.Parse(buf[1]);
            As = new int[n];
            buf = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                As[i] = int.Parse(buf[i]) - 1;
            }
        }

    }
}

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

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

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

#define INF 1e16
#define mod 1000000007

ll m,k;
vector<ll> res;

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

  cin>>m>>k;

  ll n=(1<<m);
  if(k>=n){
    cout<<-1<<endl;
    return 0;
  }

  if(n%4==0){
    rep(i,n)if(i!=k)res.push_back(i);
    res.push_back(k);
    rep(i,n)if(n-1-i!=k)res.push_back(n-1-i);
    res.push_back(k);
  }else{
    if(n==1){
      rep(i,2)res.push_back(0);
    }else{
      if(k==1){
        cout<<-1<<endl;
        return 0;
      }else{
        rep(i,2)res.push_back(0);
        rep(i,2)res.push_back(1);
      }
    }
  }

  rep(i,res.size())cout<<res[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 4080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        NSlimes solver = new NSlimes();
        solver.solve(1, in, out);
        out.close();
    }

    static class NSlimes {
        long[] prefix;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            long[][] dp = new long[n][n];
            prefix = new long[n];
            prefix[0] = arr[0];
            for (int i = 1; i < n; i++)
                prefix[i] = prefix[i - 1] + arr[i];
            for (long[] x : dp)
                Arrays.fill(x, (long) 1e18);
            for (int i = 0; i < n; i++)
                for (int j = i; j >= 0; j--)
                    if (j == i)
                        dp[i][j] = 0;
                    else {
                        for (int k = j; k < i; k++)
                            dp[j][i] = Math.min(dp[j][i], dp[j][k] + getPrefix(j, k) + dp[k + 1][i] + getPrefix(k + 1, i));
                    }
            pw.println(dp[0][n - 1]);
        }

        private long getPrefix(int i, int j) {
            long temp = prefix[j];
            if (i != 0)
                temp -= prefix[i - 1];
            return temp;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
    long int X,i,j,flag=0;
    cin >> X; 
  for(i=-1000;i<1000;i++){
    for(j=-1000;j<1000;j++){
      if(pow(i, 5)-pow(j,5) == X){
        printf("%ld %ld\n",i,j);
        return 0;
        break;
      }
    }
    if(flag==1)break;
  }

  return 0;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;



int main()
{
ll a,b,h,m;
cin>>a>>b>>h>>m;
long double k = (0.5)*(h*60 +m);
long double j = 6*m;
k= k-j;
//cout<<k<<endl;

long double x = k*3.14159265358979/180.0;
long double v = cos(x);
long double ans = a*a + b*b - 2*a*b*v;
ans = sqrt(ans);
printf("%.12Lf",ans);

return 0;
}

Measured memory_bytes: 4092
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val prim :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) church_list) ->
    (* 始点 *)
    Vertex.t ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) church_list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let prim es s =
    { fold = fun f init ->
        (*
         * プリム法のメインループ
         * acc : 最小全域木に使うのが確定した辺を入れるやつ
         * vs : 訪れた頂点の集合
         * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
         *)
        let rec prim acc vs q =
          match WMap.min_binding q with
          | exception Not_found -> acc
          | (w, []) -> prim acc vs (WMap.remove w q)
          | (w, (u, v) :: rest) ->
              ( if VSet.mem v vs
                (* vは既に訪れていた *)
                then prim acc vs
                (* vはまだ訪れていなかった *)
                else prim_aux (f (u, v, w) acc) vs v ) (WMap.add w rest q)
        (* vを訪れ，vから伸びる辺をキューに追加してループを続行する *)
        and prim_aux acc vs v q =
          prim acc (VSet.add v vs) @@
          (es v).fold (fun (u, w) q ->
            WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) q in
        prim_aux init VSet.empty s WMap.empty }
end

module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  Printf.printf "%d\n" @@
  (G.prim (fun v -> { G.fold = fun f -> List.fold_right f es.(v) }) 0).fold (fun (_, _, w) -> ( + ) w) 0


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

using namespace std;
const long long INF = 1LL << 60;

int A,B,C,N;
int r, t = -1;
int main(){
  cin >> A >> B >> C;
  N = A;
  r = A%B;
  t = r;
  if(r == C){
    cout << "YES" << endl;
    return 0;
  }

  while(r != C){
    N += A;
    r = N % B;
    if(t == r){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
bool dp[100005];
int a[105];
int main(){
	int n, k;
	for (int i = 0; i<100005; i++) dp[i] = false;
	cin >> n >> k;
	for (int i = 0; i<n; i++) cin >> a[i];
	dp[0] = false;
	for (int i = 1; i<100005; i++){
		for (int j = 0; j<n; j++){
			if (i >= a[j] && dp[i - a[j]] == false) dp[i] = true;
		}
	}
	if (dp[k] == true) cout << "First\n";
	else cout << "Second\n";
	return 0;
}

 


Measured memory_bytes: 384
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int x[N],bk[17][N];
int main()
{
	int n,l,q;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",x+i);
	scanf("%d%d",&l,&q);
	int pre=0;
	for(int i=0;i<n;i++)
	{
		while(x[i]-x[pre]>l)
			pre++;
		bk[0][i]=pre;
	}
	for(int i=1;i<17;i++)
		for(int j=0;j<=n;j++)
			bk[i][j]=bk[i-1][bk[i-1][j]];
	for(;q--;)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		if(a==b)
		{
			puts("0");
			continue;
		}
		if(a>b)
			swap(a,b);
		int ret=0;
		for(int i=16;i>=0;i--)
		{
			if(bk[i][b]>a)
			{
				ret+=1<<i;
				b=bk[i][b];
			}
		}
		printf("%d\n",ret+1);
	}
	return 0;
}


Measured memory_bytes: 7808
from collections import deque


n = int(input())
g_list = {}
for _ in range(n):
    n1, num, *cl = map(int, input().split())
    g_list[n1] = cl

# 書けないから移す。
GRAY = 1
WHITE = 0
BLACK = 2


class Graph():
    def __init__(self, g_list):
        self.g_list = g_list
        self.dst = [-1] * (len(g_list)+1)
        self.stack = deque([])
        self.colors = [WHITE] * (len(g_list)+1)

    def bfs(self, s):
        self.colors[s] = GRAY
        self.dst[s] = 0
        self.stack.append(s)

        while self.stack:
            u = self.stack.popleft()
            for v in self.g_list[u]:
                if self.colors[v] == WHITE:
                    self.colors[v] = GRAY
                    self.dst[v] = self.dst[u] + 1
                    self.stack.append(v)
            self.colors[u] = BLACK


g = Graph(g_list)
g.bfs(1)
for i in range(1, n+1):
    print(i, g.dst[i])



Measured memory_bytes: 6040
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,_n,k,res,cnt,a[200010],sum[200010];
int sm[800010],addv[800010];
map<int,int> mp,pm;

inline void init(int x)
{
	_n=1;
	while(_n<x) _n*=2;
	for(int i=1;i<=2*_n;i++){sm[i]=0;addv[i]=0;}
}

inline void maintain(int o,int l,int r)
{
	int lc=o*2,rc=o*2+1;
	sm[o]=0;
	if(r>l){
		sm[o]=sm[lc]+sm[rc];
	}
	sm[o]+=addv[o]*(r-l+1);
}

inline void update(int o,int l,int r,int xx,int yy,int v)
{
	int lc=o*2,rc=o*2+1;
	if(xx<=l&&yy>=r){
		addv[o]+=v;
	}
	else{
		int m=l+(r-l)/2;
		if(xx<=m) update(lc,l,m,xx,yy,v);
		if(yy>m) update(rc,m+1,r,xx,yy,v);
	}
	maintain(o,l,r);
}

inline void query(int o,int l,int r,int add,int xx,int yy)
{
	if(xx<=l&&yy>=r){
		res+=sm[o]+add;
	}else{
		int m=l+(r-l)/2;
		if(xx<=m) query(o*2,l,m,add+addv[o],xx,yy);
		if(yy>m) query(o*2+1,m+1,r,add+addv[o],xx,yy);
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];a[i]-=k;
	}
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	for(int i=0;i<=n;i++) mp[sum[i]]=1;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		cnt++;
		pm[it->first]=cnt;
	}
	for(int i=0;i<=n;i++) sum[i]=pm[sum[i]];
	int ans=0ll;
	init(cnt);
	for(int i=0;i<=n;i++){
		res=0ll;query(1,1,_n,0,1,sum[i]);
		ans+=res;
		update(1,1,_n,sum[i],sum[i],1ll);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 40832
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn = 5e5 + 50;
typedef pair<int, int> P;

int arr[maxn];
int a, b, c, d, e, f, g;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=0; i<t; i++)
	{
		solve();
	}
	return 0;
}

// type below

void solve()
{
	cin >> a;
	lli ans = 0;
	for(int i=1; i<=a; i++)
	{
		for(int j=1; j <= a; j++)
		{
			for(int k=1; k <= a; k++)
			{
				ans += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3620
if __name__ == '__main__':
    p_taro, p_hanako = 0, 0
    n = int(input())
    for i in range(n):
        animal_taro, animal_hanako = input().split()
        if animal_taro > animal_hanako:
            p_taro += 3
        elif animal_taro < animal_hanako:
            p_hanako += 3
        else:
            p_taro, p_hanako = p_taro+1, p_hanako+1
    print(p_taro, p_hanako)

Measured memory_bytes: 6724
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn main() {
    let s = read_line();
    let mut it = s.split_whitespace().map(|s| s.parse().unwrap());
    let h = it.next().unwrap();
    let w = it.next().unwrap();

    let mut ss: Vec<Vec<char>> = (0..h).map(|_| read_line().chars().collect()).collect();

    for y in 0..h {
        for x in 0..w {
            let mut cnt = 0;
            if ss[y][x] != '.' {
                continue;
            }

            static VECT: &'static [(isize, isize)] = &[
                (-1, -1),
                (-1, 0),
                (-1, 1),
                (0, -1),
                (0, 1),
                (1, -1),
                (1, 0),
                (1, 1),
            ];

            for &(dx, dy) in VECT {
                let cx = x as isize + dx;
                let cy = y as isize + dy;

                if cx >= 0 && cx < w as isize && cy >= 0 && cy < h as isize
                    && ss[cy as usize][cx as usize] == '#'
                {
                    cnt += 1;
                }
            }

            ss[y][x] = ('0' as u8 + cnt) as char;
        }
    }

    for row in ss {
        println!("{}", row.iter().cloned().collect::<String>());
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 3e6;
const ll mod = 1e9+7;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * (ll)i % mod;
        inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
  ll x, y;
  cin >> x >> y;
  ll a = min(x,y);
  ll b = max(x,y);
  COMinit();
  if((a + b) % 3) {
    cout << 0 << endl;
    return 0;
  }
  ll t = (a + b)/ 3;
  cout << COM(t,a-t) << endl;
  return 0;
}


Measured memory_bytes: 70528
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	string s;
	cin >> s;
	int l = s.length();
	if (s[0] == s[l - 1]) {
		// ゲーム終了後の文字列の長さは奇数
		if (l % 2 == 0) {
			cout << "First" << endl;
		} else {
			cout << "Second" << endl;
		}
	} else {
		// ゲーム終了後の文字列の長さは偶数
		if (l % 2 == 0) {
			cout << "Second" << endl;
		} else {
			cout << "First" << endl;
		}
	}
}

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

using namespace std;
string a, b, s="";
int arr[3001][3001], alen, blen;

void dp(string a, string b)
{
	alen = a.length(), blen = b.length();
	for(int i = 0; i<=blen; i++)
	{
		for(int j=0; j<=alen; j++)
		{
			int k=i-1, l=j-1;
			if(i==0 || j==0)
				arr[i][j]=0;
			else
			{
				if(a[l]==b[k])
				{
					arr[i][j]=1+arr[i-1][j-1];
				}
				else
					arr[i][j] += max(arr[i-1][j], arr[i][j-1]);
			}
		}
	}
	int curmax=arr[blen][alen];
	int i = blen, j=alen;
	while(i>0 && j>0)
	{
		if(arr[i][j]==curmax && arr[i][j] > arr[i-1][j] && arr[i][j] > arr[i][j-1])
		{
			s = a[j-1] + s;
			curmax-=1;
			i-=1;
			j-=1;
		}
		else if(arr[i-1][j]>arr[i][j-1])
			i-=1;
		else
			j-=1;
	}
}
int main()
{
	cin >> a >> b;
	dp(a, b);
	cout << s;
}

Measured memory_bytes: 35456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt()*s.nextInt();
        if(a%2==0) System.out.println("No");
        else System.out.println("Yes");


    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main(){

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int left = A + B, right = C + D;
	if(left > right) cout << "Left" << endl;
	else if(left < right) cout << "Right" << endl;
	else if(left == right) cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, x;
    cin >> n >> d >> x;
    rep(i, n) {
      int day, tmp;  cin >> day;
      tmp = day;
      ++x;
      day += 1;
      while (day <= d) {
        ++x;
        day += tmp;
      }
    }
    cout << x << '\n';

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);

vector<ll> v,w;
vector<vector<ll>> table;

ll dp(ll i,ll j)
{
  if(table.at(i).at(j)!=0) {return table.at(i).at(j);}
  if(i==0||j==0) {return 0;}
  if(j-w.at(i)<0) 
  {
    table.at(i).at(j)=dp(i-1,j);
    return table.at(i).at(j);
  }
  table.at(i).at(j)=max(v.at(i)+dp(i-1,j-w.at(i)),dp(i-1,j));
  return table.at(i).at(j);
}  
  

int main() 
{
  ll N,W; cin>>N>>W;
  v=vector<ll>(N+1);
  w=vector<ll>(W+1);
  table=vector<vector<ll>> (N+1,vector<ll>(W+1,0));
  rep(i,N)
  {
    cin>>w.at(i+1)>>v.at(i+1);
  }  
  cout<<dp(N,W)<<endl;
  return 0;
}

Measured memory_bytes: 83948
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int N;
  cin >> N;
  VI A(N+1,0);
  VI B(N, 0);
  REP(i, N+1) cin >> A[i];
  REP(i, N) cin >> B[i];
  ll ans = 0;
  REP(i, N+1)
  {
    if (i > 0 && B[i-1] > 0) {
      if (A[i] >= B[i-1]) {
        A[i] -= B[i-1];
        ans += B[i-1];
        B[i-1] = 0;
      } else {
        ans += A[i];
        B[i-1] -= A[i];
        A[i] = 0;
      }
    }
    if (A[i] > 0 && i < N) {
      if (A[i] >= B[i]) {
        A[i] -= B[i];
        ans += B[i];
        B[i] = 0;
      } else {
        ans += A[i];
        B[i] -= A[i];
        A[i] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll root = sqrt(n);
    ll x = root;
    while(true){
        if(n % x == 0) break;
        x--;
    }
    ll other = n / x;
    cout << x + other - 2 << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    for(int i=1;i<=360;i++)
    {
        if(((x*i)%360)==0)
        {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

#define rep(i,b,n) for(int i = b ; i < n ; i++)
const int MAX = 500;

int main(){
  int H,W;

  while(cin >> H >> W , H | W){
    string s[MAX];
    int field[MAX][MAX];

    rep(i,0,H){
      cin >> s[i];
      rep(j,0,W){

	if(s[i][j] == '*') field[i][j] = 0;
	else{
	  if(j > 0) field[i][j] = field[i][j-1] + 1;
	  else field[i][j] = 1;
	}

      }
    }

    int res = 0;

    rep(i,0,W){
      rep(j,0,H){
	int width = 1e9;
        rep(k,j,H){
	  width = min(width,field[k][i]);
	  res = max(res,(k-j+1)*width);
	}
      }
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 2452
n,a = map(int,input().split())
x = sorted(list(map(lambda y:int(y)-a,input().split())))

sx = max(abs(x[0]),abs(x[-1]))*n

dp = [[0 for _ in range(2*sx+2)] for _ in range(n+1)]
dp[0][0] = 1

for j in range(n):
    for t in range(-sx-1,sx+1):
        if -sx <= t-x[j] and t-x[j] <= sx: 
            dp[j+1][t] = dp[j][t] + dp[j][t-x[j]]
        else:
            dp[j+1][t] = dp[j][t]

print(dp[n][0]-1)

Measured memory_bytes: 43868
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	
	if((a==1 && b==2) || (a==2 && b==1))
	cout<<3;
	
	else if((a==3 && b==2) || (a==2 && b==3))
	cout<<1;
	
	else if((a==1 && b==3) || (a==3 && b==1))
	cout<<2;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    int L,R;
    L=1;
    R=n;
    REP(i,m){
        int l,r;
        cin>>l>>r;
        if(l>L)L=l;
        if(r<R)R=r;

    }
    OUT(max(0,R-L+1));
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int m[1005][1005];
int main()
{
	int H, W, A, B;
	scanf("%d%d%d%d", &H, &W, &A, &B);
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < A; j++) {
			m[i][j] = 1;
		}
	}
	for (int i = B; i < H; i++) {
		for (int j = A; j < W; j++) {
			m[i][j] = 1;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%d", m[i][j]);
		}
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 5120
/*************************************************************************
  >         File: D.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 21 Aug 2016 09:00:08 PM CST
*************************************************************************/
#include <bits/stdc++.h>
using LL = long long;
const int N = 1e5 + 5;
int visited[N], p[N], tot;

void Prime() {
  for (int i = 2; i < N; i++) {
    if (!visited[i]) p[tot++] = i;
    for (int j = 0; j < tot && i * p[j] < N; j++) {
      visited[i * p[j]] = p[j];
      if (i % p[j] == 0) break;
    }
  }
}

template<class T>
void in(T& x) {
  char c;
  while (isspace(c = getchar()));
  x = c - '0';
  while (!isspace(c = getchar())) x = 10 * x + c - '0';
}

std::vector<LL> numbers;
std::map<LL, LL> match;

inline int Count(LL x) {
  return std::upper_bound(numbers.begin(), numbers.end(), x) - std::lower_bound(numbers.begin(), numbers.end(), x);
}

int main() {
  std::ios::sync_with_stdio(0);
  Prime();
  int n;
  in(n);
  int zero = 0;
  for (int i = 0; i < n; i++) {
    LL x;
    in(x);
    LL now = 1, pair = 1;
    for (int j = 0; j < tot && 1LL * p[j] * p[j] * p[j] <= x; j++) if (x % p[j] == 0) {
      int cnt = 0;
      while (x % p[j] == 0) {
        x /= p[j];
        cnt++;
      }
      cnt %= 3;
      for (int i = 0; i < cnt; i++) now *= p[j];
      for (int i = 0; i < (3 - cnt) % 3; i++) pair *= p[j];
    }
    if (x == 1 && now == 1) {
      zero++;
    } else if (x == 1) {
      numbers.emplace_back(now);
      match[now] = pair;
    } else if (x != 1) {
      int rt = sqrt(x + 0.5);
      if (1LL * rt * rt == x) {
        now *= x;
        pair *= rt;
      } else {
        if (x >= N) continue;
        now *= x;
        pair *= x * x;
      }
      numbers.emplace_back(now);
      match[now] = pair;
    }
  }
  std::sort(numbers.begin(), numbers.end());
  int nouse = 0;
  for (auto it = numbers.begin(); it != numbers.end(); ) {
    auto number = *it;
    nouse += std::min(Count(number), Count(match[number]));
    it = std::upper_bound(numbers.begin(), numbers.end(), number);
  }
  std::cout << n - zero - nouse / 2 + (zero > 0) << std::endl;
  return 0;
}


Measured memory_bytes: 6644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=2e6;
int n,rt1,rt2,dx=0,px;
int d[N+10],deep[N+10];
vector <int> edge[N+10];
void Add(int u,int v) {
    edge[u].push_back(v);
    edge[v].push_back(u);
}
void Dfs1(int x,int fat) {
    deep[x]=dx;
    int cnt=0;
    for (int i=0;i<(int)edge[x].size();i++) {
        int kx=edge[x][i];
        if (kx==fat) continue;
        ++cnt;
        ++dx;
        Dfs1(kx,x);
        --dx;
    }
    if (cnt>=2&&deep[x]>=deep[px]) px=x;
}
void Dfs2(int x,int fat,bool vis) {
    if (x==px) vis=1;
    for (int i=0;i<(int)edge[x].size();i++) {
        int kx=edge[x][i];
        if (kx==fat) continue;
        Dfs2(kx,x,vis);
    }
    if (vis&&d[x]==1) {
        if (rt1) rt2=x;
        else rt1=x;
    }
}
int Solve(int x,int fat) {
    int sum=0;
    int zero=0;
    for (int i=0;i<(int)edge[x].size();i++) {
        int kx=edge[x][i];
        if (kx==fat) continue;
        int nowx=Solve(kx,x);
        sum+=nowx;
        if (nowx==0) zero++;
    }
    if (zero>1) sum+=zero-1;
    return sum;
}
int main() {
    scanf("%d",&n);
    if (n==1) {
        printf("0\n");
        return 0;
    }
    if (n==2) {
        printf("1\n");
        return 0;
    }
    for (int i=1;i<n;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        u++;
        v++;
        Add(u,v);
        d[u]++;
        d[v]++;
    }
    int rt=1;
    for (int i=2;i<=n;i++)
        if (d[i]>=2) rt=i;
    Dfs1(rt,-1);
    Dfs2(rt,-1,0);
    int ans=min(Solve(rt1,-1),Solve(rt2,-1))+1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 60800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ld n, m, d; cin >> n >> m >> d;
    cout << (n - d) / n * (m - 1) / n * (d == 0 ? 1 : 2) << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int c1,c5,c10,c50,c100,c500;
	long int sum;
	
	scanf("%d",&c1);
	scanf("%d",&c5);
	scanf("%d",&c10);
	scanf("%d",&c50);
	scanf("%d",&c100);
	scanf("%d",&c500);
	
	c1 *= 1;
	c5 *= 5;
	c10 *= 10;
	c50 *= 50;
	c100 *= 100;
	c500 *= 500;
	
	sum = c1 + c5 + c10 + c50 + c100 + c500;
	
	if(sum >= 1000){
		printf("1\n");
	}
	else if(sum < 1000){
		printf("0\n");
	}
	else{
		putchar('\n');
	}
	
	
	return 0;
}

Measured memory_bytes: 1804
N = int(input())
S = input()

def solve(s,K):
    alpha2num = lambda s: ord(s) - ord('A') + 1
    num2alpha = lambda num: chr(num+64)
    num  = alpha2num(s)
    try_num = (num+K)%26
    if try_num == 0:
        try_num = 26
    alpha = num2alpha(try_num)
    return alpha
output = []
for i in range(len(S)):
    output.append(solve(S[i],N))
print(''.join(output))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int D = 365;
vector<int> c(27);
vector<vector<int>> s(D + 1);

ll calc_score(vector<int> &t) {
    ll satisfy = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= D; ++i) {
        int con = t[i];
        // add satisfy
        satisfy += s[i][con];
        // update last
        last[con] = i;
        // sub satisfy
        for (int j = 1; j <= 26; ++j) {
            satisfy -= c[j] * (i - last[j]);
        }
    }
    return satisfy;
}

int main() {
    clock_t start = clock();

    cin >> D;
    for (int i = 1; i <= 26; ++i) cin >> c[i];
    for (int i = 1; i <= D; ++i) {
        vector<int> v(27);
        for (int j = 1; j <= 26; ++j) cin >> v[j];
        s[i] = v;
    }

    // output
    vector<int> ans(D + 1);
    vector<int> last(27, 0);
    ll satisfy = 0;
    for (int i = 1; i <= D; ++i) {
        ll max_pen = 0;
        ll choose_con = 0;
        for (int j = 1; j <= 26; ++j) {
            ll penalty = c[j] * (i - last[j]);
            if (penalty > max_pen) {
                choose_con = j;
                max_pen = penalty;
            }
        }
        // actual update
        int con = choose_con;
        last[con] = i;
        ans[i] = con;
    }

    // random
    // cout << "random" << endl;
    // clock_t end = clock();
    // double time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    ll best_score = calc_score(ans);
    random_device rd{};
    for (int i = 0; i < 50000; ++i) {
        // random
        ll times = rd() % 100;
        vector<int> c_ans = ans;
        for (int j = 0; j < times; ++j) {
            ll day = rd() % 360 + 1;
            ll con = rd() % 25 + 1;
            c_ans[day] = con;
        }
        ll score = calc_score(c_ans);
        if (score > best_score) ans = c_ans;
        // end = clock();
        // time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    }

    // output
    for (int i = 1; i <= D; ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3708
#include <stdio.h>

int main(void){
	
	typedef long long int lld;
	lld untasty_cure, tasty_cure, tasty_poison; 
	scanf("%lld %lld %lld", &untasty_cure, &tasty_cure, &tasty_poison);
	
	if(tasty_poison-1 <= tasty_cure + untasty_cure) printf("%lld", tasty_poison + tasty_cure);
	else printf("%lld", tasty_cure * 2 + untasty_cure + 1);
}

Measured memory_bytes: 128
import Control.Monad
import Control.Applicative
import Data.List
import Data.List.Split

main = do
  xs <- input (map read . splitOn ",") :: IO [[Int]]
  mapM_ putStrLn $ solve xs

solve :: [[Int]] -> [String]
solve = map poker

poker :: [Int] -> String
poker xs
  | cs == [1,4] = "four card"
  | sxs == [1,10,11,12,13] = "straight"
  | f sxs = "straight"
  | cs == [2,3] = "full house"
  | cs == [1,1,3] = "three card"
  | cs == [1,2,2] = "two pair"
  | cs == [1,1,1,2] = "one pair"
  | otherwise = "null"
  where
    cs = (sort . map length . group . sort) xs
    sxs = sort xs
    f [y] = True
    f (y:z:zs) = if y + 1 == z then f (z:zs) else False

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

Measured memory_bytes: 4164
n=int(input())
abc=[list(map(int,input().split())) for _ in range(n)]
dp=[abc[0]]
for i in range(1,n):
    dp.append([])
    dp[-1].append(max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0]))
    dp[-1].append(max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1]))
    dp[-1].append(max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2]))
print(max(dp[-1]))

Measured memory_bytes: 78296
n,a,b=map(int,input().split())
X=list(map(int,input().split()))
Y=[0]*(n-1)
cnt=0
for i in range(n-1):
    Y[i]=X[i+1]-X[i]
    if a*Y[i]>=b:
        cnt+=b
    else:
        cnt+=a*Y[i]
print(cnt)

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



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    string s;
    cin>>s;
    ll ans = 0;
    s = "0"+s;
    int n = s.size();
    ll dp[n+1][2]={};
    for(int i=0;i<=n;i++){
        dp[i][0]=1e16;
        dp[i][1] = 1e16;
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        dp[i+1][0] = dp[i][0] + s[i]-'0';
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-s[i]+'0');

        dp[i+1][1] = dp[i][0] + s[i]-'0'+1;
        dp[i+1][1] = min(dp[i+1][1], dp[i][1] + 9-s[i]+'0');
        //dp[i+1][1] = min(dp[i+1][1], dp[i+1][1] + s[i])
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 16968
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
	vector<int> v(3);
	cin >> v[0]>> v[1]>> v[2];
	sort(all(v));
	cout << v[0] + v[1] << endl;
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    int a,mx=0,mn=1000;
    while (n--) {
        cin>>a;
        mx=max(mx,a);
        mn=min(mn,a);
    }
    cout<<mx-mn<<endl;
    return 0;
}

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 X = sc.nextInt();
		if(A==X) {
			if(A+B>X) {
				System.out.println("YES");
				return;
			}
		}
		else if(A<X) {
			if(A+B==X || A+B>X) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int a,b;
    cin>>a>>b;
    int ans = 0;
    if (a >= b) {
        ans += a;
        a--;
    } else {
        ans += b;
        b--;

    }
    ans += max(a,b);
    cout<<ans<<endl;

    return 0;
}


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

int V, Mod;
vector<vector<int>> es;
vector<ll> dp0, dp1, y;

void erase(vector<int>& v, int x) { v.erase(remove(v.begin(), v.end(), x), v.end()); }

ll dfs0(int u, int p)
{
	erase(es[u], p);
	for (int v : es[u]) dp0[u] = dp0[u] * (dfs0(v, u) + 1) % Mod;
	return dp0[u];
}

void dfs1(int u)
{
	int W = es[u].size();
	y[W] = 1;
	for (int i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
	ll x = 1;
	for (int i = 0; i < W; i++)
	{
		dp1[es[u][i]] = (dp1[u] + 1) * x % Mod * y[i + 1] % Mod;
		x = x * (dp0[es[u][i]] + 1) % Mod;
	}
	for (int v : es[u]) dfs1(v);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> V >> Mod;
	dp0 = vector<ll>(V, 1);
	dp1 = vector<ll>(V);
	y = vector<ll>(V + 1, 1);
	for (int i = 0; i < V; i++) es.emplace_back(vector<int>());
	for (int i = 0; i < V - 1; i++)
	{
		int x, y; cin >> x >> y;
		es[x - 1].push_back(y - 1);
		es[y - 1].push_back(x - 1);
	}
	dfs0(0, -1);
	dfs1(0);
	for (int u = 0; u < V; u++) cout << dp0[u] * (dp1[u] + 1) % Mod << "\n";
    return 0;
}


Measured memory_bytes: 12272
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max 100001
int main()
{
    int N,i,t,x,y,d,dt;
    scanf("%d",&N);
    int lx=0,ly=0;
    int lt=0;
    int flag=0;
    for(i=0;i<N;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        d=abs(x-lx+y-ly);
        dt=abs(t-lt);
        ///printf("%d %d\n",d,dt);
        ///if((dt<d)||(d!=0&&dt%d!=0&&dt%d%2!=0)||(d==0&&dt%2!=0)||(d!=0&&d%2!=0&&(dt/d)%2==0))
           /// flag=1;
        if(d>dt||(dt-d)%2!=0)
            flag=1;
        lt=t;
        lx=x;
        ly=y;
    }
    if(flag==1)
        printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[25]; 
int res=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=1;i<n-1;i++)
	{
		int t=0;
		if (a[i-1]>a[i]) t++;
		if (a[i+1]>a[i]) t++;
		if (t==1) res++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
X,N=map(int,input().split())


    
if N==0:
	print(X)
else:
  p=list(map(int,input().split()))
  p=sorted(p)
  if X in p:
      s=X-1
      t=X+1
      while True:
          if s not in p:
              print(s)
              break
          elif t not in p:
              print(t)
              break
          else:
              s=s-1
              t=t+1
  else:
      print(X)


Measured memory_bytes: 27040
#include <stdio.h>

int main(){
  int n,count=0;
  char a[101],b[101],c[101];
  scanf("%d",&n);

  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);

  for(int i=0;i<n;i++){
    if((a[i]-b[i])*(b[i]-c[i])*(c[i]-a[i])!=0){
      count+=2;
    }else if(a[i]-b[i]==0 && b[i]-c[i]==0){
    }else{
      count++;
    }
  }

  printf("%d",count);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>

using namespace std;

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

int main(int argc, char *argv[])
{
  int n,x;
  vector<int> v;
  cin>>n>>x;
  //int p[1111111111];
  
  for(int i = 0;i<n;i++){
    int tmp;
    cin>>tmp;
    v.push_back(abs(tmp-x));
  }
  int ans = 0;
  if (n == 1) {
    ans = gcd(v[0],0);
  }else if(n > 1){
    int tmp = v[0];
    for(int i = 1;i<n;i++){
      tmp = gcd(tmp,v[i]);
    }
    ans = tmp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultipleArray solver = new AMultipleArray();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultipleArray {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] ar = new long[n];
            long[] mod = new long[n];
            long res = 0;
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextLong();
                mod[i] = in.nextLong();
            }
            for (int i = 0; i < n; i++) {
                ar[n - 1 - i] += res;
                long tmp = (mod[n - 1 - i] - ar[n - 1 - i] % mod[n - 1 - i]) % mod[n - 1 - i];
                res += tmp;
            }
            out.println(res);
        }

    }
}



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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N,greater<ll>());
    int cnt=0;
    int pow=1;
    int ind=0;
    ll ans=0;
    while(true){
        if(cnt==N-1) break;
        if(cnt==pow){
            ind++;
            pow+=2;
        }
        cnt++;
        ans+=a[ind];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#include <atcoder/mincostflow>

using namespace std;
using namespace atcoder;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll = long long;

#define S (n * 2)
#define T (n * 2 + 1)
#define K (n * k)

const int M = 1000000007;

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

  mcf_graph<int, ll> g(n * 2 + 2);
  g.add_edge(S, T, K, M);
  rep(i, n) {
    g.add_edge(S, i, k, 0);
    g.add_edge(n + i, T, k, 0);
    rep(j, n) {
      int a; cin >> a;
      g.add_edge(i, n + j, 1, M - a);
    }
  }

  ll c = (ll)K * M - g.flow(S, T, K).second;
  vector<string> f(n, string(n,'.'));
  for (auto e: g.edges()) {
    if (e.from != S && e.to != T && e.flow > 0) {
      f[e.from][e.to - n] = 'X';
    }
  }

  cout << c << endl;
  rep(i, n) cout << f[i] << endl;

  return 0;
}


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

int main(){
    char a[1001], b[1001];
    scanf("%s%s", a, b);
    int aL = strlen(a), bL = strlen(b);
    int res = aL;
    for(int i = 0; i <= aL - bL; i++){
        int dif = 0;
        for(int j = 0; j < bL; j++){
            if(b[j] != a[i + j])
                dif++;
        }
        res = min(res, dif);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3804