akhauriyash/Code-Regression huggingface dataset:
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define read(FILENAME) assert(freopen((FILENAME + ".in").c_str(), "r", stdin))
#define write(FILENAME) assert(freopen((FILENAME + ".out").c_str(), "w", stdout))
#define files(FILENAME) read(FILENAME), write(FILENAME)
using namespace std;
template <typename A, typename B> void chkmin(A &x, B y) {if (x > y) x = y;}
template <typename A, typename B> void chkmax(A &x, B y) {if (x < y) x = y;}
     
typedef pair <int, int> point;
     
const string FILENAME = "input";
const int p = 1e9 + 7;


int mul(long long a, int b) {
	return a * b % p;
}

int n, m;
int ans = 1;

int main() {
	srand(time(0));
	ios::sync_with_stdio(0);
	//read(FILENAME);
	cin >> n >> m;
	if (n > m) swap(n, m);
	if (m - n > 1) {
		cout << 0 << endl;
		return 0;
	}
	if (m == n) ans = 2;
	for (int i = 1; i <= m; ++i) {
		ans = mul(ans, i);
	}
	for (int i = 1; i <= n; ++i) {
		ans = mul(ans, i);
	}
	cout << ans << endl;
}	




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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
set<string> st;
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		st.insert(s);
	}
	
	cout << st.size() << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 19248
import sys
N, M = map(int, input().split())
D = list(map(int, input().split()))
DI = list(zip(D, list(range(N))))
G = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    G[u-1].append((v-1, i))
    G[v-1].append((u-1, i))
DI.sort()
V = [-1]*N
j = 0
used = [False]*N
ans = [10**9]*M
BW = ['']*N
for j in range(N):
    d, v = DI[j]
    if used[v]:
        continue
    for nv, i in G[v]:
        if d == D[nv]:
            if BW[nv] == '':
                BW[nv] = 'B'
                BW[v] = 'W'
                ans[i] = d
                used[v] = True
                used[nv] = True
            elif BW[nv] == 'W':
                BW[v] = 'B'
                ans[i] = d
                used[v] = True
            else:
                BW[v] = 'W'
                ans[i] = d
                used[v] = True
            break
        elif used[nv]:
            if BW[nv] == 'B':
                BW[v] = 'B'
                ans[i] = d-D[nv]
                used[v] = True
            else:
                BW[v] = 'W'
                ans[i] = d-D[nv]
                used[v] = True
            break
    if not used[v]:
        print(-1)
        sys.exit()
print(*BW, sep = '')
print(*ans, sep = '\n')

Measured memory_bytes: 122988
#[allow(dead_code)]
fn main() {
    let (n, k) = i::u2();
    let mut h = i::uv(n);
    h.sort();
    let mut ans = h[n - 1];
    for i in (k - 1)..n {
        ans = min(ans, h[i] - h[i + 1 - k]);
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();//駐車する時間
       int A = sc.nextInt();//時間当たりの駐車料金
       int B = sc.nextInt();//固定料金
       int zikanRyoukin = A * N;
       if(B > zikanRyoukin){
           System.out.println(zikanRyoukin);
       }else{
           System.out.println(B);
       }
    }
}


