akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

	int ans=0;
	for(int i=0;i<N-2;i++){
		if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C')	ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,div1,div2,rem,sum;
    scanf("%d",&n);
    div1=n/500;
    rem=n%500;
    div2=rem/5;
    sum=(div1*1000)+(div2*5);
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
/*
 * ID: ITP_3_C
 * Problem: swapping
 */

#include <stdio.h>

int main(void)
{
    int x, y;

    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0)
            break;
        if (x < y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
    } 

    return 0;
}



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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, b;
	int64_t tmp, k;
	vector<int64_t> a(100001, 0);

	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp >> b;
		a[tmp] += b;
	}
	// for (int i = 1; i <= 3; i++)
	// 	cout << a[i] << endl;
	tmp = 0;
	for (int i = 1; i < 100001; i++)
	{
		tmp += a[i];
		if (k <= tmp)
		{
			cout << i << endl;
			break;
		}
	}
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c > 21)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int q = scan.nextInt();
    long sum = 0;

    int[] a = new int[100001];

    for (int i=1;i<100001;i++){
      a[i] = find(i);
    }

    int count = 0;
    int[] b = new int[100001];
    for (int i=0;i<100001;i++){
      if (a[i] == 1){
        count += 1;
      }
      b[i] = count;
    }

    while (q > 0){
      sum = 0;
      int l = scan.nextInt();
      int r = scan.nextInt();
      sum = b[r] - b[l-1];
      System.out.println(sum);
      q--;
    }
  }

  static int find(int n){
    if (n == 3){
      return 1;
    }

    if (n%4 == 1){
      int a1 = (int) (n+1)/2;
      int a2 = 0;

      a2 += check(n);
      a2 += check(a1);

      if (a2 > 0){
        return 0;
      }
      return 1;


    }
    else{
      return 0;
    }
  }

  static int check(int n){
    int g = (int) Math.sqrt(n);

    if (g*g == n){
      return 1;
    }

    for (int i=g;i>=2;i--){
      if (n % i == 0){
        return 1;
      }
    }

    return 0;
  }

}


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

int main(){ 
long long a,b,c,k,ans=0;
cin>>a>>b>>c>>k;
  
if(k>=a+b){
ans+=a-1*(k-(a+b));
}
else if(k>=a){
ans+=a;
}
else{
ans+=k;
}
cout<<ans<<endl;
}



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

class Main {

  

  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    String s = in.next();
    String t = in.next();
    int sn = s.length();
    int tn = t.length();

    int[][] p = new int[sn + 1][tn + 1];
    // up, i - 1, j : -1
    // left, i, j - 1: -2; 
    //upleft, i - 1, j - 1: -3;

    int[][] dp = new int[sn + 1][tn + 1];
    for (int i = 1; i <= sn; i++) {
      for (int j = 1; j <= tn; j++) {
        if (s.charAt(i - 1) == t.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
          p[i][j] = -3;
        } else {
          if (dp[i - 1][j] > dp[i][j - 1]) {
            dp[i][j] = dp[i - 1][j];
            p[i][j] = -1;
          } else {
            dp[i][j] = dp[i][j - 1];
            p[i][j] = -2;
          }
        }
      }
    }

  StringBuilder sb = new StringBuilder();
    int i = sn, j = tn;
    while (p[i][j] != 0) {
      if (p[i][j] == -3) {sb.append(s.charAt(i - 1)); i--; j--;}
      else if (p[i][j] == -1) {i--;}
      else {j--;}
    }




    

    System.out.println(sb.reverse());
  }

}

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