Measured memory_bytes: 24788
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 10000000007
using namespace std;
void run(){
string s;
cin>>s;
ll n=s.length();
char old='0';
ll ans1=0,ans2=0;
for(ll i=0;i<n;i++)
{
	if(old=='0')old='1';
	else old='0';
	if(s[i]!=old)ans1++;
}
old='1';
for(ll i=0;i<n;i++)
{
	if(old=='0')old='1';
	else old='0';
	if(s[i]!=old)ans2++;
}
cout<<min(ans1,ans2);
}
int main() {
	
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string n;
    cin >> n;
    char c = n[(int)n.size()-1];
    if ( c == '3') {
        cout << "bon" << endl;
    }
    else if ( c == '2' || c == '4' || c == '5' || c == '7' || c == '9' ) {
        cout << "hon" << endl;
    } 
    else {
        cout << "pon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            if (a == b + c || b == a + c || c == a + b) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 28500
def hd(x,y):
  ans = 0
  for i in range(len(x)):
    if x[i]==y[i]:
      ans+=1
  return ans

s = input()
t = input()

if s.find(t)!=-1:
  print(0)
else:
  mx = 0
  for i in range(len(s)-len(t)+1):
    h = hd(s[i:i+len(t)],t)
    mx = max(mx,h)
  print(len(t)-mx)
	

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

int main() {
	int n,m;cin>>n>>m;
	vector<int> p(m),d;;
	for(auto& x:p){
		cin>>x;
	}
	sort(p.begin(),p.end());
	for(int i=1;i<m;i++){
		d.push_back(p[i]-p[i-1]);
	}
	sort(d.begin(),d.end());
	int ans=0;
	for(int i=0;i<m-n;i++){
		ans+=d[i];
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[][] act = new int[N][3];
        
        for(int i=0; i<N; i++) {
            String[] input = br.readLine().split(" ");
            act[i][0] = Integer.parseInt(input[0]);
            act[i][1] = Integer.parseInt(input[1]);
            act[i][2] = Integer.parseInt(input[2]);
        }
        
        System.out.println(getMaxPoints(act));
    }

    private static int getMaxPoints(int[][] act) {
        int[][] cache = new int[act.length][3];
        
        for(int i=0; i<cache.length; i++) {
            Arrays.fill(cache[i], -1);
        }

        return getMaxPointsHelper(act, cache, 0, -1);
    }
    
    private static int getMaxPointsHelper(int[][] act, int[][] cache, int row, int col) {
        if(row == act.length) {
            return 0;
        }
        
        if(col != -1 && cache[row][col] != -1) {
            return cache[row][col];
        }
        
        int maxPoints = Integer.MIN_VALUE;
        
        for(int i=0; i<3; i++) {
            if(i == col) continue;
            maxPoints = Math.max(maxPoints, act[row][i] + getMaxPointsHelper(act, cache, row+1, i));
        }

        if(col == -1) {
            return maxPoints;
        }

        cache[row][col] = maxPoints;
        
        return cache[row][col];
    }
}

Measured memory_bytes: 72456
#include <stdio.h>
#include <string.h>


int main(){
    char c[100];
    scanf("%s",c);
    if(strlen(c)>2){
        printf("%c%c%c",c[2],c[1],c[0]);
        return 0;
    }
    else
        printf("%s",c);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"sync"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	var mu = &sync.Mutex{}
	var wg sync.WaitGroup
	c := make(chan bool, 10)

	var inRanges []int

	for i := n; i > 0; i-- {
		wg.Add(1)
		c <- true
		go func(i int) {
			defer wg.Done()
			defer func() { <-c }()

			digitTotal := 0
			tempValue := i
			for tempValue > 0 {
				digitTotal += tempValue%10
				tempValue /= 10
			}

			if a <= digitTotal && digitTotal <= b {
				mu.Lock()
				inRanges = append(inRanges, i)
				mu.Unlock()
			}
		}(i)
	}

	wg.Wait()

	sum := 0
	for _, v := range inRanges {
		sum += v
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}





Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		int k;
		cin >> k;

		auto it0 = lower_bound(all(a), k);
		if (it0 != a.end())
		{
			print(distance(a.begin(), it0));
		}
		else
		{
			print(n);
		}

		print(" ");

		auto it1 = upper_bound(all(a), k);
		if (it1 != a.end())
		{
			print(distance(a.begin(), it1));
		}
		else
		{
			print(n);
		}

		println("");
	}
}



Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int taskCount = sc.nextInt();
    ArrayList<Task> tasks = new ArrayList<>();
    for (int i = 1; i <= taskCount; i++) {
      tasks.add(new Task(sc.nextInt(), sc.nextInt()));
    }
    try {
      Collections.sort(tasks, new TaskComparator());
    } catch (Exception ignored) {}
    int totalTime = 0;
    for (Task task : tasks) {
      totalTime += task.getRequiredTime();
      if (totalTime > task.getDeadline()) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

class Task {

  public Task(int requiredTime, int deadline) {
    this.requiredTime = requiredTime;
    this.deadline = deadline;
  }

  private int requiredTime;
  private int deadline;

  public int getRequiredTime() {
    return requiredTime;
  }

  public int getDeadline() {
    return deadline;
  }

}

class TaskComparator implements Comparator<Task> {

  @Override
  public int compare(Task t1, Task t2) {
    return t1.getDeadline() <= t2.getDeadline() ? -1: 1;
  }

}

Measured memory_bytes: 98840
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int H;
  while( cin >> H, H ) {
    int data[11][5];

    Rep(i, H) Rep(j, 5) cin >> data[i][j];

    int sum = 0;
    while( 1 ) {
      bool flag = false;
    
      Rep(i, H) Rep(j, 5) {
	if( data[i][j] == 0  ) continue;
	int r = j+1;
	while( r < 5 ) {
	  if( data[i][j] != data[i][r] ) break;
	  r++;
	}
	if( r - j >= 3 ) {
	  //cout << i << " " << j << " " << r << endl;
	  sum += (r - j) * data[i][j];
	  for(int k=j; k<r; k++) data[i][k] = 0;
	  flag = true;
	}
      }

      if( flag ) {
	bool flag2 = true;
	while( flag2 ) {
	  flag2 = false;
	  for(int i=H-1; i>0; i--) {
	    for(int j=0; j<5; j++) {
	      if( data[i][j] == 0 && data[i-1][j] != 0 ) {
		flag2 = true;
		data[i][j] = data[i-1][j];
		data[i-1][j] = 0;
	      }
	    }
	  }
	}
      } else {
	break;
      }
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int P[1000];

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

	sort(P, P + N);

	int sum=0;

	for (int i = 0; i < K; ++i) {
		sum += P[i];
	}

	cout << sum << endl;

}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <time.h>
#include <cstdio>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector< pair<int,int> > v;
	for(int i = 0 ; i < n ; i++){
		int a,b;
		cin >> a >> b;
		v.push_back(make_pair(-b,a));
	}
	sort(v.begin(),v.end());
	cout << v[0].second << " " << v[0].first * (-1) << endl;
}

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

signed main() {
  int h, w; cin >> h >> w;
  int row = 0, col = 0;
  string s;
  bool flag = false;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> s;
      if(s == "snuke") {
        row = i, col = j;
        flag = true;
        break;
      }
    }
    if(flag) break;
  }
  cout << (char)(col+'A') << row+1 << '\n';
  return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  int l = S.length();

  int ans = 0;
  for (int i = l - 1; i >= 2; --i) {
    if (i % 2 != 0) {
      continue;
    }

    // cout << S.substr(0, i / 2) << ":" << S.substr(i / 2, i / 2) << endl;

    if (S.substr(0, i / 2) == S.substr(i / 2, i / 2)) {
      ans = max(ans, i);
    }
  }

  cout << ans << endl;

  return 0;
}


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

    MOD = 10**9 + 7
    count = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if A[i] == A[j]:
                continue
            elif A[i] > A[j]:
                count += K + K*(K-1) // 2
            else:
                k = K - 1
                count += k + k*(k-1) // 2
            count %= MOD

    print(count)
    



main()

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;


int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n,0);
	int ans = 1000000000;
	for(int i = 0; i < n; i ++){
		int num;
		cin>>num;
		int localAns = 0;
		while( num % 2 == 0){
			num /= 2;
			localAns++;
		}
		ans = min(localAns,ans);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
using ll = long long;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;

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

    for (int i = 0; i < 3 ; i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


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


int MOD=1000000007;
int main(void){
	int N;
	string S;
	char s[10000]={};
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++){
		s[i] = S[i];
		for (int j = 0; j < N; j++){
			if(s[i]=='Z'){
				s[i] = 'A';
			}else{
				s[i] += 1;
			}
		}
	}
	for (int i = 0; i < S.size(); i++){
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int arr[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x, y;
	cin >> x >> y;

	if(arr[x - 1] == arr[y - 1]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << 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 N = sc.nextInt();
        int C = sc.nextInt();
        int[][] D = new int[C+1][C+1];
        for (int i=1; i<=C; i++) {
            for (int j=1; j<=C; j++) {
                D[i][j] = sc.nextInt();
            }
        }
        int[][] c = new int[N+1][N+1];
        for (int i=1; i<=N; i++) {
            for (int j=1; j<=N; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        System.out.println(solve(N, C, c, D));
    }

    private static int solve(int N, int C, int[][] c, int[][] D) {
        int[][] typeCount = new int[3][C+1];
        for (int i=1; i<=N; i++) {
            for (int j=1; j<=N; j++) {
                typeCount[(i+j)%3][c[i][j]]++;
            }
        }

        int minDiff = Integer.MAX_VALUE;
        for (int x=1; x<=C; x++) {
            for (int y=1; y<=C; y++) {
                if (x == y) continue;
                for (int z=1; z<=C; z++) {
                    if (y == z || z == x) continue;
                    int tmp = Math.min(minDiff, calcDiff(C, typeCount, new int[]{x, y, z}, D));
                    minDiff = Math.min(minDiff, tmp);
                }
            }
        }

        return minDiff;
    }

    private static int calcDiff(int C, int[][] typeCount, int[]  xyz, int[][] D) {
        int diff = 0;

        for (int i=0; i<3; i++) {
            for (int c=1; c<=C; c++) {
//                System.err.println("from=" + xyz[i] + " to=" + c + " for count=" + typeCount[i][c] + " with cost=" + D[c][xyz[i]]);
                diff += typeCount[i][c] * D[c][xyz[i]];
            }
        }

        return diff;
    }
}


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

typedef long long ll;
const int MAXN = 20000;

ll k = 0;
int n;
int a[MAXN], b[MAXN];
ll num[MAXN];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i], k += a[i];
    for(int i = 0; i < n; i++) cin >> b[i], k -= b[i];
    if(k > 0) return !printf("No");
    for(int i = 0; i < n; i++) num[i] = a[i] - b[i];
    sort(num, num+n, greater<ll>());
    ll t1 = 0;
    int cur = n;
    for(int i = 0; i < n; i++){
        if(num[i] > 0) t1 += num[i];
        else if(num[i] < 0){
            if((num[i] % 2 + 2) % 2 == 1) t1 ++;
        }
    }
    //cout << "k == " << k << " t1 = " << t1 << endl;
    if(t1 + k > 0) return !printf("No");
    else return !printf("Yes");



}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))

money = 1000
stocks = 0
up_flag = False

for i in range(n-1):
    if a[i] < a[i+1] and not up_flag:
        stocks += money//a[i]
        money -= stocks*a[i]
        up_flag = True
    elif a[i] > a[i+1] and up_flag:
        money += stocks*a[i]
        stocks = 0
        up_flag = False

if stocks>0:
    money += stocks*a[-1]

print(money) 

Measured memory_bytes: 9200
#!/usr/bin/env python3
import sys


def solve(N: int):
    answer = 1000 - (N % 1000)
    if answer == 1000:
        answer = 0
    return answer

def main():
    N = int(input())  # type: int
    answer = solve(N)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long>A(N+1);
  vector<long long>B(N);
  for (int i = 0; i < N+1; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  long long count = 0;
  
  for (int i = 0; i < N; i++) {
    if (B.at(i) >= A.at(i)){
      count += A.at(i);
      B.at(i) -= A.at(i);
    }
    else {
      count += B.at(i);
      B.at(i) = 0;
    }
    
    if (B.at(i) <= A.at(i+1)){
      count += B.at(i);
      A.at(i+1) -= B.at(i);
    }
    else {
      count += A.at(i+1);
      A.at(i+1) = 0;
    }
  }
  cout << count << endl;
}
 
   

Measured memory_bytes: 4756
import math

N,K = map(int,input().split())

ret = (N - K + 1) if N > K else 0
counter = N + 1 if N < K else K
C = 1 / N
tmp = 0
e = math.ceil(math.log2(K/1))
pro = 1
for i in range(e):
    pro *= 2
tmp = 1/pro
for  i in range(2,counter):
    e_next = math.ceil(math.log2(K/i))
    if e_next < e:
        e = e_next
        pro /= 2
    tmp += 1/pro
print((ret + tmp)/N)
    

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */


VVI lcs(const string&s, const string& t) {
	int n = SZ(s), m = SZ(t);
	VVI L(n + 1, VI(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				L[i][j] = L[i - 1][j - 1] + 1;
			}
			else {
				L[i][j] = max(L[i - 1][j], L[i][j - 1]);
			}
		}
	}
	return L;
}