int main() {
  int N, K;
  cin >> N >> K;
  int num = 1;
  for(int i = 0; i < N; i++){
    if(num*2 >= num + K) num += K;
    else num *= 2;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq

#Union-Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
ans = [0]*(M+1)

ans[M] = math.factorial(N) // (math.factorial(N-2) * 2)

uf = UnionFind(N)

for i in reversed(range(M)):
  if not(uf.same(AB[i][0]-1, AB[i][1]-1)):
    ans[i] = ans[i+1] - uf.size(AB[i][0]-1)*uf.size(AB[i][1]-1)
  else:
    ans[i] = ans[i+1]
  uf.union(AB[i][0]-1, AB[i][1]-1)

for i in range(M):
  print(ans[i+1])


Measured memory_bytes: 126036
package main

import (
	"fmt"
)

func main() {
	var a, ans int

	fmt.Scan(&a)
	for {
		aa := a - 500
		if aa >= 0 {
			a = a - 500
			ans += 1000

		} else {
			break
		}
	}
	for {
		aa := a - 5
		if aa >= 0 {
			a = a - 5
			ans += 5

		} else {
			break
		}
	}

	fmt.Println(ans)
}


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

class graph{
	public:
		vector<vector<ll>> adjlist;
		vector<ll> dp;
	graph(ll n,vector<pair<ll,ll>>&edges){
		adjlist.resize(n+1);
		dp.resize(n+1,-1);
		for(auto i:edges){
			adjlist[i.first].push_back(i.second);
		}
	}		
	
	void dfs(ll start){
		dp[start]=0;
		for(ll i:adjlist[start]){
			if(dp[i]==-1){
				dfs(i);
			}
			dp[start]=max(dp[start],1+dp[i]);
		}
	}
	
	ll maxDepth(){
		for(ll i=1;i<adjlist.size();i++){
			if(dp[i]==-1){
				dfs(i);
			}
		}
		ll maxval=0;
		for(ll i:dp){
			maxval=max(maxval,i);
		}
		return maxval;
	}
};


int main(){
 ll n,m;
 cin>>n>>m;
 vector<pair<ll,ll>> e;
 for(ll i=0;i<m;i++){
	ll a,b;
	cin>>a>>b;
	e.push_back({a,b});
 }
 graph g(n,e);
 cout<<g.maxDepth()<<endl;
 return 0;
}

Measured memory_bytes: 13072
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	cout<<n*n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    vector<ll> B(N + 1);
    B[0] = 0;
    rep(i,N){
        B[i + 1] = B[i] + A[i];
    }
    map<ll,ll> mp;
    rep(i,N + 1){
        mp[B[i]]++;
    }
    ll ans = 0;
    for (map<ll,ll>::iterator itr = mp.begin(); itr != mp.end(); itr++){
        ans += (itr->second * (itr->second - 1)/ 2);
    }
    cout << ans << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  size_t size = S.length();
  (int)(size);
  
  int Q=size/2;
  int R=size%2;
  
  int even=0;
  int odd=0;
  for(int i=0; i<size; i++){
    if(i%2==0 && S[i]== '1'){
      even++;
    }else if(i%2==1 && S[i]== '1'){
      odd++;
    }
  }
  
  int even_zero;
  int odd_zero;
  
  if(R==0){
    even_zero = Q-even;
    odd_zero = Q-odd;
  }else{
    even_zero = Q+1-even;
    odd_zero = Q-odd;
  }
  
  int ans = min(even_zero+odd, odd_zero+even);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  int ans;
  for (int i = 1; i <= n; i *= 2) {
    ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	char S[11];

	scanf("%s", S);

	const int val = atoi(S) * 10000 + (atoi(&S[5]) * 100) + (atoi(&S[8]));

	puts((val <= 20190430 ? "Heisei" : "TBD"));

	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());

        // 主処理
        int ab = a + b;
        int ac = a + c;
        int bc = b + c;
        String result = (ab == c || ac == b || bc == a) ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 22612
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 15;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll dp[105][305];
ll tdp[105][305];
ll in[105][2];
int main() {
	int N, W, i, j, k;
	scanf("%d %d", &N, &W);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &in[i][0], &in[i][1]);

	for (i = 0; i <= N; i++) for (j = 0; j <= 3 * N; j++) dp[i][j] = -LL_INF;
	dp[0][0] = 0;
	for (k = 1; k <= N; k++) {
		for (i = N; i >= 1; i--) {
			for (j = 3 * N; j >= in[k][0] - in[1][0]; j--) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - (in[k][0] - in[1][0])] + in[k][1]);
			}
		}
	}

	ll ans = 0;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= 3 * N; j++) {
			ll v = i * in[1][0] + j;
			if (v <= W) ans = max(ans, dp[i][j]);
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int i,n,data[100]={};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	for(i=n-1;i>=0;i--){
		if(i!=0)
			printf("%d ",data[i]);
		else
			printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 1740
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    a.sort();

    let mut plus = a[a.len()-1];
    let mut minus = a[0];

    let mut pluses = vec![];
    let mut minuses = vec![];

    for &x in a[1..a.len()-1].iter() {
        if x < 0 {
            minuses.push(x);
        } else {
            pluses.push(x);
        }
    }

    let mut ans = vec![];

    for m in minuses {
        ans.push((plus, m));
        plus -= m;
    }

    for p in pluses {
        ans.push((minus, p));
        minus -= p;
    }

    ans.push((plus, minus));
    plus -= minus;

    println!("{}", plus);
    for (a, b) in ans {
        println!("{} {}", a, b);
    }
}


Measured memory_bytes: 10688
#include <stdio.h>
int partition(int, int);
int A[100000];
int main(){
  int v,n,p,j;
 
  scanf("%d",&n);
  for(j=0; j<n; j++){
    scanf("%d", &A[j]);
  }
  p=0;
  v=partition(p, n-1);
  for(j=0; j<n; j++){
    if(j!=0){
      printf(" ");}
    if(v==j){
      printf("[%d]", A[j]);}
    else printf("%d", A[j]);
    }
  
  printf("\n");
  return 0;
}
 
int partition(int p, int r)
{
  int a,c,i,j;
  i = p-1;
  a = A[r];
  for(j=p; j<r; j++){
    if (A[j] <= a){
      i = i+1;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;
  return i+1;
}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> A(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
		
	int q;
	cin >> q;
	
	int b, e;
	vector<int>::iterator it = A.begin();
	while (q--)
	{
		cin >> b >> e;
//		while (b < e)
//		{
//			iter_swap(it + b++, it + --e);
//		}

		//使用库函数
		reverse(A.begin()+b, A.begin()+e); 
	}
	
	while (it != A.end())
	{
		if(it != A.begin())
			cout << ' ';
		cout << *it++;
	}
	cout << endl;
	
	
	
} 





Measured memory_bytes: 3096
k = int(input())

x = 7 % k
s = set()
for i in range(k):
    if x % k == 0:
        ans = i + 1
        break
    if x in s:
        ans = -1
        break

    s.add(x)
    x = 10 * x + 7
    x %= k

print(ans)


Measured memory_bytes: 156948
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int x=s.length();
    for (int i=0;i<x;i++){
        if (i%2==0){
            if (s[i]=='L'){
                cout<<"No";
                return 0;
            }
        }
        else{
            if (s[i]=='R'){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int h[2000][2000];
int v[2000][2000];
string S[2000];

int main()
{
	int H, W, len, id, ans = 0;
	stack<int> memo;

	cin >> H >> W;
	rep(i, H) cin >> S[i];

	rep(i, H) {
		rep(j, W) {
			if (S[i][j] == '.') {
				memo.push(j);

				if (j == W - 1) {
					len = memo.size();
					while (!memo.empty()) {
						id = memo.top(); memo.pop();
						h[i][id] = len;
					}
				}
			}
			else {
				h[i][j] = 0;
				len = memo.size();
				while (!memo.empty()) {
					id = memo.top(); memo.pop();
					h[i][id] = len;
				}
			}
		}
	}

	rep(i, W) {
		rep(j, H) {
			if (S[j][i] == '.') {
				memo.push(j);

				if (j == H - 1) {
					len = memo.size();
					while (!memo.empty()) {
						id = memo.top(); memo.pop();
						v[id][i] = len;
					}
				}
			}
			else {
				v[j][i] = 0;
				len = memo.size();
				while (!memo.empty()) {
					id = memo.top(); memo.pop();
					v[id][i] = len;
				}
			}
		}
	}

	rep(i, H) {
		rep(j, W) {
			ans = max(ans, h[i][j] + v[i][j] - 1);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35584
s = [0]
M = 104850
p = [1]*M
S = 0
for i in range(2,M):
    if p[i]:
        for j in range(i*i,M,i):
            p[j] = 0
        S += i; s.append(S)
while 1:
    n = input()
    if n==0: break
    print s[n]

Measured memory_bytes: 9992
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    lia = list(map(int, input().split()))

    C = 0
    for i in range(N):
        if lia[i] % 2 ==0:
            tmp = lia[i]
            while tmp % 2 ==0:
                tmp = tmp / 2
                C += 1

    print(int(C))

Measured memory_bytes: 10076
#include <iostream>

#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <cassert>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <ctime>

#include <fstream>

#include <cassert>

using namespace std;

#define MY_PI 3.14159265358979323846264338327950288
using LL = long long;
const int INF = 1e9;
const int MAXN = 1e5 + 10;

const long double kek = 1.0;
const float eps = 1e-9;
#define DB(x) cerr << #x << " " << x << endl;

//vector < int > dp (MAXN, -1);

int dfs(int v, int p, const vector < vector < int > > &g){
    //if (dp[v])
    vector < int > ans;
    //cout << v << " : ";
    for (auto to: g[v]) {
        //cout << v <<  " -> " << to << " ";
        if (to == p) {
            continue;
        }

        ans.push_back(dfs(to, v, g));
    }
    //cout << endl;
    sort(ans.rbegin(), ans.rend());
    int res = 0;
    int add = 1;
    //cout << v << " : ";
    for (int i = 0; i < ans.size(); ++i) {
        //cout << ans[i] << " ";
        res = max(res, ans[i] + add);
        add++;
    }
    //cout << endl;
    return res;
}


int main()
{
    //gen(1001);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    //cout << fixed;
    //cout.precision(6);
    int n;
    cin >> n;
    vector < vector < int > > gr(n);
    for (int i = 1; i < n; ++i){
        int a;
        cin >> a;
        a--;
        gr[a].push_back(i);
        gr[i].push_back(a);
        //cin >> a[i] >> b[i];
    }

    cout << dfs(0, -1, gr);
    return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	long long ans = 0;
	for(int j=1; j<=n; j++){
		int y = n/j;
		ans += 1LL*(y+1)*y/2*j;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
def main():
    [N,W]=input().split(" ")
    N=int(N)
    W=int(W)
    inputset=[]
    for i in range(N):
        [vi,wi]=input().split(" ")
        inputset.append([int(vi),int(wi)])

    graph=[]
    for i in range(N+1):
        graph.append([])
        for j in range(W+1):
            graph[i].append(0)

    for i in range(N):
        for j in range(W+1):
            if(inputset[i][1]>j):
                graph[i+1][j]=graph[i][j]
            else:
                rest=j-inputset[i][1]
                choosevalue=graph[i][rest]+inputset[i][0]
                nonchoosevalue=graph[i][j]
                if(choosevalue>nonchoosevalue):
                    graph[i+1][j]=choosevalue
                else:
                    graph[i+1][j]=nonchoosevalue

    print(graph[N][W])

main()

Measured memory_bytes: 25892
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    ll N;
    cin >> N;
    ll ans = LONG_LONG_MAX;
    REP(i,1, 1000001){
        if (i <= N && N % i == 0) {
            if (ans > (N/i + i - 2) ){
                ans = N/i + i - 2;
//                cout << ans << endl;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll x; cin >> x;
    print(10 - x / 200)
    
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll MAXN = 3 * 1e5 + 5;
ll n, ans;
ll pre[65][MAXN];	// bit 1

int main()
{
	scanf("%lld", &n);
	
	for(ll i = 1; i <= n; i++){
		ll inp; scanf("%lld", &inp);
		
//		printf("i : %lld\n", i);
		
		for(ll j = 0; j <= 60; j++){
			pre[j][i] = pre[j][i - 1];
			if((1LL << j) & inp) pre[j][i]++;
		}
		if(i > 1){
			for(ll j = 0; j <= 60; j++){
				if((1LL << j) & inp){
					ans = (ans + ( ((1LL << j) % mod) * (i - 1 - pre[j][i - 1]) ) % mod) % mod;
				}
				else {
					ans = (ans + ( ((1LL << j) % mod) * pre[j][i - 1] ) % mod) % mod;
				}
//				printf("	j : %lld  ans : %lld\n", j, ans);
			}
		}
	}
//	printf("\n");
//	for(int i = 1; i <= 3; i++){
//		for(int j = 31; j <= 33; j++){
//			printf("pre[%d][%d] : %lld\n", j, i, pre[j][i]);
//		}
//	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 146764
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1310;  
#define FI first
#define SE second
typedef pair<int, int>pii;

int num[N];
int main()  
{  
 
 
   int n;
   while (~scanf("%d", &n))
   {
     for (int i = 0; i < n; i++)
        scanf("%d", num + i);
        sort(num, num + n);
        printf("%d\n", num[n-1] - num[0]);
   }

   return 0;  

}  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
static class Program
{
	public static bool IsKaibun(string s) {
		return s.Substring(0,s.Length/2) == new string(s.Substring(s.Length - s.Length / 2).Reverse().ToArray());
	}

	public static void Main(string[] args)
	{
		var s = Console.In.ReadLine();
		var l = s.Length;
		var c = (l - 1) / 2;
		if (IsKaibun(s) && IsKaibun(s.Substring(0, c)) && IsKaibun(s.Substring((l+3)/2-1))) {
			Console.WriteLine("Yes");
		} else {
			Console.WriteLine("No");
		}

	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

#define ll long long
using namespace std;

int main()
{
	int N, k;
	cin >> N >> k;
	ll ans = 0;
	ll n = N/k;
	ans = n*n*n;
	if(k%2==0)
	{
		n = (N+k/2)/k;
		ans+=n*n*n;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
/* 
 Author:N_o_o_B 
 Created:November 19 2019 13:54:12
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    if(n&1) {cout << "No" << endl;return 0;}
    string s;
    cin >> s;
    n>>=1;
    if(s.substr(0,n)==s.substr(n,n)) cout << "Yes" << endl;
    else cout << "No" << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int S;
	scanf("%d",&S);
	int h=S/3600;//時間
	S %=3600;//S=S%3600表示したいものではなく使う文字を置く
	int m=S/60;//分
	int s=S%60;//秒

	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    ll ans = 0;
    auto g = [](auto n) {return (n*(n+1))/2;};
    Rep(i, 1, N+1){
        ans += (ll)i * g(N/i); 
    }
    pr(ans);
}

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

#define ll long long
#define REP(i, n) for(int i = 0;i < (int)(n);i++)
#define REPD(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, a, b) for(int i = a;i <= (int)(b);i++)
#define FORD(i, a, b) for(int i = a;i >= (int)(b);i--)
int main() {
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3628
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(N)]
m = 10000
for c,t in ct :
    if t<=T:
        if c <m:
            m = c
if m !=10000:
    print(m)
else:
    print("TLE")

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


int main(){
    string s;
    string ans;
    cin >> s;
    rep(i,s.size()){
        ans += "x";
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){
    int H, N;
    cin >> H >> N;
    vector<int> dp(H + 1, 1 << 30);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        for(int h = 0; h <= H; h++){
            int l = min(H, h + A);
            dp[l] = min(dp[l], dp[h] + B);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())

x=30*h+0.5*m
y=6*m
k=min(abs(x-y),360-abs(x-y))

print((a**2+b**2-2*a*b*math.cos(k*2*math.pi/360))**(1/2))

Measured memory_bytes: 9564
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int A,B;
      A = sc.nextInt();
      B = sc.nextInt();
      int result = 0;
      if (A >= B){
      	result = result + A;
        A = A - 1;
      }
      else{
      	result = result + B;
        B = B - 1;
      }
            if (A >= B){
      	result = result + A;
        A = A - 1;
      }
      else{
      	result = result + B;
        B = B - 1;
      }
      System.out.println(result);
    }
}

Measured memory_bytes: 21844
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;




long long n, m;

int main(int argc, const char * argv[]) {
//    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    long long res = n * 1ll * m;
    long long x, y;
    cin >> x >> y;
    res -= x * m;
    res -= y * n;
    res += x * y;
    cout << res << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



void test_case()
{
    int n;
    cin>>n;

    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

    int cnt = 0;
    int ind = 1;
    for(int i=0; i<n; i++) {
        if(arr[i] == ind) {
            cnt++;
            ind++;
        }
    }

    // cout<<ind<<endl;

    int ans = n - cnt;

    if(ans > n-1) {
        cout<<-1<<endl;
    } else {
        cout<<ans<<endl;
    }
    
    
    
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), x = in.ni()-1, y = in.ni()-1;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int[] dist = new int[n];
            Arrays.fill(dist,-1);
            ArrayDeque<Integer> que = new ArrayDeque<>();
            que.addFirst(i);
            dist[i] = 0;
            while(!que.isEmpty()){
                int a = que.pollLast();
                if(a-1>=0&&dist[a-1]==-1){
                    dist[a-1] = dist[a]+1;
                    que.addFirst(a-1);
                }
                if(a+1<n&&dist[a+1]==-1){
                    dist[a+1] = dist[a]+1;
                    que.addFirst(a+1);
                }
                if(a==x&&dist[y]==-1){
                    dist[y] = dist[a]+1;
                    que.addFirst(y);
                }else if(a==y&&dist[x]==-1){
                    dist[x] = dist[a]+1;
                    que.addFirst(x);
                }
            }
            for (int j = 0; j < n; j++) {
                ans[dist[j]]++;
            }
        }
        for (int i = 1; i < n; i++) {
            out.println(ans[i]/2);
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 46076
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int i=(l); i<(r); ++i)
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int i=(r)-1; i>=(l); --i)
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n; V(int)ans(26,100);
  rep(i,n){
    cin>>s; V(int)cnt(26,0);
    for(char c:s)cnt[c-'a']++;
    rep(j,26)cmin(ans[j],cnt[j]);
  }
  rep(i,26){
    rep(j,ans[i])cout<<char('a'+i);
  }
  cout<<'\n';
}


Measured memory_bytes: 3568
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    dp = [[0] * 3 for _ in range(N + 1)]

    for i in range(1, N + 1):
        dp[i] = list(map(int, input().split()))
        dp[i][0] += max(dp[i - 1][1], dp[i - 1][2])
        dp[i][1] += max(dp[i - 1][0], dp[i - 1][2])
        dp[i][2] += max(dp[i - 1][0], dp[i - 1][1])
    print(max(dp[N]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 94456
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const int inf=100000;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	ll n;
	cin>>n;
	ll rep=sqrt(n);
	vector<ll> a;
	for(ll i=1;i<=rep;++i)
	{
		if(n%i==0)
		{
			ll ans=n/i+i-2;
			a.push_back(ans);
		}
	}
	sort(a.begin(),a.end());
	cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std;

const ll mod = 1e9+7;


ll solve(string str){
    ll n = str.size(), sum = 0;
    for(ll i = 0; i < n ; i++){
        sum += (str[i] - '0');
    }
    return sum;
}
int main() {
    string str;
    cin >> str;
    ll sum = solve(str);
    // cout << sum << "\n";
    if(sum % 3 == 0){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}






Measured memory_bytes: 3828
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

#define d7 1000000007
#define l7 998244353
vector<ll> primes;

int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    
    ll n,k;
    cin>>n>>k;
    ll a[k];
    fori(k) cin>>a[i];
    ll d[k];
    sort(a, a+k);
    fori(k-1){
        d[i]=a[i+1]-a[i];
    }
    d[k-1]=n-a[k-1]+a[0];
    
    ll mx=-1;
    fori(k){
        mx=max(mx,d[i]);
    }
    cout<<n-mx;
    
//code ends
    return 0;
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int n = (a+b-3)/(a-1);
		System.out.println(n);
		
	}

}


Measured memory_bytes: 23252
unittest
{
	assert( [ "2", "ab", "ca" ].parse.expand.solve == 2 );
	assert( [ "4", "aaaa", "aaaa", "aaaa", "aaaa" ].parse.expand.solve == 16 );
	assert( [ "5", "abcde", "fghij", "klmno", "pqrst", "uvwxy" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][]( n, n );
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( n, ss );
}

auto solve( long n, dchar[][] ss )
{
	auto ans = 0L;
	foreach( a; 0L .. ss.length )
	{
		// シンメトリー判定
		auto c = true;
		LOOP: for( auto i = 0L; i < ss.length; i++ )
		{
			for( auto j = 0L; j < ss[ i ].length; j++ )
			{
				c = ( ss[ i ][ j ] == ss[ j ][ i ] );
				if( !c ) break LOOP;
			}
		}
		
		// a,bのときとa+k,b+kのときの判定結果は同じになるので、n通りとして加算
		if( c ) ans += n;
		
		// 盤面をずらす
		ss = ss[ 1 .. $ ] ~ ss[ 0 ];
	}
	return ans;
}


Measured memory_bytes: 7548
#include<bits/stdc++.h>
using namespace std;
int main()
{


   char ara[1000006];
   int n,i,j,len;

    cin>>ara>>n;
    len=strlen(ara);

     for(i=0;i<len;i+=n){

        cout<<ara[i];

     }


return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, x, t := scanInt(), scanInt(), scanInt()
	fmt.Fprintln(wr, (n+x-1)/x*t)
}


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

int main() {
    set<long long>s;
    int len;
    cin >> len;
    while(len--){
        long long ai;
        cin >> ai;
        if(s.find(ai) != s.end()){
            cout << "NO" << endl;
            return 0;
        }else{
            s.insert(ai);
        }
    }
    cout << "YES" << endl;
}

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

using namespace std;

int main()
{
	int a, b, t, i;
	double ans;
	cin >> a; cin >> b;

	t = b;
	for (i = 0; t > 0; i++) {
		t = t / 10;
	}

	ans = sqrt(a*pow(10, i) + b);

	if ((ans - (int)ans) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512