VVL lcscount(const string&s, const string&t, const VVI &L) {
	int n = SZ(s), m = SZ(t);
	VVL D(n + 1, VL(m + 1));
	for (int i = 0; i <= n; i++)D[i][0] = 1;
	for (int j = 0; j <= m; j++)D[0][j] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				D[i][j] = D[i - 1][j - 1];
			}
			else {
				if (L[i][j] == L[i - 1][j])D[i][j] += D[i - 1][j];
				if (L[i][j] == L[i][j - 1])D[i][j] += D[i][j - 1];
				if (L[i][j] == L[i - 1][j - 1])D[i][j] -= D[i - 1][j - 1];
				if (D[i][j] >= 1E18)D[i][j] = 1E18;
			}
		}
	}
	return D;
}

VVI nexts(const string&s, int inf, int sup) {
	int n = SZ(s);
	VVI ret(n + 1, VI(sup - inf + 1, -1));
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < sup - inf + 1; j++) {
			ret[i][j] = ret[i + 1][j];
		}
		ret[i][s[i] - inf] = i;
	}

	return ret;
}

string f(const string& s, const string& t) {
	int K = 0;
	int N = SZ(s); int M = SZ(t);
	VVI L = lcs(s, t);
	if (L[N][M] == 0) {
		return "";
	}
	string rs = s; reverse(ALL(rs));
	string rt = t; reverse(ALL(rt));
	VVI RL = lcs(rs, rt);
	VVL RD = lcscount(rs, rt, RL);
	VVI sn = nexts(s, 'a', 'z');
	VVI tn = nexts(t, 'a', 'z');
	int r = 0, c = 0;
	string ret(L[N][M], ' ');
	if (K >= RD[N][M]) {
		return "";
	}
	for (int i = 0; i < L[N][M]; i++) {
		for (int j = 0; j < 26; j++) {
			int nr = sn[r][j];
			int nc = tn[c][j];
			if (nr == -1 || nc == -1)continue;
			nr++; nc++;
			if (L[nr][nc] + RL[N - nr][M - nc] != L[N][M])continue;
			if (L[nr][nc] != L[r][c] + 1)continue;
			if (K < RD[N - nr][M - nc]) {
				r = nr; c = nc;
				ret[i] = (char)('a' + j);
				break;
			}
			else {
				K -= RD[N - nr][M - nc];
			}
		}
	}
	return ret;
}
int main() {
	string s, t; cin >> s >> t;
	cout << f(s, t) << endl;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  sort(all(a));
  vector<int32> asum(n+1,0);
  REP(i,n)asum[i+1] = asum[i] + a[i];
  FORR(i,n-2,0){
    if(asum[i+1] * 2 < a[i+1]){
      ANS(n-i-1);
      return 0;
    }
  }
  ANS(n);
  return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define rep(i,m,n) for(int i = m;i < n;i++)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  int K;
  bool flag=0;
  cin >> K;
  Vec(mt,int,10*K+100,1000000);
  rep(i,0,10*K+100)mt[i]=i%K;
  DV(dp,unsigned short,2,K,45);//上位i桁決定，余りがKのとき，桁和の最小値
  dp[0][0]=0;
  rep(i,0,575){
    rep(j,0,K)rep(k,0,10)if(i!=574||j+k!=0)chmin(dp[flag^1][mt[j*10+k]],dp[flag][j]+k);
    dp[flag][0]=45;
    flag^=1;
  }
  if(K==37618||K==73433)dp[flag][0]=2;
  cout << dp[flag][0] << endl;
}

Measured memory_bytes: 7740
length = int(input())
a_list = map(int, input().split())

num_list = []
for a in a_list:
    t = a
    num = 0
    while t % 2 == 0:
        num += 1
        t = t / 2
    num_list.append(num)

print(min(num_list))
#こぴぺです。


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

double f(int K) {
    double t = K;
    int s = 0;
    while(K > 0) {
        s += K % 10;
        K /= 10;
    }
    return t / s;
}

double func(int s, int d, double t, vector<long long> &v) {
    double u = f(s);

    if (s == 98LL) {
        cerr << "pass" << s << "," << u << "," << t << endl;
    }
    if (u > t) {
        return t;
    }

    v.push_back(s);

    double r = u;

    if (d >= 10) {
        int e = s - d / 10;
        r = min(r, func(e, d / 10, r, v));
    }


    if (s - d > 0) {
        int w = s - d;
        r = min(r, func(w, d, r, v));
    }

    return r;
}

vector<int> res;

void solve(long long K){
    vector<int> v;

    int d = (int)1e15;
    func(d - 1, d / 10, d, v);
//    for(int k = 1; k < 15; ++k) {
//        cerr << k << "," << v.size() << endl;
//        double t = f(d - 1);
//        func(d - 1, d / 10, t, v);
//        d *= 10;
//    }
    sort(ALL(v));
    for(int i = 0; i < res.size(); ++i) {
        if (res[i] != v[i]) {
            cout << res[i] << " " << v[i] << endl;
            break;
        }
    }
    for(int i = 0; i < K; ++i) {
        cout << v[i] << endl;
    }
}

signed main(){
    for(int i = 1; i < 1000; ++i) {
        bool b = true;
        double s = f(i);
        for(int j = i + 1; j <= i * 10; ++j) {
            b = b && s <= f(j);
        }
        if (b) {
            res.push_back(i);
            cerr << i << " " << s << endl;
        }
    }

    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}

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

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

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

            double result = 2 * r * Math.PI;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27516
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back


void solve()
{

   int h,w;
   cin>>h>>w;

   int a,b;
   int c,d;

   cin>>a>>b;

   cin>>c>>d;

   a--;c--;b--;d--;

   int i,j;

   vector<string>v(h);

   for(i=0;i<h;i++)
   {
       cin>>v[i];
   }

   deque<pair<int,int> >q;

   q.push_front(mp(a,b));

   vector<int>temp(w,0);
   vector<int>temp2(w,100000000);
   vector<vector<int> >visited(h, temp);
   vector<vector<int> >dist(h,temp2);
   dist[a][b] = 0;

   visited[a][b] = 1;

   while(!q.empty())
   {
       pair<int,int>p = q.front();
       q.pop_front();

       int x = p.first;
       int y =p.second;
       int level = dist[x][y];
       visited[x][y] = 1;
      //cout<<x<<" "<<y<<" "<<dist[x][y]<<endl;


       for(i=-2;i<=2;i++)
       {
           for(j=-2;j<=2;j++)
           {
               if(i==0 && j==0)
                continue;

               int x1 = x+i;
               int y1 = y+j;

               if(x1>=0 && x1<h && y1>=0 && y1<w)
               {
                   if(v[x1][y1]=='.')
                   {
                       int distance = abs(x1-x) + abs(y1-y);
                       int val;
                       if(distance==1)
                       {
                           val = 0;
                       }
                       else
                        val = 1;
                      if(dist[x1][y1] > level+val)
                      {
                         if(val==1)
                         q.push_back(mp(x1,y1));
                         else
                            q.push_front(mp(x1,y1));
                         dist[x1][y1] = level+val;
                      }

                   }
               }
           }
       }

   }

   if(visited[c][d] ==0)
   {
       cout<<-1;
   }
   else
    cout<<dist[c][d];


}

int main()
{

  int t = 1;
  //cin>>t;

  while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 13472
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define ll long long
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main()
{
    int q, inputl, inputr, sim, ans;
    vector<int> l, r;
    cin >> q;
    rep(i, q)
    {
        cin >> inputl >> inputr;
        l.push_back(inputl);
        r.push_back(inputr);
    }
    //エラトステネスのふるい
    int size = 100001;
    vector<int> furui(size, 1); //素数は1
    furui[0] = 0;
    furui[1] = 0;
    for (int i = 2; i <= sqrt(size); i++)
    {
        if (furui[i] == 1)
        {
            int j = 2 * i;
            while (j < size)
            {
                furui[j] = 0;
                j += i;
            }
        }
    }
    vector<int> ln(size, 0);
    ans = 0;
    for (int i = 3; i < size; i++)
    {
        if (i % 2 == 0)
        {
            ln[i] = ans;
        }
        else if (furui[i] == 1 and furui[(i + 1) / 2] == 1)
        {
            ans++;
            ln[i] = ans;
        }
        else
        {
            ln[i] = ans;
        }
    }
    rep(i, q)
    {
        inputl = l[i];
        inputr = r[i];
        cout << ln[inputr] - ln[inputl - 1] << endl;
    }
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int A[100000];

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    int N, T;
    std::cin >> N >> T;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }
    
    int mx = 0, mx_n = 0;
    set<int> s;
    s.insert(A[0]);
    for(int i=1;i<N;++i){
        auto it = s.lower_bound(0);
        int maxDiff = A[i] - *it;
        if(maxDiff > mx){
            mx = maxDiff;
            mx_n = 1;
        }else if(maxDiff == mx){
            ++mx_n;
        }
        s.insert(A[i]);
    }

    printf("%d\n", mx_n);
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,x,j,t,a[100005];
    while(cin>>n>>x)
    {
        int sum=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        int add=x-sum;
        sort(a,a+n);
        int cc=add/a[0];

        cout<<n+cc<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long N, ans[1000000], n,d = 0;
int main(){
	//freopen("abc169.inp", "r", stdin);
	//freopen("abc169.out", "w", stdout);
	cin>>n;
	ll cc = n;
	for (int i = 2; i <= sqrt(cc); i++){
		if (n % i == 0){
			++d;
			while (n % i == 0){
				ans[d]++; n = n / i;
			}
		}
	}
	ll _ans = 0;
	if (n > 1)  _ans++;
	//for (int i = 1; i <=d ; i++) cout<<ans[i]<<"\n";
	for (int i = 1; i <= d; i++){
		ll lo = 1, hi = 1e9, res = 0;
		while (lo <= hi){
			ll mid = (lo + hi)/2;
			if (mid * (mid + 1) <= ans[i] * 2){
				res = mid;
				lo = mid + 1;
			}
			else hi = mid - 1;
		} 
		_ans += res;
	}
	cout<<_ans;
}	

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

LLI dp[101000][3];

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

  int N; cin >> N;
  vector<vector<int>> v(N, vector<int>(3)); cin >> v;

  REP(i,N){
    REP(j,3){
      REP(k,3){
	if(j==k) continue;
	dp[i+1][j] = max(dp[i+1][j], dp[i][k]+v[i][k]);
      }
    }
  }

  LLI ans = max({dp[N][0], dp[N][1], dp[N][2]});
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
vector<pil> a[100001];
int ans[100001];
bool check[100001];
void go(int x,int c) {
	ans[x] = c;
	rep(i, (int)a[x].size()) {
		int y = a[x][i].first;
		ll z = a[x][i].second;
		if (!check[y]) {
			check[y] = true;
			if (!(z & 1)) {
				go(y, c);
			}
			else {
				go(y, (c + 1) % 2);
			}
		}
	}
}
int main() { // E,F , virtual
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	rep(i, n - 1) {
		int x, y;  ll z;
		cin >> x >> y >> z;
		a[x].push_back({ y,z });
		a[y].push_back({ x,z });
	}
	check[1] = true;
	go(1, 1);
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}




}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, ans = 0;
	cin >> n;
	vector<ll> v(n);
	for (ll i = 0; i < n; i++)
		cin >> v.at(i);
	for (ll i = 0; i < n; i++) {
		while (v.at(i) % 2 == 0) {
			v.at(i) /= 2;
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  
  int N; cin >> N;
  
  string cStr; cin >> cStr;
  
  int wNumber = 0, rNumber = 0, alreadyPlaced = 0;
  
  for (int i = 0; i < cStr.size(); i++) {
    if (cStr.at(i) == 'W') wNumber++;
    if (cStr.at(i) == 'R') rNumber++;
  }
  
  for (int i = 0; i < rNumber; i++) {
    if (cStr.at(i) == 'R') alreadyPlaced++;
  }
  
  int ans = min(rNumber - alreadyPlaced, wNumber);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, m, ans, mod = 1e9+7, fac[500005], inv[500005];

ll qexp(ll a, ll b) {
    a %= mod;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return res % mod;
}

inline ll choose(ll n, ll k) {
	return (fac[n] * ((inv[k] * inv[n-k]) % mod)) % mod;
}

int main() {
	fastio; cin >> n >> m;
	fac[0] = 1; FOR(i, 1, m) fac[i] = (fac[i-1] * i) % mod;
	FOR(i, 0, m) inv[i] = qexp(fac[i], mod-2);
	FOR(i, 1, n) {
		ll t = ((fac[n-i] * choose(m-i, n-i)) % mod * choose(n, i)) % mod;
		ans += (i % 2 == 1 ? t : mod-t);
		ans %= mod;
	}
	ans = (fac[n] * choose(m, n) - ans + mod) % mod;
	cout << ((ans * fac[n]) % mod * choose(m, n)) % mod;
}


Measured memory_bytes: 11368
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,d,x;
    cin  >> n;
    cin >> d>>x;
    int a[n],b[n];
    int ans = 0;
    rep(i,n){
        cin >> a[i];
        b[i] = a[i]+1;
    }
    for (int i = 2; i <= d; i++)
    {
        rep(j,n){
            if(b[j] == i){
                ans++;
                b[j] += a[j];
            }
        }
    }
    cout << ans +x +n<< endl;
    return 0;
}

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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, x, m[max];
    int ans=0, prc=0;
    
    scanf("%d%d", &n, &x);
    rep(i, n){
        scanf("%d", &m[i]);
    }
    
    qsort(m, n, sizeof(int), up_comp);
    
    ans=n;
    rep(i, n){
        prc+=m[i];
    }
    
    ans+=(x-prc)/m[0];
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 1740
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 10000;


bool isPrime(int x){
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;

    int i = 3;
    while(i <= sqrt(x)){
        if(x % i == 0) return false;
        i += 2;
    }
    
    return true;
}


int main(){
    int A[MAX], n, count = 0;

    cin >> n;
    rep(i, n) cin >> A[i];
    
    rep(i, n){
        if(isPrime(A[i])) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> ii;
 
const int N = 1e5 + 5;
 
int n,x[N],y[N],h[N];
 
int geth(int cx,int cy) {
  int res = -1,mx = -1;
  for (int i = 1 ; i <= n ; i++) {
    int a = abs(cx - x[i]);
    int b = abs(cy - y[i]);
    if (res == -1) {
      if (h[i] == 0) {
        mx = max(mx,a + b);
      } else {
        res = a + b + h[i];
      }
    } else {
      if (max(res - a - b,0) != h[i]) return -1;
    }
  }
  if (mx != -1 && res > mx) return -1;
  return res;
 
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++)
    cin >> x[i] >> y[i] >> h[i];
  for (int cx = 0 ; cx <= 100 ; cx++)
    for (int cy = 0 ; cy <= 100 ; cy++) {
      int temp = geth(cx,cy);
      if (temp != -1) {
        cout << cx << " " << cy << " " << temp << endl;
        return 0;
      }
    }
}

Measured memory_bytes: 256